Update for item use scripts to be used in battle
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
0d87e480d1
commit
c0bdc73606
|
@ -65,20 +65,25 @@ bool AngelScriptItemUseScript::IsHoldable() const {
|
||||||
[&]([[maybe_unused]] asIScriptContext* ctx) { res = ctx->GetReturnByte() == 1; });
|
[&]([[maybe_unused]] asIScriptContext* ctx) { res = ctx->GetReturnByte() == 1; });
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
void AngelScriptItemUseScript::OnUse() const {
|
void AngelScriptItemUseScript::OnUse(CreatureLib::Battling::Battle* battle) const {
|
||||||
if (!__OnUse.Exists) {
|
if (!__OnUse.Exists) {
|
||||||
CreatureLib::Battling::ItemUseScript::OnUse();
|
CreatureLib::Battling::ItemUseScript::OnUse(battle);
|
||||||
}
|
}
|
||||||
AngelScriptUtils::AngelscriptFunctionCall(
|
AngelScriptUtils::AngelscriptFunctionCall(
|
||||||
__OnUse.Function, _resolver->GetContextPool(), _scriptObject, _resolver, ""_cnc,
|
__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) {
|
if (!__OnPokemonUse.Exists) {
|
||||||
CreatureLib::Battling::ItemUseScript::OnUse();
|
CreatureLib::Battling::ItemUseScript::OnCreatureUse(creature, isBattle);
|
||||||
}
|
}
|
||||||
AngelScriptUtils::AngelscriptFunctionCall(
|
AngelScriptUtils::AngelscriptFunctionCall(
|
||||||
__OnPokemonUse.Function, _resolver->GetContextPool(), _scriptObject, _resolver, ""_cnc,
|
__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) {});
|
[&]([[maybe_unused]] asIScriptContext* ctx) {});
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ public:
|
||||||
|
|
||||||
bool IsHoldable() const override;
|
bool IsHoldable() const override;
|
||||||
|
|
||||||
void OnUse() const override;
|
void OnUse(CreatureLib::Battling::Battle* battle) const override;
|
||||||
void OnCreatureUse(CreatureLib::Battling::Creature* creature) const override;
|
void OnCreatureUse(CreatureLib::Battling::Creature* creature, bool isBattle) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
asIScriptObject* _scriptObject;
|
asIScriptObject* _scriptObject;
|
||||||
|
|
|
@ -84,8 +84,8 @@ shared abstract class ItemUseScript {
|
||||||
|
|
||||||
bool IsHoldable() { return false; }
|
bool IsHoldable() { return false; }
|
||||||
|
|
||||||
void OnUse() { };
|
void OnUse(Battle@ battle) { };
|
||||||
void OnPokemonUse(Pokemon@ target) { };
|
void OnPokemonUse(Pokemon@ target, bool isBattle) { };
|
||||||
}
|
}
|
||||||
)");
|
)");
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
|
Loading…
Reference in New Issue