Add new damage library script hooks to AngelScript.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-02-19 10:25:27 +01:00
parent a6e1726dc5
commit 83a49eee6c
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
4 changed files with 91 additions and 3 deletions

View File

@ -45,7 +45,7 @@ class PkmnLibConan(ConanFile):
self.options["AngelScript"].link_std_statically = True
def requirements(self):
self.requires("CreatureLib/5e29f50ea138bdc82f873e80bea49cca0441ee5e@creaturelib/master")
self.requires("CreatureLib/b886f0aebf86945ef333ce0913d1661c2396adf9@creaturelib/master")
if self.options.script_handler == "angelscript":
self.requires("AngelScript/2.34@AngelScript/Deukhoofd")
else:

View File

@ -187,6 +187,70 @@ public:
ctx->SetArgAddress(2, chance);
})
}
void OverrideBasePower(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
uint8_t hitIndex, uint8_t* basePower) override {
CALL_HOOK(OverrideBasePower, {
ctx->SetArgObject(0, (void*)attack);
ctx->SetArgObject(1, (void*)target);
ctx->SetArgByte(2, hitIndex);
ctx->SetArgAddress(3, basePower);
})
}
void ChangeDamageStatsUser(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
uint8_t hitIndex, CreatureLib::Battling::Creature** statsUser) override {
CALL_HOOK(ChangeDamageStatsUser, {
ctx->SetArgObject(0, (void*)attack);
ctx->SetArgObject(1, (void*)target);
ctx->SetArgByte(2, hitIndex);
ctx->SetArgAddress(3, statsUser);
})
}
void BypassDefensiveStat(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
uint8_t hitIndex, bool* bypass) override {
CALL_HOOK(BypassDefensiveStat, {
ctx->SetArgObject(0, (void*)attack);
ctx->SetArgObject(1, (void*)target);
ctx->SetArgByte(2, hitIndex);
ctx->SetArgAddress(3, bypass);
})
}
void BypassOffensiveStat(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
uint8_t hitIndex, bool* bypass) override {
CALL_HOOK(BypassOffensiveStat, {
ctx->SetArgObject(0, (void*)attack);
ctx->SetArgObject(1, (void*)target);
ctx->SetArgByte(2, hitIndex);
ctx->SetArgAddress(3, bypass);
})
}
void ModifyStatModifier(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
uint8_t hitIndex, float* modifier) override {
CALL_HOOK(ModifyStatModifier, {
ctx->SetArgObject(0, (void*)attack);
ctx->SetArgObject(1, (void*)target);
ctx->SetArgByte(2, hitIndex);
ctx->SetArgAddress(3, modifier);
})
}
void ModifyDamageModifier(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
uint8_t hitIndex, float* modifier) override {
CALL_HOOK(ModifyDamageModifier, {
ctx->SetArgObject(0, (void*)attack);
ctx->SetArgObject(1, (void*)target);
ctx->SetArgByte(2, hitIndex);
ctx->SetArgAddress(3, modifier);
})
}
void OverrideDamage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target,
uint8_t hitIndex, int32_t* damage) override {
CALL_HOOK(OverrideDamage, {
ctx->SetArgObject(0, (void*)attack);
ctx->SetArgObject(1, (void*)target);
ctx->SetArgByte(2, hitIndex);
ctx->SetArgAddress(3, damage);
})
}
};
#undef CALL_HOOK

View File

@ -90,8 +90,24 @@ public:
SCRIPT_HOOK_FUNCTION(OnAfterHits, "void OnAfterHits(ExecutingMove@ attack, Pokemon@ target)");
SCRIPT_HOOK_FUNCTION(ModifyEffectChance,
"void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance)");
SCRIPT_HOOK_FUNCTION(ModifyIncomingEffectChance,
SCRIPT_HOOK_FUNCTION(ModifyIncomingEffectChance,
"void ModifyIncomingEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance)");
SCRIPT_HOOK_FUNCTION(OverrideBasePower,
"void OverrideBasePower(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& chance)");
SCRIPT_HOOK_FUNCTION(ChangeDamageStatsUser,
"void ChangeDamageStatsUser(ExecutingMove@ attack, Pokemon@ target, uint8 hit, Pokemon@& user)");
SCRIPT_HOOK_FUNCTION(BypassDefensiveStat,
"void BypassDefensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass)");
SCRIPT_HOOK_FUNCTION(BypassOffensiveStat,
"void BypassOffensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass)");
SCRIPT_HOOK_FUNCTION(ModifyStatModifier,
"void ModifyStatModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier)");
SCRIPT_HOOK_FUNCTION(ModifyDamageModifier,
"void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier)");
SCRIPT_HOOK_FUNCTION(OverrideDamage,
"void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, int& damage)");
};
#undef SCRIPT_HOOK_FUNCTION

View File

@ -23,6 +23,14 @@ shared abstract class PkmnScript {
void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance){};
void ModifyIncomingEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance){};
void OverrideBasePower(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint8& chance){};
void ChangeDamageStatsUser(ExecutingMove@ attack, Pokemon@ target, uint8 hit, Pokemon@& user){};
void BypassDefensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass){};
void BypassOffensiveStat(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& bypass){};
void ModifyStatModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){};
void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){};
void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, int& damage){};
}
)");
assert(r >= 0);