Skip to content

Commit

Permalink
Backward-compatible BoxPokemon Refactor
Browse files Browse the repository at this point in the history
Reuses space that contains zeros to provide space for:
- HP/status in the box
- 12-character nicknames
- Up to 63 PokéBalls
- Shininess separate from PID
- Hidden Nature
- Hyper Training
- Dynamax Level
- Gigantamax Factor
- Terastallization Types
- Shadow

Implements:
- OW_PC_HEAL to switch between Gen7- and Gen8+ behavior
- Nature Mints
- Dynamax Candy
- Hyper Training commands (canhypertrain/hypertrain)
- Gigantamax Factor commands (hasgigantamaxfactor/togglegigantamaxfactor)
- Terastallization Type on the summary screen
- Prevents Gigantamax Factor Pokémon from evolving into a species without a Gigantamax form
  • Loading branch information
mrgriffin committed Nov 9, 2023
1 parent 54d8705 commit 4b0d9c2
Show file tree
Hide file tree
Showing 62 changed files with 1,365 additions and 521 deletions.
28 changes: 28 additions & 0 deletions asm/macros/event.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2025,3 +2025,31 @@
callnative CreateTrainerPartyForPlayer
trainerbattle_no_intro \trainer2, NULL
.endm

@ Sets VAR_RESULT to TRUE if stat can be hyper trained, or to
@ FALSE otherwise.
.macro canhypertrain stat:req, slot:req
callnative CanHyperTrain
.byte \stat
.2byte \slot
.endm

@ Hyper Trains a stat.
.macro hypertrain stat:req, slot:req
callnative HyperTrain
.byte \stat
.2byte \slot
.endm

@ Sets VAR_RESULT to TRUE if the Pokemon has the Gigantamax Factor,
@ or to FALSE otherwise.
.macro hasgigantamaxfactor slot:req
callnative HasGigantamaxFactor
.2byte \slot
.endm

