Update for item use scripts to be used in battle
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2022-02-13 13:47:30 +01:00
parent 0d87e480d1
commit c0bdc73606
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
3 changed files with 15 additions and 10 deletions

View File

@ -65,20 +65,25 @@ bool AngelScriptItemUseScript::IsHoldable() const {
[&]([[maybe_unused]] asIScriptContext* ctx) { res = ctx->GetReturnByte() == 1; });
return res;
}
void AngelScriptItemUseScript::OnUse() const {
void AngelScriptItemUseScript::OnUse(CreatureLib::Battling::Battle* battle) const {
if (!__OnUse.Exists) {
CreatureLib::Battling::ItemUseScript::OnUse();
CreatureLib::Battling::ItemUseScript::OnUse(battle);
}
AngelScriptUtils::AngelscriptFunctionCall(
__OnUse.Function, _resolver->GetContextPool(), _scriptObject, _resolver, ""_cnc,
[&]([[maybe_unused]] asIScriptContext* ctx) {}, [&]([[maybe_unused]] asIScriptContext* ctx) {});
[&]([[maybe_unused]] asIScriptContext* ctx) {
ctx->SetArgObject(0, battle);
}, [&]([[maybe_unused]] asIScriptContext* ctx) {});
}
void AngelScriptItemUseScript::OnCreatureUse(CreatureLib::Battling::Creature* creature) const {
void AngelScriptItemUseScript::OnCreatureUse(CreatureLib::Battling::Creature* creature, bool isBattle) const {
if (!__OnPokemonUse.Exists) {
CreatureLib::Battling::ItemUseScript::OnUse();
CreatureLib::Battling::ItemUseScript::OnCreatureUse(creature, isBattle);
}
AngelScriptUtils::AngelscriptFunctionCall(
__OnPokemonUse.Function, _resolver->GetContextPool(), _scriptObject, _resolver, ""_cnc,
[&]([[maybe_unused]] asIScriptContext* ctx) { ctx->SetArgObject(0, (void*)creature); },
[&]([[maybe_unused]] asIScriptContext* ctx) {
ctx->SetArgObject(0, (void*)creature);
ctx->SetArgByte(1, isBattle);
},
[&]([[maybe_unused]] asIScriptContext* ctx) {});
}

View File

@ -25,8 +25,8 @@ public:
bool IsHoldable() const override;
void OnUse() const override;
void OnCreatureUse(CreatureLib::Battling::Creature* creature) const override;
void OnUse(CreatureLib::Battling::Battle* battle) const override;
void OnCreatureUse(CreatureLib::Battling::Creature* creature, bool isBattle) const override;
private:
asIScriptObject* _scriptObject;

View File

@ -84,8 +84,8 @@ shared abstract class ItemUseScript {
bool IsHoldable() { return false; }
void OnUse() { };
void OnPokemonUse(Pokemon@ target) { };
void OnUse(Battle@ battle) { };
void OnPokemonUse(Pokemon@ target, bool isBattle) { };
}
)");
Ensure(r >= 0);