Adds helper functions to create Pokemon with more control.
This commit is contained in:
@@ -31,6 +31,21 @@ class BattleFunctions {
|
||||
return p1;
|
||||
}
|
||||
|
||||
static CreatureLib::Battling::CreatureParty* CreateParty(CScriptArray* mons) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
TestEnvironment* env = static_cast<TestEnvironment*>(ctx->GetUserData(684));
|
||||
|
||||
auto p1 = new PkmnLib::Battling::PokemonParty(mons->GetSize());
|
||||
for (u32 i = 0; i < mons->GetSize(); ++i) {
|
||||
auto s = *reinterpret_cast<PkmnLib::Battling::Pokemon**>(mons->At(i));
|
||||
p1->SwapInto(i, s);
|
||||
// Party becomes owner of mon, so take it from GC.
|
||||
env->TakeOwnershipOfGarbage(s);
|
||||
}
|
||||
env->AddGarbage(p1);
|
||||
return p1;
|
||||
}
|
||||
|
||||
static PkmnLib::Battling::Battle* CreateSimpleBattle(u32 seed, const ArbUt::StringView& species1,
|
||||
const ArbUt::StringView& species2, u8 level) {
|
||||
auto* ctx = asGetActiveContext();
|
||||
@@ -152,6 +167,8 @@ public:
|
||||
Ensure(
|
||||
engine->RegisterGlobalFunction("Party@ CreateSimpleParty(const array<constString>&in species, uint8 level)",
|
||||
asFUNCTION(CreateSimpleParty), asCALL_CDECL) >= 0);
|
||||
Ensure(engine->RegisterGlobalFunction("Party@ CreateParty(const array<Pokemon@>&in mons)",
|
||||
asFUNCTION(CreateParty), asCALL_CDECL) >= 0);
|
||||
Ensure(engine->RegisterGlobalFunction("Battle@ CreateSimpleBattle(uint seed, const constString&in species1, "
|
||||
"const constString&in species2, uint8 level)",
|
||||
asFUNCTION(CreateSimpleBattle), asCALL_CDECL) >= 0);
|
||||
|
||||
Reference in New Issue
Block a user