From 2ea928e67b7f288130dc5de26ca57f2d5368ca64 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 19 Nov 2021 12:12:46 +0100 Subject: [PATCH] Adds OnFaint script hook. --- src/Battling/Models/Creature.cpp | 2 +- src/Battling/ScriptHandling/BattleScript.hpp | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 93e1f55..6163604 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -174,9 +174,9 @@ namespace CreatureLib::Battling { void Creature::OnFaint() { EnsureNotNull(_battleData.Battle) EnsureNotNull(_battleData.Side) - // HOOK: On Faint if (_battleData.Battle.HasValue()) { _battleData.Battle.GetValue()->TriggerEventListener(this); + HOOK(OnFaint, this, this); } _library->GetExperienceLibrary()->HandleExperienceGain(this, _battleData.SeenOpponents); if (_battleData.Battle.HasValue() && _battleData.Side.HasValue()) { diff --git a/src/Battling/ScriptHandling/BattleScript.hpp b/src/Battling/ScriptHandling/BattleScript.hpp index 17c9c93..59471a3 100644 --- a/src/Battling/ScriptHandling/BattleScript.hpp +++ b/src/Battling/ScriptHandling/BattleScript.hpp @@ -99,6 +99,7 @@ namespace CreatureLib::Battling { [[maybe_unused]] bool* result){}; virtual void OnEndTurn(){}; + virtual void OnFaint([[maybe_unused]] Creature* creature){}; }; }