Pass ExecutingAttack for target as pointer instead of reference.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-02-16 12:02:17 +01:00
parent 252be18630
commit 579ee82f02
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 4 additions and 4 deletions

View File

@ -3,7 +3,7 @@
using namespace CreatureLib::Battling;
int DamageLibrary::GetDamage(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
auto levelMod = static_cast<float>(2 * attack->GetUser()->GetLevel());
auto hit = attack->GetAttackDataForTarget(target).GetHit(hitIndex);
auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex);
auto bp = hit->GetBasePower();
auto statMod = GetStatModifier(attack, target, hitIndex);
// HOOK: Modify stat modifier
@ -22,7 +22,7 @@ int DamageLibrary::GetBasePower(ExecutingAttack* attack, Creature* target, uint8
float DamageLibrary::GetStatModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
auto user = attack->GetUser();
// HOOK: allow overriding for which users stat we use.
auto hit = attack->GetAttackDataForTarget(target).GetHit(hitIndex);
auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex);
Core::Statistic offensiveStat;
Core::Statistic defensiveStat;
if (attack->GetAttack()->GetAttack()->GetCategory() == Library::AttackCategory::Physical) {
@ -57,7 +57,7 @@ float DamageLibrary::GetStatModifier(ExecutingAttack* attack, Creature* target,
float DamageLibrary::GetDamageModifier(ExecutingAttack* attack, Creature* target, uint8_t hitIndex) const {
float mod = 1;
auto hit = attack->GetAttackDataForTarget(target).GetHit(hitIndex);
auto hit = attack->GetAttackDataForTarget(target)->GetHit(hitIndex);
mod *= hit->GetEffectiveness();
// HOOK: Modify damage modifier.
return mod;

View File

@ -69,7 +69,7 @@ namespace CreatureLib::Battling {
virtual ~ExecutingAttack() { delete _script; };
TargetData& GetAttackDataForTarget(Creature* creature) { return _targets[creature]; }
TargetData* GetAttackDataForTarget(Creature* creature) { return &_targets[creature]; }
bool IsCreatureTarget(Creature* creature) { return _targets.find(creature) != _targets.end(); }