Adds angelscript helper function to check if Pokemon has a type by the types string name.
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
8de1d4d635
commit
4d1b3448ba
|
@ -81,6 +81,11 @@ static CScriptHandle AddVolatileWrapper(PkmnLib::Battling::Pokemon* obj, const A
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool HasTypeStringWrapper(PkmnLib::Battling::Pokemon* p, const ArbUt::StringView& sv) {
|
||||||
|
auto typeId = p->GetLibrary()->GetTypeLibrary()->GetTypeId(sv);
|
||||||
|
return p->HasType(typeId);
|
||||||
|
}
|
||||||
|
|
||||||
static float GetEffectivenessHelper(CreatureLib::Library::TypeLibrary* typeLib, u8 attackingType,
|
static float GetEffectivenessHelper(CreatureLib::Library::TypeLibrary* typeLib, u8 attackingType,
|
||||||
PkmnLib::Battling::Pokemon* pokemon) {
|
PkmnLib::Battling::Pokemon* pokemon) {
|
||||||
return typeLib->GetEffectiveness(attackingType, pokemon->GetTypes());
|
return typeLib->GetEffectiveness(attackingType, pokemon->GetTypes());
|
||||||
|
@ -152,6 +157,9 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) {
|
||||||
r = engine->RegisterObjectMethod("Pokemon", "bool HasType(uint8 type) const",
|
r = engine->RegisterObjectMethod("Pokemon", "bool HasType(uint8 type) const",
|
||||||
asMETHOD(PkmnLib::Battling::Pokemon, HasType), asCALL_THISCALL);
|
asMETHOD(PkmnLib::Battling::Pokemon, HasType), asCALL_THISCALL);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
r = engine->RegisterObjectMethod("Pokemon", "bool HasType(const constString& type) const",
|
||||||
|
asFUNCTION(HasTypeStringWrapper), asCALL_CDECL_OBJFIRST);
|
||||||
|
Ensure(r >= 0);
|
||||||
r = engine->RegisterObjectMethod("Pokemon", "void Damage(uint32 type, DamageSource source)",
|
r = engine->RegisterObjectMethod("Pokemon", "void Damage(uint32 type, DamageSource source)",
|
||||||
asMETHOD(PkmnLib::Battling::Pokemon, Damage), asCALL_THISCALL);
|
asMETHOD(PkmnLib::Battling::Pokemon, Damage), asCALL_THISCALL);
|
||||||
Ensure(r >= 0);
|
Ensure(r >= 0);
|
||||||
|
|
Loading…
Reference in New Issue