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:
parent
af59013dbe
commit
98ccf34c32
4 changed files with 23 additions and 14 deletions
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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() )
|
||||
|
|
Loading…
Add table
Reference in a new issue