Adds DamageSource to OnFaint script hook.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
2ea928e67b
commit
c6d814e886
|
@ -4,6 +4,7 @@
|
||||||
#include "../History/HistoryElements/DamageHistory.hpp"
|
#include "../History/HistoryElements/DamageHistory.hpp"
|
||||||
#include "../Models/Battle.hpp"
|
#include "../Models/Battle.hpp"
|
||||||
#include "../ScriptHandling/ScriptMacros.hpp"
|
#include "../ScriptHandling/ScriptMacros.hpp"
|
||||||
|
#include "DamageSource.hpp"
|
||||||
|
|
||||||
using namespace CreatureLib;
|
using namespace CreatureLib;
|
||||||
|
|
||||||
|
@ -171,12 +172,12 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
bool Creature::IsFainted() const noexcept { return this->_currentHealth == 0; }
|
bool Creature::IsFainted() const noexcept { return this->_currentHealth == 0; }
|
||||||
|
|
||||||
void Creature::OnFaint() {
|
void Creature::OnFaint(DamageSource damageSource) {
|
||||||
EnsureNotNull(_battleData.Battle)
|
EnsureNotNull(_battleData.Battle)
|
||||||
EnsureNotNull(_battleData.Side)
|
EnsureNotNull(_battleData.Side)
|
||||||
if (_battleData.Battle.HasValue()) {
|
if (_battleData.Battle.HasValue()) {
|
||||||
_battleData.Battle.GetValue()->TriggerEventListener<FaintEvent>(this);
|
_battleData.Battle.GetValue()->TriggerEventListener<FaintEvent>(this);
|
||||||
HOOK(OnFaint, this, this);
|
HOOK(OnFaint, this, this, damageSource);
|
||||||
}
|
}
|
||||||
_library->GetExperienceLibrary()->HandleExperienceGain(this, _battleData.SeenOpponents);
|
_library->GetExperienceLibrary()->HandleExperienceGain(this, _battleData.SeenOpponents);
|
||||||
if (_battleData.Battle.HasValue() && _battleData.Side.HasValue()) {
|
if (_battleData.Battle.HasValue() && _battleData.Side.HasValue()) {
|
||||||
|
@ -205,7 +206,7 @@ namespace CreatureLib::Battling {
|
||||||
_currentHealth = newHealth;
|
_currentHealth = newHealth;
|
||||||
|
|
||||||
if (IsFainted() && damage > 0 && battle != nullptr) {
|
if (IsFainted() && damage > 0 && battle != nullptr) {
|
||||||
OnFaint();
|
OnFaint(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace CreatureLib::Battling {
|
||||||
std::vector<u8> _types = {};
|
std::vector<u8> _types = {};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void OnFaint();
|
void OnFaint(DamageSource damageSource);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Creature(const ArbUt::BorrowedPtr<const BattleLibrary>& library,
|
Creature(const ArbUt::BorrowedPtr<const BattleLibrary>& library,
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include <Arbutils/Memory/Memory.hpp>
|
#include <Arbutils/Memory/Memory.hpp>
|
||||||
#include <Arbutils/Misc.hpp>
|
#include <Arbutils/Misc.hpp>
|
||||||
#include "../../Library/EffectParameter.hpp"
|
#include "../../Library/EffectParameter.hpp"
|
||||||
|
#include "../Models/DamageSource.hpp"
|
||||||
|
|
||||||
namespace CreatureLib::Battling {
|
namespace CreatureLib::Battling {
|
||||||
class BaseTurnChoice;
|
class BaseTurnChoice;
|
||||||
|
@ -99,7 +100,7 @@ namespace CreatureLib::Battling {
|
||||||
[[maybe_unused]] bool* result){};
|
[[maybe_unused]] bool* result){};
|
||||||
|
|
||||||
virtual void OnEndTurn(){};
|
virtual void OnEndTurn(){};
|
||||||
virtual void OnFaint([[maybe_unused]] Creature* creature){};
|
virtual void OnFaint(Creature*, DamageSource){};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue