Fixes for damage calculations always using a base power of 0.

This commit is contained in:
2019-12-07 22:09:06 +01:00
parent 262279bd2c
commit 7c642f7df5
5 changed files with 23 additions and 23 deletions

View File

@@ -85,7 +85,7 @@ void TurnHandler::ExecuteAttackChoice(AttackTurnChoice* choice) {
HOOK(OnBeforeAttack, attack, attack);
for (auto& kv : attack->GetTargets()) {
HandleAttackForTarget(attack, kv.first, kv.second);
HandleAttackForTarget(attack, kv.first, &kv.second);
}
// TODO: We currently delete this, but we probably want to store this in a log, so scripts can look it up.
@@ -93,7 +93,7 @@ void TurnHandler::ExecuteAttackChoice(AttackTurnChoice* choice) {
}
void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* target,
const ExecutingAttack::TargetData& targetData) {
ExecutingAttack::TargetData* targetData) {
auto user = attack->GetUser();
ScriptSource* targetSource = target;
@@ -113,12 +113,12 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
return;
}
if (!targetData.IsHit()) {
if (!targetData->IsHit()) {
HOOK(OnAttackMiss, targetSource, attack, target);
return;
}
auto numHits = targetData.GetNumberOfHits();
auto numHits = targetData->GetNumberOfHits();
if (numHits == 0)
return;
auto attackData = attack->GetAttack()->GetAttack();
@@ -132,22 +132,22 @@ void TurnHandler::HandleAttackForTarget(ExecutingAttack* attack, Creature* targe
// STOP, STOP! HE'S ALREADY DEAD ;_;
break;
}
auto hit = targetData.GetHit(hitIndex);
auto hit = targetData->GetHit(hitIndex);
auto hitType = hit.GetType();
auto hitType = hit->GetType();
HOOK(ChangeAttackType, targetSource, attack, target, hitIndex, hitType);
hit.SetEffectiveness(library->GetTypeLibrary()->GetEffectiveness(hitType, target->GetTypes()));
hit.SetCritical(library->GetCriticalLibrary()->IsCritical(attack, target, hitIndex));
hit.SetBasePower(dmgLibrary->GetBasePower(attack, target, hitIndex));
hit.SetDamage(dmgLibrary->GetDamage(attack, target, hitIndex));
hit->SetEffectiveness(library->GetTypeLibrary()->GetEffectiveness(hitType, target->GetTypes()));
hit->SetCritical(library->GetCriticalLibrary()->IsCritical(attack, target, hitIndex));
hit->SetBasePower(dmgLibrary->GetBasePower(attack, target, hitIndex));
hit->SetDamage(dmgLibrary->GetDamage(attack, target, hitIndex));
if (attackData->GetCategory() == Library::AttackCategory::Status) {
HOOK(OnStatusMove, userSource, attack, target, hitIndex);
} else {
auto damage = hit.GetDamage();
auto damage = hit->GetDamage();
if (damage > target->GetCurrentHealth()) {
damage = target->GetCurrentHealth();
hit.SetDamage(damage);
hit->SetDamage(damage);
}
if (damage > 0) {
target->Damage(damage, DamageSource::AttackDamage);

View File

@@ -13,7 +13,7 @@ namespace CreatureLib::Battling {
static void ExecuteAttackChoice(AttackTurnChoice* choice);
static void HandleAttackForTarget(ExecutingAttack* attack, Creature* target,
const ExecutingAttack::TargetData& targetData);
ExecutingAttack::TargetData* targetData);
public:
static void RunTurn(Battle* battle, ChoiceQueue* queue);