From 987f60ee85480c5476790f958326732a1971973c Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Fri, 15 Jan 2021 16:31:47 +0100 Subject: [PATCH] Clear scripts from creature when a battle is cleared from it. Signed-off-by: Deukhoofd --- src/Battling/Models/Creature.cpp | 1 + src/Battling/ScriptHandling/ScriptSource.hpp | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 4812dbc..9735f93 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -104,6 +104,7 @@ namespace CreatureLib::Battling { _battle = nullptr; _side = nullptr; _seenOpponents = {}; + ResetActiveScripts(); } bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) { diff --git a/src/Battling/ScriptHandling/ScriptSource.hpp b/src/Battling/ScriptHandling/ScriptSource.hpp index 4e3104f..c340ac2 100644 --- a/src/Battling/ScriptHandling/ScriptSource.hpp +++ b/src/Battling/ScriptHandling/ScriptSource.hpp @@ -13,7 +13,10 @@ namespace CreatureLib::Battling { protected: virtual void GetActiveScripts(ArbUt::List& scripts) = 0; - void ResetActiveScripts() { _areScriptsInitialized = false; } + void ResetActiveScripts() { + _areScriptsInitialized = false; + _scripts.Clear(); + } public: virtual size_t ScriptCount() const = 0;