mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-21 19:00:18 +01:00
Fixed edge case with givemon
This commit is contained in:
parent
af5ff05338
commit
aec4d78bd4
@ -64,11 +64,23 @@ u8 ScriptGiveMon(u16 species, u8 level, u16 item, u32 unused1, u32 unused2, u8 u
|
||||
int sentToPc;
|
||||
u8 heldItem[2];
|
||||
struct Pokemon mon;
|
||||
u16 targetSpecies;
|
||||
|
||||
CreateMon(&mon, species, level, USE_RANDOM_IVS, 0, 0, OT_ID_PLAYER_ID, 0);
|
||||
heldItem[0] = item;
|
||||
heldItem[1] = item >> 8;
|
||||
SetMonData(&mon, MON_DATA_HELD_ITEM, heldItem);
|
||||
|
||||
// In case a mon with a form changing item is given. Eg: SPECIES_ARCEUS with ITEM_SPLASH_PLATE will transform into SPECIES_ARCEUS_WATER upon gifted.
|
||||
targetSpecies = GetFormChangeTargetSpecies(&mon, FORM_ITEM_HOLD_ABILITY, 0);
|
||||
if (targetSpecies == SPECIES_NONE)
|
||||
targetSpecies = GetFormChangeTargetSpecies(&mon, FORM_ITEM_HOLD, 0);
|
||||
if (targetSpecies != SPECIES_NONE)
|
||||
{
|
||||
SetMonData(&mon, MON_DATA_SPECIES, &targetSpecies);
|
||||
CalculateMonStats(&mon);
|
||||
}
|
||||
|
||||
sentToPc = GiveMonToPlayer(&mon);
|
||||
nationalDexNum = SpeciesToNationalPokedexNum(species);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user