From d6858c2d445f6da291c45f1c3f919c7570f0c251 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 27 Mar 2021 15:10:56 +0100 Subject: [PATCH] Adds choice pointer to flee prevention script. Signed-off-by: Deukhoofd --- src/Battling/Flow/TurnHandler.cpp | 4 ++-- src/Battling/ScriptHandling/BattleScript.hpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Battling/Flow/TurnHandler.cpp b/src/Battling/Flow/TurnHandler.cpp index 03f42f3..2c63cde 100644 --- a/src/Battling/Flow/TurnHandler.cpp +++ b/src/Battling/Flow/TurnHandler.cpp @@ -274,7 +274,7 @@ void TurnHandler::ExecuteFleeChoice(const ArbUt::BorrowedPtr& ch } bool preventRun = false; - HOOK(PreventRunAway, choice, &preventRun); + HOOK(PreventRunAway, choice, choice, &preventRun); if (preventRun) { return; } @@ -286,7 +286,7 @@ void TurnHandler::ExecuteFleeChoice(const ArbUt::BorrowedPtr& ch if (!creature.HasValue()) { continue; } - HOOK(PreventOpponentRunAway, creature.GetValue(), &preventRun); + HOOK(PreventOpponentRunAway, creature.GetValue(), choice, &preventRun); if (preventRun) { return; } diff --git a/src/Battling/ScriptHandling/BattleScript.hpp b/src/Battling/ScriptHandling/BattleScript.hpp index 64a23ad..2b070e1 100644 --- a/src/Battling/ScriptHandling/BattleScript.hpp +++ b/src/Battling/ScriptHandling/BattleScript.hpp @@ -7,6 +7,7 @@ namespace CreatureLib::Battling { class BaseTurnChoice; class AttackTurnChoice; class SwitchTurnChoice; + class FleeTurnChoice; class ExecutingAttack; class Creature; @@ -79,8 +80,9 @@ namespace CreatureLib::Battling { virtual void OnFail([[maybe_unused]] Creature* target){}; virtual void OnOpponentFail([[maybe_unused]] Creature* target){}; - virtual void PreventRunAway([[maybe_unused]] bool* result){}; - virtual void PreventOpponentRunAway([[maybe_unused]] bool* result){}; + virtual void PreventRunAway([[maybe_unused]] const FleeTurnChoice* choice, [[maybe_unused]] bool* result){}; + virtual void PreventOpponentRunAway([[maybe_unused]] const FleeTurnChoice* choice, + [[maybe_unused]] bool* result){}; }; }