mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 15:17:46 +00:00
Apply status effects properly for self when having a target
This commit is contained in:
parent
b525495636
commit
bfaec90e00
5 changed files with 18 additions and 9 deletions
|
@ -533,8 +533,6 @@ 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
|
||||
|
@ -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 );
|
||||
|
||||
// TODO: disabled, reset kills our queued actions
|
||||
|
@ -604,12 +605,18 @@ void Action::Action::handleAction()
|
|||
|
||||
void Action::Action::handleStatusEffects()
|
||||
{
|
||||
if( isComboAction() && !isCorrectCombo() )
|
||||
return;
|
||||
|
||||
// handle caster statuses
|
||||
if( m_lutEntry.statuses.caster.size() > 0 )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,10 +93,10 @@ void EffectBuilder::comboSucceed( Entity::CharaPtr& target )
|
|||
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 );
|
||||
nextResult->applyStatusEffect( statusId, param );
|
||||
nextResult->applyStatusEffect( statusId, param, forSelf );
|
||||
addResultToActor( target, nextResult );
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace Sapphire::World::Action
|
|||
|
||||
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 );
|
||||
|
||||
|
|
|
@ -70,11 +70,13 @@ void EffectResult::comboSucceed()
|
|||
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.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 )
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace Sapphire::World::Action
|
|||
void restoreMP( uint32_t amount, Common::ActionEffectResultFlag flag = Common::ActionEffectResultFlag::None );
|
||||
void startCombo( uint16_t actionId );
|
||||
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 );
|
||||
|
||||
Entity::CharaPtr getTarget() const;
|
||||
|
|
Loading…
Add table
Reference in a new issue