Turn SecondaryEffect class into pointer type, owned by AttackData.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -172,11 +172,11 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
|
||||
if (!preventSecondary) {
|
||||
auto effect = attackData->GetSecondaryEffect();
|
||||
bool hasSecondaryEffect;
|
||||
if (effect.GetChance() == -1) {
|
||||
if (effect->GetChance() == -1) {
|
||||
hasSecondaryEffect = true;
|
||||
} else {
|
||||
hasSecondaryEffect =
|
||||
user->GetBattle()->GetRandom()->EffectChance(effect.GetChance(), attack, target);
|
||||
user->GetBattle()->GetRandom()->EffectChance(effect->GetChance(), attack, target);
|
||||
}
|
||||
if (hasSecondaryEffect) {
|
||||
HOOK(OnSecondaryEffect, userSource, attack, target, hitIndex);
|
||||
|
||||
@@ -17,7 +17,7 @@ static CreatureLib::Library::AttackData* GetReplacementAttackData() {
|
||||
if (_replacementAttackData == nullptr) {
|
||||
_replacementAttackData = new CreatureLib::Library::AttackData(
|
||||
"replacement"_cnc, 0, CreatureLib::Library::AttackCategory::Physical, 30, 255, 255,
|
||||
CreatureLib::Library::AttackTarget::Any, 0, CreatureLib::Library::SecondaryEffect(), {});
|
||||
CreatureLib::Library::AttackTarget::Any, 0, new CreatureLib::Library::SecondaryEffect(), {});
|
||||
}
|
||||
return _replacementAttackData;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ namespace CreatureLib::Battling {
|
||||
if (battle != nullptr) {
|
||||
if (_attack->GetAttack()->HasSecondaryEffect()) {
|
||||
auto library = battle->GetLibrary();
|
||||
auto& effect = _attack->GetAttack()->GetSecondaryEffect();
|
||||
_attackScript = library->LoadScript(ScriptCategory::Attack, effect.GetEffectName());
|
||||
auto effect = _attack->GetAttack()->GetSecondaryEffect();
|
||||
_attackScript = library->LoadScript(ScriptCategory::Attack, effect->GetEffectName());
|
||||
if (_attackScript != nullptr) {
|
||||
_attackScript->OnInitialize(effect.GetParameters());
|
||||
_attackScript->OnInitialize(effect->GetParameters());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user