Support for new move fail handling.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-03-27 13:33:56 +01:00
parent 301c28d7a7
commit af559f757c
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
6 changed files with 35 additions and 3 deletions

View File

@ -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;

View File

@ -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);
})
}

View File

@ -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//
////////////////////

View File

@ -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

View File

@ -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);