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

198 lines
5.1 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>
2020-01-05 17:09:27 +09:00
#include "ActionLut.h"
#include "Util/ActorFilter.h"
#include "ForwardsZone.h"
2017-08-08 13:53:47 +02:00
namespace Sapphire::Data
{
struct Action;
using ActionPtr = std::shared_ptr< Action >;
}
namespace Sapphire::World::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:
2018-10-28 21:53:21 +01:00
Action();
2019-07-26 20:28:01 +10:00
Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t sequence, FrameworkPtr fw );
Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t sequence, Data::ActionPtr actionData, 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
bool init();
void setPos( Common::FFXIVARR_POSITION3 pos );
Common::FFXIVARR_POSITION3 getPos() const;
void setTargetId( uint64_t targetId );
uint64_t getTargetId() const;
Entity::CharaPtr getSourceChara() const;
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
bool isInterrupted() const;
2020-01-05 17:09:27 +09:00
Common::ActionInterruptType getInterruptType() const;
void setInterrupted( Common::ActionInterruptType type );
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
uint32_t getAdditionalData() const;
void setAdditionalData( uint32_t data );
2020-01-05 17:09:27 +09:00
bool isCorrectCombo() const;
bool isComboAction() const;
/*!
* @brief Checks if a chara has enough resources available to cast the action (tp/mp/etc)
* @return true if they have the required resources
*/
bool hasResources();
/*!
* @brief Checks if a chara has enough resources available to cast the action and then consumes them (tp/mp/etc)
* @return true if they have the required resources
*/
bool consumeResources();
2019-02-10 22:13:47 +11:00
/*!
* @brief Checks if the action *may* target a resident instead of an actor
* @return true if the target *may* be a resident and not an actor, otherwise false.
*/
bool hasClientsideTarget() const;
2019-02-10 22:13:47 +11:00
/*!
* @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 hasCastTime() const;
2017-08-08 13:53:47 +02:00
/*!
* @brief Tests if an action is castable by the current source chara
* @return true if castable, false if the caster doesn't meet the requirements
*/
2019-06-02 02:30:54 +10:00
bool preCheck();
2019-02-09 17:36:44 +11:00
/*!
* @brief Snapshots characters affected by a cast.
* @param filters A vector of filters to be applied to the in range set of the caster
* @param actors Actors that match the filters are copied here
* @return true if actors are hit
*/
bool snapshotAffectedActors( std::vector< Entity::CharaPtr >& actors );
2019-07-25 22:46:10 +10:00
void buildEffects();
/*!
* @brief Adds an actor filter to this action.
* @param filter The ptr to the ActorFilter to add
*/
void addActorFilter( World::Util::ActorFilterPtr filter );
/*!
* @brief Adds the default actor filters based on the CastType entry in the Action exd.
*/
void addDefaultActorFilters();
std::pair< uint32_t, Common::ActionHitSeverityType > calcDamage( uint32_t potency );
std::pair< uint32_t, Common::ActionHitSeverityType > calcHealing( uint32_t potency );
std::vector< Entity::CharaPtr >& getHitCharas();
/*!
* @brief Returns the first hit actor inside the m_hitActors vector.
* @return The CharaPtr otherwise nullptr
*/
Entity::CharaPtr getHitChara();
/*!
* @brief Starts the cast. Finishes it immediately if there is no cast time (weaponskills).
*/
virtual void start();
/*!
* @brief Finishes the cast, effected targets are calculated here.
*/
virtual void execute();
2019-02-09 17:36:44 +11:00
/*!
* @brief Called when a cast is interrupted for any reason
*
* m_interruptType will have the reason why the action was interrupted (eg. damage, movement, ...)
*/
virtual void interrupt();
2017-08-08 13:53:47 +02:00
/*!
* @brief Called on each player update tick
* @return true if a cast has finished and should be removed from the owning chara
*/
2018-10-28 21:53:21 +01:00
virtual bool update();
2017-08-08 13:53:47 +02:00
2018-10-28 21:53:21 +01:00
protected:
bool primaryCostCheck( bool subtractCosts );
bool secondaryCostCheck( bool subtractCosts );
2019-06-02 02:30:54 +10:00
bool playerPreCheck( Entity::Player& player );
2019-02-09 17:36:44 +11:00
bool preFilterActor( Entity::Actor& actor ) const;
2020-01-05 17:09:27 +09:00
bool hasValidLutEntry() const;
2019-02-09 17:36:44 +11:00
uint32_t m_id;
2019-07-26 20:28:01 +10:00
uint16_t m_sequence;
Common::ActionPrimaryCostType m_primaryCostType;
uint16_t m_primaryCost;
2018-10-28 21:53:21 +01:00
uint64_t m_startTime;
uint32_t m_castTimeMs;
uint32_t m_recastTimeMs;
uint8_t m_cooldownGroup;
2019-02-11 01:50:41 +11:00
int8_t m_range;
uint8_t m_effectRange;
uint8_t m_xAxisModifier;
Common::ActionAspect m_aspect;
Common::CastType m_castType;
uint32_t m_additionalData;
2018-10-28 21:53:21 +01:00
Entity::CharaPtr m_pSource;
Entity::CharaPtr m_pTarget;
uint64_t m_targetId;
bool m_canTargetSelf;
bool m_canTargetParty;
bool m_canTargetFriendly;
bool m_canTargetHostile;
bool m_canTargetDead;
Common::ActionInterruptType m_interruptType;
2017-08-08 13:53:47 +02:00
FrameworkPtr m_pFw;
Data::ActionPtr m_actionData;
Common::FFXIVARR_POSITION3 m_pos;
2019-07-25 22:46:10 +10:00
EffectBuilderPtr m_effectBuilder;
std::vector< World::Util::ActorFilterPtr > m_actorFilters;
std::vector< Entity::CharaPtr > m_hitActors;
2020-01-05 17:09:27 +09:00
ActionEntry m_lutEntry;
2018-10-28 21:53:21 +01:00
};
2017-08-08 13:53:47 +02:00
}
#endif