mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-27 12:14:20 +01:00
PSS uses form change table for holding items.
# Conflicts: # src/pokemon.c
This commit is contained in:
parent
fdd284b50b
commit
55b61313a4
@ -55,6 +55,7 @@ void ItemUseCB_PPUp(u8 taskId, TaskFunc task);
|
||||
u16 ItemIdToBattleMoveId(u16 item);
|
||||
bool8 IsMoveHm(u16 move);
|
||||
bool8 MonKnowsMove(struct Pokemon *mon, u16 move);
|
||||
bool8 BoxMonKnowsMove(struct BoxPokemon *mon, u16 move);
|
||||
void ItemUseCB_TMHM(u8 taskId, TaskFunc task);
|
||||
void ItemUseCB_RareCandy(u8 taskId, TaskFunc task);
|
||||
void ItemUseCB_SacredAsh(u8 taskId, TaskFunc task);
|
||||
|
@ -439,4 +439,5 @@ u8 *sub_806F4F8(u8 id, u8 arg1);
|
||||
u16 GetFormSpeciesId(u16 speciesId, u8 formId);
|
||||
u8 GetFormIdFromFormSpeciesId(u16 formSpeciesId);
|
||||
u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg);
|
||||
u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *mon, u16 method, u32 arg);
|
||||
#endif // GUARD_POKEMON_H
|
||||
|
@ -4640,6 +4640,18 @@ bool8 MonKnowsMove(struct Pokemon *mon, u16 move)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 BoxMonKnowsMove(struct BoxPokemon *mon, u16 move)
|
||||
{
|
||||
u8 i;
|
||||
|
||||
for (i = 0; i < MAX_MON_MOVES; i++)
|
||||
{
|
||||
if (GetMonData(mon, MON_DATA_MOVE1 + i) == move)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void DisplayLearnMoveMessage(const u8 *str)
|
||||
{
|
||||
StringExpandPlaceholders(gStringVar4, str);
|
||||
|
@ -8049,12 +8049,17 @@ u8 GetFormIdFromFormSpeciesId(u16 formSpeciesId)
|
||||
return targetFormId;
|
||||
}
|
||||
|
||||
// returns SPECIES_NONE if no form change is possible
|
||||
u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg)
|
||||
{
|
||||
return GetFormChangeTargetSpeciesBoxMon(&mon->box, method, arg);
|
||||
}
|
||||
|
||||
// returns SPECIES_NONE if no form change is possible
|
||||
u16 GetFormChangeTargetSpeciesBoxMon(struct BoxPokemon *mon, u16 method, u32 arg)
|
||||
{
|
||||
u32 i;
|
||||
u16 targetSpecies = SPECIES_NONE;
|
||||
u16 originalSpecies = GetMonData(mon, MON_DATA_SPECIES, NULL);
|
||||
u16 originalSpecies = GetBoxMonData(mon, MON_DATA_SPECIES, NULL);
|
||||
const struct FormChange *formChanges = gFormChangeTablePointers[originalSpecies];
|
||||
|
||||
if (formChanges == NULL)
|
||||
@ -8064,11 +8069,11 @@ u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg)
|
||||
{
|
||||
if (method == formChanges[i].method)
|
||||
{
|
||||
u32 ability = GetAbilityBySpecies(originalSpecies, GetMonData(mon, MON_DATA_ABILITY_NUM, NULL));
|
||||
u32 ability = GetAbilityBySpecies(originalSpecies, GetBoxMonData(mon, MON_DATA_ABILITY_NUM, NULL));
|
||||
switch (method)
|
||||
{
|
||||
case FORM_ITEM_HOLD:
|
||||
if (GetMonData(mon, MON_DATA_HELD_ITEM, NULL) == formChanges[i].param1 && (ability == formChanges[i].param2 || formChanges[i].param2 == ABILITY_NONE))
|
||||
if (GetBoxMonData(mon, MON_DATA_HELD_ITEM, NULL) == formChanges[i].param1 && (ability == formChanges[i].param2 || formChanges[i].param2 == ABILITY_NONE))
|
||||
targetSpecies = formChanges[i].targetSpecies;
|
||||
break;
|
||||
case FORM_ITEM_USE:
|
||||
@ -8076,7 +8081,7 @@ u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg)
|
||||
targetSpecies = formChanges[i].targetSpecies;
|
||||
break;
|
||||
case FORM_MOVE:
|
||||
if (MonKnowsMove(mon, formChanges[i].param1) != formChanges[i].param2)
|
||||
if (BoxMonKnowsMove(mon, formChanges[i].param1) != formChanges[i].param2)
|
||||
targetSpecies = formChanges[i].targetSpecies;
|
||||
break;
|
||||
case FORM_ITEM_USE_DAY:
|
||||
|
@ -870,6 +870,10 @@ static void UnkUtil_Run(void);
|
||||
static void UnkUtil_CpuRun(struct UnkUtilData *);
|
||||
static void UnkUtil_DmaRun(struct UnkUtilData *);
|
||||
|
||||
// Form changing
|
||||
void SetArceusFormPSS(struct BoxPokemon *boxMon);
|
||||
void UpdateSpeciesSpritePSS(struct BoxPokemon *boxmon);
|
||||
|
||||
struct {
|
||||
const u8 *text;
|
||||
const u8 *desc;
|
||||
@ -6866,6 +6870,34 @@ static void ReshowDisplayMon(void)
|
||||
TryRefreshDisplayMon();
|
||||
}
|
||||
|
||||
void SetArceusFormPSS(struct BoxPokemon *boxMon)
|
||||
{
|
||||
u16 species = GetMonData(boxMon, MON_DATA_SPECIES);
|
||||
u16 targetSpecies = GetFormChangeTargetSpeciesBoxMon(boxMon, FORM_ITEM_HOLD, 0);
|
||||
if (targetSpecies != SPECIES_NONE)
|
||||
{
|
||||
//PlayCry2(targetSpecies, 0, 0x7D, 0xA);
|
||||
SetBoxMonData(boxMon, MON_DATA_SPECIES, &targetSpecies);
|
||||
UpdateSpeciesSpritePSS(boxMon);
|
||||
}
|
||||
/*
|
||||
#ifdef POKEMON_EXPANSION
|
||||
u16 species = GetMonData(boxMon, MON_DATA_SPECIES);
|
||||
u16 forme;
|
||||
u8 abilityNum = GetMonData(boxMon, MON_DATA_ABILITY_NUM);
|
||||
u16 ability = GetAbilityBySpecies(species, abilityNum);
|
||||
|
||||
if (GET_BASE_SPECIES_ID(species) == SPECIES_ARCEUS
|
||||
&& ability == ABILITY_MULTITYPE)
|
||||
{
|
||||
forme = GetArceusFormPSS(boxMon);
|
||||
SetBoxMonData(boxMon, MON_DATA_SPECIES, &forme);
|
||||
UpdateSpeciesSpritePSS(boxMon);
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
|
||||
static void SetDisplayMonData(void *pokemon, u8 mode)
|
||||
{
|
||||
u8 *txtPtr;
|
||||
@ -6953,6 +6985,8 @@ static void SetDisplayMonData(void *pokemon, u8 mode)
|
||||
if (sStorage->displayMonSpecies == SPECIES_NIDORAN_F || sStorage->displayMonSpecies == SPECIES_NIDORAN_M)
|
||||
gender = MON_GENDERLESS;
|
||||
|
||||
SetArceusFormPSS(pokemon);
|
||||
|
||||
StringCopyPadded(sStorage->displayMonNameText, sStorage->displayMonName, CHAR_SPACE, 5);
|
||||
|
||||
txtPtr = sStorage->displayMonSpeciesName;
|
||||
@ -10078,3 +10112,15 @@ static void UnkUtil_DmaRun(struct UnkUtilData *data)
|
||||
data->dest += 64;
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateSpeciesSpritePSS(struct BoxPokemon *boxMon)
|
||||
{
|
||||
u16 species = GetBoxMonData(boxMon, MON_DATA_SPECIES);
|
||||
u32 otId = GetBoxMonData(boxMon, MON_DATA_OT_ID);
|
||||
u32 pid = GetBoxMonData(boxMon, MON_DATA_PERSONALITY);
|
||||
|
||||
// Update front sprite
|
||||
sStorage->displayMonSpecies = species;
|
||||
sStorage->displayMonPalette = GetMonSpritePalFromSpeciesAndPersonality(species, otId, pid);
|
||||
LoadDisplayMonGfx(species, pid);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user