diff --git a/src/Battling/Models/Creature.cpp b/src/Battling/Models/Creature.cpp index 6163604..4b5ebce 100644 --- a/src/Battling/Models/Creature.cpp +++ b/src/Battling/Models/Creature.cpp @@ -4,6 +4,7 @@ #include "../History/HistoryElements/DamageHistory.hpp" #include "../Models/Battle.hpp" #include "../ScriptHandling/ScriptMacros.hpp" +#include "DamageSource.hpp" using namespace CreatureLib; @@ -171,12 +172,12 @@ namespace CreatureLib::Battling { bool Creature::IsFainted() const noexcept { return this->_currentHealth == 0; } - void Creature::OnFaint() { + void Creature::OnFaint(DamageSource damageSource) { EnsureNotNull(_battleData.Battle) EnsureNotNull(_battleData.Side) if (_battleData.Battle.HasValue()) { _battleData.Battle.GetValue()->TriggerEventListener(this); - HOOK(OnFaint, this, this); + HOOK(OnFaint, this, this, damageSource); } _library->GetExperienceLibrary()->HandleExperienceGain(this, _battleData.SeenOpponents); if (_battleData.Battle.HasValue() && _battleData.Side.HasValue()) { @@ -205,7 +206,7 @@ namespace CreatureLib::Battling { _currentHealth = newHealth; if (IsFainted() && damage > 0 && battle != nullptr) { - OnFaint(); + OnFaint(nullptr); } } diff --git a/src/Battling/Models/Creature.hpp b/src/Battling/Models/Creature.hpp index 99b16ed..d21c7d2 100644 --- a/src/Battling/Models/Creature.hpp +++ b/src/Battling/Models/Creature.hpp @@ -67,7 +67,7 @@ namespace CreatureLib::Battling { std::vector _types = {}; private: - void OnFaint(); + void OnFaint(DamageSource damageSource); public: Creature(const ArbUt::BorrowedPtr& library, diff --git a/src/Battling/ScriptHandling/BattleScript.hpp b/src/Battling/ScriptHandling/BattleScript.hpp index 59471a3..7e3ff80 100644 --- a/src/Battling/ScriptHandling/BattleScript.hpp +++ b/src/Battling/ScriptHandling/BattleScript.hpp @@ -5,6 +5,7 @@ #include #include #include "../../Library/EffectParameter.hpp" +#include "../Models/DamageSource.hpp" namespace CreatureLib::Battling { class BaseTurnChoice; @@ -99,7 +100,7 @@ namespace CreatureLib::Battling { [[maybe_unused]] bool* result){}; virtual void OnEndTurn(){}; - virtual void OnFaint([[maybe_unused]] Creature* creature){}; + virtual void OnFaint(Creature*, DamageSource){}; }; }