diff --git a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp index 0e7acb0..f155d76 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp @@ -177,7 +177,7 @@ CreatureLib::Battling::ItemUseScript* AngelScriptResolver::LoadItemScript(const asIScriptObject* obj = *(asIScriptObject**)ctx->GetAddressOfReturnValue(); obj->AddRef(); auto scriptObject = new AngelScriptItemUseScript(obj, this); - scriptObject->OnInitialize(item->GetEffect()->GetParameters()); + scriptObject->OnInitialize(item->GetEffect().GetValue()->GetParameters()); _itemUseScripts.Insert(item, scriptObject); _contextPool->ReturnContextToPool(ctx); return scriptObject; diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp index d5f24df..7ec823c 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp @@ -261,3 +261,19 @@ void AngelScriptScript::OverrideSTABModifier(CreatureLib::Battling::ExecutingAtt ctx->SetArgAddress(3, stabModifier); }) } +void AngelScriptScript::ChangePriority(CreatureLib::Battling::AttackTurnChoice* choice, int8_t* priority) { + CALL_HOOK(ChangePriority, { + ctx->SetArgObject(0, (void*)choice); + ctx->SetArgAddress(1, priority); + }) +} +void AngelScriptScript::OnFail(CreatureLib::Battling::Creature* target) { + CALL_HOOK(OnFail, { + ctx->SetArgObject(0, (void*)target); + }) +} +void AngelScriptScript::OnOpponentFail(CreatureLib::Battling::Creature* target) { + CALL_HOOK(OnOpponentFail, { + ctx->SetArgObject(0, (void*)target); + }) +} diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp index da3e3fe..08dd636 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.hpp @@ -97,6 +97,10 @@ public: void OverrideDamage(CreatureLib::Battling::ExecutingAttack* attack, CreatureLib::Battling::Creature* target, uint8_t hitIndex, uint32_t* damage) override; + void ChangePriority(CreatureLib::Battling::AttackTurnChoice* choice, int8_t* priority) override; + void OnFail(CreatureLib::Battling::Creature* target) override; + void OnOpponentFail(CreatureLib::Battling::Creature* target) override; + //////////////////// // PkmnLib methods// //////////////////// diff --git a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp index b4f1690..e8840a3 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptTypeInfo.hpp @@ -52,7 +52,7 @@ public: } asIScriptObject* Instantiate(asIScriptContext* ctx) { - auto factory = _type->GetFactoryByIndex(0); + auto* factory = _type->GetFactoryByIndex(0); ctx->Prepare(factory); auto result = ctx->Execute(); if (result != asEXECUTION_FINISHED) { @@ -132,6 +132,10 @@ public: "void ModifyExperienceGain(Pokemon@ faintedMon, Pokemon@ winningMon, uint32& critStage)"); SCRIPT_HOOK_FUNCTION(DoesShareExperience, "void DoesShareExperience(Pokemon@ faintedMon, Pokemon@ winningMon, bool& shareExperience)"); + + SCRIPT_HOOK_FUNCTION(ChangePriority, "void ChangePriority(MoveTurnChoice@ choice, int8& priority)"); + SCRIPT_HOOK_FUNCTION(OnFail, "void OnFail(Pokemon@ user)"); + SCRIPT_HOOK_FUNCTION(OnOpponentFail, "void OnOpponentFail(Pokemon@ user)"); }; #undef SCRIPT_HOOK_FUNCTION diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp index f94cdab..ca0e06e 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/BasicScriptClass.cpp @@ -36,7 +36,7 @@ shared abstract class PkmnScript { void ModifyDamageModifier(ExecutingMove@ attack, Pokemon@ target, uint8 hit, float& modifier){}; void OverrideDamage(ExecutingMove@ attack, Pokemon@ target, uint8 hit, uint& damage){}; - // PkmnLib methods + // 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){}; diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp index 6dc839d..efd8075 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterExecutingAttack.cpp @@ -36,6 +36,14 @@ void RegisterExecutingAttack::RegisterHitData(asIScriptEngine* engine) { asMETHOD(CreatureLib::Battling::ExecutingAttack::HitData, GetType), asCALL_THISCALL); Ensure(r >= 0); + r = engine->RegisterObjectMethod("HitData", "bool get_HasFailed() const property", + asMETHOD(CreatureLib::Battling::ExecutingAttack::HitData, HasFailed), + asCALL_THISCALL); + Ensure(r >= 0); + r = engine->RegisterObjectMethod("HitData", "void Fail()", + asMETHOD(CreatureLib::Battling::ExecutingAttack::HitData, Fail), + asCALL_THISCALL); + Ensure(r >= 0); } void RegisterExecutingAttack::RegisterExecutingAttackType(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("ExecutingMove", 0, asOBJ_REF | asOBJ_NOCOUNT);