mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
Even more refactoring for cleaner code
This commit is contained in:
parent
ff0f793cb9
commit
8174d4082c
13 changed files with 47 additions and 39 deletions
|
@ -12,7 +12,7 @@ Core::Action::Action::~Action()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Core::Action::Action::getId() const
|
uint16_t Core::Action::Action::getId() const
|
||||||
{
|
{
|
||||||
return m_id;
|
return m_id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Core { namespace Action {
|
||||||
Action();
|
Action();
|
||||||
virtual ~Action();
|
virtual ~Action();
|
||||||
|
|
||||||
uint32_t getId() const;
|
uint16_t getId() const;
|
||||||
|
|
||||||
Common::HandleActionType getHandleActionType() const;
|
Common::HandleActionType getHandleActionType() const;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ namespace Core { namespace Action {
|
||||||
virtual bool update();
|
virtual bool update();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint32_t m_id;
|
uint16_t m_id;
|
||||||
Common::HandleActionType m_handleActionType;
|
Common::HandleActionType m_handleActionType;
|
||||||
|
|
||||||
uint64_t m_startTime;
|
uint64_t m_startTime;
|
||||||
|
|
|
@ -26,7 +26,7 @@ Core::Action::ActionCast::ActionCast()
|
||||||
m_handleActionType = Common::HandleActionType::Event;
|
m_handleActionType = Common::HandleActionType::Event;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Action::ActionCast::ActionCast( Entity::ActorPtr pActor, Entity::ActorPtr pTarget, uint32_t actionId )
|
Core::Action::ActionCast::ActionCast( Entity::ActorPtr pActor, Entity::ActorPtr pTarget, uint16_t actionId )
|
||||||
{
|
{
|
||||||
m_startTime = 0;
|
m_startTime = 0;
|
||||||
m_id = actionId;
|
m_id = actionId;
|
||||||
|
@ -37,10 +37,7 @@ Core::Action::ActionCast::ActionCast( Entity::ActorPtr pActor, Entity::ActorPtr
|
||||||
m_bInterrupt = false;
|
m_bInterrupt = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Action::ActionCast::~ActionCast()
|
Core::Action::ActionCast::~ActionCast() = default;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Core::Action::ActionCast::onStart()
|
void Core::Action::ActionCast::onStart()
|
||||||
{
|
{
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Core { namespace Action {
|
||||||
ActionCast();
|
ActionCast();
|
||||||
~ActionCast();
|
~ActionCast();
|
||||||
|
|
||||||
ActionCast( Entity::ActorPtr pActor, Entity::ActorPtr pTarget, uint32_t actionId );
|
ActionCast( Entity::ActorPtr pActor, Entity::ActorPtr pTarget, uint16_t actionId );
|
||||||
|
|
||||||
void onStart() override;
|
void onStart() override;
|
||||||
void onFinish() override;
|
void onFinish() override;
|
||||||
|
|
|
@ -50,7 +50,10 @@ bool ActionCollision::isActorApplicable( ActorPtr actorPtr, TargetFilter targetF
|
||||||
return ( actorApplicable && actorPtr->isAlive() );
|
return ( actorApplicable && actorPtr->isAlive() );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXIVARR_POSITION3 aoePosition, std::set< ActorPtr > actorsInRange, boost::shared_ptr< Core::Data::ActionInfo > actionInfo, TargetFilter targetFilter )
|
std::set< Core::Entity::ActorPtr > ActionCollision::getActorsHitFromAction( FFXIVARR_POSITION3 aoePosition,
|
||||||
|
std::set< ActorPtr > actorsInRange,
|
||||||
|
boost::shared_ptr< Core::Data::ActionInfo > actionInfo,
|
||||||
|
TargetFilter targetFilter )
|
||||||
{
|
{
|
||||||
std::set< ActorPtr > actorsCollided;
|
std::set< ActorPtr > actorsCollided;
|
||||||
|
|
||||||
|
|
|
@ -23,11 +23,17 @@ namespace Core {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static bool isActorApplicable( ActorPtr actorPtr, TargetFilter targetFilter );
|
static bool isActorApplicable( ActorPtr actorPtr, TargetFilter targetFilter );
|
||||||
static std::set< ActorPtr > getActorsHitFromAction( Common::FFXIVARR_POSITION3 aoePosition, std::set< ActorPtr > actorsInRange, boost::shared_ptr< Data::ActionInfo > actionInfo, TargetFilter targetFilter );
|
static std::set< ActorPtr > getActorsHitFromAction( Common::FFXIVARR_POSITION3 aoePosition,
|
||||||
|
std::set< ActorPtr > actorsInRange,
|
||||||
|
boost::shared_ptr< Data::ActionInfo > actionInfo,
|
||||||
|
TargetFilter targetFilter );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool radiusCollision( Common::FFXIVARR_POSITION3 actorPosition, Common::FFXIVARR_POSITION3 aoePosition, uint16_t radius );
|
static bool radiusCollision( Common::FFXIVARR_POSITION3 actorPosition, Common::FFXIVARR_POSITION3 aoePosition,
|
||||||
static bool boxCollision( Common::FFXIVARR_POSITION3 actorPosition, Common::FFXIVARR_POSITION3 aoePosition, uint16_t width, uint16_t height );
|
uint16_t radius );
|
||||||
|
|
||||||
|
static bool boxCollision( Common::FFXIVARR_POSITION3 actorPosition, Common::FFXIVARR_POSITION3 aoePosition,
|
||||||
|
uint16_t width, uint16_t height );
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ Core::Action::ActionMount::ActionMount()
|
||||||
m_handleActionType = Common::HandleActionType::Event;
|
m_handleActionType = Common::HandleActionType::Event;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Action::ActionMount::ActionMount( Entity::ActorPtr pActor, uint32_t mountId )
|
Core::Action::ActionMount::ActionMount( Entity::ActorPtr pActor, uint16_t mountId )
|
||||||
{
|
{
|
||||||
m_startTime = 0;
|
m_startTime = 0;
|
||||||
m_id = mountId;
|
m_id = mountId;
|
||||||
|
@ -54,7 +54,8 @@ void Core::Action::ActionMount::onStart()
|
||||||
castPacket.data().action_id = m_id;
|
castPacket.data().action_id = m_id;
|
||||||
castPacket.data().skillType = Common::SkillType::MountSkill;
|
castPacket.data().skillType = Common::SkillType::MountSkill;
|
||||||
castPacket.data().unknown_1 = m_id;
|
castPacket.data().unknown_1 = m_id;
|
||||||
castPacket.data().cast_time = static_cast< float >( m_castTime / 1000 ); // This is used for the cast bar above the target bar of the caster.
|
// This is used for the cast bar above the target bar of the caster.
|
||||||
|
castPacket.data().cast_time = static_cast< float >( m_castTime / 1000 );
|
||||||
castPacket.data().target_id = m_pSource->getAsPlayer()->getId();
|
castPacket.data().target_id = m_pSource->getAsPlayer()->getId();
|
||||||
|
|
||||||
m_pSource->sendToInRangeSet( castPacket, true );
|
m_pSource->sendToInRangeSet( castPacket, true );
|
||||||
|
@ -101,7 +102,7 @@ void Core::Action::ActionMount::onInterrupt()
|
||||||
m_pSource->getAsPlayer()->sendStateFlags();
|
m_pSource->getAsPlayer()->sendStateFlags();
|
||||||
|
|
||||||
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
|
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
|
||||||
0x219, 1, m_id, 0 );
|
0x219, 1, m_id, 0 );
|
||||||
|
|
||||||
// Note: When cast interrupt from taking too much damage, set the last value to 1. This enables the cast interrupt effect. Example:
|
// Note: When cast interrupt from taking too much damage, set the last value to 1. This enables the cast interrupt effect. Example:
|
||||||
// auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 1, m_id, 0 );
|
// auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 1, m_id, 0 );
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Core { namespace Action {
|
||||||
ActionMount();
|
ActionMount();
|
||||||
~ActionMount();
|
~ActionMount();
|
||||||
|
|
||||||
ActionMount( Entity::ActorPtr pActor, uint32_t mountId );
|
ActionMount( Entity::ActorPtr pActor, uint16_t mountId );
|
||||||
|
|
||||||
void onStart() override;
|
void onStart() override;
|
||||||
void onFinish() override;
|
void onFinish() override;
|
||||||
|
|
|
@ -90,7 +90,7 @@ void Core::Action::ActionTeleport::onFinish()
|
||||||
effectPacket.data().actionTextId = 5;
|
effectPacket.data().actionTextId = 5;
|
||||||
effectPacket.data().unknown_5 = 1;
|
effectPacket.data().unknown_5 = 1;
|
||||||
effectPacket.data().numEffects = 1;
|
effectPacket.data().numEffects = 1;
|
||||||
effectPacket.data().rotation = static_cast< uint16_t >( 0x8000 * ((pPlayer->getRotation() + 3.1415926)) / 3.1415926 );
|
effectPacket.data().rotation = static_cast< uint16_t >( 0x8000 * ( (pPlayer->getRotation() + 3.1415926) ) / 3.1415926 );
|
||||||
effectPacket.data().effectTarget = pPlayer->getId();
|
effectPacket.data().effectTarget = pPlayer->getId();
|
||||||
pPlayer->sendToInRangeSet( effectPacket, true );
|
pPlayer->sendToInRangeSet( effectPacket, true );
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ void Core::Action::ActionTeleport::onInterrupt()
|
||||||
m_pSource->getAsPlayer()->sendStateFlags();
|
m_pSource->getAsPlayer()->sendStateFlags();
|
||||||
|
|
||||||
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
|
auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt,
|
||||||
0x219, 0x04, m_id, 0 );
|
0x219, 0x04, m_id, 0 );
|
||||||
m_pSource->sendToInRangeSet( control, true );
|
m_pSource->sendToInRangeSet( control, true );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ Core::Action::EventItemAction::EventItemAction()
|
||||||
m_handleActionType = Common::HandleActionType::Event;
|
m_handleActionType = Common::HandleActionType::Event;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Action::EventItemAction::EventItemAction( Entity::ActorPtr pActor, uint32_t eventId, uint32_t action,
|
Core::Action::EventItemAction::EventItemAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action,
|
||||||
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional )
|
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional )
|
||||||
{
|
{
|
||||||
m_additional = additional;
|
m_additional = additional;
|
||||||
|
@ -37,10 +37,7 @@ Core::Action::EventItemAction::EventItemAction( Entity::ActorPtr pActor, uint32_
|
||||||
m_bInterrupt = false;
|
m_bInterrupt = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Action::EventItemAction::~EventItemAction()
|
Core::Action::EventItemAction::~EventItemAction() = default;
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Core::Action::EventItemAction::onStart()
|
void Core::Action::EventItemAction::onStart()
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace Core { namespace Action {
|
||||||
EventItemAction();
|
EventItemAction();
|
||||||
~EventItemAction();
|
~EventItemAction();
|
||||||
|
|
||||||
EventItemAction( Entity::ActorPtr pActor, uint32_t eventId, uint32_t action,
|
EventItemAction( Entity::ActorPtr pActor, uint32_t eventId, uint16_t action,
|
||||||
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional );
|
ActionCallback finishRef, ActionCallback interruptRef, uint64_t additional );
|
||||||
|
|
||||||
void onStart() override;
|
void onStart() override;
|
||||||
|
|
|
@ -210,7 +210,6 @@ void Core::Entity::Actor::setInvincibilityType( Common::InvincibilityType type )
|
||||||
m_invincibilityType = type;
|
m_invincibilityType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*! \return current status of the actor */
|
/*! \return current status of the actor */
|
||||||
Core::Entity::Actor::ActorStatus Core::Entity::Actor::getStatus() const
|
Core::Entity::Actor::ActorStatus Core::Entity::Actor::getStatus() const
|
||||||
{
|
{
|
||||||
|
@ -450,7 +449,7 @@ Core::Entity::ActorPtr Core::Entity::Actor::getClosestActor()
|
||||||
// arbitrary high number
|
// arbitrary high number
|
||||||
float minDistance = 10000;
|
float minDistance = 10000;
|
||||||
|
|
||||||
for( auto pCurAct : m_inRangeActors )
|
for( const auto& pCurAct : m_inRangeActors )
|
||||||
{
|
{
|
||||||
float distance = Math::Util::distance( getPos().x,
|
float distance = Math::Util::distance( getPos().x,
|
||||||
getPos().y,
|
getPos().y,
|
||||||
|
@ -492,11 +491,11 @@ void Core::Entity::Actor::sendToInRangeSet( Network::Packets::GamePacketPtr pPac
|
||||||
if( m_inRangePlayers.empty() )
|
if( m_inRangePlayers.empty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for( auto pCurAct : m_inRangePlayers )
|
for( const auto &pCurAct : m_inRangePlayers )
|
||||||
{
|
{
|
||||||
assert( pCurAct );
|
assert( pCurAct );
|
||||||
pPacket->setValAt<uint32_t>( 0x04, m_id );
|
pPacket->setValAt< uint32_t >( 0x04, m_id );
|
||||||
pPacket->setValAt<uint32_t>( 0x08, pCurAct->m_id );
|
pPacket->setValAt< uint32_t >( 0x08, pCurAct->m_id );
|
||||||
// it might be that the player DC'd in which case the session would be invalid
|
// it might be that the player DC'd in which case the session would be invalid
|
||||||
pCurAct->queuePacket( pPacket );
|
pCurAct->queuePacket( pPacket );
|
||||||
}
|
}
|
||||||
|
@ -625,8 +624,8 @@ void Core::Entity::Actor::autoAttack( ActorPtr pTarget )
|
||||||
m_lastAttack = tick;
|
m_lastAttack = tick;
|
||||||
srand( static_cast< uint32_t >( tick ) );
|
srand( static_cast< uint32_t >( tick ) );
|
||||||
|
|
||||||
uint32_t damage = 10 + rand() % 12;
|
uint16_t damage = static_cast< uint16_t >( 10 + rand() % 12 );
|
||||||
uint32_t variation = 0 + rand() % 4;
|
uint32_t variation = static_cast< uint32_t >( 0 + rand() % 4 );
|
||||||
|
|
||||||
ZoneChannelPacket< FFXIVIpcEffect > effectPacket( getId() );
|
ZoneChannelPacket< FFXIVIpcEffect > effectPacket( getId() );
|
||||||
effectPacket.data().targetId = pTarget->getId();
|
effectPacket.data().targetId = pTarget->getId();
|
||||||
|
@ -657,7 +656,8 @@ ChaiScript Skill Handler.
|
||||||
\param GamePacketPtr to send
|
\param GamePacketPtr to send
|
||||||
\param bool should be send to self?
|
\param bool should be send to self?
|
||||||
*/
|
*/
|
||||||
void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint32_t actionId, uint64_t param1, uint64_t param2, Entity::Actor& pTarget )
|
void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1,
|
||||||
|
uint64_t param2, Entity::Actor& pTarget )
|
||||||
{
|
{
|
||||||
|
|
||||||
if ( isPlayer() )
|
if ( isPlayer() )
|
||||||
|
@ -709,14 +709,16 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint32_t actionId, u
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
std::set< ActorPtr > actorsCollided = ActionCollision::getActorsHitFromAction( pTarget.getPos(), getInRangeActors( true ), actionInfoPtr, TargetFilter::Enemies );
|
auto actorsCollided = ActionCollision::getActorsHitFromAction( pTarget.getPos(), getInRangeActors( true ),
|
||||||
|
actionInfoPtr, TargetFilter::Enemies );
|
||||||
|
|
||||||
for ( auto pHitActor : actorsCollided )
|
for ( const auto& pHitActor : actorsCollided )
|
||||||
{
|
{
|
||||||
effectPacket.data().targetId = pHitActor->getId();
|
effectPacket.data().targetId = pHitActor->getId();
|
||||||
effectPacket.data().effectTarget = pHitActor->getId();
|
effectPacket.data().effectTarget = pHitActor->getId();
|
||||||
|
|
||||||
sendToInRangeSet( effectPacket, true ); // todo: send to range of what? ourselves? when mob script hits this is going to be lacking
|
// todo: send to range of what? ourselves? when mob script hits this is going to be lacking
|
||||||
|
sendToInRangeSet( effectPacket, true );
|
||||||
|
|
||||||
pHitActor->takeDamage( static_cast< uint32_t >( param1 ) );
|
pHitActor->takeDamage( static_cast< uint32_t >( param1 ) );
|
||||||
|
|
||||||
|
@ -756,9 +758,11 @@ void Core::Entity::Actor::handleScriptSkill( uint32_t type, uint32_t actionId, u
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// todo: get proper packets: the following was just kind of thrown together from what we know. atm buggy (packets look "delayed" from client)
|
// todo: get proper packets: the following was just kind of thrown together from what we know.
|
||||||
|
// atm buggy (packets look "delayed" from client)
|
||||||
|
|
||||||
std::set< ActorPtr > actorsCollided = ActionCollision::getActorsHitFromAction( pTarget.getPos(), getInRangeActors( true ), actionInfoPtr, TargetFilter::Allies );
|
auto actorsCollided = ActionCollision::getActorsHitFromAction( pTarget.getPos(), getInRangeActors( true ),
|
||||||
|
actionInfoPtr, TargetFilter::Allies );
|
||||||
|
|
||||||
for ( auto pHitActor : actorsCollided )
|
for ( auto pHitActor : actorsCollided )
|
||||||
{
|
{
|
||||||
|
|
|
@ -249,7 +249,7 @@ public:
|
||||||
|
|
||||||
void setStatus( ActorStatus status );
|
void setStatus( ActorStatus status );
|
||||||
|
|
||||||
void handleScriptSkill( uint32_t type, uint32_t actionId, uint64_t param1, uint64_t param2, Entity::Actor& target );
|
void handleScriptSkill( uint32_t type, uint16_t actionId, uint64_t param1, uint64_t param2, Entity::Actor& target );
|
||||||
|
|
||||||
virtual void autoAttack( ActorPtr pTarget );
|
virtual void autoAttack( ActorPtr pTarget );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue