From 59a092a06ef65c64ac31d3aa34b6d6a0466f9f9f Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 13 May 2021 13:25:08 +0200 Subject: [PATCH] Use GetUseAttack for executingmove --- src/Battling/Library/DamageLibrary.cpp | 5 ++--- .../TypeRegistry/Battling/RegisterExecutingAttack.cpp | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Battling/Library/DamageLibrary.cpp b/src/Battling/Library/DamageLibrary.cpp index 66d238e..df1aba8 100644 --- a/src/Battling/Library/DamageLibrary.cpp +++ b/src/Battling/Library/DamageLibrary.cpp @@ -30,7 +30,7 @@ uint8_t PkmnLib::Battling::DamageLibrary::GetBasePower(CreatureLib::Battling::Ex [[maybe_unused]] CreatureLib::Battling::Creature* target, [[maybe_unused]] uint8_t hitIndex, [[maybe_unused]] const HitData& hitData) const { - auto bp = attack->GetAttack()->GetAttack()->GetBasePower(); + auto bp = attack->GetUseAttack()->GetBasePower(); // HOOK: modify base power. return bp; } @@ -41,8 +41,7 @@ float PkmnLib::Battling::DamageLibrary::GetStatModifier(CreatureLib::Battling::E // HOOK: allow overriding for which users stat we use. CreatureLib::Library::Statistic offensiveStat; CreatureLib::Library::Statistic defensiveStat; - auto learnedMove = attack->GetAttack().ForceAs(); - auto moveData = learnedMove->GetMoveData(); + auto moveData = attack->GetUseAttack().ForceAs(); if (moveData->GetCategory() == Library::MoveCategory::Physical) { offensiveStat = Library::Statistic::PhysicalAttack; defensiveStat = Library::Statistic::PhysicalDefense; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp index b06d928..b72fc52 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp @@ -8,6 +8,7 @@ void RegisterExecutingAttack::Register(asIScriptEngine* engine) { } BORROWED_PTR_GETTER_FUNC(CreatureLib::Battling::ExecutingAttack, CreatureLib::Battling::Creature, GetUser); BORROWED_PTR_GETTER_FUNC(CreatureLib::Battling::ExecutingAttack, CreatureLib::Battling::LearnedAttack, GetAttack); +BORROWED_PTR_GETTER_FUNC(CreatureLib::Battling::ExecutingAttack, const CreatureLib::Library::AttackData, GetUseAttack); static CreatureLib::Battling::ExecutingAttack::HitData* GetHitDataWrapper(CreatureLib::Battling::ExecutingAttack* obj, CreatureLib::Battling::Creature* c, uint8_t hit) { return &obj->GetHitData(c, hit); @@ -60,4 +61,7 @@ void RegisterExecutingAttack::RegisterExecutingAttackType(asIScriptEngine* engin r = engine->RegisterObjectMethod("ExecutingMove", "LearnedMove@ get_Move() const property", asFUNCTION(GetAttackWrapper), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); + r = engine->RegisterObjectMethod("ExecutingMove", "MoveData@ get_UseMove() const property", + asFUNCTION(GetUseAttackWrapper), asCALL_CDECL_OBJFIRST); + Ensure(r >= 0); }