1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 22:37:45 +00:00
sapphire/src/world/Action/Action.h

132 lines
3 KiB
C
Raw Normal View History

2017-08-08 13:53:47 +02:00
#ifndef _ACTION_H_
#define _ACTION_H_
2018-03-06 22:22:19 +01:00
#include <Common.h>
#include "ForwardsZone.h"
2019-02-09 19:43:30 +11:00
#include <array>
2017-08-08 13:53:47 +02:00
namespace Sapphire::Data
{
struct Action;
using ActionPtr = std::shared_ptr< Action >;
}
namespace Sapphire::Action
{
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
class Action
{
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
public:
struct ActionCostEntry
{
Common::ActionCostType m_costType;
uint16_t m_cost;
};
using ActionCostArray = std::array< ActionCostEntry, 2 >;
2018-10-28 21:53:21 +01:00
Action();
Action( Entity::CharaPtr caster, uint32_t actionId, Data::ActionPtr action, FrameworkPtr fw );
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
virtual ~Action();
2017-08-08 13:53:47 +02:00
uint32_t getId() const;
2017-08-08 13:53:47 +02:00
void setPos( Common::FFXIVARR_POSITION3 pos );
Common::FFXIVARR_POSITION3 getPos() const;
void setTargetChara( Entity::CharaPtr chara );
2018-10-28 21:53:21 +01:00
Entity::CharaPtr getTargetChara() const;
Entity::CharaPtr getActionSource() const;
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
bool isInterrupted() const;
void setInterrupted();
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
uint32_t getCastTime() const;
void setCastTime( uint32_t castTime );
2017-08-08 13:53:47 +02:00
const ActionCostArray& getCostArray() const;
/*!
* @brief Tests whether the action is instantly usable or has a cast assoc'd with it
* @return true if action has a cast time
*/
bool isCastedAction() const;
2017-08-08 13:53:47 +02:00
/*!
* @brief Starts the cast. Finishes it immediately if there is no cast time (weaponskills).
*/
void start();
2017-08-08 13:53:47 +02:00
2019-02-09 17:36:44 +11:00
void buildEffectPacket();
/*!
* @brief Damages a target and adds the effect entry
* @param amount The amount of damage the target takes
* @param chara The chara to inflict damage upon
* @param aspect The aspect of the damage
*/
2019-02-09 23:07:13 +11:00
void damageTarget( uint32_t amount, Entity::Chara& chara, Common::ActionAspect aspect = Common::ActionAspect::None );
/*!
* @brief Heals a target and adds the effect entry
* @param amount Amount of healing to apply
* @param chara Chara to receive healing
*/
2019-02-09 17:36:44 +11:00
void healTarget( uint32_t amount, Entity::Chara& chara );
virtual void onStart();
virtual void onFinish();
virtual void onInterrupt();
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
// update action, if returns true, action is done and has to be removed from the actor
virtual bool update();
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
protected:
void calculateActionCost();
void calculateMPCost( uint8_t costArrayIndex );
2019-02-09 17:36:44 +11:00
/*!
* @brief Some actions are capable of both healing and dealing damage. This identifies them.
*/
enum EffectPacketIdentity : uint8_t
{
DamageEffect,
HealingEffect,
MAX_ACTION_EFFECT_PACKET_IDENT
};
struct EffectPacketData
{
std::vector< Common::EffectEntry > m_entries;
std::vector< uint32_t > m_hitActors;
};
uint32_t m_id;
Common::ActionCostType m_costType;
uint16_t m_cost;
ActionCostArray m_actionCost;
2018-10-28 21:53:21 +01:00
uint64_t m_startTime;
uint32_t m_castTime;
2018-10-28 21:53:21 +01:00
Entity::CharaPtr m_pSource;
Entity::CharaPtr m_pTarget;
uint64_t m_targetId;
2018-10-28 21:53:21 +01:00
bool m_bInterrupt;
2017-08-08 13:53:47 +02:00
FrameworkPtr m_pFw;
Common::FFXIVARR_POSITION3 m_pos;
2019-02-09 17:36:44 +11:00
std::array< EffectPacketData, MAX_ACTION_EFFECT_PACKET_IDENT > m_effects;
2018-10-28 21:53:21 +01:00
};
2017-08-08 13:53:47 +02:00
}
#endif