From d11fa5a6a52d23143642e7390ec180b7f5edf41f Mon Sep 17 00:00:00 2001 From: NotAdam Date: Fri, 26 Jul 2019 20:28:01 +1000 Subject: [PATCH] kinda working effect packets --- src/world/Action/Action.cpp | 12 ++++++---- src/world/Action/Action.h | 6 +++-- src/world/Action/EffectBuilder.cpp | 25 +++++++++++++++----- src/world/Action/EffectBuilder.h | 8 +++---- src/world/Manager/ActionMgr.cpp | 10 ++++---- src/world/Manager/ActionMgr.h | 4 ++-- src/world/Network/Handlers/ActionHandler.cpp | 4 ++-- 7 files changed, 44 insertions(+), 25 deletions(-) diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 886cab4e..40d8f73b 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -35,19 +35,21 @@ using namespace Sapphire::World; Action::Action::Action() = default; Action::Action::~Action() = default; -Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, FrameworkPtr fw ) : - Action( std::move( caster ), actionId, nullptr, std::move( fw ) ) +Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t sequence, FrameworkPtr fw ) : + Action( std::move( caster ), actionId, sequence, nullptr, std::move( fw ) ) { } -Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, Data::ActionPtr actionData, FrameworkPtr fw ) : +Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, uint16_t sequence, + Data::ActionPtr actionData, FrameworkPtr fw ) : m_pSource( std::move( caster ) ), m_pFw( std::move( fw ) ), m_actionData( std::move( actionData ) ), m_id( actionId ), m_targetId( 0 ), m_startTime( 0 ), - m_interruptType( Common::ActionInterruptType::None ) + m_interruptType( Common::ActionInterruptType::None ), + m_sequence( sequence ) { } @@ -70,7 +72,7 @@ bool Action::Action::init() m_actionData = actionData; } - m_effectBuilder = make_EffectBuilder( m_pSource, getId() ); + m_effectBuilder = make_EffectBuilder( m_pSource, getId(), m_sequence ); m_castTimeMs = static_cast< uint32_t >( m_actionData->cast100ms * 100 ); m_recastTimeMs = static_cast< uint32_t >( m_actionData->recast100ms * 100 ); diff --git a/src/world/Action/Action.h b/src/world/Action/Action.h index debaaea0..d4308882 100644 --- a/src/world/Action/Action.h +++ b/src/world/Action/Action.h @@ -20,8 +20,8 @@ namespace Sapphire::World::Action public: Action(); - Action( Entity::CharaPtr caster, uint32_t actionId, FrameworkPtr fw ); - Action( Entity::CharaPtr caster, uint32_t actionId, Data::ActionPtr actionData, FrameworkPtr fw ); + 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 ); virtual ~Action(); @@ -141,6 +141,8 @@ namespace Sapphire::World::Action uint32_t m_id; + uint16_t m_sequence; + Common::ActionPrimaryCostType m_primaryCostType; uint16_t m_primaryCost; diff --git a/src/world/Action/EffectBuilder.cpp b/src/world/Action/EffectBuilder.cpp index ee0c04d2..d6f206eb 100644 --- a/src/world/Action/EffectBuilder.cpp +++ b/src/world/Action/EffectBuilder.cpp @@ -1,7 +1,7 @@ #include "EffectBuilder.h" #include "EffectResult.h" -#include +#include #include @@ -16,9 +16,10 @@ using namespace Sapphire; using namespace Sapphire::World::Action; using namespace Sapphire::Network::Packets; -EffectBuilder::EffectBuilder( Entity::CharaPtr source, uint32_t actionId ) : +EffectBuilder::EffectBuilder( Entity::CharaPtr source, uint32_t actionId, uint16_t sequence ) : m_sourceChara( std::move( source ) ), - m_actionId( actionId ) + m_actionId( actionId ), + m_sequence( sequence ) { } @@ -77,13 +78,25 @@ void EffectBuilder::buildAndSendPackets() auto effectPacket = std::make_shared< Server::EffectPacket >( m_sourceChara->getId(), result->getTarget()->getId(), m_actionId ); effectPacket->setRotation( Common::Util::floatToUInt16Rot( m_sourceChara->getRot() ) ); + effectPacket->setSequence( m_sequence ); effectPacket->addEffect( result->buildEffectEntry() ); - auto sequence = m_sourceChara->getCurrentTerritory()->getNextEffectSequence(); - effectPacket->setSequence( sequence ); + m_sourceChara->sendToInRangeSet( effectPacket, false ); - m_sourceChara->sendToInRangeSet( effectPacket, true ); + // send a dupe packet to the caster with hiddenAnimation field set + if( auto player = m_sourceChara->getAsPlayer() ) + { + auto effectPacket2 = std::make_shared< Server::EffectPacket >( m_sourceChara->getId(), result->getTarget()->getId(), m_actionId ); + effectPacket2->setRotation( Common::Util::floatToUInt16Rot( m_sourceChara->getRot() ) ); + effectPacket2->setSequence( m_sequence ); + + effectPacket2->data().hiddenAnimation = m_sequence; + + effectPacket2->addEffect( result->buildEffectEntry() ); + + player->queuePacket( effectPacket2 ); + } } } \ No newline at end of file diff --git a/src/world/Action/EffectBuilder.h b/src/world/Action/EffectBuilder.h index 386bf080..f8d3bb40 100644 --- a/src/world/Action/EffectBuilder.h +++ b/src/world/Action/EffectBuilder.h @@ -17,7 +17,7 @@ namespace Sapphire::World::Action CriticalDirectHit }; - EffectBuilder( Entity::CharaPtr source, uint32_t actionId ); + EffectBuilder( Entity::CharaPtr source, uint32_t actionId, uint16_t sequence ); void healTarget( Entity::CharaPtr& target, uint32_t amount, @@ -34,11 +34,11 @@ namespace Sapphire::World::Action uint32_t getResultDelayMs(); + private: + uint32_t m_actionId; + uint16_t m_sequence; Entity::CharaPtr m_sourceChara; - - uint32_t m_actionId; - std::unordered_map< uint32_t, EffectResultPtr > m_resolvedEffects; }; diff --git a/src/world/Manager/ActionMgr.cpp b/src/world/Manager/ActionMgr.cpp index feced875..43d14170 100644 --- a/src/world/Manager/ActionMgr.cpp +++ b/src/world/Manager/ActionMgr.cpp @@ -19,12 +19,13 @@ World::Manager::ActionMgr::ActionMgr( Sapphire::FrameworkPtr pFw ) : } void World::Manager::ActionMgr::handlePlacedPlayerAction( Entity::Player& player, uint32_t actionId, - Data::ActionPtr actionData, Common::FFXIVARR_POSITION3 pos ) + Data::ActionPtr actionData, Common::FFXIVARR_POSITION3 pos, + uint16_t sequence ) { player.sendDebug( "got aoe act: {0}", actionData->name ); - auto action = Action::make_Action( player.getAsPlayer(), actionId, actionData, framework() ); + auto action = Action::make_Action( player.getAsPlayer(), actionId, sequence, actionData, framework() ); if( !action->init() ) return; @@ -42,9 +43,10 @@ void World::Manager::ActionMgr::handlePlacedPlayerAction( Entity::Player& player } void World::Manager::ActionMgr::handleTargetedPlayerAction( Entity::Player& player, uint32_t actionId, - Data::ActionPtr actionData, uint64_t targetId ) + Data::ActionPtr actionData, uint64_t targetId, + uint16_t sequence ) { - auto action = Action::make_Action( player.getAsPlayer(), actionId, actionData, framework() ); + auto action = Action::make_Action( player.getAsPlayer(), actionId, sequence, actionData, framework() ); action->setTargetId( targetId ); diff --git a/src/world/Manager/ActionMgr.h b/src/world/Manager/ActionMgr.h index e3ab37d3..75e238e9 100644 --- a/src/world/Manager/ActionMgr.h +++ b/src/world/Manager/ActionMgr.h @@ -22,9 +22,9 @@ namespace Sapphire::World::Manager ~ActionMgr() = default; void handleTargetedPlayerAction( Entity::Player& player, uint32_t actionId, - Data::ActionPtr actionData, uint64_t targetId ); + Data::ActionPtr actionData, uint64_t targetId, uint16_t sequence ); void handlePlacedPlayerAction( Entity::Player& player, uint32_t actionId, - Data::ActionPtr actionData, Common::FFXIVARR_POSITION3 pos ); + Data::ActionPtr actionData, Common::FFXIVARR_POSITION3 pos, uint16_t sequence ); void handleItemAction( Entity::Player& player, uint32_t itemId, Data::ItemActionPtr itemActionData, uint16_t itemSourceSlot, uint16_t itemSourceContainer ); diff --git a/src/world/Network/Handlers/ActionHandler.cpp b/src/world/Network/Handlers/ActionHandler.cpp index 99137c62..92641c98 100644 --- a/src/world/Network/Handlers/ActionHandler.cpp +++ b/src/world/Network/Handlers/ActionHandler.cpp @@ -48,7 +48,7 @@ void Sapphire::Network::GameConnection::actionHandler( FrameworkPtr pFw, if( !action ) return; - actionMgr->handleTargetedPlayerAction( player, actionId, action, targetId ); + actionMgr->handleTargetedPlayerAction( player, actionId, action, targetId, sequence ); break; } @@ -112,5 +112,5 @@ void Sapphire::Network::GameConnection::placedActionHandler( FrameworkPtr pFw, return; auto actionMgr = pFw->get< World::Manager::ActionMgr >(); - actionMgr->handlePlacedPlayerAction( player, actionId, action, pos ); + actionMgr->handlePlacedPlayerAction( player, actionId, action, pos, sequence ); }