From 98ccf34c32f6f9912a89ef49ed030c14141a1935 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 10 Feb 2019 21:12:22 +1100 Subject: [PATCH] handle damaged based interrupts versus regular cast interrupts --- src/world/Action/Action.cpp | 22 ++++++++++--------- src/world/Action/Action.h | 11 ++++++++-- .../Network/Handlers/ClientTriggerHandler.cpp | 2 +- src/world/Network/Handlers/PacketHandlers.cpp | 2 +- 4 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index ab613811..2a3b08e4 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -28,7 +28,7 @@ Sapphire::Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId, m_pFw( std::move( fw ) ), m_id( actionId ), m_startTime( 0 ), - m_bInterrupt( false ) + m_interruptType( ActionInterruptType::None ) { m_castTime = static_cast< uint32_t >( action->cast100ms * 100 ); m_cooldownTime = static_cast< uint16_t >( action->recast100ms * 100 ); @@ -74,12 +74,12 @@ Sapphire::Entity::CharaPtr Sapphire::Action::Action::getTargetChara() const bool Sapphire::Action::Action::isInterrupted() const { - return m_bInterrupt; + return m_interruptType != ActionInterruptType::None; } -void Sapphire::Action::Action::setInterrupted() +void Sapphire::Action::Action::setInterrupted( ActionInterruptType type ) { - m_bInterrupt = true; + m_interruptType = type; } void Sapphire::Action::Action::start() @@ -115,7 +115,7 @@ bool Sapphire::Action::Action::update() if( m_startTime == 0 ) return false; - if( m_bInterrupt ) + if( isInterrupted() ) { onInterrupt(); return true; @@ -171,16 +171,18 @@ void Sapphire::Action::Action::onInterrupt() // reset state flag // player->unsetStateFlag( PlayerStateFlag::Occupied1 ); player->unsetStateFlag( PlayerStateFlag::Casting ); - - return; } if( isCastedAction() ) { - auto control = makeActorControl142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 1, m_id, 0 ); + uint8_t interruptEffect = 0; + if( m_interruptType == ActionInterruptType::DamageInterrupt ) + interruptEffect = 1; - // 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 ); + // Note: When cast interrupt from taking too much damage, set the last value to 1. + // This enables the cast interrupt effect. + auto control = makeActorControl142( m_pSource->getId(), ActorControlType::CastInterrupt, + 0x219, 1, m_id, interruptEffect ); m_pSource->sendToInRangeSet( control, true ); } diff --git a/src/world/Action/Action.h b/src/world/Action/Action.h index 6c8a4731..0bc0c083 100644 --- a/src/world/Action/Action.h +++ b/src/world/Action/Action.h @@ -24,6 +24,13 @@ namespace Sapphire::Action uint16_t m_cost; }; + enum class ActionInterruptType : uint8_t + { + None, + RegularInterrupt, + DamageInterrupt, + }; + using ActionCostArray = std::array< ActionCostEntry, 2 >; Action(); @@ -41,7 +48,7 @@ namespace Sapphire::Action Entity::CharaPtr getActionSource() const; bool isInterrupted() const; - void setInterrupted(); + void setInterrupted( ActionInterruptType type ); uint32_t getCastTime() const; void setCastTime( uint32_t castTime ); @@ -120,7 +127,7 @@ namespace Sapphire::Action Entity::CharaPtr m_pTarget; uint64_t m_targetId; - bool m_bInterrupt; + ActionInterruptType m_interruptType; FrameworkPtr m_pFw; diff --git a/src/world/Network/Handlers/ClientTriggerHandler.cpp b/src/world/Network/Handlers/ClientTriggerHandler.cpp index 60dd7a4d..63fd35f4 100644 --- a/src/world/Network/Handlers/ClientTriggerHandler.cpp +++ b/src/world/Network/Handlers/ClientTriggerHandler.cpp @@ -139,7 +139,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw, case ClientTriggerType::CastCancel: // Cancel cast { if( player.getCurrentAction() ) - player.getCurrentAction()->setInterrupted(); + player.getCurrentAction()->setInterrupted( Action::Action::ActionInterruptType::RegularInterrupt ); break; } case ClientTriggerType::Examine: diff --git a/src/world/Network/Handlers/PacketHandlers.cpp b/src/world/Network/Handlers/PacketHandlers.cpp index da9cb293..fb5fcd97 100644 --- a/src/world/Network/Handlers/PacketHandlers.cpp +++ b/src/world/Network/Handlers/PacketHandlers.cpp @@ -196,7 +196,7 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw, player.setPos( updatePositionPacket.data().position ); if( ( player.getCurrentAction() != nullptr ) && bPosChanged ) - player.getCurrentAction()->setInterrupted(); + player.getCurrentAction()->setInterrupted( Action::Action::ActionInterruptType::RegularInterrupt ); // if no one is in range, don't bother trying to send a position update if( !player.hasInRangeActor() )