@ Toggles the Gigantamax Factor for a Pokemon.
.macro togglegigantamaxfactor slot:req
callnative ToggleGigantamaxFactor
.2byte \slot
.endm
4 changes: 2 additions & 2 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct ResourceFlags
struct DisableStruct
{
u32 transformedMonPersonality;
u32 transformedMonOtId;
bool8 transformedMonShininess;
u16 disabledMove;
u16 encoredMove;
u8 protectUses;
Expand Down Expand Up @@ -1033,7 +1033,7 @@ extern u8 gBattlerStatusSummaryTaskId[MAX_BATTLERS_COUNT];
extern u8 gBattlerInMenuId;
extern bool8 gDoingBattleAnim;
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
extern u32 gTransformedOtIds[MAX_BATTLERS_COUNT];
extern bool8 gTransformedShininess[MAX_BATTLERS_COUNT];
extern u8 gPlayerDpadHoldFrames;
extern struct BattleSpriteData *gBattleSpritesDataPtr;
extern struct MonSpritesGfx *gMonSpritesGfxPtr;
Expand Down
2 changes: 1 addition & 1 deletion include/battle_anim.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void PrepareAffineAnimInTaskData(struct Task *task, u8 spriteId, const union Aff
bool8 RunAffineAnimFromTaskData(struct Task *task);
void AnimThrowProjectile(struct Sprite *sprite);
void GetBgDataForTransform(struct BattleAnimBgData *dest, u8 battlerId);
u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 id, s16 x, s16 y, u8 subpriority, u32 personality, u32 trainerId, u32 battlerId);
u8 CreateAdditionalMonSpriteForMoveAnim(u16 species, bool8 isBackpic, u8 id, s16 x, s16 y, u8 subpriority, u32 personality, bool8 isShiny, u32 battlerId);
void ResetSpriteRotScale_PreserveAffine(struct Sprite *sprite);
void Trade_MoveSelectedMonToTarget(struct Sprite *sprite);
void DestroyAnimVisualTaskAndDisableBlend(u8 taskId);
Expand Down
1 change: 1 addition & 0 deletions include/config/overworld.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

// PC settings
#define OW_PC_PRESS_B GEN_LATEST // In Gen4, pressing B when holding a Pokémon is equivalent to placing it. In Gen3, it gives the "You're holding a Pokémon!" error.
#define OW_PC_HEAL GEN_LATEST // In Gen8+, Pokémon are not healed when deposited in the PC.

// Out-of-battle Ability effects
#define OW_SYNCHRONIZE_NATURE GEN_LATEST // In Gen8, if a Pokémon with Synchronize is leading the party, it's 100% guaranteed that wild Pokémon will have the same Nature, as opposed to 50% previously. Stationary Pokémon are excluded in Gen3. In Gen6, all No Eggs Discovered gift Pokémon will have the same Nature, while in Gen7 all gift Pokémon will, regardless of Egg Group - In Gen 8, no gift Pokémon are affected. In Gen9, this ability has no out-of-battle effect.
Expand Down
1 change: 1 addition & 0 deletions include/config/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define P_CUSTOM_GENDER_DIFF_ICONS TRUE // If TRUE, will give more Pokémon custom icons for their female forms, i.e. Hippopotas and Hippowdon
#define P_LEGENDARY_PERFECT_IVS GEN_LATEST // Since Gen 6, Legendaries, Mythicals and Ultra Beasts found in the wild or given through gifts have at least 3 perfect IVs.
#define P_EV_CAP GEN_LATEST // Since Gen 6, the max EVs per stat is 252 instead of 255.
#define P_SHOW_TERA_TYPE GEN_LATEST // Since Gen 9, the Tera Type is shown on the summary screen.

// Flag settings
// To use the following features in scripting, replace the 0s with the flag ID you're assigning it to.
Expand Down
5 changes: 4 additions & 1 deletion include/constants/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@
#define B_OUTCOME_LINK_BATTLE_RAN (1 << 7) // 128

// Non-volatile status conditions
// These persist remain outside of battle and after switching out
// These remain outside of battle and after switching out.
// If a new STATUS1 is added here, it should also be added to
// sCompressedStatuses in src/pokemon.c or else it will be lost outside
// of battle.
#define STATUS1_NONE 0
#define STATUS1_SLEEP (1 << 0 | 1 << 1 | 1 << 2) // First 3 bits (Number of turns to sleep)
#define STATUS1_SLEEP_TURN(num) ((num) << 0) // Just for readability (or if rearranging statuses)
Expand Down
2 changes: 2 additions & 0 deletions include/constants/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
#define VERSION_PLATINUM 12
#define VERSION_GAMECUBE 15

#define NUM_VERSIONS 15

#define LANGUAGE_JAPANESE 1
#define LANGUAGE_ENGLISH 2
#define LANGUAGE_FRENCH 3
Expand Down
2 changes: 2 additions & 0 deletions include/constants/moves.h
Original file line number Diff line number Diff line change
Expand Up @@ -973,6 +973,8 @@

#define MOVES_COUNT_DYNAMAX (LAST_MAX_MOVE + 1)

#define MOVES_COUNT_ALL MOVES_COUNT_DYNAMAX

// Used for checks for moves affected by Disable, Mimic, etc.
#define MOVE_UNAVAILABLE 0xFFFF

Expand Down
2 changes: 2 additions & 0 deletions include/constants/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@
#define MIN_LEVEL 1
#define MAX_LEVEL 100

#define MAX_DYNAMAX_LEVEL 10

#define OT_ID_PLAYER_ID 0
#define OT_ID_PRESET 1
#define OT_ID_RANDOM_NO_SHINY 2
Expand Down
6 changes: 5 additions & 1 deletion include/contest.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ struct ContestPokemon
u8 sheen;
u8 highestRank;
bool8 gameCleared;
u8 unused[10];
u8 isShiny:1;
u8 unused1:7;
u8 unused2[9];
u32 personality;
u32 otId;
};
Expand All @@ -124,6 +126,8 @@ struct ContestMoveAnimData
u16 species;
u16 targetSpecies;
bool8 hasTargetAnim:1;
u8 isShiny:1;
u8 targetIsShiny:1;
u8 contestant;
u32 personality;
u32 otId;
Expand Down
2 changes: 2 additions & 0 deletions include/data.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ struct TrainerMon
u8 nature : 5;
bool8 gender : 2;
bool8 isShiny : 1;
u8 dynamaxLevel : 4;
bool8 gigantamaxFactor : 1;
};

