Adds angelscript helper to easily get effectiveness of a type against a Pokemon.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-11-20 10:56:32 +01:00
parent e39056d3d6
commit d94d1287ef
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 11 additions and 0 deletions

View File

@ -81,6 +81,10 @@ static CScriptHandle AddVolatileWrapper(PkmnLib::Battling::Pokemon* obj, const A
return handle; 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) { void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
Ensure(engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0); Ensure(engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0);
REGISTER_GETTER("Pokemon", "const Species@ get_Species() const property", CreatureLib::Battling::Creature, 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)", r = engine->RegisterObjectMethod("Pokemon", "void SetStatus(const constString& name)",
asMETHOD(PkmnLib::Battling::Pokemon, SetStatus), asCALL_THISCALL); asMETHOD(PkmnLib::Battling::Pokemon, SetStatus), asCALL_THISCALL);
Ensure(r >= 0); Ensure(r >= 0);
r = engine->RegisterObjectMethod("TypeLibrary", "float GetEffectiveness(uint8 attackingType, Pokemon@ defender)",
asFUNCTION(GetEffectivenessHelper), asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);
} }