From d94d1287ef3a4d1278c7176722f9fa0a8a07a9f5 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 20 Nov 2021 10:56:32 +0100 Subject: [PATCH] Adds angelscript helper to easily get effectiveness of a type against a Pokemon. --- .../TypeRegistry/Battling/RegisterPokemonClass.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp index 36239fc..8f7065e 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp @@ -81,6 +81,10 @@ static CScriptHandle AddVolatileWrapper(PkmnLib::Battling::Pokemon* obj, const A return handle; } +static float GetEffectivenessHelper(CreatureLib::Library::TypeLibrary* typeLib, u8 attackingType, PkmnLib::Battling::Pokemon* pokemon){ + return typeLib->GetEffectiveness(attackingType, pokemon->GetTypes()); +} + void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { Ensure(engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0); REGISTER_GETTER("Pokemon", "const Species@ get_Species() const property", CreatureLib::Battling::Creature, @@ -189,4 +193,11 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { r = engine->RegisterObjectMethod("Pokemon", "void SetStatus(const constString& name)", asMETHOD(PkmnLib::Battling::Pokemon, SetStatus), asCALL_THISCALL); Ensure(r >= 0); + + + + + r = engine->RegisterObjectMethod("TypeLibrary", "float GetEffectiveness(uint8 attackingType, Pokemon@ defender)", + asFUNCTION(GetEffectivenessHelper), asCALL_CDECL_OBJFIRST); + Ensure(r >= 0); } \ No newline at end of file