1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-02 08:57:44 +00:00

Add basic generic handler for applying statuseffects

This commit is contained in:
Lucy 2023-03-06 23:09:03 +01:00
parent 65ad14a475
commit 0cd43df305
2 changed files with 33 additions and 0 deletions

View file

@ -533,6 +533,8 @@ void Action::Action::handleAction()
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.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
@ -600,6 +602,35 @@ void Action::Action::handleAction()
// 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()
{
if( auto player = m_pSource->getAsPlayer() )

View file

@ -107,6 +107,8 @@ namespace Sapphire::World::Action
void handleAction();
void handleStatusEffects();
/*!
* @brief Adds an actor filter to this action.
* @param filter The ptr to the ActorFilter to add