mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-28 20:27:46 +00:00
Interrupt casting if target died and casting queue.
This commit is contained in:
parent
0cd7bd7f49
commit
4623ed535a
5 changed files with 92 additions and 6 deletions
|
@ -162,6 +162,11 @@ bool Action::Action::isInterrupted() const
|
||||||
return m_interruptType != Common::ActionInterruptType::None;
|
return m_interruptType != Common::ActionInterruptType::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Common::ActionInterruptType Action::Action::getInterruptType() const
|
||||||
|
{
|
||||||
|
return m_interruptType;
|
||||||
|
}
|
||||||
|
|
||||||
void Action::Action::setInterrupted( Common::ActionInterruptType type )
|
void Action::Action::setInterrupted( Common::ActionInterruptType type )
|
||||||
{
|
{
|
||||||
m_interruptType = type;
|
m_interruptType = type;
|
||||||
|
@ -212,6 +217,30 @@ bool Action::Action::update()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( m_pTarget == nullptr && m_targetId != 0 )
|
||||||
|
{
|
||||||
|
// try to search for the target actor
|
||||||
|
for( auto actor : m_pSource->getInRangeActors( true ) )
|
||||||
|
{
|
||||||
|
if ( actor->getId() == m_targetId )
|
||||||
|
{
|
||||||
|
m_pTarget = actor->getAsChara();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_pTarget != nullptr )
|
||||||
|
{
|
||||||
|
if ( !m_pTarget->isAlive() )
|
||||||
|
{
|
||||||
|
// interrupt the cast if target died
|
||||||
|
setInterrupted( Common::ActionInterruptType::RegularInterrupt );
|
||||||
|
interrupt();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace Sapphire::World::Action
|
||||||
Entity::CharaPtr getSourceChara() const;
|
Entity::CharaPtr getSourceChara() const;
|
||||||
|
|
||||||
bool isInterrupted() const;
|
bool isInterrupted() const;
|
||||||
|
Common::ActionInterruptType getInterruptType() const;
|
||||||
void setInterrupted( Common::ActionInterruptType type );
|
void setInterrupted( Common::ActionInterruptType type );
|
||||||
|
|
||||||
uint32_t getCastTime() const;
|
uint32_t getCastTime() const;
|
||||||
|
|
|
@ -76,7 +76,8 @@ Sapphire::Entity::Player::Player( FrameworkPtr pFw ) :
|
||||||
m_emoteMode( 0 ),
|
m_emoteMode( 0 ),
|
||||||
m_directorInitialized( false ),
|
m_directorInitialized( false ),
|
||||||
m_onEnterEventDone( false ),
|
m_onEnterEventDone( false ),
|
||||||
m_falling( false )
|
m_falling( false ),
|
||||||
|
m_pQueuedAction( nullptr )
|
||||||
{
|
{
|
||||||
m_id = 0;
|
m_id = 0;
|
||||||
m_currentStance = Stance::Passive;
|
m_currentStance = Stance::Passive;
|
||||||
|
@ -2131,3 +2132,43 @@ Sapphire::Common::ActiveLand Sapphire::Entity::Player::getActiveLand() const
|
||||||
{
|
{
|
||||||
return m_activeLand;
|
return m_activeLand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Sapphire::Entity::Player::hasQueuedAction() const
|
||||||
|
{
|
||||||
|
return m_pQueuedAction != nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Sapphire::Entity::Player::setQueuedAction( Sapphire::World::Action::ActionPtr pAction )
|
||||||
|
{
|
||||||
|
m_pQueuedAction = nullptr; // overwrite whatever is already there
|
||||||
|
m_pQueuedAction = std::move( pAction );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Sapphire::Entity::Player::checkAction()
|
||||||
|
{
|
||||||
|
if( m_pCurrentAction == nullptr )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if( m_pCurrentAction->update() )
|
||||||
|
{
|
||||||
|
if ( m_pCurrentAction->isInterrupted() && m_pCurrentAction->getInterruptType() != Common::ActionInterruptType::DamageInterrupt )
|
||||||
|
{
|
||||||
|
// we moved (or whatever not damage interrupt) so we don't want to execute queued cast
|
||||||
|
m_pQueuedAction = nullptr;
|
||||||
|
}
|
||||||
|
m_pCurrentAction = nullptr;
|
||||||
|
|
||||||
|
if( hasQueuedAction() )
|
||||||
|
{
|
||||||
|
sendDebug( "Queued skill start: {0}", m_pQueuedAction->getId() );
|
||||||
|
if ( m_pQueuedAction->hasCastTime() )
|
||||||
|
{
|
||||||
|
setCurrentAction( m_pQueuedAction );
|
||||||
|
}
|
||||||
|
m_pQueuedAction->start();
|
||||||
|
m_pQueuedAction = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
|
@ -643,6 +643,11 @@ namespace Sapphire::Entity
|
||||||
/*! return a const pointer to the mount guide bitmask array */
|
/*! return a const pointer to the mount guide bitmask array */
|
||||||
const uint8_t* getMountGuideBitmask() const;
|
const uint8_t* getMountGuideBitmask() const;
|
||||||
|
|
||||||
|
bool checkAction() override;
|
||||||
|
|
||||||
|
bool hasQueuedAction() const;
|
||||||
|
|
||||||
|
void setQueuedAction( World::Action::ActionPtr pAction );
|
||||||
|
|
||||||
// Spawn handling
|
// Spawn handling
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -1002,6 +1007,8 @@ namespace Sapphire::Entity
|
||||||
|
|
||||||
uint32_t m_inventorySequence;
|
uint32_t m_inventorySequence;
|
||||||
|
|
||||||
|
World::Action::ActionPtr m_pQueuedAction;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using InventoryMap = std::map< uint16_t, Sapphire::ItemContainerPtr >;
|
using InventoryMap = std::map< uint16_t, Sapphire::ItemContainerPtr >;
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,13 @@ void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( player.getCurrentAction() )
|
||||||
|
{
|
||||||
|
player.sendDebug( "Skill queued: {0}", currentAction->getId() );
|
||||||
|
player.setQueuedAction( currentAction );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
// if we have a cast time we want to associate the action with the player so update is called
|
// if we have a cast time we want to associate the action with the player so update is called
|
||||||
if( currentAction->hasCastTime() )
|
if( currentAction->hasCastTime() )
|
||||||
{
|
{
|
||||||
|
@ -96,3 +103,4 @@ void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player,
|
||||||
// todo: what do in cases of swiftcast/etc? script callback?
|
// todo: what do in cases of swiftcast/etc? script callback?
|
||||||
currentAction->start();
|
currentAction->start();
|
||||||
}
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue