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

Apply status effects properly for self when having a target

This commit is contained in:
Lucy 2023-03-07 19:58:08 +01:00
parent b525495636
commit bfaec90e00
5 changed files with 18 additions and 9 deletions

View file

@ -533,8 +533,6 @@ 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
@ -595,6 +593,9 @@ void Action::Action::handleAction()
} }
} }
if( m_lutEntry.statuses.caster.size() > 0 || m_lutEntry.statuses.target.size() > 0 )
handleStatusEffects();
m_effectBuilder->buildAndSendPackets( m_hitActors ); m_effectBuilder->buildAndSendPackets( m_hitActors );
// TODO: disabled, reset kills our queued actions // TODO: disabled, reset kills our queued actions
@ -604,12 +605,18 @@ void Action::Action::handleAction()
void Action::Action::handleStatusEffects() void Action::Action::handleStatusEffects()
{ {
if( isComboAction() && !isCorrectCombo() )
return;
// handle caster statuses // handle caster statuses
if( m_lutEntry.statuses.caster.size() > 0 ) if( m_lutEntry.statuses.caster.size() > 0 )
{ {
for( auto& status : m_lutEntry.statuses.caster ) for( auto& status : m_lutEntry.statuses.caster )
{ {
getEffectbuilder()->applyStatusEffect( m_pSource, status.id, 0 ); if( m_hitActors.size() > 0 )
getEffectbuilder()->applyStatusEffect( m_pSource, status.id, 0, true );
else
getEffectbuilder()->applyStatusEffect( m_pSource, status.id, 0 );
m_pSource->addStatusEffectByIdIfNotExist( status.id, status.duration, *m_pSource, status.modifiers ); m_pSource->addStatusEffectByIdIfNotExist( status.id, status.duration, *m_pSource, status.modifiers );
} }
} }

View file

@ -93,10 +93,10 @@ void EffectBuilder::comboSucceed( Entity::CharaPtr& target )
addResultToActor( target, nextResult ); addResultToActor( target, nextResult );
} }
void EffectBuilder::applyStatusEffect( Entity::CharaPtr& target, uint16_t statusId, uint8_t param ) void EffectBuilder::applyStatusEffect( Entity::CharaPtr& target, uint16_t statusId, uint8_t param, bool forSelf )
{ {
EffectResultPtr nextResult = make_EffectResult( target, 0 ); EffectResultPtr nextResult = make_EffectResult( target, 0 );
nextResult->applyStatusEffect( statusId, param ); nextResult->applyStatusEffect( statusId, param, forSelf );
addResultToActor( target, nextResult ); addResultToActor( target, nextResult );
} }

View file

@ -25,7 +25,7 @@ namespace Sapphire::World::Action
void comboSucceed( Entity::CharaPtr& target ); void comboSucceed( Entity::CharaPtr& target );
void applyStatusEffect( Entity::CharaPtr& target, uint16_t statusId, uint8_t param ); void applyStatusEffect( Entity::CharaPtr& target, uint16_t statusId, uint8_t param, bool forSelf = false );
void mount( Entity::CharaPtr& target, uint16_t mountId ); void mount( Entity::CharaPtr& target, uint16_t mountId );

View file

@ -70,11 +70,13 @@ void EffectResult::comboSucceed()
m_result.Type = Common::ActionEffectType::CALC_RESULT_TYPE_COMBO_HIT; m_result.Type = Common::ActionEffectType::CALC_RESULT_TYPE_COMBO_HIT;
} }
void EffectResult::applyStatusEffect( uint16_t statusId, uint8_t param ) void EffectResult::applyStatusEffect( uint16_t statusId, uint8_t param, bool forSelf )
{ {
m_result.Value = static_cast< int16_t >( statusId ); m_result.Value = static_cast< int16_t >( statusId );
m_result.Arg2 = param; m_result.Arg2 = param;
m_result.Type = Common::ActionEffectType::CALC_RESULT_TYPE_SET_STATUS; if( forSelf )
m_result.Flag = static_cast< uint8_t >( Common::ActionEffectResultFlag::EffectOnSource );
m_result.Type = forSelf ? Common::ActionEffectType::CALC_RESULT_TYPE_SET_STATUS_ME : Common::ActionEffectType::CALC_RESULT_TYPE_SET_STATUS;
} }
void EffectResult::mount( uint16_t mountId ) void EffectResult::mount( uint16_t mountId )

View file

@ -19,7 +19,7 @@ namespace Sapphire::World::Action
void restoreMP( uint32_t amount, Common::ActionEffectResultFlag flag = Common::ActionEffectResultFlag::None ); void restoreMP( uint32_t amount, Common::ActionEffectResultFlag flag = Common::ActionEffectResultFlag::None );
void startCombo( uint16_t actionId ); void startCombo( uint16_t actionId );
void comboSucceed(); void comboSucceed();
void applyStatusEffect( uint16_t statusId, uint8_t param ); void applyStatusEffect( uint16_t statusId, uint8_t param, bool forSelf );
void mount( uint16_t mountId ); void mount( uint16_t mountId );
Entity::CharaPtr getTarget() const; Entity::CharaPtr getTarget() const;