Implements most of the Damage Modifier calculation.
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
ce54861966
commit
12066e1dfe
|
@ -1,5 +1,8 @@
|
|||
#include "DamageLibrary.hpp"
|
||||
#include <CreatureLib/Battling/Models/Battle.hpp>
|
||||
#include "../PkmnScriptHook.hpp"
|
||||
#include "../Pokemon/Pokemon.hpp"
|
||||
|
||||
using HitData = const CreatureLib::Battling::ExecutingAttack::HitData;
|
||||
|
||||
uint32_t PkmnLib::Battling::DamageLibrary::GetDamage(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
|
@ -63,6 +66,21 @@ float PkmnLib::Battling::DamageLibrary::GetDamageModifier(CreatureLib::Battling:
|
|||
CreatureLib::Battling::Creature* target, uint8_t hitIndex,
|
||||
const HitData& hitData) const {
|
||||
float mod = 1;
|
||||
if (attack->GetTargetCount() > 1)
|
||||
mod *= 0.75;
|
||||
if (hitData.IsCritical()) {
|
||||
float critModifier = 1.5;
|
||||
PKMN_HOOK(OverrideCriticalModifier, attack, attack, target, hitIndex, &critModifier);
|
||||
mod *= critModifier;
|
||||
}
|
||||
float randPercentage = 85 + attack->GetUser()->GetBattle()->GetRandom()->Get(0, 16);
|
||||
mod *= randPercentage / 100.0;
|
||||
if (attack->GetUser()->HasType(hitData.GetType())) {
|
||||
float stabModifier = 1.5;
|
||||
PKMN_HOOK(OverrideSTABModifier, attack, attack, target, hitIndex, &stabModifier);
|
||||
mod *= stabModifier;
|
||||
}
|
||||
|
||||
mod *= hitData.GetEffectiveness();
|
||||
// HOOK: Modify damage modifier.
|
||||
return mod;
|
||||
|
|
|
@ -7,6 +7,12 @@ namespace PkmnLib::Battling {
|
|||
public:
|
||||
virtual void ModifyCriticalStage(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit, uint8_t* critStage){};
|
||||
virtual void OverrideCriticalModifier(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit,
|
||||
float* critModifier){};
|
||||
virtual void OverrideSTABModifier(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit, float* stabModifier){};
|
||||
|
||||
virtual void ModifyExperienceGain(CreatureLib::Battling::Creature* faintedMon,
|
||||
CreatureLib::Battling::Creature* winningMon, uint32_t* experienceGain){};
|
||||
virtual void DoesShareExperience(CreatureLib::Battling::Creature* faintedMon,
|
||||
|
|
|
@ -273,3 +273,23 @@ void AngelScriptScript::DoesShareExperience(CreatureLib::Battling::Creature* fai
|
|||
ctx->SetArgAddress(2, shareExperience);
|
||||
})
|
||||
}
|
||||
void AngelScriptScript::OverrideCriticalModifier(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit,
|
||||
float* critModifier) {
|
||||
CALL_HOOK(OverrideCriticalModifier, {
|
||||
ctx->SetArgObject(0, (void*)attack);
|
||||
ctx->SetArgObject(1, (void*)target);
|
||||
ctx->SetArgByte(2, hit);
|
||||
ctx->SetArgAddress(3, critModifier);
|
||||
})
|
||||
}
|
||||
void AngelScriptScript::OverrideSTABModifier(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit,
|
||||
float* stabModifier) {
|
||||
CALL_HOOK(OverrideSTABModifier, {
|
||||
ctx->SetArgObject(0, (void*)attack);
|
||||
ctx->SetArgObject(1, (void*)target);
|
||||
ctx->SetArgByte(2, hit);
|
||||
ctx->SetArgAddress(3, stabModifier);
|
||||
})
|
||||
}
|
||||
|
|
|
@ -107,6 +107,10 @@ public:
|
|||
|
||||
void ModifyCriticalStage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
|
||||
uint8_t hit, uint8_t* critStage) override;
|
||||
void OverrideCriticalModifier(CreatureLib::Battling::ExecutingAttack* attack,
|
||||
CreatureLib::Battling::Creature* target, uint8_t hit, float* critModifier) override;
|
||||
void OverrideSTABModifier(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
|
||||
uint8_t hit, float* stabModifier) override;
|
||||
|
||||
void ModifyExperienceGain(CreatureLib::Battling::Creature* faintedMon, CreatureLib::Battling::Creature* winningMon,
|
||||
uint32_t* experienceGain) override;
|
||||
|
|
|
@ -130,6 +130,12 @@ public:
|
|||
SCRIPT_HOOK_FUNCTION(
|
||||
ModifyCriticalStage,
|
||||
"void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage)");
|
||||
SCRIPT_HOOK_FUNCTION(
|
||||
OverrideCriticalModifier,
|
||||
"void OverrideCriticalModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& critModifier)");
|
||||
SCRIPT_HOOK_FUNCTION(
|
||||
OverrideSTABModifier,
|
||||
"void OverrideSTABModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& stabModifier)");
|
||||
SCRIPT_HOOK_FUNCTION(ModifyExperienceGain,
|
||||
"void ModifyExperienceGain(Pokemon@ faintedMon, Pokemon@ winningMon, uint32& critStage)");
|
||||
SCRIPT_HOOK_FUNCTION(DoesShareExperience,
|
||||
|
|
|
@ -39,6 +39,9 @@ shared abstract class PkmnScript {
|
|||
|
||||
// PkmnLib methods
|
||||
void ModifyCriticalStage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& critStage){};
|
||||
void OverrideCriticalModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& critModifier){};
|
||||
void OverrideSTABModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& stabModifier){};
|
||||
|
||||
void ModifyExperienceGain(Pokemon@ faintedMon, Pokemon@ winningMon, uint32& critStage){};
|
||||
void DoesShareExperience(Pokemon@ faintedMon, Pokemon@ winningMon, bool& shareExperience){};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue