Implements missing Script functions.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
b1442f25fb
commit
2e60096d57
|
@ -102,11 +102,14 @@ public:
|
||||||
void OnRemove() override { CALL_HOOK(OnRemove, ); }
|
void OnRemove() override { CALL_HOOK(OnRemove, ); }
|
||||||
|
|
||||||
void OnBeforeTurn(const CreatureLib::Battling::BaseTurnChoice* choice) override {
|
void OnBeforeTurn(const CreatureLib::Battling::BaseTurnChoice* choice) override {
|
||||||
throw NotImplementedException(); // TODO
|
CALL_HOOK(OnBeforeTurn, { ctx->SetArgObject(0, (void*)choice); })
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChangeAttack(CreatureLib::Battling::AttackTurnChoice* choice, ConstString* outAttack) override {
|
void ChangeAttack(CreatureLib::Battling::AttackTurnChoice* choice, ConstString* outAttack) override {
|
||||||
throw NotImplementedException(); // TODO
|
CALL_HOOK(ChangeAttack, {
|
||||||
|
ctx->SetArgObject(0, (void*)choice);
|
||||||
|
ctx->SetArgAddress(0, outAttack);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreventAttack(CreatureLib::Battling::ExecutingAttack* attack, bool* outResult) override {
|
void PreventAttack(CreatureLib::Battling::ExecutingAttack* attack, bool* outResult) override {
|
||||||
|
@ -206,7 +209,10 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreventSelfSwitch(const CreatureLib::Battling::SwitchTurnChoice* choice, bool* outResult) override {
|
void PreventSelfSwitch(const CreatureLib::Battling::SwitchTurnChoice* choice, bool* outResult) override {
|
||||||
throw NotImplementedException(); // TODO
|
CALL_HOOK(PreventSelfSwitch, {
|
||||||
|
ctx->SetArgObject(0, (void*)choice);
|
||||||
|
ctx->SetArgAddress(1, outResult);
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModifyEffectChance(const CreatureLib::Battling::ExecutingAttack* attack,
|
void ModifyEffectChance(const CreatureLib::Battling::ExecutingAttack* attack,
|
||||||
|
|
|
@ -82,6 +82,9 @@ public:
|
||||||
SCRIPT_HOOK_FUNCTION(OnInitialize, "void OnInitialize(const array<EffectParameter@> &in parameters)");
|
SCRIPT_HOOK_FUNCTION(OnInitialize, "void OnInitialize(const array<EffectParameter@> &in parameters)");
|
||||||
SCRIPT_HOOK_FUNCTION(Stack, "void Stack()");
|
SCRIPT_HOOK_FUNCTION(Stack, "void Stack()");
|
||||||
SCRIPT_HOOK_FUNCTION(OnRemove, "void OnRemove()");
|
SCRIPT_HOOK_FUNCTION(OnRemove, "void OnRemove()");
|
||||||
|
SCRIPT_HOOK_FUNCTION(OnBeforeTurn, "void OnBeforeTurn(BaseTurnChoice@ choice)");
|
||||||
|
SCRIPT_HOOK_FUNCTION(ChangeAttack, "void ChangeAttack(MoveTurnChoice@ choice, constString& changedMove)");
|
||||||
|
|
||||||
SCRIPT_HOOK_FUNCTION(PreventAttack, "void PreventAttack(ExecutingMove@ attack, bool& result)");
|
SCRIPT_HOOK_FUNCTION(PreventAttack, "void PreventAttack(ExecutingMove@ attack, bool& result)");
|
||||||
SCRIPT_HOOK_FUNCTION(FailAttack, "void FailAttack(ExecutingMove@ attack, bool& result)");
|
SCRIPT_HOOK_FUNCTION(FailAttack, "void FailAttack(ExecutingMove@ attack, bool& result)");
|
||||||
SCRIPT_HOOK_FUNCTION(StopBeforeAttack, "void StopBeforeAttack(ExecutingMove@ attack, bool& result)");
|
SCRIPT_HOOK_FUNCTION(StopBeforeAttack, "void StopBeforeAttack(ExecutingMove@ attack, bool& result)");
|
||||||
|
@ -101,6 +104,8 @@ 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(PreventSelfSwitch, "void PreventSelfSwitch(SwitchTurnChoice@ choice, bool& prevented)");
|
||||||
|
|
||||||
SCRIPT_HOOK_FUNCTION(ModifyEffectChance,
|
SCRIPT_HOOK_FUNCTION(ModifyEffectChance,
|
||||||
"void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance)");
|
"void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance)");
|
||||||
SCRIPT_HOOK_FUNCTION(ModifyIncomingEffectChance,
|
SCRIPT_HOOK_FUNCTION(ModifyIncomingEffectChance,
|
||||||
|
|
|
@ -2,14 +2,16 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
void BasicScriptClass::Register(asIScriptEngine* engine) {
|
void BasicScriptClass::Register(asIScriptEngine* engine) {
|
||||||
// As far as I am aware at the moment you can't create an abstract class with virtual members through the application
|
// As far as I am aware at the moment you can't create an abstract class with virtual members through the
|
||||||
// registry interface. As such, we just create it from string.
|
// application registry interface. As such, we just create it from string.
|
||||||
[[maybe_unused]] int r = engine->GetModuleByIndex(0)->AddScriptSection("PkmnScript", R"(
|
[[maybe_unused]] int r = engine->GetModuleByIndex(0)->AddScriptSection("PkmnScript", R"(
|
||||||
shared abstract class PkmnScript {
|
shared abstract class PkmnScript {
|
||||||
// CreatureLib methods
|
// CreatureLib methods
|
||||||
void OnInitialize(const array<EffectParameter@> &in parameters){};
|
void OnInitialize(const array<EffectParameter@> &in parameters){};
|
||||||
void Stack(){};
|
void Stack(){};
|
||||||
void OnRemove(){};
|
void OnRemove(){};
|
||||||
|
void OnBeforeTurn(BaseTurnChoice@ choice){};
|
||||||
|
void ChangeAttack(MoveTurnChoice@ choice, constString& changedMove){};
|
||||||
void PreventAttack(ExecutingMove@ attack, bool& result){};
|
void PreventAttack(ExecutingMove@ attack, bool& result){};
|
||||||
void FailAttack(ExecutingMove@ attack, bool& result){};
|
void FailAttack(ExecutingMove@ attack, bool& result){};
|
||||||
void StopBeforeAttack(ExecutingMove@ attack, bool& result){};
|
void StopBeforeAttack(ExecutingMove@ attack, bool& result){};
|
||||||
|
@ -22,6 +24,7 @@ shared abstract class PkmnScript {
|
||||||
void PreventSecondaryEffects(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& outResult){};
|
void PreventSecondaryEffects(ExecutingMove@ attack, Pokemon@ target, uint8 hit, bool& outResult){};
|
||||||
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 PreventSelfSwitch(SwitchTurnChoice@ choice, bool& prevented){};
|
||||||
|
|
||||||
void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance){};
|
void ModifyEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance){};
|
||||||
void ModifyIncomingEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance){};
|
void ModifyIncomingEffectChance(ExecutingMove@ attack, Pokemon@ target, float& chance){};
|
||||||
|
|
|
@ -1,63 +1,89 @@
|
||||||
#include "RegisterTurnChoices.hpp"
|
#include "RegisterTurnChoices.hpp"
|
||||||
#include <CreatureLib/Battling/TurnChoices/AttackTurnChoice.hpp>
|
#include <CreatureLib/Battling/TurnChoices/AttackTurnChoice.hpp>
|
||||||
#include <CreatureLib/Battling/TurnChoices/BaseTurnChoice.hpp>
|
#include <CreatureLib/Battling/TurnChoices/BaseTurnChoice.hpp>
|
||||||
#include <cassert>
|
#include <CreatureLib/Battling/TurnChoices/SwitchTurnChoice.hpp>
|
||||||
#include "../RefCast.hpp"
|
#include "../RefCast.hpp"
|
||||||
|
|
||||||
void RegisterTurnChoices::Register(asIScriptEngine* engine) {
|
void RegisterTurnChoices::Register(asIScriptEngine* engine) {
|
||||||
RegisterTurnChoiceKindEnum(engine);
|
RegisterTurnChoiceKindEnum(engine);
|
||||||
RegisterBaseTurnChoice(engine);
|
RegisterBaseTurnChoice(engine);
|
||||||
RegisterMoveTurnChoice(engine);
|
RegisterMoveTurnChoice(engine);
|
||||||
|
RegisterSwitchTurnChoice(engine);
|
||||||
}
|
}
|
||||||
void RegisterTurnChoices::RegisterTurnChoiceKindEnum(asIScriptEngine* engine) {
|
void RegisterTurnChoices::RegisterTurnChoiceKindEnum(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterEnum("TurnChoiceKind");
|
[[maybe_unused]] int r = engine->RegisterEnum("TurnChoiceKind");
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterEnumValue("TurnChoiceKind", "Pass", (int)CreatureLib::Battling::TurnChoiceKind::Pass);
|
r = engine->RegisterEnumValue("TurnChoiceKind", "Pass", (int)CreatureLib::Battling::TurnChoiceKind::Pass);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterEnumValue("TurnChoiceKind", "Attack", (int)CreatureLib::Battling::TurnChoiceKind::Attack);
|
r = engine->RegisterEnumValue("TurnChoiceKind", "Attack", (int)CreatureLib::Battling::TurnChoiceKind::Attack);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterEnumValue("TurnChoiceKind", "Item", (int)CreatureLib::Battling::TurnChoiceKind::Item);
|
r = engine->RegisterEnumValue("TurnChoiceKind", "Item", (int)CreatureLib::Battling::TurnChoiceKind::Item);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterEnumValue("TurnChoiceKind", "Switch", (int)CreatureLib::Battling::TurnChoiceKind::Switch);
|
r = engine->RegisterEnumValue("TurnChoiceKind", "Switch", (int)CreatureLib::Battling::TurnChoiceKind::Switch);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterEnumValue("TurnChoiceKind", "Flee", (int)CreatureLib::Battling::TurnChoiceKind::Flee);
|
r = engine->RegisterEnumValue("TurnChoiceKind", "Flee", (int)CreatureLib::Battling::TurnChoiceKind::Flee);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
}
|
}
|
||||||
void RegisterTurnChoices::RegisterBaseTurnChoice(asIScriptEngine* engine) {
|
void RegisterTurnChoices::RegisterBaseTurnChoice(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("BaseTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
[[maybe_unused]] int r = engine->RegisterObjectType("BaseTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("BaseTurnChoice", "TurnChoiceKind get_Kind() const property",
|
r = engine->RegisterObjectMethod("BaseTurnChoice", "TurnChoiceKind get_Kind() const property",
|
||||||
asMETHOD(CreatureLib::Battling::BaseTurnChoice, GetKind), asCALL_THISCALL);
|
asMETHOD(CreatureLib::Battling::BaseTurnChoice, GetKind), asCALL_THISCALL);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("BaseTurnChoice", "Pokemon@ get_User() const property",
|
r = engine->RegisterObjectMethod("BaseTurnChoice", "Pokemon@ get_User() const property",
|
||||||
asMETHOD(CreatureLib::Battling::BaseTurnChoice, GetUser), asCALL_THISCALL);
|
asMETHOD(CreatureLib::Battling::BaseTurnChoice, GetUser), asCALL_THISCALL);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegisterTurnChoices::RegisterMoveTurnChoice(asIScriptEngine* engine) {
|
void RegisterTurnChoices::RegisterMoveTurnChoice(asIScriptEngine* engine) {
|
||||||
[[maybe_unused]] int r = engine->RegisterObjectType("MoveTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
[[maybe_unused]] int r = engine->RegisterObjectType("MoveTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("MoveTurnChoice", "TurnChoiceKind get_Kind() const property",
|
r = engine->RegisterObjectMethod("MoveTurnChoice", "TurnChoiceKind get_Kind() const property",
|
||||||
asMETHOD(CreatureLib::Battling::AttackTurnChoice, GetKind), asCALL_THISCALL);
|
asMETHOD(CreatureLib::Battling::AttackTurnChoice, GetKind), asCALL_THISCALL);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("MoveTurnChoice", "Pokemon@ get_User() const property",
|
r = engine->RegisterObjectMethod("MoveTurnChoice", "Pokemon@ get_User() const property",
|
||||||
asMETHOD(CreatureLib::Battling::AttackTurnChoice, GetUser), asCALL_THISCALL);
|
asMETHOD(CreatureLib::Battling::AttackTurnChoice, GetUser), asCALL_THISCALL);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("MoveTurnChoice", "LearnedMove@ get_Move() const property",
|
r = engine->RegisterObjectMethod("MoveTurnChoice", "LearnedMove@ get_Move() const property",
|
||||||
asMETHOD(CreatureLib::Battling::AttackTurnChoice, GetAttack), asCALL_THISCALL);
|
asMETHOD(CreatureLib::Battling::AttackTurnChoice, GetAttack), asCALL_THISCALL);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("MoveTurnChoice", "int8 get_Priority() const property",
|
r = engine->RegisterObjectMethod("MoveTurnChoice", "int8 get_Priority() const property",
|
||||||
asMETHOD(CreatureLib::Battling::AttackTurnChoice, GetPriority), asCALL_THISCALL);
|
asMETHOD(CreatureLib::Battling::AttackTurnChoice, GetPriority), asCALL_THISCALL);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
|
|
||||||
r = engine->RegisterObjectMethod(
|
r = engine->RegisterObjectMethod(
|
||||||
"BaseTurnChoice", "MoveTurnChoice@ opCast()",
|
"BaseTurnChoice", "MoveTurnChoice@ opCast()",
|
||||||
asFUNCTION((refCast<CreatureLib::Battling::BaseTurnChoice, CreatureLib::Battling::AttackTurnChoice>)),
|
asFUNCTION((refCast<CreatureLib::Battling::BaseTurnChoice, CreatureLib::Battling::AttackTurnChoice>)),
|
||||||
asCALL_CDECL_OBJLAST);
|
asCALL_CDECL_OBJLAST);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
r = engine->RegisterObjectMethod(
|
r = engine->RegisterObjectMethod(
|
||||||
"MoveTurnChoice", "BaseTurnChoice@ opImplCast()",
|
"MoveTurnChoice", "BaseTurnChoice@ opImplCast()",
|
||||||
asFUNCTION((refCast<CreatureLib::Battling::AttackTurnChoice, CreatureLib::Battling::BaseTurnChoice>)),
|
asFUNCTION((refCast<CreatureLib::Battling::AttackTurnChoice, CreatureLib::Battling::BaseTurnChoice>)),
|
||||||
asCALL_CDECL_OBJLAST);
|
asCALL_CDECL_OBJLAST);
|
||||||
assert(r >= 0);
|
Assert(r >= 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterTurnChoices::RegisterSwitchTurnChoice(asIScriptEngine* engine) {
|
||||||
|
[[maybe_unused]] int r = engine->RegisterObjectType("SwitchTurnChoice", 0, asOBJ_REF | asOBJ_NOCOUNT);
|
||||||
|
Assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("SwitchTurnChoice", "TurnChoiceKind get_Kind() const property",
|
||||||
|
asMETHOD(CreatureLib::Battling::SwitchTurnChoice, GetKind), asCALL_THISCALL);
|
||||||
|
Assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("SwitchTurnChoice", "Pokemon@ get_User() const property",
|
||||||
|
asMETHOD(CreatureLib::Battling::SwitchTurnChoice, GetUser), asCALL_THISCALL);
|
||||||
|
Assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("SwitchTurnChoice", "Pokemon@ get_NewPokemon() const property",
|
||||||
|
asMETHOD(CreatureLib::Battling::SwitchTurnChoice, GetNewCreature), asCALL_THISCALL);
|
||||||
|
Assert(r >= 0);
|
||||||
|
|
||||||
|
r = engine->RegisterObjectMethod(
|
||||||
|
"SwitchTurnChoice", "MoveTurnChoice@ opCast()",
|
||||||
|
asFUNCTION((refCast<CreatureLib::Battling::BaseTurnChoice, CreatureLib::Battling::SwitchTurnChoice>)),
|
||||||
|
asCALL_CDECL_OBJLAST);
|
||||||
|
Assert(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod(
|
||||||
|
"SwitchTurnChoice", "BaseTurnChoice@ opImplCast()",
|
||||||
|
asFUNCTION((refCast<CreatureLib::Battling::AttackTurnChoice, CreatureLib::Battling::SwitchTurnChoice>)),
|
||||||
|
asCALL_CDECL_OBJLAST);
|
||||||
|
Assert(r >= 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ class RegisterTurnChoices {
|
||||||
static void RegisterTurnChoiceKindEnum(asIScriptEngine* engine);
|
static void RegisterTurnChoiceKindEnum(asIScriptEngine* engine);
|
||||||
static void RegisterBaseTurnChoice(asIScriptEngine* engine);
|
static void RegisterBaseTurnChoice(asIScriptEngine* engine);
|
||||||
static void RegisterMoveTurnChoice(asIScriptEngine* engine);
|
static void RegisterMoveTurnChoice(asIScriptEngine* engine);
|
||||||
|
static void RegisterSwitchTurnChoice(asIScriptEngine* engine);
|
||||||
public:
|
public:
|
||||||
static void Register(asIScriptEngine* engine);
|
static void Register(asIScriptEngine* engine);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue