diff --git a/src/Battling/Models/BattleSide.cpp b/src/Battling/Models/BattleSide.cpp index 245746a..189680b 100644 --- a/src/Battling/Models/BattleSide.cpp +++ b/src/Battling/Models/BattleSide.cpp @@ -1,7 +1,7 @@ #include "BattleSide.hpp" #include "../EventHooks/EventDataClasses.hpp" -#include "Battle.hpp" #include "../ScriptHandling/ScriptMacros.hpp" +#include "Battle.hpp" using namespace CreatureLib::Battling; @@ -53,7 +53,7 @@ void BattleSide::SetChoice(BaseTurnChoice* choice) { void BattleSide::SetCreature(ArbUt::OptionalBorrowedPtr creature, uint8_t index) { auto old = _creatures[index]; if (old.HasValue()) { - HOOK(OnRemove, this); + HOOK(OnRemove, old.GetValue()); old.GetValue()->SetOnBattleField(false); } _creatures[index] = creature; @@ -75,6 +75,7 @@ void BattleSide::SetCreature(ArbUt::OptionalBorrowedPtr creature, uint } } _battle->TriggerEventListener(CreatureIndex(this->_index, index), creature.GetValue()); + HOOK(OnSwitchIn, creature.GetValue(), creature.GetValue()); } bool BattleSide::CreatureOnSide(const ArbUt::BorrowedPtr& creature) const { diff --git a/src/Battling/ScriptHandling/BattleScript.hpp b/src/Battling/ScriptHandling/BattleScript.hpp index ec785d0..8304f27 100644 --- a/src/Battling/ScriptHandling/BattleScript.hpp +++ b/src/Battling/ScriptHandling/BattleScript.hpp @@ -108,6 +108,7 @@ namespace CreatureLib::Battling { virtual void OnEndTurn(){}; virtual void OnFaint(Creature*, DamageSource){}; + virtual void OnSwitchIn(Creature*){}; }; }