Reworks attack scripts to handle effect chance and effect name through data files.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-04-06 12:02:29 +02:00
parent e2675d06fb
commit 340520e0e3
8 changed files with 68 additions and 21 deletions

View File

@@ -154,7 +154,9 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
hit->SetDamage(dmgLibrary->GetDamage(attack, target, hitIndex));
if (attackData->GetCategory() == Library::AttackCategory::Status) {
HOOK(OnStatusMove, userSource, attack, target, hitIndex);
if (attackData->HasSecondaryEffect()) {
HOOK(OnStatusMove, userSource, attack, target, hitIndex);
}
} else {
auto damage = hit->GetDamage();
if (damage > target->GetCurrentHealth()) {
@@ -164,10 +166,22 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
if (damage > 0) {
target->Damage(damage, DamageSource::AttackDamage);
bool preventSecondary = false;
HOOK(PreventSecondaryEffects, targetSource, attack, target, hitIndex, &preventSecondary);
if (!preventSecondary) {
HOOK(OnSecondaryEffect, userSource, attack, target, hitIndex);
if (attackData->HasSecondaryEffect()) {
bool preventSecondary = false;
HOOK(PreventSecondaryEffects, targetSource, attack, target, hitIndex, &preventSecondary);
if (!preventSecondary) {
auto effect = attackData->GetSecondaryEffect();
bool hasSecondaryEffect;
if (effect.GetChance() == -1) {
hasSecondaryEffect = true;
} else {
hasSecondaryEffect =
user->GetBattle()->GetRandom()->EffectChance(effect.GetChance(), attack, target);
}
if (hasSecondaryEffect) {
HOOK(OnSecondaryEffect, userSource, attack, target, hitIndex);
}
}
}
}
}