#define TRAINER_PARTY(partyArray) partyArray, .partySize = ARRAY_COUNT(partyArray)
Expand Down
3 changes: 2 additions & 1 deletion include/global.h
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,8 @@ struct ContestWinner
u8 contestCategory;
u8 monName[POKEMON_NAME_LENGTH + 1];
u8 trainerName[PLAYER_NAME_LENGTH + 1];
u8 contestRank;
u8 contestRank:7;
bool8 isShiny:1;
//u8 padding;
};

Expand Down
2 changes: 2 additions & 0 deletions include/item_use.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ void ItemUseOutOfBattle_WailmerPail(u8);
void ItemUseOutOfBattle_Medicine(u8);
void ItemUseOutOfBattle_AbilityCapsule(u8);
void ItemUseOutOfBattle_AbilityPatch(u8);
void ItemUseOutOfBattle_Mint(u8);
void ItemUseOutOfBattle_ResetEVs(u8);
void ItemUseOutOfBattle_ReduceEV(u8);
void ItemUseOutOfBattle_SacredAsh(u8);
void ItemUseOutOfBattle_PPRecovery(u8);
void ItemUseOutOfBattle_PPUp(u8);
void ItemUseOutOfBattle_RareCandy(u8);
void ItemUseOutOfBattle_DynamaxCandy(u8);
void ItemUseOutOfBattle_TMHM(u8);
void ItemUseOutOfBattle_Repel(u8);
void ItemUseOutOfBattle_Lure(u8);
Expand Down
2 changes: 2 additions & 0 deletions include/party_menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void ItemUseCB_BattleChooseMove(u8 taskId, TaskFunc task);
void ItemUseCB_Medicine(u8 taskId, TaskFunc task);
void ItemUseCB_AbilityCapsule(u8 taskId, TaskFunc task);
void ItemUseCB_AbilityPatch(u8 taskId, TaskFunc task);
void ItemUseCB_Mint(u8 taskId, TaskFunc task);
void ItemUseCB_ResetEVs(u8 taskId, TaskFunc task);
void ItemUseCB_ReduceEV(u8 taskId, TaskFunc task);
void ItemUseCB_PPRecovery(u8 taskId, TaskFunc task);
Expand All @@ -62,6 +63,7 @@ bool8 MonKnowsMove(struct Pokemon *mon, u16 move);
bool8 BoxMonKnowsMove(struct BoxPokemon *boxMon, u16 move);
void ItemUseCB_TMHM(u8 taskId, TaskFunc task);
void ItemUseCB_RareCandy(u8 taskId, TaskFunc task);
void ItemUseCB_DynamaxCandy(u8 taskId, TaskFunc task);
void ItemUseCB_SacredAsh(u8 taskId, TaskFunc task);
void ItemUseCB_EvolutionStone(u8 taskId, TaskFunc task);
void ItemUseCB_FormChange(u8 taskId, TaskFunc task);
Expand Down
2 changes: 1 addition & 1 deletion include/pokedex.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void ResetPokedex(void);
u16 GetPokedexHeightWeight(u16 dexNum, u8 data);
u16 GetNationalPokedexCount(u8);
u16 GetHoennPokedexCount(u8);
u8 DisplayCaughtMonDexPage(u16 dexNum, u32 otId, u32 personality);
u8 DisplayCaughtMonDexPage(u16 dexNum, bool8 isShiny, u32 personality);
s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId);
u16 CreateMonSpriteFromNationalDexNumber(u16, s16, s16, u16);
bool16 HasAllHoennMons(void);
Expand Down
Loading

0 comments on commit 4b0d9c2

Please sign in to comment.