From 7fcc4a63c5bf75a100905ba94024455c774c5316 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Mon, 23 Aug 2021 21:40:20 +0200 Subject: [PATCH] Adds get function to angelscript to get a pokemon at index. --- .../TypeRegistry/Battling/RegisterBattleClass.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp index 5cb91d6..df5117e 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleClass.cpp @@ -77,6 +77,10 @@ static u8 GetPokemonIndexWrapper(CreatureLib::Battling::BattleSide* obj, PkmnLib return obj->GetCreatureIndex(pokemon); } +static PkmnLib::Battling::Pokemon* GetPokemonWrapper(CreatureLib::Battling::BattleSide* obj, u8 index) { + return dynamic_cast(obj->GetCreature(index).GetValue()); +} + void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) { int r = engine->RegisterObjectMethod( "BattleSide", "bool SwapPositions(uint8 a, uint8 b)", @@ -88,6 +92,9 @@ void RegisterBattleClass::RegisterBattleSide(asIScriptEngine* engine) { r = engine->RegisterObjectMethod("BattleSide", "uint8 GetPokemonIndex(const Pokemon@ pokemon) const", asFUNCTION(GetPokemonIndexWrapper), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); + r = engine->RegisterObjectMethod("BattleSide", "Pokemon@ GetPokemon(uint8 index) const", + asFUNCTION(GetPokemonWrapper), asCALL_CDECL_OBJFIRST); + Ensure(r >= 0); } void RegisterBattleClass::RegisterBattle(asIScriptEngine* engine) {