Adds Script Hook to change stat boost changes
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
6da591dd92
commit
34f1e43269
|
@ -141,6 +141,7 @@ namespace CreatureLib::Battling {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) {
|
bool Creature::ChangeStatBoost(Library::Statistic stat, int8_t diffAmount) {
|
||||||
|
HOOK(ModifyStatBoostChange, this, this, stat, &diffAmount);
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
auto oldValue = this->_statBoost.GetStat(stat);
|
auto oldValue = this->_statBoost.GetStat(stat);
|
||||||
if (diffAmount > 0) {
|
if (diffAmount > 0) {
|
||||||
|
@ -148,11 +149,14 @@ namespace CreatureLib::Battling {
|
||||||
} else if (diffAmount < 0) {
|
} else if (diffAmount < 0) {
|
||||||
changed = this->_statBoost.DecreaseStatBy(stat, -diffAmount);
|
changed = this->_statBoost.DecreaseStatBy(stat, -diffAmount);
|
||||||
}
|
}
|
||||||
if (this->GetBattle().HasValue()) {
|
if (changed) {
|
||||||
auto newValue = this->_statBoost.GetStat(stat);
|
if (this->GetBattle().HasValue()) {
|
||||||
this->GetBattle().GetValue()->TriggerEventListener<ChangeStatBoostEvent>(this, stat, oldValue, newValue);
|
auto newValue = this->_statBoost.GetStat(stat);
|
||||||
|
this->GetBattle().GetValue()->TriggerEventListener<ChangeStatBoostEvent>(this, stat, oldValue,
|
||||||
|
newValue);
|
||||||
|
}
|
||||||
|
this->RecalculateBoostedStat(stat);
|
||||||
}
|
}
|
||||||
this->RecalculateBoostedStat(stat);
|
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 "../../Library/Statistic.hpp"
|
||||||
#include "../Models/DamageSource.hpp"
|
#include "../Models/DamageSource.hpp"
|
||||||
|
|
||||||
namespace CreatureLib::Battling {
|
namespace CreatureLib::Battling {
|
||||||
|
@ -40,82 +41,76 @@ namespace CreatureLib::Battling {
|
||||||
|
|
||||||
[[nodiscard]] virtual const ArbUt::StringView& GetName() const noexcept = 0;
|
[[nodiscard]] virtual const ArbUt::StringView& GetName() const noexcept = 0;
|
||||||
|
|
||||||
virtual void
|
#define _par_ [[maybe_unused]]
|
||||||
OnInitialize([[maybe_unused]] const ArbUt::List<CreatureLib::Library::EffectParameter*>& parameters){};
|
|
||||||
virtual void OnBeforeTurn([[maybe_unused]] const BaseTurnChoice* choice){};
|
|
||||||
|
|
||||||
virtual void ChangePriority([[maybe_unused]] AttackTurnChoice* choice, [[maybe_unused]] int8_t* priority){};
|
virtual void OnInitialize(_par_ const ArbUt::List<CreatureLib::Library::EffectParameter*>& parameters){};
|
||||||
virtual void ChangeAttack([[maybe_unused]] AttackTurnChoice* choice,
|
virtual void OnBeforeTurn(_par_ const BaseTurnChoice* choice){};
|
||||||
[[maybe_unused]] ArbUt::StringView* outAttack){};
|
|
||||||
virtual void ModifyNumberOfHits([[maybe_unused]] AttackTurnChoice* choice, [[maybe_unused]] u8* numberOfHits){};
|
|
||||||
virtual void PreventAttack([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] bool* outResult){};
|
|
||||||
virtual void FailAttack([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] bool* outFailed){};
|
|
||||||
virtual void StopBeforeAttack([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] bool* outResult){};
|
|
||||||
virtual void OnBeforeAttack([[maybe_unused]] ExecutingAttack* attack){};
|
|
||||||
|
|
||||||
virtual void FailIncomingAttack([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
virtual void ChangePriority(_par_ AttackTurnChoice* choice, _par_ int8_t* priority){};
|
||||||
[[maybe_unused]] bool* outResult){};
|
virtual void ChangeAttack(_par_ AttackTurnChoice* choice, _par_ ArbUt::StringView* outAttack){};
|
||||||
virtual void IsInvulnerable([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
virtual void ModifyNumberOfHits(_par_ AttackTurnChoice* choice, _par_ u8* numberOfHits){};
|
||||||
[[maybe_unused]] bool* outResult){};
|
virtual void PreventAttack(_par_ ExecutingAttack* attack, _par_ bool* outResult){};
|
||||||
virtual void OnAttackMiss([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target){};
|
virtual void FailAttack(_par_ ExecutingAttack* attack, _par_ bool* outFailed){};
|
||||||
virtual void ChangeAttackType([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
virtual void StopBeforeAttack(_par_ ExecutingAttack* attack, _par_ bool* outResult){};
|
||||||
[[maybe_unused]] u8 hitNumber, [[maybe_unused]] u8* outType){};
|
virtual void OnBeforeAttack(_par_ ExecutingAttack* attack){};
|
||||||
virtual void ChangeEffectiveness([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
|
||||||
[[maybe_unused]] u8 hitNumber, [[maybe_unused]] float* effectiveness){};
|
|
||||||
virtual void BlockCritical([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
|
||||||
[[maybe_unused]] u8 hitNumber, [[maybe_unused]] bool* blockCritical){};
|
|
||||||
|
|
||||||
virtual void OverrideBasePower([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
virtual void FailIncomingAttack(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ bool* outResult){};
|
||||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] u8* basePower){};
|
virtual void IsInvulnerable(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ bool* outResult){};
|
||||||
virtual void ChangeDamageStatsUser([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
virtual void OnAttackMiss(_par_ ExecutingAttack* attack, _par_ Creature* target){};
|
||||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] Creature** statsUser){};
|
virtual void ChangeAttackType(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitNumber,
|
||||||
|
_par_ u8* outType){};
|
||||||
|
virtual void ChangeEffectiveness(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitNumber,
|
||||||
|
_par_ float* effectiveness){};
|
||||||
|
virtual void BlockCritical(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitNumber,
|
||||||
|
_par_ bool* blockCritical){};
|
||||||
|
|
||||||
virtual void BypassDefensiveStat([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
virtual void OverrideBasePower(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitIndex,
|
||||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] bool* bypass){};
|
_par_ u8* basePower){};
|
||||||
virtual void BypassOffensiveStat([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
virtual void ChangeDamageStatsUser(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitIndex,
|
||||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] bool* bypass){};
|
_par_ Creature** statsUser){};
|
||||||
virtual void ModifyStatModifier([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
|
||||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] float* modifier){};
|
|
||||||
virtual void ModifyDamageModifier([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
|
||||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] float* modifier){};
|
|
||||||
virtual void OverrideDamage([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
|
||||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] u32* damage){};
|
|
||||||
virtual void OverrideIncomingDamage([[maybe_unused]] ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
|
||||||
[[maybe_unused]] u8 hitIndex, [[maybe_unused]] u32* damage){};
|
|
||||||
|
|
||||||
virtual void OnIncomingHit([[maybe_unused]] const ExecutingAttack* attack, [[maybe_unused]] Creature* target,
|
virtual void BypassDefensiveStat(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitIndex,
|
||||||
[[maybe_unused]] u8 hitNumber){};
|
_par_ bool* bypass){};
|
||||||
virtual void OnFaintingOpponent([[maybe_unused]] const ExecutingAttack* attack,
|
virtual void BypassOffensiveStat(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitIndex,
|
||||||
[[maybe_unused]] Creature* target, [[maybe_unused]] u8 hitNumber){};
|
_par_ bool* bypass){};
|
||||||
|
virtual void ModifyStatModifier(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitIndex,
|
||||||
|
_par_ float* modifier){};
|
||||||
|
virtual void ModifyDamageModifier(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitIndex,
|
||||||
|
_par_ float* modifier){};
|
||||||
|
virtual void OverrideDamage(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitIndex,
|
||||||
|
_par_ u32* damage){};
|
||||||
|
virtual void OverrideIncomingDamage(_par_ ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitIndex,
|
||||||
|
_par_ u32* damage){};
|
||||||
|
|
||||||
virtual void PreventSecondaryEffects([[maybe_unused]] const ExecutingAttack* attack,
|
virtual void OnIncomingHit(_par_ const ExecutingAttack* attack, _par_ Creature* target, _par_ u8 hitNumber){};
|
||||||
[[maybe_unused]] Creature* target, [[maybe_unused]] u8 hitNumber,
|
virtual void OnFaintingOpponent(_par_ const ExecutingAttack* attack, _par_ Creature* target,
|
||||||
[[maybe_unused]] bool* outResult){};
|
_par_ u8 hitNumber){};
|
||||||
virtual void OnSecondaryEffect([[maybe_unused]] const ExecutingAttack* attack,
|
|
||||||
[[maybe_unused]] Creature* target, [[maybe_unused]] u8 hitNumber){};
|
|
||||||
|
|
||||||
virtual void OnAfterHits([[maybe_unused]] const ExecutingAttack* attack, [[maybe_unused]] Creature* target){};
|
virtual void ModifyStatBoostChange(_par_ Creature* target, _par_ Library::Statistic stat,
|
||||||
|
_par_ int8_t* diffAmount){};
|
||||||
|
virtual void PreventSecondaryEffects(_par_ const ExecutingAttack* attack, _par_ Creature* target,
|
||||||
|
_par_ u8 hitNumber, _par_ bool* outResult){};
|
||||||
|
virtual void OnSecondaryEffect(_par_ const ExecutingAttack* attack, _par_ Creature* target,
|
||||||
|
_par_ u8 hitNumber){};
|
||||||
|
|
||||||
virtual void PreventSelfSwitch([[maybe_unused]] const SwitchTurnChoice* choice,
|
virtual void OnAfterHits(_par_ const ExecutingAttack* attack, _par_ Creature* target){};
|
||||||
[[maybe_unused]] bool* outResult){};
|
|
||||||
virtual void PreventOpponentSwitch([[maybe_unused]] const SwitchTurnChoice* choice,
|
|
||||||
[[maybe_unused]] bool* outResult){};
|
|
||||||
|
|
||||||
virtual void ModifyEffectChance([[maybe_unused]] const ExecutingAttack* attack,
|
virtual void PreventSelfSwitch(_par_ const SwitchTurnChoice* choice, _par_ bool* outResult){};
|
||||||
[[maybe_unused]] Creature* target, [[maybe_unused]] float* chance){};
|
virtual void PreventOpponentSwitch(_par_ const SwitchTurnChoice* choice, _par_ bool* outResult){};
|
||||||
virtual void ModifyIncomingEffectChance([[maybe_unused]] const ExecutingAttack* attack,
|
|
||||||
[[maybe_unused]] Creature* target, [[maybe_unused]] float* chance){};
|
|
||||||
|
|
||||||
virtual void OnFail([[maybe_unused]] Creature* target){};
|
virtual void ModifyEffectChance(_par_ const ExecutingAttack* attack, _par_ Creature* target,
|
||||||
virtual void OnOpponentFail([[maybe_unused]] Creature* target){};
|
_par_ float* chance){};
|
||||||
|
virtual void ModifyIncomingEffectChance(_par_ const ExecutingAttack* attack, _par_ Creature* target,
|
||||||
|
_par_ float* chance){};
|
||||||
|
|
||||||
virtual void PreventRunAway([[maybe_unused]] const FleeTurnChoice* choice, [[maybe_unused]] bool* result){};
|
virtual void OnFail(_par_ Creature* target){};
|
||||||
virtual void PreventOpponentRunAway([[maybe_unused]] const FleeTurnChoice* choice,
|
virtual void OnOpponentFail(_par_ Creature* target){};
|
||||||
[[maybe_unused]] bool* result){};
|
|
||||||
|
virtual void PreventRunAway(_par_ const FleeTurnChoice* choice, _par_ bool* result){};
|
||||||
|
virtual void PreventOpponentRunAway(_par_ const FleeTurnChoice* choice, _par_ bool* result){};
|
||||||
|
|
||||||
virtual void OnEndTurn(){};
|
virtual void OnEndTurn(){};
|
||||||
virtual void OnDamage(Creature*, DamageSource, [[maybe_unused]] u32 oldHealth,
|
virtual void OnDamage(Creature*, DamageSource, _par_ u32 oldHealth, _par_ u32 newHealth){};
|
||||||
[[maybe_unused]] u32 newHealth){};
|
|
||||||
virtual void OnFaint(Creature*, DamageSource){};
|
virtual void OnFaint(Creature*, DamageSource){};
|
||||||
virtual void OnSwitchIn(Creature*){};
|
virtual void OnSwitchIn(Creature*){};
|
||||||
};
|
};
|
||||||
|
|
|
@ -74,24 +74,24 @@ namespace CreatureLib::Library {
|
||||||
|
|
||||||
inline bool IncreaseStatBy(Statistic stat, T amount) {
|
inline bool IncreaseStatBy(Statistic stat, T amount) {
|
||||||
switch (stat) {
|
switch (stat) {
|
||||||
case CreatureLib::Library::Statistic::Health: ModifyStat(_health, +) break;
|
case CreatureLib::Library::Statistic::Health:
|
||||||
case CreatureLib::Library::Statistic::PhysicalAttack: ModifyStat(_physicalAttack, +) break;
|
ModifyStat(_health, +) case CreatureLib::Library::Statistic::PhysicalAttack
|
||||||
case CreatureLib::Library::Statistic::PhysicalDefense: ModifyStat(_physicalDefense, +) break;
|
: ModifyStat(_physicalAttack, +) case CreatureLib::Library::Statistic::PhysicalDefense
|
||||||
case CreatureLib::Library::Statistic::MagicalAttack: ModifyStat(_magicalAttack, +) break;
|
: ModifyStat(_physicalDefense, +) case CreatureLib::Library::Statistic::MagicalAttack
|
||||||
case CreatureLib::Library::Statistic::MagicalDefense: ModifyStat(_magicalDefense, +) break;
|
: ModifyStat(_magicalAttack, +) case CreatureLib::Library::Statistic::MagicalDefense
|
||||||
case CreatureLib::Library::Statistic::Speed: ModifyStat(_speed, +) break;
|
: ModifyStat(_magicalDefense, +) case CreatureLib::Library::Statistic::Speed
|
||||||
default: NOT_REACHABLE;
|
: ModifyStat(_speed, +) default : NOT_REACHABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline bool DecreaseStatBy(Statistic stat, T amount) {
|
inline bool DecreaseStatBy(Statistic stat, T amount) {
|
||||||
switch (stat) {
|
switch (stat) {
|
||||||
case CreatureLib::Library::Statistic::Health: ModifyStat(_health, -) break;
|
case CreatureLib::Library::Statistic::Health:
|
||||||
case CreatureLib::Library::Statistic::PhysicalAttack: ModifyStat(_physicalAttack, -) break;
|
ModifyStat(_health, -) case CreatureLib::Library::Statistic::PhysicalAttack
|
||||||
case CreatureLib::Library::Statistic::PhysicalDefense: ModifyStat(_physicalDefense, -) break;
|
: ModifyStat(_physicalAttack, -) case CreatureLib::Library::Statistic::PhysicalDefense
|
||||||
case CreatureLib::Library::Statistic::MagicalAttack: ModifyStat(_magicalAttack, -) break;
|
: ModifyStat(_physicalDefense, -) case CreatureLib::Library::Statistic::MagicalAttack
|
||||||
case CreatureLib::Library::Statistic::MagicalDefense: ModifyStat(_magicalDefense, -) break;
|
: ModifyStat(_magicalAttack, -) case CreatureLib::Library::Statistic::MagicalDefense
|
||||||
case CreatureLib::Library::Statistic::Speed: ModifyStat(_speed, -) break;
|
: ModifyStat(_magicalDefense, -) case CreatureLib::Library::Statistic::Speed
|
||||||
default: NOT_REACHABLE;
|
: ModifyStat(_speed, -) default : NOT_REACHABLE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue