2021-11-27 00:53:57 +01:00
|
|
|
#pragma once
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2018-03-06 22:22:19 +01:00
|
|
|
#include <Common.h>
|
2020-01-05 17:09:27 +09:00
|
|
|
#include "ActionLut.h"
|
2019-04-07 16:04:36 +10:00
|
|
|
#include "Util/ActorFilter.h"
|
2018-09-24 23:48:42 +02:00
|
|
|
#include "ForwardsZone.h"
|
2023-03-09 21:54:30 +01:00
|
|
|
#include "ActionResultBuilder.h"
|
2021-11-27 00:53:57 +01:00
|
|
|
#include "Exd/Structs.h"
|
2019-02-09 15:39:05 +11:00
|
|
|
|
2019-06-02 00:34:22 +10:00
|
|
|
namespace Sapphire::World::Action
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
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:
|
2019-02-09 23:14:30 +11:00
|
|
|
|
2023-02-28 22:30:54 +01:00
|
|
|
Action() = default;
|
2023-02-28 10:31:59 +01:00
|
|
|
Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t requestId );
|
|
|
|
Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t requestId, std::shared_ptr< Excel::ExcelStruct< Excel::Action > > actionData );
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2023-02-28 22:30:54 +01:00
|
|
|
virtual ~Action() = default;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2019-02-09 15:39:05 +11:00
|
|
|
uint32_t getId() const;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2023-03-09 21:54:30 +01:00
|
|
|
uint32_t getResultId() const;
|
|
|
|
|
2019-03-07 21:58:12 +11:00
|
|
|
bool init();
|
|
|
|
|
2022-01-20 17:39:22 -03:00
|
|
|
void setPos( const Common::FFXIVARR_POSITION3& pos );
|
|
|
|
const Common::FFXIVARR_POSITION3& getPos() const;
|
2019-02-09 18:32:10 +11:00
|
|
|
|
2019-03-07 21:58:12 +11:00
|
|
|
void setTargetId( uint64_t targetId );
|
|
|
|
uint64_t getTargetId() const;
|
2019-02-11 10:14:14 +11:00
|
|
|
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;
|
2019-02-10 21:21:34 +11:00
|
|
|
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
|
|
|
|
2019-03-07 21:58:12 +11:00
|
|
|
uint32_t getAdditionalData() const;
|
|
|
|
void setAdditionalData( uint32_t data );
|
|
|
|
|
2020-01-05 17:09:27 +09:00
|
|
|
bool isCorrectCombo() const;
|
|
|
|
|
2019-03-23 20:59:41 +11:00
|
|
|
bool isComboAction() const;
|
|
|
|
|
2021-12-17 15:48:56 +01:00
|
|
|
uint8_t getActionKind() const;
|
|
|
|
void setActionKind( uint8_t actionKind );
|
|
|
|
|
2022-01-27 20:03:51 -03:00
|
|
|
void setAggroMultiplier( float aggroMultiplier );
|
|
|
|
|
2022-01-14 12:51:37 +01:00
|
|
|
uint64_t getCastTimeRest() const;
|
|
|
|
|
2023-03-08 18:13:29 +01:00
|
|
|
void enableGenericHandler();
|
2023-03-12 20:50:17 +01:00
|
|
|
|
2023-03-12 20:46:27 +01:00
|
|
|
std::shared_ptr< Excel::ExcelStruct< Excel::Action > > getActionData() const;
|
2023-03-08 18:13:29 +01:00
|
|
|
|
2019-04-04 21:56:59 +11:00
|
|
|
/*!
|
2019-04-04 22:19:56 +11:00
|
|
|
* @brief Checks if a chara has enough resources available to cast the action (tp/mp/etc)
|
|
|
|
* @return true if they have the required resources
|
2019-04-04 21:56:59 +11:00
|
|
|
*/
|
2019-04-04 22:16:00 +11:00
|
|
|
bool hasResources();
|
|
|
|
|
2019-04-04 22:19:56 +11:00
|
|
|
/*!
|
|
|
|
* @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
|
|
|
|
*/
|
2019-04-04 22:16:00 +11:00
|
|
|
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.
|
|
|
|
*/
|
2019-03-07 21:58:12 +11:00
|
|
|
bool hasClientsideTarget() const;
|
2019-02-10 22:13:47 +11:00
|
|
|
|
2019-02-08 22:09:48 +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
|
|
|
|
*/
|
2019-02-11 00:40:00 +11:00
|
|
|
bool hasCastTime() const;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2022-01-20 17:39:22 -03:00
|
|
|
/*!
|
|
|
|
* @brief Tests whether the action is an ability/oGCD
|
|
|
|
* @return true if action is an ability
|
|
|
|
*/
|
|
|
|
bool isAbility() const;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Tests whether the action is a weaponskill
|
|
|
|
* @return true if action is an weaponskill
|
|
|
|
*/
|
|
|
|
bool isWeaponskill() const;
|
|
|
|
|
2019-03-07 20:27:45 +11: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
|
|
|
|
*/
|
2020-01-23 22:36:01 +09:00
|
|
|
virtual bool preCheck();
|
2019-02-09 17:36:44 +11:00
|
|
|
|
2019-04-07 16:04:36 +10: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 );
|
|
|
|
|
2023-03-09 21:54:30 +01:00
|
|
|
ActionResultBuilderPtr getActionResultBuilder();
|
2020-01-06 19:25:01 +09:00
|
|
|
|
2023-03-09 21:54:30 +01:00
|
|
|
void buildActionResults();
|
2019-07-25 22:46:10 +10:00
|
|
|
|
2023-03-06 23:09:03 +01:00
|
|
|
void handleStatusEffects();
|
|
|
|
|
2023-03-08 18:07:15 +01:00
|
|
|
void handleJobAction();
|
|
|
|
|
2019-04-07 16:04:36 +10:00
|
|
|
/*!
|
|
|
|
* @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();
|
|
|
|
|
2023-03-15 15:21:03 +01:00
|
|
|
std::pair< uint32_t, Common::CalcResultType > calcDamage( uint32_t potency );
|
2019-07-27 00:37:40 +10:00
|
|
|
|
2023-03-15 15:21:03 +01:00
|
|
|
std::pair< uint32_t, Common::CalcResultType > calcHealing( uint32_t potency );
|
2019-07-27 00:37:40 +10:00
|
|
|
|
2019-04-07 16:04:36 +10:00
|
|
|
|
2019-04-07 16:31:09 +10:00
|
|
|
std::vector< Entity::CharaPtr >& getHitCharas();
|
2019-04-07 16:04:36 +10:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* @brief Returns the first hit actor inside the m_hitActors vector.
|
|
|
|
* @return The CharaPtr otherwise nullptr
|
|
|
|
*/
|
2019-04-07 16:31:09 +10:00
|
|
|
Entity::CharaPtr getHitChara();
|
2019-04-07 16:04:36 +10:00
|
|
|
|
2019-02-09 18:32:10 +11:00
|
|
|
/*!
|
2019-03-07 20:27:45 +11:00
|
|
|
* @brief Starts the cast. Finishes it immediately if there is no cast time (weaponskills).
|
2019-02-09 18:32:10 +11:00
|
|
|
*/
|
2019-03-07 20:33:14 +11:00
|
|
|
virtual void start();
|
2019-02-11 10:03:36 +11:00
|
|
|
|
2019-02-09 18:32:10 +11:00
|
|
|
/*!
|
2019-03-07 20:27:45 +11:00
|
|
|
* @brief Finishes the cast, effected targets are calculated here.
|
2019-02-09 18:32:10 +11:00
|
|
|
*/
|
2019-03-07 20:33:14 +11:00
|
|
|
virtual void execute();
|
2019-02-09 17:36:44 +11:00
|
|
|
|
2019-02-11 00:40:00 +11:00
|
|
|
/*!
|
2019-03-07 20:27:45 +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, ...)
|
2019-02-11 00:40:00 +11:00
|
|
|
*/
|
2019-03-07 20:33:14 +11:00
|
|
|
virtual void interrupt();
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2019-03-07 20:33:14 +11: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
|
|
|
|
2021-12-17 15:48:56 +01:00
|
|
|
virtual void onInterrupt();
|
|
|
|
virtual void onStart();
|
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
protected:
|
2019-02-09 15:39:05 +11:00
|
|
|
|
2019-04-04 21:56:59 +11:00
|
|
|
bool primaryCostCheck( bool subtractCosts );
|
|
|
|
bool secondaryCostCheck( bool subtractCosts );
|
2019-02-09 20:49:22 +11:00
|
|
|
|
2019-06-02 02:30:54 +10:00
|
|
|
bool playerPreCheck( Entity::Player& player );
|
2019-02-09 17:36:44 +11:00
|
|
|
|
2021-11-27 00:53:57 +01:00
|
|
|
bool preFilterActor( Entity::GameObject& actor ) const;
|
2019-04-07 16:04:36 +10:00
|
|
|
|
2020-01-05 17:09:27 +09:00
|
|
|
bool hasValidLutEntry() const;
|
|
|
|
|
2022-01-23 11:04:26 +01:00
|
|
|
uint32_t m_id{};
|
|
|
|
uint8_t m_actionKind{};
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2023-02-28 10:31:59 +01:00
|
|
|
uint16_t m_requestId{};
|
2023-03-09 21:54:30 +01:00
|
|
|
uint32_t m_resultId{};
|
2019-07-26 20:28:01 +10:00
|
|
|
|
2019-03-07 20:27:45 +11:00
|
|
|
Common::ActionPrimaryCostType m_primaryCostType;
|
2022-01-23 11:04:26 +01:00
|
|
|
uint16_t m_primaryCost{};
|
|
|
|
|
2022-01-27 20:03:51 -03:00
|
|
|
float m_aggroMultiplier{ 1.f };
|
|
|
|
|
2022-01-23 11:04:26 +01:00
|
|
|
uint64_t m_startTime{};
|
|
|
|
uint64_t m_castTimeRestMs{};
|
|
|
|
uint32_t m_castTimeMs{};
|
|
|
|
uint32_t m_recastTimeMs{};
|
|
|
|
uint8_t m_cooldownGroup{};
|
|
|
|
int8_t m_range{};
|
|
|
|
uint8_t m_effectRange{};
|
2023-03-12 16:45:52 +01:00
|
|
|
uint8_t m_effectWidth{};
|
2022-01-23 11:04:26 +01:00
|
|
|
uint8_t m_xAxisModifier{};
|
2019-02-11 10:03:36 +11:00
|
|
|
Common::ActionAspect m_aspect;
|
2019-04-07 16:04:36 +10:00
|
|
|
Common::CastType m_castType;
|
2022-01-20 17:39:22 -03:00
|
|
|
Common::ActionCategory m_category;
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2022-01-23 11:04:26 +01:00
|
|
|
uint32_t m_additionalData{};
|
2019-03-07 20:27:45 +11:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
Entity::CharaPtr m_pSource;
|
|
|
|
Entity::CharaPtr m_pTarget;
|
2022-01-23 11:04:26 +01:00
|
|
|
uint64_t m_targetId{};
|
2018-08-29 21:40:59 +02:00
|
|
|
|
2022-01-23 11:04:26 +01:00
|
|
|
bool m_canTargetSelf{};
|
|
|
|
bool m_canTargetParty{};
|
|
|
|
bool m_canTargetFriendly{};
|
|
|
|
bool m_canTargetHostile{};
|
|
|
|
bool m_canTargetDead{};
|
2023-03-08 18:13:29 +01:00
|
|
|
bool m_enableGenericHandler{};
|
2019-04-07 16:04:36 +10:00
|
|
|
|
2019-02-10 21:21:34 +11:00
|
|
|
Common::ActionInterruptType m_interruptType;
|
2017-08-08 13:53:47 +02:00
|
|
|
|
2022-01-27 21:24:54 +01:00
|
|
|
std::shared_ptr< Excel::ExcelStruct< Excel::Action > > m_actionData;
|
2018-12-29 00:53:52 +01:00
|
|
|
|
2022-01-23 11:04:26 +01:00
|
|
|
Common::FFXIVARR_POSITION3 m_pos{};
|
2019-04-07 16:04:36 +10:00
|
|
|
|
2023-03-09 21:54:30 +01:00
|
|
|
ActionResultBuilderPtr m_actionResultBuilder;
|
2019-07-25 22:46:10 +10:00
|
|
|
|
2019-04-07 16:04:36 +10:00
|
|
|
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
|
|
|
}
|