mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-03 17:27:47 +00:00
Add basic generic handler for applying statuseffects
This commit is contained in:
parent
65ad14a475
commit
0cd43df305
2 changed files with 33 additions and 0 deletions
|
@ -533,6 +533,8 @@ void Action::Action::handleAction()
|
||||||
Manager::PlayerMgr::sendDebug( *player, "Hit target: pot: {} (c: {}, f: {}, r: {}), heal pot: {}, mpp: {}",
|
Manager::PlayerMgr::sendDebug( *player, "Hit target: pot: {} (c: {}, f: {}, r: {}), heal pot: {}, mpp: {}",
|
||||||
m_lutEntry.potency, m_lutEntry.comboPotency, m_lutEntry.flankPotency, m_lutEntry.rearPotency,
|
m_lutEntry.potency, m_lutEntry.comboPotency, m_lutEntry.flankPotency, m_lutEntry.rearPotency,
|
||||||
m_lutEntry.curePotency, m_lutEntry.restoreMPPercentage );
|
m_lutEntry.curePotency, m_lutEntry.restoreMPPercentage );
|
||||||
|
if( m_lutEntry.statuses.caster.size() > 0 || m_lutEntry.statuses.target.size() > 0 )
|
||||||
|
handleStatusEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
// when aoe, these effects are in the target whatever is hit first
|
// when aoe, these effects are in the target whatever is hit first
|
||||||
|
@ -600,6 +602,35 @@ void Action::Action::handleAction()
|
||||||
// m_effectBuilder.reset();
|
// m_effectBuilder.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Action::Action::handleStatusEffects()
|
||||||
|
{
|
||||||
|
// handle caster statuses
|
||||||
|
if( m_lutEntry.statuses.caster.size() > 0 )
|
||||||
|
{
|
||||||
|
for( auto& status : m_lutEntry.statuses.caster )
|
||||||
|
{
|
||||||
|
getEffectbuilder()->applyStatusEffect( m_pSource, status.id, 0 );
|
||||||
|
m_pSource->addStatusEffectByIdIfNotExist( status.id, status.duration, *m_pSource, status.modifiers );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// handle hit actor statuses
|
||||||
|
if( m_lutEntry.statuses.target.size() > 0 && m_hitActors.size() > 0 )
|
||||||
|
{
|
||||||
|
for( auto& actor : m_hitActors )
|
||||||
|
{
|
||||||
|
for( auto& status : m_lutEntry.statuses.target )
|
||||||
|
{
|
||||||
|
getEffectbuilder()->applyStatusEffect( actor, status.id, 0 );
|
||||||
|
actor->addStatusEffectByIdIfNotExist( status.id, status.duration, *m_pSource, status.modifiers );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( actor->getStatusEffectMap().size() > 0 )
|
||||||
|
actor->onActionHostile( m_pSource );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool Action::Action::preCheck()
|
bool Action::Action::preCheck()
|
||||||
{
|
{
|
||||||
if( auto player = m_pSource->getAsPlayer() )
|
if( auto player = m_pSource->getAsPlayer() )
|
||||||
|
|
|
@ -107,6 +107,8 @@ namespace Sapphire::World::Action
|
||||||
|
|
||||||
void handleAction();
|
void handleAction();
|
||||||
|
|
||||||
|
void handleStatusEffects();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Adds an actor filter to this action.
|
* @brief Adds an actor filter to this action.
|
||||||
* @param filter The ptr to the ActorFilter to add
|
* @param filter The ptr to the ActorFilter to add
|
||||||
|
|
Loading…
Add table
Reference in a new issue