Skip to content

Commit

Permalink
Null-check ActionResultBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
arieshi255 committed Jun 20, 2024
1 parent 97e1772 commit cc63ac1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 10 deletions.
9 changes: 5 additions & 4 deletions src/scripts/action/war/ActionInnerBeast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,19 @@ class ActionInnerBeast : public Sapphire::ScriptAPI::ActionScript
auto pPlayer = action.getSourceChara()->getAsPlayer();
auto pSource = action.getSourceChara();
auto pTarget = action.getHitChara();
auto pActionBuilder = action.getActionResultBuilder();

if( !pPlayer )
if( !pPlayer || !pActionBuilder )
return;

if( auto status = pPlayer->getStatusEffectById( Defiance ); status )
status->setModifier( Common::ParamModifier::DamageDealtPercent, 0 );

auto dmg = action.calcDamage( Potency );
action.getActionResultBuilder()->damage( pSource, pTarget, dmg.first, dmg.second );
action.getActionResultBuilder()->heal( pTarget, pSource, dmg.first, Common::CalcResultType::TypeRecoverHp, Common::ActionResultFlag::EffectOnSource );
pActionBuilder->damage( pSource, pTarget, dmg.first, dmg.second );
pActionBuilder->heal( pTarget, pSource, dmg.first, Common::CalcResultType::TypeRecoverHp, Common::ActionResultFlag::EffectOnSource );

action.getActionResultBuilder()->applyStatusEffectSelf( InnerBeast, 15000, 0, { StatusModifier{ Common::ParamModifier::DamageTakenPercent, -20 } } );
pActionBuilder->applyStatusEffectSelf( InnerBeast, 15000, 0, { StatusModifier{ Common::ParamModifier::DamageTakenPercent, -20 } } );

if( !pPlayer->hasStatusEffect( Unchained ) )
{
Expand Down
5 changes: 3 additions & 2 deletions src/scripts/action/war/ActionUnchained.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ class ActionUnchained : public Sapphire::ScriptAPI::ActionScript
void onExecute( Sapphire::World::Action::Action& action ) override
{
auto pPlayer = action.getSourceChara()->getAsPlayer();
auto pActionBuilder = action.getActionResultBuilder();

if( !pPlayer )
if( !pPlayer || !pActionBuilder )
return;

if( auto status = pPlayer->getStatusEffectById( Defiance ); status )
status->setModifier( Common::ParamModifier::DamageDealtPercent, 0 );

action.getActionResultBuilder()->applyStatusEffectSelf( Unchained, 20000, 0 );
pActionBuilder->applyStatusEffectSelf( Unchained, 20000, 0 );
}
};

Expand Down
9 changes: 7 additions & 2 deletions src/world/Action/Action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,11 @@ void Action::Action::buildActionResults()

void Action::Action::handleStatusEffects()
{
auto pActionBuilder = getActionResultBuilder();

if( !pActionBuilder )
return;

if( isComboAction() && !isCorrectCombo() )
return;

Expand All @@ -619,7 +624,7 @@ void Action::Action::handleStatusEffects()
{
for( auto& status : m_lutEntry.statuses.caster )
{
getActionResultBuilder()->applyStatusEffectSelf( status.id, status.duration, 0, status.modifiers, status.flag, true );
pActionBuilder->applyStatusEffectSelf( status.id, status.duration, 0, status.modifiers, status.flag, true );
}
}

Expand All @@ -630,7 +635,7 @@ void Action::Action::handleStatusEffects()
{
for( auto& status : m_lutEntry.statuses.target )
{
getActionResultBuilder()->applyStatusEffect( actor, status.id, status.duration, 0, status.modifiers, status.flag, true );
pActionBuilder->applyStatusEffect( actor, status.id, status.duration, 0, status.modifiers, status.flag, true );
}

if( actor->getStatusEffectMap().size() > 0 )
Expand Down
9 changes: 7 additions & 2 deletions src/world/Action/Job/Warrior.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ void Warrior::handleWrath( Entity::Player& player, Action& action )
auto parry = 2;
auto asChara = player.getAsChara();

auto pActionBuilder = action.getActionResultBuilder();

if( !pActionBuilder )
return;

if( player.hasStatusEffect( Wrath ) )
{
player.replaceSingleStatusEffectById( Wrath );
Expand All @@ -59,7 +64,7 @@ void Warrior::handleWrath( Entity::Player& player, Action& action )
}

if( !player.hasStatusEffect( Infuriated ) )
{
action.getActionResultBuilder()->applyStatusEffectSelf( effectToApply, 30000, 0, { StatusModifier{ Common::ParamModifier::ParryPercent, parry } }, 0, false );
{
pActionBuilder->applyStatusEffectSelf( effectToApply, 30000, 0, { StatusModifier{ Common::ParamModifier::ParryPercent, parry } }, 0, false );
}
}

0 comments on commit cc63ac1

Please sign in to comment.