Adds DamageSource to OnFaint script hook.
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Deukhoofd 2021-11-19 12:15:38 +01:00
parent 2ea928e67b
commit c6d814e886
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 7 additions and 5 deletions

View File

@ -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<FaintEvent>(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);
}
}

View File

@ -67,7 +67,7 @@ namespace CreatureLib::Battling {
std::vector<u8> _types = {};
private:
void OnFaint();
void OnFaint(DamageSource damageSource);
public:
Creature(const ArbUt::BorrowedPtr<const BattleLibrary>& library,

View File

@ -5,6 +5,7 @@
#include <Arbutils/Memory/Memory.hpp>
#include <Arbutils/Misc.hpp>
#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){};
};
}