From f811fc06541999959d105e7eb889445f7db649e1 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 19 Nov 2021 18:01:58 +0100 Subject: [PATCH] Adds OnIncomingHit script hook. --- src/Battling/Flow/TurnHandler.cpp | 1 + src/Battling/ScriptHandling/BattleScript.hpp | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/Battling/Flow/TurnHandler.cpp b/src/Battling/Flow/TurnHandler.cpp index 20c1f18..d603cd9 100644 --- a/src/Battling/Flow/TurnHandler.cpp +++ b/src/Battling/Flow/TurnHandler.cpp @@ -255,6 +255,7 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, const ArbUt::Bo } if (damage > 0) { target->Damage(damage, DamageSource::AttackDamage); + HOOK(OnIncomingHit, target, attack, target.GetRaw(), hitIndex); if (attackData->HasSecondaryEffect() && !user->IsFainted()) { bool preventSecondary = false; diff --git a/src/Battling/ScriptHandling/BattleScript.hpp b/src/Battling/ScriptHandling/BattleScript.hpp index 8304f27..899f726 100644 --- a/src/Battling/ScriptHandling/BattleScript.hpp +++ b/src/Battling/ScriptHandling/BattleScript.hpp @@ -81,6 +81,9 @@ namespace CreatureLib::Battling { virtual void OverrideIncomingDamage([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target, [[maybe_unused]] u8 hitIndex, [[maybe_unused]] u32* damage){}; + virtual void OnIncomingHit([[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, [[maybe_unused]] bool* outResult){};