From 21231761ef7c5413ffc6dabccfca79574586cd98 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 28 Mar 2021 18:24:49 +0200 Subject: [PATCH] Adds OnEndTurn script hook. Signed-off-by: Deukhoofd --- src/Battling/Flow/TurnHandler.cpp | 10 ++++++++++ src/Battling/ScriptHandling/BattleScript.hpp | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/Battling/Flow/TurnHandler.cpp b/src/Battling/Flow/TurnHandler.cpp index 644d604..ad07ab3 100644 --- a/src/Battling/Flow/TurnHandler.cpp +++ b/src/Battling/Flow/TurnHandler.cpp @@ -24,6 +24,16 @@ void TurnHandler::RunTurn(const ArbUt::BorrowedPtr& queue, const Ar << CreatureLib::Battling::TurnChoiceKindHelper::ToString(item->GetKind()) << " " << " with message"); } + if (!battle->HasEnded()) { + for (const auto& side : battle->GetSides()) { + for (const auto& creature : side->GetCreatures()) { + if (!creature.HasValue()) { + continue; + } + HOOK(OnEndTurn, creature.GetValue()); + } + } + } queue->HasCompletedQueue = true; } diff --git a/src/Battling/ScriptHandling/BattleScript.hpp b/src/Battling/ScriptHandling/BattleScript.hpp index 2eff568..f270261 100644 --- a/src/Battling/ScriptHandling/BattleScript.hpp +++ b/src/Battling/ScriptHandling/BattleScript.hpp @@ -85,6 +85,8 @@ namespace CreatureLib::Battling { virtual void PreventRunAway([[maybe_unused]] const FleeTurnChoice* choice, [[maybe_unused]] bool* result){}; virtual void PreventOpponentRunAway([[maybe_unused]] const FleeTurnChoice* choice, [[maybe_unused]] bool* result){}; + + virtual void OnEndTurn(){}; }; }