Adds pointer to battle library in on initialize function
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2022-02-12 17:19:07 +01:00
parent 179b94a677
commit 173c6c9926
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 6 additions and 4 deletions

View File

@ -24,7 +24,7 @@ namespace CreatureLib::Battling {
_activeTalent = std::unique_ptr<BattleScript>(
_library->LoadScript(this, ScriptCategory::Talent, GetActiveTalent()->GetEffect()));
if (_activeTalent != nullptr) {
_activeTalent->OnInitialize(GetActiveTalent()->GetParameters());
_activeTalent->OnInitialize(_library.GetRaw(), GetActiveTalent()->GetParameters());
}
for (auto t : _variant->GetTypes()) {
_types.push_back(t);
@ -80,7 +80,7 @@ namespace CreatureLib::Battling {
_activeTalent = std::unique_ptr<BattleScript>(
_library->LoadScript(this, ScriptCategory::Talent, GetActiveTalent()->GetEffect()));
if (_activeTalent != nullptr) {
_activeTalent->OnInitialize(GetActiveTalent()->GetParameters());
_activeTalent->OnInitialize(_library.GetRaw(), GetActiveTalent()->GetParameters());
}
// We modify the health of the creature by the change in its max health.

View File

@ -15,6 +15,7 @@ namespace CreatureLib::Battling {
class FleeTurnChoice;
class ExecutingAttack;
class Creature;
class BattleLibrary;
class BattleScript {
ArbUt::OptionalBorrowedPtr<void> _owner;
@ -43,7 +44,8 @@ namespace CreatureLib::Battling {
#define _par_ [[maybe_unused]]
virtual void OnInitialize(_par_ const ArbUt::List<CreatureLib::Library::EffectParameter*>& parameters){};
virtual void OnInitialize(_par_ const BattleLibrary*,
_par_ const ArbUt::List<CreatureLib::Library::EffectParameter*>& parameters){};
virtual void OnBeforeTurn(_par_ const BaseTurnChoice* choice){};
virtual void ChangePriority(_par_ AttackTurnChoice* choice, _par_ int8_t* priority){};

View File

@ -28,7 +28,7 @@ namespace CreatureLib::Battling {
_attackScript = std::unique_ptr<BattleScript>(
library->LoadScript(this, ScriptCategory::Attack, effect->GetEffectName()));
if (_attackScript != nullptr) {
_attackScript->OnInitialize(effect->GetParameters());
_attackScript->OnInitialize(battle.GetValue()->GetLibrary().GetRaw(), effect->GetParameters());
}
}
}