1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-29 07:37:45 +00:00

handle damaged based interrupts versus regular cast interrupts

This commit is contained in:
NotAdam 2019-02-10 21:12:22 +11:00
parent af59013dbe
commit 98ccf34c32
4 changed files with 23 additions and 14 deletions

View file

@ -28,7 +28,7 @@ Sapphire::Action::Action::Action( Entity::CharaPtr caster, uint32_t actionId,
m_pFw( std::move( fw ) ), m_pFw( std::move( fw ) ),
m_id( actionId ), m_id( actionId ),
m_startTime( 0 ), m_startTime( 0 ),
m_bInterrupt( false ) m_interruptType( ActionInterruptType::None )
{ {
m_castTime = static_cast< uint32_t >( action->cast100ms * 100 ); m_castTime = static_cast< uint32_t >( action->cast100ms * 100 );
m_cooldownTime = static_cast< uint16_t >( action->recast100ms * 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 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() void Sapphire::Action::Action::start()
@ -115,7 +115,7 @@ bool Sapphire::Action::Action::update()
if( m_startTime == 0 ) if( m_startTime == 0 )
return false; return false;
if( m_bInterrupt ) if( isInterrupted() )
{ {
onInterrupt(); onInterrupt();
return true; return true;
@ -171,16 +171,18 @@ void Sapphire::Action::Action::onInterrupt()
// reset state flag // reset state flag
// player->unsetStateFlag( PlayerStateFlag::Occupied1 ); // player->unsetStateFlag( PlayerStateFlag::Occupied1 );
player->unsetStateFlag( PlayerStateFlag::Casting ); player->unsetStateFlag( PlayerStateFlag::Casting );
return;
} }
if( isCastedAction() ) 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: // Note: When cast interrupt from taking too much damage, set the last value to 1.
// auto control = ActorControlPacket142( m_pSource->getId(), ActorControlType::CastInterrupt, 0x219, 1, m_id, 0 ); // This enables the cast interrupt effect.
auto control = makeActorControl142( m_pSource->getId(), ActorControlType::CastInterrupt,
0x219, 1, m_id, interruptEffect );
m_pSource->sendToInRangeSet( control, true ); m_pSource->sendToInRangeSet( control, true );
} }

View file

@ -24,6 +24,13 @@ namespace Sapphire::Action
uint16_t m_cost; uint16_t m_cost;
}; };
enum class ActionInterruptType : uint8_t
{
None,
RegularInterrupt,
DamageInterrupt,
};
using ActionCostArray = std::array< ActionCostEntry, 2 >; using ActionCostArray = std::array< ActionCostEntry, 2 >;
Action(); Action();
@ -41,7 +48,7 @@ namespace Sapphire::Action
Entity::CharaPtr getActionSource() const; Entity::CharaPtr getActionSource() const;
bool isInterrupted() const; bool isInterrupted() const;
void setInterrupted(); void setInterrupted( ActionInterruptType type );
uint32_t getCastTime() const; uint32_t getCastTime() const;
void setCastTime( uint32_t castTime ); void setCastTime( uint32_t castTime );
@ -120,7 +127,7 @@ namespace Sapphire::Action
Entity::CharaPtr m_pTarget; Entity::CharaPtr m_pTarget;
uint64_t m_targetId; uint64_t m_targetId;
bool m_bInterrupt; ActionInterruptType m_interruptType;
FrameworkPtr m_pFw; FrameworkPtr m_pFw;

View file

@ -139,7 +139,7 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw,
case ClientTriggerType::CastCancel: // Cancel cast case ClientTriggerType::CastCancel: // Cancel cast
{ {
if( player.getCurrentAction() ) if( player.getCurrentAction() )
player.getCurrentAction()->setInterrupted(); player.getCurrentAction()->setInterrupted( Action::Action::ActionInterruptType::RegularInterrupt );
break; break;
} }
case ClientTriggerType::Examine: case ClientTriggerType::Examine:

View file

@ -196,7 +196,7 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
player.setPos( updatePositionPacket.data().position ); player.setPos( updatePositionPacket.data().position );
if( ( player.getCurrentAction() != nullptr ) && bPosChanged ) 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 no one is in range, don't bother trying to send a position update
if( !player.hasInRangeActor() ) if( !player.hasInRangeActor() )