Implement AngelScript support for effect chance changes.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-02-16 15:21:58 +01:00
parent 321afbebe4
commit 0147515ffb
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
4 changed files with 23 additions and 1 deletions

View File

@ -44,7 +44,7 @@ class PkmnLibConan(ConanFile):
self.options["AngelScript"].link_std_statically = True self.options["AngelScript"].link_std_statically = True
def requirements(self): def requirements(self):
self.requires("CreatureLib/579ee82f02d6eedb5d924c8b4b056bfdb561ef53@creaturelib/master") self.requires("CreatureLib/54e366fc1b3a44b200de41421707bfe4802aaecb@creaturelib/master")
if self.options.script_handler == "angelscript": if self.options.script_handler == "angelscript":
self.requires("AngelScript/2.34@AngelScript/Deukhoofd") self.requires("AngelScript/2.34@AngelScript/Deukhoofd")
else: else:

View File

@ -170,6 +170,23 @@ public:
void PreventSelfSwitch(const CreatureLib::Battling::SwitchTurnChoice* choice, bool* outResult) override { void PreventSelfSwitch(const CreatureLib::Battling::SwitchTurnChoice* choice, bool* outResult) override {
throw NotImplementedException(); // TODO throw NotImplementedException(); // TODO
} }
void ModifyEffectChance(const CreatureLib::Battling::ExecutingAttack* attack,
CreatureLib::Battling::Creature* target, float* chance) override {
CALL_HOOK(ModifyEffectChance, {
ctx->SetArgObject(0, (void*)attack);
ctx->SetArgObject(1, (void*)target);
ctx->SetArgAddress(2, chance);
})
}
void ModifyIncomingEffectChance(const CreatureLib::Battling::ExecutingAttack* attack,
CreatureLib::Battling::Creature* target, float* chance) override {
CALL_HOOK(ModifyIncomingEffectChance, {
ctx->SetArgObject(0, (void*)attack);
ctx->SetArgObject(1, (void*)target);
ctx->SetArgAddress(2, chance);
})
}
}; };
#undef CALL_HOOK #undef CALL_HOOK

View File

@ -88,6 +88,10 @@ public:
SCRIPT_HOOK_FUNCTION(OnSecondaryEffect, SCRIPT_HOOK_FUNCTION(OnSecondaryEffect,
"void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit)"); "void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit)");
SCRIPT_HOOK_FUNCTION(OnAfterHits, "void OnAfterHits(ExecutingMove@ attack, Pokemon@ target)"); SCRIPT_HOOK_FUNCTION(OnAfterHits, "void OnAfterHits(ExecutingMove@ attack, Pokemon@ target)");
SCRIPT_HOOK_FUNCTION(ModifyEffectChance,
"void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, uint16& chance)");
SCRIPT_HOOK_FUNCTION(ModifyIncomingEffectChance,
"void ModifyIncomingEffectChance(ExecutingMove@ attack, Pokemon@ target, uint16& chance)");
}; };
#undef SCRIPT_HOOK_FUNCTION #undef SCRIPT_HOOK_FUNCTION

View File

@ -21,6 +21,7 @@ shared abstract class PkmnScript {
void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit){}; void OnSecondaryEffect(ExecutingMove@ attack, Pokemon@ target, uint8 hit){};
void OnAfterHits(ExecutingMove@ attack, Pokemon@ target){}; void OnAfterHits(ExecutingMove@ attack, Pokemon@ target){};
void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, uint16& chance){};
} }
)"); )");
assert(r >= 0); assert(r >= 0);