diff --git a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp index b15e389..4ab890b 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp @@ -6,6 +6,7 @@ #include "../../../extern/angelscript_addons/scripthelper/scripthelper.h" #include "../../../extern/angelscript_addons/scriptstdstring/scriptstdstring.h" #include "../../Battling/PkmnScriptCategory.hpp" +#include "../../Battling/Pokemon/Pokemon.hpp" #include "ByteCodeHandling/FileByteCodeStream.hpp" #include "ByteCodeHandling/MemoryByteCodeStream.hpp" #include "TypeRegistry/BasicScriptClass.hpp" @@ -15,6 +16,7 @@ #include "TypeRegistry/Battling/RegisterPokemonClass.hpp" #include "TypeRegistry/Battling/RegisterTurnChoices.hpp" #include "TypeRegistry/ConstString.hpp" +#include "TypeRegistry/HelperFile.hpp" #include "TypeRegistry/Library/RegisterEffectParameter.hpp" #include "TypeRegistry/Library/RegisterGrowthRateTypes.hpp" #include "TypeRegistry/Library/RegisterItemTypes.hpp" @@ -87,6 +89,7 @@ void AngelScriptResolver::Initialize(CreatureLib::Battling::BattleLibrary* arg) _contextPool = new ContextPool(_engine); } +SMART_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, CreatureLib::Battling::Battle, GetBattle); void AngelScriptResolver::RegisterTypes() { // Register static library types @@ -104,9 +107,8 @@ void AngelScriptResolver::RegisterTypes() { RegisterTurnChoices::Register(_engine); RegisterBattleLibrary::Register(_engine); RegisterBattleClass::Register(_engine); - [[maybe_unused]] int r = - _engine->RegisterObjectMethod("Pokemon", "const Battle@ get_Battle() const property", - asMETHOD(CreatureLib::Battling::Creature, GetBattle), asCALL_THISCALL); + [[maybe_unused]] int r = _engine->RegisterObjectMethod("Pokemon", "const Battle@ get_Battle() const property", + asFUNCTION(GetBattleWrapper), asCALL_CDECL_OBJFIRST); assert(r >= 0); // Register base script diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp index 4b168af..b62094b 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp @@ -2,6 +2,7 @@ #include #include #include "../../../../Battling/Battle/Battle.hpp" +#include "../HelperFile.hpp" void RegisterBattleClass::Register(asIScriptEngine* engine) { RegisterChoiceQueue(engine); @@ -42,6 +43,8 @@ void RegisterBattleClass::RegisterBattleRandom(asIScriptEngine* engine) { Assert(r >= 0); } +SMART_PTR_GETTER_FUNC(PkmnLib::Battling::Battle, CreatureLib::Battling::ChoiceQueue, GetCurrentTurnQueue); + void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("Battle", 0, asOBJ_REF | asOBJ_NOCOUNT); Assert(r >= 0); @@ -58,7 +61,7 @@ void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) { asMETHOD(PkmnLib::Battling::Battle, GetRandom), asCALL_THISCALL); Assert(r >= 0); r = engine->RegisterObjectMethod("Battle", "ChoiceQueue@ get_TurnQueue() const property", - asMETHOD(PkmnLib::Battling::Battle, GetCurrentTurnQueue), asCALL_THISCALL); + asFUNCTION(GetCurrentTurnQueueWrapper), asCALL_CDECL_OBJFIRST); Assert(r >= 0); r = engine->RegisterObjectMethod( "Battle", "void AddVolatile(const constString &in name) const", diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp index 4739ec6..9091c28 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp @@ -40,12 +40,13 @@ void RegisterPokemonClass::RegisterMoveLearnMethod(asIScriptEngine* engine) { } ENUM__SIZE_WRAPPER(LearnedMove_LearnMethodWrapper, CreatureLib::Battling::LearnedAttack, GetLearnMethod) +SMART_PTR_GETTER_FUNC(CreatureLib::Battling::LearnedAttack, const CreatureLib::Library::AttackData, GetAttack); void RegisterPokemonClass::RegisterLearnedAttack(asIScriptEngine* engine) { [[maybe_unused]] int r = engine->RegisterObjectType("LearnedMove", 0, asOBJ_REF | asOBJ_NOCOUNT); Assert(r >= 0); r = engine->RegisterObjectMethod("LearnedMove", "const MoveData@ get_MoveData() const property", - asMETHOD(CreatureLib::Battling::LearnedAttack, GetAttack), asCALL_THISCALL); + asFUNCTION(GetAttackWrapper), asCALL_CDECL_OBJFIRST); Assert(r >= 0); r = engine->RegisterObjectMethod("LearnedMove", "uint8 get_MaxUses() const property", asMETHOD(CreatureLib::Battling::LearnedAttack, GetMaxUses), asCALL_THISCALL);