mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2025-01-13 15:13:42 +01:00
Merge pull request #1698 from AsparagusEduardo/PE_FormChangeHoldItems
Form changing by holding items
This commit is contained in:
commit
2736223b1b
@ -23,153 +23,153 @@
|
||||
#ifndef ITEM_EXPANSION
|
||||
//Item Definitions for gEvolutionTable
|
||||
|
||||
//EVO_MEGA_EVOLUTION
|
||||
#define ITEM_VENUSAURITE ITEM_NONE
|
||||
#define ITEM_CHARIZARDITE_X ITEM_NONE
|
||||
#define ITEM_CHARIZARDITE_Y ITEM_NONE
|
||||
#define ITEM_BLASTOISINITE ITEM_NONE
|
||||
#define ITEM_BEEDRILLITE ITEM_NONE
|
||||
#define ITEM_PIDGEOTITE ITEM_NONE
|
||||
#define ITEM_ALAKAZITE ITEM_NONE
|
||||
#define ITEM_SLOWBRONITE ITEM_NONE
|
||||
#define ITEM_GENGARITE ITEM_NONE
|
||||
#define ITEM_KANGASKHANITE ITEM_NONE
|
||||
#define ITEM_PINSIRITE ITEM_NONE
|
||||
#define ITEM_GYARADOSITE ITEM_NONE
|
||||
#define ITEM_AERODACTYLITE ITEM_NONE
|
||||
#define ITEM_MEWTWONITE_X ITEM_NONE
|
||||
#define ITEM_MEWTWONITE_Y ITEM_NONE
|
||||
#define ITEM_AMPHAROSITE ITEM_NONE
|
||||
#define ITEM_STEELIXITE ITEM_NONE
|
||||
#define ITEM_SCIZORITE ITEM_NONE
|
||||
#define ITEM_HERACRONITE ITEM_NONE
|
||||
#define ITEM_HOUNDOOMINITE ITEM_NONE
|
||||
#define ITEM_TYRANITARITE ITEM_NONE
|
||||
#define ITEM_SCEPTILITE ITEM_NONE
|
||||
#define ITEM_BLAZIKENITE ITEM_NONE
|
||||
#define ITEM_SWAMPERTITE ITEM_NONE
|
||||
#define ITEM_SABLENITE ITEM_NONE
|
||||
#define ITEM_SHARPEDONITE ITEM_NONE
|
||||
#define ITEM_MANECTITE ITEM_NONE
|
||||
#define ITEM_CAMERUPTITE ITEM_NONE
|
||||
#define ITEM_GLALITITE ITEM_NONE
|
||||
#define ITEM_MAWILITE ITEM_NONE
|
||||
#define ITEM_MEDICHAMITE ITEM_NONE
|
||||
#define ITEM_ALTARIANITE ITEM_NONE
|
||||
#define ITEM_ABSOLITE ITEM_NONE
|
||||
#define ITEM_BANETTITE ITEM_NONE
|
||||
#define ITEM_AGGRONITE ITEM_NONE
|
||||
#define ITEM_GARDEVOIRITE ITEM_NONE
|
||||
#define ITEM_SALAMENCITE ITEM_NONE
|
||||
#define ITEM_METAGROSSITE ITEM_NONE
|
||||
#define ITEM_LATIASITE ITEM_NONE
|
||||
#define ITEM_LATIOSITE ITEM_NONE
|
||||
#define ITEM_LOPUNNITE ITEM_NONE
|
||||
#define ITEM_GARCHOMPITE ITEM_NONE
|
||||
#define ITEM_LUCARIONITE ITEM_NONE
|
||||
#define ITEM_ABOMASITE ITEM_NONE
|
||||
#define ITEM_GALLADITE ITEM_NONE
|
||||
#define ITEM_AUDINITE ITEM_NONE
|
||||
#define ITEM_DIANCITE ITEM_NONE
|
||||
//EVO_MEGA_EVOLUTION
|
||||
#define ITEM_VENUSAURITE 10001
|
||||
#define ITEM_CHARIZARDITE_X 10002
|
||||
#define ITEM_CHARIZARDITE_Y 10003
|
||||
#define ITEM_BLASTOISINITE 10004
|
||||
#define ITEM_BEEDRILLITE 10005
|
||||
#define ITEM_PIDGEOTITE 10006
|
||||
#define ITEM_ALAKAZITE 10007
|
||||
#define ITEM_SLOWBRONITE 10008
|
||||
#define ITEM_GENGARITE 10009
|
||||
#define ITEM_KANGASKHANITE 10010
|
||||
#define ITEM_PINSIRITE 10011
|
||||
#define ITEM_GYARADOSITE 10012
|
||||
#define ITEM_AERODACTYLITE 10013
|
||||
#define ITEM_MEWTWONITE_X 10014
|
||||
#define ITEM_MEWTWONITE_Y 10015
|
||||
#define ITEM_AMPHAROSITE 10016
|
||||
#define ITEM_STEELIXITE 10017
|
||||
#define ITEM_SCIZORITE 10018
|
||||
#define ITEM_HERACRONITE 10019
|
||||
#define ITEM_HOUNDOOMINITE 10020
|
||||
#define ITEM_TYRANITARITE 10021
|
||||
#define ITEM_SCEPTILITE 10022
|
||||
#define ITEM_BLAZIKENITE 10023
|
||||
#define ITEM_SWAMPERTITE 10024
|
||||
#define ITEM_SABLENITE 10025
|
||||
#define ITEM_SHARPEDONITE 10026
|
||||
#define ITEM_MANECTITE 10027
|
||||
#define ITEM_CAMERUPTITE 10028
|
||||
#define ITEM_GLALITITE 10029
|
||||
#define ITEM_MAWILITE 10030
|
||||
#define ITEM_MEDICHAMITE 10031
|
||||
#define ITEM_ALTARIANITE 10032
|
||||
#define ITEM_ABSOLITE 10033
|
||||
#define ITEM_BANETTITE 10034
|
||||
#define ITEM_AGGRONITE 10035
|
||||
#define ITEM_GARDEVOIRITE 10036
|
||||
#define ITEM_SALAMENCITE 10037
|
||||
#define ITEM_METAGROSSITE 10038
|
||||
#define ITEM_LATIASITE 10039
|
||||
#define ITEM_LATIOSITE 10040
|
||||
#define ITEM_LOPUNNITE 10041
|
||||
#define ITEM_GARCHOMPITE 10042
|
||||
#define ITEM_LUCARIONITE 10043
|
||||
#define ITEM_ABOMASITE 10044
|
||||
#define ITEM_GALLADITE 10045
|
||||
#define ITEM_AUDINITE 10046
|
||||
#define ITEM_DIANCITE 10047
|
||||
|
||||
//EVO_TRADE_ITEM
|
||||
#define ITEM_PROTECTOR ITEM_NONE
|
||||
#define ITEM_ELECTIRIZER ITEM_NONE
|
||||
#define ITEM_MAGMARIZER ITEM_NONE
|
||||
#define ITEM_DUBIOUS_DISC ITEM_NONE
|
||||
#define ITEM_PRISM_SCALE ITEM_NONE
|
||||
#define ITEM_REAPER_CLOTH ITEM_NONE
|
||||
#define ITEM_SACHET ITEM_NONE
|
||||
#define ITEM_WHIPPED_DREAM ITEM_NONE
|
||||
//EVO_TRADE_ITEM
|
||||
#define ITEM_PROTECTOR 10048
|
||||
#define ITEM_ELECTIRIZER 10049
|
||||
#define ITEM_MAGMARIZER 10050
|
||||
#define ITEM_DUBIOUS_DISC 10051
|
||||
#define ITEM_PRISM_SCALE 10052
|
||||
#define ITEM_REAPER_CLOTH 10053
|
||||
#define ITEM_SACHET 10054
|
||||
#define ITEM_WHIPPED_DREAM 10055
|
||||
|
||||
//EVO_ITEM
|
||||
#define ITEM_ICE_STONE ITEM_NONE
|
||||
#define ITEM_SHINY_STONE ITEM_NONE
|
||||
#define ITEM_DUSK_STONE ITEM_NONE
|
||||
#define ITEM_DAWN_STONE ITEM_NONE
|
||||
#define ITEM_TART_APPLE ITEM_NONE
|
||||
#define ITEM_SWEET_APPLE ITEM_NONE
|
||||
#define ITEM_CRACKED_POT ITEM_NONE
|
||||
#define ITEM_GALARICA_CUFF ITEM_NONE
|
||||
#define ITEM_GALARICA_WREATH ITEM_NONE
|
||||
#define ITEM_CHIPPED_POT ITEM_NONE
|
||||
//EVO_ITEM
|
||||
#define ITEM_ICE_STONE 10056
|
||||
#define ITEM_SHINY_STONE 10057
|
||||
#define ITEM_DUSK_STONE 10058
|
||||
#define ITEM_DAWN_STONE 10059
|
||||
#define ITEM_TART_APPLE 10060
|
||||
#define ITEM_SWEET_APPLE 10061
|
||||
#define ITEM_CRACKED_POT 10062
|
||||
#define ITEM_GALARICA_CUFF 10063
|
||||
#define ITEM_GALARICA_WREATH 10064
|
||||
#define ITEM_CHIPPED_POT 10065
|
||||
|
||||
//EVO_ITEM_HOLD
|
||||
#define ITEM_RAZOR_FANG ITEM_NONE
|
||||
#define ITEM_RAZOR_CLAW ITEM_NONE
|
||||
#define ITEM_OVAL_STONE ITEM_NONE
|
||||
//EVO_ITEM_HOLD
|
||||
#define ITEM_RAZOR_FANG 10066
|
||||
#define ITEM_RAZOR_CLAW 10067
|
||||
#define ITEM_OVAL_STONE 10068
|
||||
|
||||
//FORM_ITEM_HOLD
|
||||
#define ITEM_GRISEOUS_ORB ITEM_NONE
|
||||
#define ITEM_DRACO_PLATE ITEM_NONE
|
||||
#define ITEM_DREAD_PLATE ITEM_NONE
|
||||
#define ITEM_EARTH_PLATE ITEM_NONE
|
||||
#define ITEM_FIST_PLATE ITEM_NONE
|
||||
#define ITEM_FLAME_PLATE ITEM_NONE
|
||||
#define ITEM_ICICLE_PLATE ITEM_NONE
|
||||
#define ITEM_INSECT_PLATE ITEM_NONE
|
||||
#define ITEM_IRON_PLATE ITEM_NONE
|
||||
#define ITEM_MEADOW_PLATE ITEM_NONE
|
||||
#define ITEM_MIND_PLATE ITEM_NONE
|
||||
#define ITEM_PIXIE_PLATE ITEM_NONE
|
||||
#define ITEM_SKY_PLATE ITEM_NONE
|
||||
#define ITEM_SPLASH_PLATE ITEM_NONE
|
||||
#define ITEM_SPOOKY_PLATE ITEM_NONE
|
||||
#define ITEM_STONE_PLATE ITEM_NONE
|
||||
#define ITEM_TOXIC_PLATE ITEM_NONE
|
||||
#define ITEM_ZAP_PLATE ITEM_NONE
|
||||
#define ITEM_FIGHTINIUM_Z ITEM_NONE
|
||||
#define ITEM_FLYINIUM_Z ITEM_NONE
|
||||
#define ITEM_POISONIUM_Z ITEM_NONE
|
||||
#define ITEM_GROUNDIUM_Z ITEM_NONE
|
||||
#define ITEM_ROCKIUM_Z ITEM_NONE
|
||||
#define ITEM_BUGINIUM_Z ITEM_NONE
|
||||
#define ITEM_GHOSTIUM_Z ITEM_NONE
|
||||
#define ITEM_STEELIUM_Z ITEM_NONE
|
||||
#define ITEM_FIRIUM_Z ITEM_NONE
|
||||
#define ITEM_WATERIUM_Z ITEM_NONE
|
||||
#define ITEM_GRASSIUM_Z ITEM_NONE
|
||||
#define ITEM_ELECTRIUM_Z ITEM_NONE
|
||||
#define ITEM_PSYCHIUM_Z ITEM_NONE
|
||||
#define ITEM_ICIUM_Z ITEM_NONE
|
||||
#define ITEM_DRAGONIUM_Z ITEM_NONE
|
||||
#define ITEM_DARKINIUM_Z ITEM_NONE
|
||||
#define ITEM_FAIRIUM_Z ITEM_NONE
|
||||
#define ITEM_DOUSE_DRIVE ITEM_NONE
|
||||
#define ITEM_SHOCK_DRIVE ITEM_NONE
|
||||
#define ITEM_BURN_DRIVE ITEM_NONE
|
||||
#define ITEM_CHILL_DRIVE ITEM_NONE
|
||||
#define ITEM_BUG_MEMORY ITEM_NONE
|
||||
#define ITEM_DARK_MEMORY ITEM_NONE
|
||||
#define ITEM_DRAGON_MEMORY ITEM_NONE
|
||||
#define ITEM_ELECTRIC_MEMORY ITEM_NONE
|
||||
#define ITEM_FAIRY_MEMORY ITEM_NONE
|
||||
#define ITEM_FIGHTING_MEMORY ITEM_NONE
|
||||
#define ITEM_FIRE_MEMORY ITEM_NONE
|
||||
#define ITEM_FLYING_MEMORY ITEM_NONE
|
||||
#define ITEM_GHOST_MEMORY ITEM_NONE
|
||||
#define ITEM_GRASS_MEMORY ITEM_NONE
|
||||
#define ITEM_GROUND_MEMORY ITEM_NONE
|
||||
#define ITEM_ICE_MEMORY ITEM_NONE
|
||||
#define ITEM_POISON_MEMORY ITEM_NONE
|
||||
#define ITEM_PSYCHIC_MEMORY ITEM_NONE
|
||||
#define ITEM_ROCK_MEMORY ITEM_NONE
|
||||
#define ITEM_STEEL_MEMORY ITEM_NONE
|
||||
#define ITEM_WATER_MEMORY ITEM_NONE
|
||||
//FORM_ITEM_HOLD
|
||||
#define ITEM_GRISEOUS_ORB 10069
|
||||
#define ITEM_DRACO_PLATE 10070
|
||||
#define ITEM_DREAD_PLATE 10071
|
||||
#define ITEM_EARTH_PLATE 10072
|
||||
#define ITEM_FIST_PLATE 10073
|
||||
#define ITEM_FLAME_PLATE 10074
|
||||
#define ITEM_ICICLE_PLATE 10075
|
||||
#define ITEM_INSECT_PLATE 10076
|
||||
#define ITEM_IRON_PLATE 10077
|
||||
#define ITEM_MEADOW_PLATE 10078
|
||||
#define ITEM_MIND_PLATE 10079
|
||||
#define ITEM_PIXIE_PLATE 10080
|
||||
#define ITEM_SKY_PLATE 10081
|
||||
#define ITEM_SPLASH_PLATE 10082
|
||||
#define ITEM_SPOOKY_PLATE 10083
|
||||
#define ITEM_STONE_PLATE 10084
|
||||
#define ITEM_TOXIC_PLATE 10085
|
||||
#define ITEM_ZAP_PLATE 10086
|
||||
#define ITEM_FIGHTINIUM_Z 10087
|
||||
#define ITEM_FLYINIUM_Z 10088
|
||||
#define ITEM_POISONIUM_Z 10089
|
||||
#define ITEM_GROUNDIUM_Z 10090
|
||||
#define ITEM_ROCKIUM_Z 10091
|
||||
#define ITEM_BUGINIUM_Z 10092
|
||||
#define ITEM_GHOSTIUM_Z 10093
|
||||
#define ITEM_STEELIUM_Z 10094
|
||||
#define ITEM_FIRIUM_Z 10095
|
||||
#define ITEM_WATERIUM_Z 10096
|
||||
#define ITEM_GRASSIUM_Z 10097
|
||||
#define ITEM_ELECTRIUM_Z 10098
|
||||
#define ITEM_PSYCHIUM_Z 10099
|
||||
#define ITEM_ICIUM_Z 10100
|
||||
#define ITEM_DRAGONIUM_Z 10101
|
||||
#define ITEM_DARKINIUM_Z 10102
|
||||
#define ITEM_FAIRIUM_Z 10103
|
||||
#define ITEM_DOUSE_DRIVE 10104
|
||||
#define ITEM_SHOCK_DRIVE 10105
|
||||
#define ITEM_BURN_DRIVE 10106
|
||||
#define ITEM_CHILL_DRIVE 10107
|
||||
#define ITEM_BUG_MEMORY 10108
|
||||
#define ITEM_DARK_MEMORY 10109
|
||||
#define ITEM_DRAGON_MEMORY 10110
|
||||
#define ITEM_ELECTRIC_MEMORY 10111
|
||||
#define ITEM_FAIRY_MEMORY 10112
|
||||
#define ITEM_FIGHTING_MEMORY 10113
|
||||
#define ITEM_FIRE_MEMORY 10114
|
||||
#define ITEM_FLYING_MEMORY 10115
|
||||
#define ITEM_GHOST_MEMORY 10116
|
||||
#define ITEM_GRASS_MEMORY 10117
|
||||
#define ITEM_GROUND_MEMORY 10118
|
||||
#define ITEM_ICE_MEMORY 10119
|
||||
#define ITEM_POISON_MEMORY 10120
|
||||
#define ITEM_PSYCHIC_MEMORY 10121
|
||||
#define ITEM_ROCK_MEMORY 10122
|
||||
#define ITEM_STEEL_MEMORY 10123
|
||||
#define ITEM_WATER_MEMORY 10124
|
||||
|
||||
//FORM_ITEM_USE
|
||||
#define ITEM_GRACIDEA ITEM_NONE
|
||||
// #define ITEM_REVEAL_GLASS ITEM_NONE
|
||||
// #define ITEM_PRISON_BOTTLE ITEM_NONE
|
||||
#define ITEM_RED_NECTAR ITEM_NONE
|
||||
#define ITEM_YELLOW_NECTAR ITEM_NONE
|
||||
#define ITEM_PINK_NECTAR ITEM_NONE
|
||||
#define ITEM_PURPLE_NECTAR ITEM_NONE
|
||||
//FORM_ITEM_USE
|
||||
#define ITEM_GRACIDEA 10125
|
||||
// #define ITEM_REVEAL_GLASS 10126
|
||||
// #define ITEM_PRISON_BOTTLE 10127
|
||||
#define ITEM_RED_NECTAR 10128
|
||||
#define ITEM_YELLOW_NECTAR 10129
|
||||
#define ITEM_PINK_NECTAR 10130
|
||||
#define ITEM_PURPLE_NECTAR 10131
|
||||
#endif // ITEM_EXPANSION
|
||||
|
||||
#ifndef BATTLE_ENGINE
|
||||
#define ABILITY_MULTITYPE ABILITY_NONE
|
||||
#define ABILITY_RKS_SYSTEM ABILITY_NONE
|
||||
#define ABILITY_MULTITYPE ABILITY_NONE
|
||||
#define ABILITY_RKS_SYSTEM ABILITY_NONE
|
||||
#endif // BATTLE_ENGINE
|
||||
|
||||
#endif // GUARD_CONSTANTS_POKEMON_CONFIG_H
|
||||
|
@ -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);
|
||||
|
@ -455,5 +455,6 @@ u8 *MonSpritesGfxManager_GetSpritePtr(u8 managerId, u8 spriteNum);
|
||||
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
|
||||
|
@ -1,6 +1,7 @@
|
||||
const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] =
|
||||
{
|
||||
[SPECIES_GIRATINA] = sGiratinaFormChangeTable,
|
||||
[SPECIES_GIRATINA_ORIGIN] = sGiratinaFormChangeTable,
|
||||
[SPECIES_SHAYMIN] = sShayminFormChangeTable,
|
||||
[SPECIES_SHAYMIN_SKY] = sShayminSkyFormChangeTable,
|
||||
[SPECIES_ARCEUS] = sArceusFormChangeTable,
|
||||
|
@ -40,6 +40,7 @@ FORM_ITEM_USE_TIME:
|
||||
#define NIGHT 1
|
||||
|
||||
static const struct FormChange sGiratinaFormChangeTable[] = {
|
||||
{FORM_ITEM_HOLD, SPECIES_GIRATINA, ITEM_NONE},
|
||||
{FORM_ITEM_HOLD, SPECIES_GIRATINA_ORIGIN, ITEM_GRISEOUS_ORB},
|
||||
{FORM_CHANGE_END},
|
||||
};
|
||||
|
@ -403,6 +403,7 @@ static bool8 SetUpFieldMove_Surf(void);
|
||||
static bool8 SetUpFieldMove_Fly(void);
|
||||
static bool8 SetUpFieldMove_Waterfall(void);
|
||||
static bool8 SetUpFieldMove_Dive(void);
|
||||
void TryItemHoldFormChange(struct Pokemon *mon);
|
||||
|
||||
// static const data
|
||||
#include "data/pokemon/tutor_learnsets.h"
|
||||
@ -1731,6 +1732,7 @@ static void GiveItemToMon(struct Pokemon *mon, u16 item)
|
||||
itemBytes[0] = item;
|
||||
itemBytes[1] = item >> 8;
|
||||
SetMonData(mon, MON_DATA_HELD_ITEM, itemBytes);
|
||||
TryItemHoldFormChange(&gPlayerParty[gPartyMenu.slotId]);
|
||||
}
|
||||
|
||||
static u8 TryTakeMonItem(struct Pokemon* mon)
|
||||
@ -1744,6 +1746,7 @@ static u8 TryTakeMonItem(struct Pokemon* mon)
|
||||
|
||||
item = ITEM_NONE;
|
||||
SetMonData(mon, MON_DATA_HELD_ITEM, &item);
|
||||
TryItemHoldFormChange(&gPlayerParty[gPartyMenu.slotId]);
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -4633,6 +4636,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);
|
||||
@ -5294,6 +5309,22 @@ void ItemUseCB_FormChange_ConsumedOnUse(u8 taskId, TaskFunc task)
|
||||
if (TryItemUseFormChange(taskId, task))
|
||||
RemoveBagItem(gSpecialVar_ItemId, 1);
|
||||
}
|
||||
void TryItemHoldFormChange(struct Pokemon *mon)
|
||||
{
|
||||
u16 species = GetMonData(mon, MON_DATA_SPECIES);
|
||||
u16 targetSpecies = GetFormChangeTargetSpecies(mon, FORM_ITEM_HOLD_ABILITY, 0);
|
||||
if (targetSpecies == SPECIES_NONE)
|
||||
targetSpecies = GetFormChangeTargetSpecies(mon, FORM_ITEM_HOLD, 0);
|
||||
if (targetSpecies != SPECIES_NONE)
|
||||
{
|
||||
PlayCry_NormalNoDucking(targetSpecies, 0, CRY_VOLUME_RS, CRY_VOLUME_RS);
|
||||
SetMonData(mon, MON_DATA_SPECIES, &targetSpecies);
|
||||
FreeAndDestroyMonIconSprite(&gSprites[sPartyMenuBoxes[gPartyMenu.slotId].monSpriteId]);
|
||||
CreatePartyMonIconSpriteParameterized(targetSpecies, GetMonData(mon, MON_DATA_PERSONALITY, NULL), &sPartyMenuBoxes[gPartyMenu.slotId], 1);
|
||||
CalculateMonStats(mon);
|
||||
UpdatePartyMonHeldItemSprite(mon, &sPartyMenuBoxes[gPartyMenu.slotId]);
|
||||
}
|
||||
}
|
||||
|
||||
#undef tState
|
||||
#undef tTargetSpecies
|
||||
|
@ -8192,20 +8192,25 @@ 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 species = GetMonData(mon, MON_DATA_SPECIES, NULL);
|
||||
u16 species = GetBoxMonData(mon, MON_DATA_SPECIES, NULL);
|
||||
const struct FormChange *formChanges = gFormChangeTablePointers[species];
|
||||
u16 heldItem;
|
||||
u32 ability;
|
||||
|
||||
if (formChanges != NULL)
|
||||
{
|
||||
heldItem = GetMonData(mon, MON_DATA_HELD_ITEM, NULL);
|
||||
ability = GetAbilityBySpecies(species, GetMonData(mon, MON_DATA_ABILITY_NUM, NULL));
|
||||
heldItem = GetBoxMonData(mon, MON_DATA_HELD_ITEM, NULL);
|
||||
ability = GetAbilityBySpecies(species, GetBoxMonData(mon, MON_DATA_ABILITY_NUM, NULL));
|
||||
|
||||
for (i = 0; formChanges[i].method != FORM_CHANGE_END; i++)
|
||||
{
|
||||
@ -8214,7 +8219,7 @@ u16 GetFormChangeTargetSpecies(struct Pokemon *mon, u16 method, u32 arg)
|
||||
switch (method)
|
||||
{
|
||||
case FORM_ITEM_HOLD:
|
||||
if (heldItem == formChanges[i].param1)
|
||||
if (heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE)
|
||||
targetSpecies = formChanges[i].targetSpecies;
|
||||
break;
|
||||
case FORM_ITEM_USE:
|
||||
@ -8222,11 +8227,12 @@ 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_HOLD_ABILITY:
|
||||
if (heldItem == formChanges[i].param1 && ability == formChanges[i].param2)
|
||||
if ((heldItem == formChanges[i].param1 || formChanges[i].param1 == ITEM_NONE)
|
||||
&& ability == formChanges[i].param2)
|
||||
targetSpecies = formChanges[i].targetSpecies;
|
||||
break;
|
||||
case FORM_ITEM_USE_TIME:
|
||||
|
@ -569,6 +569,7 @@ EWRAM_DATA static bool8 sIsMonBeingMoved = 0;
|
||||
EWRAM_DATA static u8 sMovingMonOrigBoxId = 0;
|
||||
EWRAM_DATA static u8 sMovingMonOrigBoxPos = 0;
|
||||
EWRAM_DATA static bool8 sAutoActionOn = 0;
|
||||
EWRAM_DATA static bool8 sJustOpenedBag = 0;
|
||||
|
||||
// Main tasks
|
||||
static void EnterPokeStorage(u8);
|
||||
@ -870,6 +871,10 @@ static void UnkUtil_Run(void);
|
||||
static void UnkUtil_CpuRun(struct UnkUtilData *);
|
||||
static void UnkUtil_DmaRun(struct UnkUtilData *);
|
||||
|
||||
// Form changing
|
||||
void SetMonFormPSS(struct BoxPokemon *boxMon);
|
||||
void UpdateSpeciesSpritePSS(struct BoxPokemon *boxmon);
|
||||
|
||||
struct {
|
||||
const u8 *text;
|
||||
const u8 *desc;
|
||||
@ -3096,6 +3101,7 @@ static void Task_TakeItemForMoving(u8 taskId)
|
||||
StartCursorAnim(CURSOR_ANIM_OPEN);
|
||||
TakeItemFromMon(sInPartyMenu ? CURSOR_AREA_IN_PARTY : CURSOR_AREA_IN_BOX, GetCursorPosition());
|
||||
sStorage->state++;
|
||||
sJustOpenedBag = FALSE;
|
||||
break;
|
||||
case 2:
|
||||
if (!IsItemIconAnimActive())
|
||||
@ -3615,6 +3621,7 @@ static void Task_GiveItemFromBag(u8 taskId)
|
||||
sWhichToReshow = SCREEN_CHANGE_ITEM_FROM_BAG - 1;
|
||||
sStorage->screenChangeType = SCREEN_CHANGE_ITEM_FROM_BAG;
|
||||
SetPokeStorageTask(Task_ChangeScreen);
|
||||
sJustOpenedBag = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -3792,9 +3799,16 @@ static void GiveChosenBagItem(void)
|
||||
{
|
||||
u8 pos = GetCursorPosition();
|
||||
if (sInPartyMenu)
|
||||
{
|
||||
struct Pokemon *mon = &gPlayerParty[pos];
|
||||
SetMonData(&gPlayerParty[pos], MON_DATA_HELD_ITEM, &itemId);
|
||||
SetMonFormPSS(&mon->box);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCurrentBoxMonData(pos, MON_DATA_HELD_ITEM, &itemId);
|
||||
SetMonFormPSS(&gPokemonStoragePtr->boxes[StorageGetCurrentBox()][pos]);
|
||||
}
|
||||
|
||||
RemoveBagItem(itemId, 1);
|
||||
}
|
||||
@ -6889,6 +6903,19 @@ static void ReshowDisplayMon(void)
|
||||
TryRefreshDisplayMon();
|
||||
}
|
||||
|
||||
void SetMonFormPSS(struct BoxPokemon *boxMon)
|
||||
{
|
||||
u16 species = GetMonData(boxMon, MON_DATA_SPECIES);
|
||||
u16 targetSpecies = GetFormChangeTargetSpeciesBoxMon(boxMon, FORM_ITEM_HOLD_ABILITY, 0);
|
||||
if (targetSpecies == SPECIES_NONE)
|
||||
targetSpecies = GetFormChangeTargetSpeciesBoxMon(boxMon, FORM_ITEM_HOLD, 0);
|
||||
if (targetSpecies != SPECIES_NONE)
|
||||
{
|
||||
SetBoxMonData(boxMon, MON_DATA_SPECIES, &targetSpecies);
|
||||
UpdateSpeciesSpritePSS(boxMon);
|
||||
}
|
||||
}
|
||||
|
||||
static void SetDisplayMonData(void *pokemon, u8 mode)
|
||||
{
|
||||
u8 *txtPtr;
|
||||
@ -8863,11 +8890,14 @@ static void TakeItemFromMon(u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &itemId);
|
||||
SetBoxMonIconObjMode(cursorPos, 1);
|
||||
SetMonFormPSS(&gPokemonStoragePtr->boxes[StorageGetCurrentBox()][cursorPos]);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct Pokemon *mon = &gPlayerParty[cursorPos];
|
||||
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &itemId);
|
||||
SetPartyMonIconObjMode(cursorPos, 1);
|
||||
SetMonFormPSS(&mon->box);
|
||||
}
|
||||
|
||||
sStorage->movingItemId = sStorage->displayMonItemId;
|
||||
@ -8902,12 +8932,15 @@ static void SwapItemsWithMon(u8 cursorArea, u8 cursorPos)
|
||||
itemId = GetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM);
|
||||
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sStorage->movingItemId);
|
||||
sStorage->movingItemId = itemId;
|
||||
SetMonFormPSS(&gPokemonStoragePtr->boxes[StorageGetCurrentBox()][cursorPos]);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct Pokemon *mon = &gPlayerParty[cursorPos];
|
||||
itemId = GetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM);
|
||||
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sStorage->movingItemId);
|
||||
sStorage->movingItemId = itemId;
|
||||
SetMonFormPSS(&mon->box);
|
||||
}
|
||||
|
||||
id = GetItemIconIdxByPosition(CURSOR_AREA_IN_HAND, 0);
|
||||
@ -8929,11 +8962,14 @@ static void GiveItemToMon(u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &sStorage->movingItemId);
|
||||
SetBoxMonIconObjMode(cursorPos, 0);
|
||||
SetMonFormPSS(&gPokemonStoragePtr->boxes[StorageGetCurrentBox()][cursorPos]);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct Pokemon *mon = &gPlayerParty[cursorPos];
|
||||
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &sStorage->movingItemId);
|
||||
SetPartyMonIconObjMode(cursorPos, 0);
|
||||
SetMonFormPSS(&mon->box);
|
||||
}
|
||||
}
|
||||
|
||||
@ -8953,11 +8989,14 @@ static void MoveItemFromMonToBag(u8 cursorArea, u8 cursorPos)
|
||||
{
|
||||
SetCurrentBoxMonData(cursorPos, MON_DATA_HELD_ITEM, &itemId);
|
||||
SetBoxMonIconObjMode(cursorPos, 1);
|
||||
SetMonFormPSS(&gPokemonStoragePtr->boxes[StorageGetCurrentBox()][cursorPos]);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct Pokemon *mon = &gPlayerParty[cursorPos];
|
||||
SetMonData(&gPlayerParty[cursorPos], MON_DATA_HELD_ITEM, &itemId);
|
||||
SetPartyMonIconObjMode(cursorPos, 1);
|
||||
SetMonFormPSS(&mon->box);
|
||||
}
|
||||
}
|
||||
|
||||
@ -10101,3 +10140,33 @@ 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);
|
||||
if (!sJustOpenedBag)
|
||||
{
|
||||
LoadDisplayMonGfx(species, pid);
|
||||
StartDisplayMonMosaicEffect();
|
||||
|
||||
// Recreate icon sprite
|
||||
if (sInPartyMenu)
|
||||
{
|
||||
DestroyAllPartyMonIcons();
|
||||
CreatePartyMonsSprites(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
DestroyBoxMonIcon(sStorage->boxMonsSprites[sCursorPosition]);
|
||||
CreateBoxMonIconAtPos(sCursorPosition);
|
||||
SetBoxMonIconObjMode(sCursorPosition, GetMonData(boxMon, MON_DATA_HELD_ITEM) == ITEM_NONE);
|
||||
}
|
||||
}
|
||||
sJustOpenedBag = FALSE;
|
||||
}
|
||||
|
@ -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, FALSE, 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