Adds OnFaintingOpponent script hook.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-11-21 13:29:41 +01:00
parent 70ac3813cf
commit 9270dcca8c
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 13 additions and 7 deletions

View File

@ -26,20 +26,20 @@ void TurnHandler::RunTurn(const ArbUt::BorrowedPtr<ChoiceQueue>& queue, const Ar
}
scripts.Clear();
creature.GetValue()->GetOwnScripts(scripts);
for (auto& s : scripts) {
EXECUTE_SCRIPT_FUNC(s, OnEndTurn);
for (auto& script : scripts) {
EXECUTE_SCRIPT_FUNC(script, OnEndTurn);
}
}
scripts.Clear();
side->GetOwnScripts(scripts);
for (auto& s : scripts) {
EXECUTE_SCRIPT_FUNC(s, OnEndTurn);
for (auto& script : scripts) {
EXECUTE_SCRIPT_FUNC(script, OnEndTurn);
}
}
scripts.Clear();
battle->GetOwnScripts(scripts);
for (auto& s : scripts) {
EXECUTE_SCRIPT_FUNC(s, OnEndTurn);
for (auto& script : scripts) {
EXECUTE_SCRIPT_FUNC(script, OnEndTurn);
}
}
queue->HasCompletedQueue = true;
@ -254,7 +254,11 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo
}
if (damage > 0) {
target->Damage(damage, DamageSource::AttackDamage);
HOOK(OnIncomingHit, target, attack, target.GetRaw(), hitIndex);
if (!target->IsFainted()) {
HOOK(OnIncomingHit, target, attack, target.GetRaw(), hitIndex);
} else {
HOOK(OnFaintingOpponent, attack, attack, target.GetRaw(), hitIndex);
}
if (attackData->HasSecondaryEffect() && !user->IsFainted()) {
bool preventSecondary = false;

View File

@ -85,6 +85,8 @@ namespace CreatureLib::Battling {
virtual void OnIncomingHit([[maybe_unused]] const ExecutingAttack* attack, [[maybe_unused]] Creature* target,
[[maybe_unused]] u8 hitNumber){};
virtual void OnFaintingOpponent([[maybe_unused]] const ExecutingAttack* attack,
[[maybe_unused]] Creature* target, [[maybe_unused]] u8 hitNumber){};
virtual void PreventSecondaryEffects([[maybe_unused]] const ExecutingAttack* attack,
[[maybe_unused]] Creature* target, [[maybe_unused]] u8 hitNumber,