From 0620aaa932375a4d69671d1416423e6b3682ee4f Mon Sep 17 00:00:00 2001 From: collett Date: Sat, 11 Jan 2020 21:02:11 +0900 Subject: [PATCH 1/3] Update EffectResult packet and send proper animation lock time. --- src/common/Network/PacketDef/Zone/ServerZoneDef.h | 2 +- src/world/Action/EffectBuilder.cpp | 5 ++++- src/world/Actor/Chara.cpp | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index 74bd02b2..fc716d32 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -439,7 +439,7 @@ namespace Sapphire::Network::Packets::Server */ struct FFXIVIpcEffectResult : FFXIVIpcBasePacket< EffectResult > { - uint32_t unknown; + uint32_t globalSequence; uint32_t actor_id; //uint8_t unknown1; //uint8_t unknown2; diff --git a/src/world/Action/EffectBuilder.cpp b/src/world/Action/EffectBuilder.cpp index 64af6932..83803896 100644 --- a/src/world/Action/EffectBuilder.cpp +++ b/src/world/Action/EffectBuilder.cpp @@ -28,7 +28,7 @@ uint64_t EffectBuilder::getResultDelayMs() { // todo: actually figure this retarded shit out - return Common::Util::getTimeMs() + 850; + return Common::Util::getTimeMs() + 600; } void EffectBuilder::moveToResultList( Entity::CharaPtr& chara, EffectResultPtr result ) @@ -176,6 +176,7 @@ std::shared_ptr< FFXIVPacketBase > EffectBuilder::buildNextEffectPacket( uint32_ pHeader->effectCount = static_cast< uint8_t >( remainingTargetCount > packetSize ? packetSize : remainingTargetCount ); pHeader->sourceSequence = m_sequence; pHeader->globalSequence = globalSequence; + pHeader->animationLockTime = 0.6f; uint8_t targetIndex = 0; for( auto it = m_resolvedEffects.begin(); it != m_resolvedEffects.end(); ) @@ -220,6 +221,7 @@ std::shared_ptr< FFXIVPacketBase > EffectBuilder::buildNextEffectPacket( uint32_ auto effectPacket = std::make_shared< Server::EffectPacket >( m_sourceChara->getId(), firstResult->getTarget()->getId(), m_actionId ); effectPacket->setRotation( Common::Util::floatToUInt16Rot( m_sourceChara->getRot() ) ); effectPacket->setSequence( seq, m_sequence ); + effectPacket->data().animationLockTime = 0.6f; for( int i = 0; i < resultList->size(); i++ ) { @@ -247,6 +249,7 @@ std::shared_ptr< FFXIVPacketBase > EffectBuilder::buildNextEffectPacket( uint32_ effectPacket->data().effectCount = 0; effectPacket->data().sourceSequence = m_sequence; effectPacket->data().globalSequence = globalSequence; + effectPacket->data().animationLockTime = 0.6f; return effectPacket; } diff --git a/src/world/Actor/Chara.cpp b/src/world/Actor/Chara.cpp index 97712dd8..ee661a18 100644 --- a/src/world/Actor/Chara.cpp +++ b/src/world/Actor/Chara.cpp @@ -532,6 +532,7 @@ void Sapphire::Entity::Chara::addStatusEffect( StatusEffect::StatusEffectPtr pEf auto statusEffectAdd = makeZonePacket< FFXIVIpcEffectResult >( getId() ); + statusEffectAdd->data().globalSequence = getCurrentTerritory()->getNextEffectSequence(); statusEffectAdd->data().actor_id = pEffect->getTargetActorId(); statusEffectAdd->data().current_hp = getHp(); statusEffectAdd->data().current_mp = static_cast< uint16_t >( getMp() ); From fc66254da33c32186b1b18fdd2aad2a9ff4ce16a Mon Sep 17 00:00:00 2001 From: collett Date: Mon, 13 Jan 2020 17:58:07 +0900 Subject: [PATCH 2/3] more animation lock stuff --- src/world/Action/Action.cpp | 20 ++++++++++++++++++-- src/world/Action/Action.h | 2 ++ src/world/Action/EffectBuilder.cpp | 12 ++++++------ src/world/Action/EffectBuilder.h | 4 ++-- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 1f3de39a..e93088f8 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -471,7 +471,7 @@ void Action::Action::buildEffects() if( !hasLutEntry || m_hitActors.empty() ) { // send any effect packet added by script or an empty one just to play animation for other players - m_effectBuilder->buildAndSendPackets(); + m_effectBuilder->buildAndSendPackets( getAnimationLock() ); return; } @@ -541,7 +541,7 @@ void Action::Action::buildEffects() } } - m_effectBuilder->buildAndSendPackets(); + m_effectBuilder->buildAndSendPackets( getAnimationLock() ); // at this point we're done with it and no longer need it m_effectBuilder.reset(); @@ -813,6 +813,22 @@ bool Action::Action::hasValidLutEntry() const m_lutEntry.rearPotency != 0 || m_lutEntry.curePotency != 0 || m_lutEntry.restoreMPPercentage != 0; } +float Action::Action::getAnimationLock() +{ + switch( static_cast< Common::ActionCategory >( m_actionData->actionCategory ) ) + { + case Common::ActionCategory::Item: + { + return 1.1f; + } + case Common::ActionCategory::Mount: + { + return 0.1f; + } + } + return 0.6f; +} + Action::EffectBuilderPtr Action::Action::getEffectbuilder() { return m_effectBuilder; diff --git a/src/world/Action/Action.h b/src/world/Action/Action.h index 355514b5..25115601 100644 --- a/src/world/Action/Action.h +++ b/src/world/Action/Action.h @@ -118,6 +118,8 @@ namespace Sapphire::World::Action */ Entity::CharaPtr getHitChara(); + float getAnimationLock(); + /*! * @brief Starts the cast. Finishes it immediately if there is no cast time (weaponskills). */ diff --git a/src/world/Action/EffectBuilder.cpp b/src/world/Action/EffectBuilder.cpp index 83803896..c4815cdb 100644 --- a/src/world/Action/EffectBuilder.cpp +++ b/src/world/Action/EffectBuilder.cpp @@ -91,7 +91,7 @@ void EffectBuilder::applyStatusEffect( Entity::CharaPtr& target, uint16_t status moveToResultList( target, nextResult ); } -void EffectBuilder::buildAndSendPackets() +void EffectBuilder::buildAndSendPackets( float animationLock ) { auto targetCount = m_resolvedEffects.size(); Logger::debug( "EffectBuilder result: " ); @@ -101,13 +101,13 @@ void EffectBuilder::buildAndSendPackets() do // we want to send at least one packet even nothing is hit so other players can see { - auto packet = buildNextEffectPacket( globalSequence ); + auto packet = buildNextEffectPacket( globalSequence, animationLock ); m_sourceChara->sendToInRangeSet( packet, true ); } while( !m_resolvedEffects.empty() ); } -std::shared_ptr< FFXIVPacketBase > EffectBuilder::buildNextEffectPacket( uint32_t globalSequence ) +std::shared_ptr< FFXIVPacketBase > EffectBuilder::buildNextEffectPacket( uint32_t globalSequence, float animationLock ) { auto remainingTargetCount = m_resolvedEffects.size(); @@ -176,7 +176,7 @@ std::shared_ptr< FFXIVPacketBase > EffectBuilder::buildNextEffectPacket( uint32_ pHeader->effectCount = static_cast< uint8_t >( remainingTargetCount > packetSize ? packetSize : remainingTargetCount ); pHeader->sourceSequence = m_sequence; pHeader->globalSequence = globalSequence; - pHeader->animationLockTime = 0.6f; + pHeader->animationLockTime = animationLock; uint8_t targetIndex = 0; for( auto it = m_resolvedEffects.begin(); it != m_resolvedEffects.end(); ) @@ -221,7 +221,7 @@ std::shared_ptr< FFXIVPacketBase > EffectBuilder::buildNextEffectPacket( uint32_ auto effectPacket = std::make_shared< Server::EffectPacket >( m_sourceChara->getId(), firstResult->getTarget()->getId(), m_actionId ); effectPacket->setRotation( Common::Util::floatToUInt16Rot( m_sourceChara->getRot() ) ); effectPacket->setSequence( seq, m_sequence ); - effectPacket->data().animationLockTime = 0.6f; + effectPacket->data().animationLockTime = animationLock; for( int i = 0; i < resultList->size(); i++ ) { @@ -249,7 +249,7 @@ std::shared_ptr< FFXIVPacketBase > EffectBuilder::buildNextEffectPacket( uint32_ effectPacket->data().effectCount = 0; effectPacket->data().sourceSequence = m_sequence; effectPacket->data().globalSequence = globalSequence; - effectPacket->data().animationLockTime = 0.6f; + effectPacket->data().animationLockTime = animationLock; return effectPacket; } diff --git a/src/world/Action/EffectBuilder.h b/src/world/Action/EffectBuilder.h index 6a4aa240..0ff0251b 100644 --- a/src/world/Action/EffectBuilder.h +++ b/src/world/Action/EffectBuilder.h @@ -28,7 +28,7 @@ namespace Sapphire::World::Action void applyStatusEffect( Entity::CharaPtr& target, uint16_t statusId, uint8_t param ); - void buildAndSendPackets(); + void buildAndSendPackets( float animationLock ); private: @@ -36,7 +36,7 @@ namespace Sapphire::World::Action uint64_t getResultDelayMs(); - std::shared_ptr< Sapphire::Network::Packets::FFXIVPacketBase > buildNextEffectPacket( uint32_t globalSequence ); + std::shared_ptr< Sapphire::Network::Packets::FFXIVPacketBase > buildNextEffectPacket( uint32_t globalSequence, float animationLock ); private: uint32_t m_actionId; From 983c7722600ff965a7774af1a74cb293d7975053 Mon Sep 17 00:00:00 2001 From: collett Date: Tue, 14 Jan 2020 22:01:11 +0900 Subject: [PATCH 3/3] fix inaccurate animation lock time for casts --- src/world/Action/Action.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index e93088f8..39df5f34 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -826,7 +826,7 @@ float Action::Action::getAnimationLock() return 0.1f; } } - return 0.6f; + return hasCastTime() ? 0.1f : 0.6f; } Action::EffectBuilderPtr Action::Action::getEffectbuilder()