Skip to content

Commit

Permalink
Dynamax Cleanup (#3435)
Browse files Browse the repository at this point in the history
* Mon animation names
* Moved indicator code so it follows the same standards as the other indicators
* Whitespace
* Fixed modern compile
* Fixed issue that caused Low Key Toxtricity learning Amped moves when Gigantamaxed
  • Loading branch information
AsparagusEduardo authored Oct 23, 2023
1 parent 3755155 commit 6585a62
Show file tree
Hide file tree
Showing 25 changed files with 342 additions and 329 deletions.
4 changes: 2 additions & 2 deletions data/battle_anim_scripts.s
Original file line number Diff line number Diff line change
Expand Up @@ -1007,8 +1007,8 @@ gBattleAnims_General::
.4byte General_Snow @ B_ANIM_SNOW_CONTINUES
.4byte General_UltraBurst @ B_ANIM_ULTRA_BURST
.4byte General_SaltCureDamage @ B_ANIM_SALT_CURE_DAMAGE
.4byte General_DynamaxGrowth @ B_ANIM_DYNAMAX_GROWTH
.4byte General_SetWeather @ B_ANIM_MAX_SET_WEATHER
.4byte General_DynamaxGrowth @ B_ANIM_DYNAMAX_GROWTH
.4byte General_SetWeather @ B_ANIM_MAX_SET_WEATHER

.align 2
gBattleAnims_Special::
Expand Down
4 changes: 2 additions & 2 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectVictoryDance @ EFFECT_VICTORY_DANCE
.4byte BattleScript_EffectTeatime @ EFFECT_TEATIME
.4byte BattleScript_EffectAttackUpUserAlly @ EFFECT_ATTACK_UP_USER_ALLY
.4byte BattleScript_EffectShellTrap @ EFFECT_SHELL_TRAP
.4byte BattleScript_EffectShellTrap @ EFFECT_SHELL_TRAP
.4byte BattleScript_EffectHit @ EFFECT_PSYBLADE
.4byte BattleScript_EffectHit @ EFFECT_HYDRO_STEAM
.4byte BattleScript_EffectHitSetEntryHazard @ EFFECT_HIT_SET_ENTRY_HAZARD
Expand All @@ -439,7 +439,7 @@ gBattleScriptsForMoveEffects::
.4byte BattleScript_EffectMatchaGotcha @ EFFECT_MATCHA_GOTCHA
.4byte BattleScript_EffectSyrupBomb @ EFFECT_SYRUP_BOMB
.4byte BattleScript_EffectHit @ EFFECT_IVY_CUDGEL
.4byte BattleScript_EffectMaxMove @ EFFECT_MAX_MOVE
.4byte BattleScript_EffectMaxMove @ EFFECT_MAX_MOVE

BattleScript_EffectSyrupBomb::
setmoveeffect MOVE_EFFECT_SYRUP_BOMB
Expand Down
1 change: 0 additions & 1 deletion include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,6 @@ struct DynamaxData
{
bool8 playerSelect;
u8 triggerSpriteId;
u8 indicatorSpriteId[MAX_BATTLERS_COUNT];
u8 toDynamax; // flags using gBitTable
bool8 alreadyDynamaxed[NUM_BATTLE_SIDES];
bool8 dynamaxed[MAX_BATTLERS_COUNT];
Expand Down
9 changes: 0 additions & 9 deletions include/battle_dynamax.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,4 @@ void HideDynamaxTriggerSprite(void);
bool32 IsDynamaxTriggerSpriteActive(void);
void DestroyDynamaxTriggerSprite(void);

void DynamaxIndicator_LoadSpriteGfx(void);
bool32 DynamaxIndicator_ShouldBeInvisible(u32 battlerId);
u8 DynamaxIndicator_GetSpriteId(u32 healthboxSpriteId);
void DynamaxIndicator_SetVisibilities(u32 healthboxId, bool32 invisible);
void DynamaxIndicator_UpdateOamPriority(u32 healthboxId, u32 oamPriority);
void DynamaxIndicator_UpdateLevel(u32 healthboxId, u32 level);
void DynamaxIndicator_CreateSprite(u32 battlerId, u32 healthboxSpriteId);
void DynamaxIndicator_DestroySprite(u32 healthboxSpriteId);

#endif
19 changes: 10 additions & 9 deletions include/constants/species.h
Original file line number Diff line number Diff line change
Expand Up @@ -1396,15 +1396,16 @@
#define SPECIES_FLAPPLE_GIGANTAMAX FORMS_START + 351
#define SPECIES_APPLETUN_GIGANTAMAX FORMS_START + 352
#define SPECIES_SANDACONDA_GIGANTAMAX FORMS_START + 353
#define SPECIES_TOXTRICITY_GIGANTAMAX FORMS_START + 354
#define SPECIES_CENTISKORCH_GIGANTAMAX FORMS_START + 355
#define SPECIES_HATTERENE_GIGANTAMAX FORMS_START + 356
#define SPECIES_GRIMMSNARL_GIGANTAMAX FORMS_START + 357
#define SPECIES_ALCREMIE_GIGANTAMAX FORMS_START + 358
#define SPECIES_COPPERAJAH_GIGANTAMAX FORMS_START + 359
#define SPECIES_DURALUDON_GIGANTAMAX FORMS_START + 360
#define SPECIES_URSHIFU_GIGANTAMAX FORMS_START + 361
#define SPECIES_URSHIFU_RAPID_STRIKE_STYLE_GIGANTAMAX FORMS_START + 362
#define SPECIES_TOXTRICITY_AMPED_GIGANTAMAX FORMS_START + 354
#define SPECIES_TOXTRICITY_LOW_KEY_GIGANTAMAX FORMS_START + 355
#define SPECIES_CENTISKORCH_GIGANTAMAX FORMS_START + 356
#define SPECIES_HATTERENE_GIGANTAMAX FORMS_START + 357
#define SPECIES_GRIMMSNARL_GIGANTAMAX FORMS_START + 358
#define SPECIES_ALCREMIE_GIGANTAMAX FORMS_START + 359
#define SPECIES_COPPERAJAH_GIGANTAMAX FORMS_START + 360
#define SPECIES_DURALUDON_GIGANTAMAX FORMS_START + 361
#define SPECIES_URSHIFU_GIGANTAMAX FORMS_START + 362
#define SPECIES_URSHIFU_RAPID_STRIKE_STYLE_GIGANTAMAX FORMS_START + 363

#define FORMS_START SPECIES_ENAMORUS
#define SPECIES_EGG SPECIES_URSHIFU_RAPID_STRIKE_STYLE_GIGANTAMAX + 1
Expand Down
145 changes: 2 additions & 143 deletions src/battle_dynamax.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ static const struct GMaxMove sGMaxMoveTable[] =
{SPECIES_FLAPPLE_GIGANTAMAX, TYPE_GRASS, MOVE_G_MAX_TARTNESS},
{SPECIES_APPLETUN_GIGANTAMAX, TYPE_GRASS, MOVE_G_MAX_SWEETNESS},
{SPECIES_SANDACONDA_GIGANTAMAX, TYPE_GROUND, MOVE_G_MAX_SANDBLAST},
{SPECIES_TOXTRICITY_GIGANTAMAX, TYPE_ELECTRIC, MOVE_G_MAX_STUN_SHOCK},
{SPECIES_TOXTRICITY_AMPED_GIGANTAMAX, TYPE_ELECTRIC, MOVE_G_MAX_STUN_SHOCK},
{SPECIES_TOXTRICITY_LOW_KEY_GIGANTAMAX, TYPE_ELECTRIC, MOVE_G_MAX_STUN_SHOCK},
{SPECIES_CENTISKORCH_GIGANTAMAX, TYPE_FIRE, MOVE_G_MAX_CENTIFERNO},
{SPECIES_HATTERENE_GIGANTAMAX, TYPE_FAIRY, MOVE_G_MAX_SMITE},
{SPECIES_GRIMMSNARL_GIGANTAMAX, TYPE_DARK, MOVE_G_MAX_SNOOZE},
Expand All @@ -93,7 +94,6 @@ static const struct GMaxMove sGMaxMoveTable[] =

// forward declarations
static void SpriteCb_DynamaxTrigger(struct Sprite *);
static void SpriteCb_DynamaxIndicator(struct Sprite *);

// Returns whether a battler is Dynamaxed.
bool32 IsDynamaxed(u16 battlerId)
Expand Down Expand Up @@ -1283,62 +1283,6 @@ void DestroyDynamaxTriggerSprite(void)
#undef tBattler
#undef tHide


// DYNAMAX INDICATOR:
static const u8 ALIGNED(4) sDynamaxIndicatorGfx[] = INCBIN_U8("graphics/battle_interface/dynamax_indicator.4bpp");
static const u16 sDynamaxIndicatorPal[] = INCBIN_U16("graphics/battle_interface/misc_indicator.gbapal");

static const struct SpriteSheet sSpriteSheet_DynamaxIndicator =
{
sDynamaxIndicatorGfx, sizeof(sDynamaxIndicatorGfx), TAG_DYNAMAX_INDICATOR_TILE
};
static const struct SpritePalette sSpritePalette_DynamaxIndicator =
{
sDynamaxIndicatorPal, TAG_MISC_INDICATOR_PAL
};

static const struct SpriteSheet sDynamaxIndicator_SpriteSheet[] =
{
{sDynamaxIndicatorGfx, sizeof(sDynamaxIndicatorGfx), TAG_DYNAMAX_INDICATOR_TILE}
};

static const struct SpritePalette sDynamaxIndicator_SpritePalette[] =
{
{sDynamaxIndicatorPal, TAG_MISC_INDICATOR_PAL}
};

static const struct OamData sOamData_DynamaxIndicator =
{
.shape = SPRITE_SHAPE(16x16),
.size = SPRITE_SIZE(16x16),
.priority = 1,
};

static const struct SpriteTemplate sSpriteTemplate_DynamaxIndicator =
{
.tileTag = TAG_DYNAMAX_INDICATOR_TILE,
.paletteTag = TAG_MISC_INDICATOR_PAL,
.oam = &sOamData_DynamaxIndicator,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCb_DynamaxIndicator,
};

static const s8 sIndicatorPositions[][2] =
{
[B_POSITION_PLAYER_LEFT] = {52, -9},
[B_POSITION_OPPONENT_LEFT] = {44, -9},
[B_POSITION_PLAYER_RIGHT] = {52, -9},
[B_POSITION_OPPONENT_RIGHT] = {44, -9},
};

// for sprite data fields
#define tBattler data[0]
#define tType data[1] // Indicator type: dynamax
#define tPosX data[2]
#define tLevelXDelta data[3] // X position depends whether level has 3, 2 or 1 digit

// data fields for healthboxMain
// oam.affineParam holds healthboxRight spriteId
#define hMain_DynamaxIndicatorId data[3]
Expand All @@ -1351,88 +1295,3 @@ static const s8 sIndicatorPositions[][2] =

// data fields for healthbar
#define hBar_HealthBoxSpriteId data[5]

void DynamaxIndicator_LoadSpriteGfx(void)
{
LoadSpriteSheet(sDynamaxIndicator_SpriteSheet);
LoadSpritePalette(sDynamaxIndicator_SpritePalette);
}

bool32 DynamaxIndicator_ShouldBeInvisible(u32 battlerId)
{
return !IsDynamaxed(battlerId);
}

u8 DynamaxIndicator_GetSpriteId(u32 healthboxSpriteId)
{
return gBattleStruct->dynamax.indicatorSpriteId[gSprites[healthboxSpriteId].hMain_Battler];
}

void DynamaxIndicator_SetVisibilities(u32 healthboxId, bool32 invisible)
{
u8 spriteId = DynamaxIndicator_GetSpriteId(healthboxId);
u32 battlerId = gSprites[healthboxId].hMain_Battler;

if (invisible == TRUE)
gSprites[spriteId].invisible = TRUE;
else // Try visible.
gSprites[spriteId].invisible = DynamaxIndicator_ShouldBeInvisible(battlerId);
}

void DynamaxIndicator_UpdateOamPriority(u32 healthboxId, u32 oamPriority)
{
u8 spriteId = DynamaxIndicator_GetSpriteId(healthboxId);
gSprites[spriteId].oam.priority = oamPriority;
}

void DynamaxIndicator_UpdateLevel(u32 healthboxId, u32 level)
{
s16 xDelta = 0;
u8 spriteId = DynamaxIndicator_GetSpriteId(healthboxId);

if (level >= 100)
xDelta -= 4;
else if (level < 10)
xDelta += 5;

gSprites[spriteId].tLevelXDelta = xDelta;
}

void DynamaxIndicator_CreateSprite(u32 battlerId, u32 healthboxSpriteId)
{
u32 position;
u8 spriteId;
s16 xHealthbox = 0, y = 0;
s32 x = 0;

position = GetBattlerPosition(battlerId);
GetBattlerHealthboxCoords(battlerId, &xHealthbox, &y);

x = sIndicatorPositions[position][0];
y += sIndicatorPositions[position][1];

spriteId = gBattleStruct->dynamax.indicatorSpriteId[battlerId] = CreateSpriteAtEnd(&sSpriteTemplate_DynamaxIndicator, 0, y, 0);
gSprites[spriteId].tBattler = battlerId;
gSprites[spriteId].tPosX = x;
gSprites[spriteId].invisible = TRUE;
}

void DynamaxIndicator_DestroySprite(u32 healthboxSpriteId)
{
u8 spriteId = DynamaxIndicator_GetSpriteId(healthboxSpriteId);
DestroySprite(&gSprites[spriteId]);
}

static void SpriteCb_DynamaxIndicator(struct Sprite *sprite)
{
u32 battlerId = sprite->tBattler;

sprite->x = gSprites[gHealthboxSpriteIds[battlerId]].x + sprite->tPosX + sprite->tLevelXDelta;
sprite->x2 = gSprites[gHealthboxSpriteIds[battlerId]].x2;
sprite->y2 = gSprites[gHealthboxSpriteIds[battlerId]].y2;
}

#undef tBattler
#undef tType
#undef tPosX
#undef tLevelXDelta
1 change: 0 additions & 1 deletion src/battle_gfx_sfx_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,6 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state)
LoadSpritePalette(&sSpritePalettes_HealthBoxHealthBar[0]);
LoadSpritePalette(&sSpritePalettes_HealthBoxHealthBar[1]);
MegaIndicator_LoadSpritesGfx();
DynamaxIndicator_LoadSpriteGfx();
}
else if (!IsDoubleBattle())
{
Expand Down
20 changes: 10 additions & 10 deletions src/battle_interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,6 @@ u8 CreateBattlerHealthboxSprites(u8 battlerId)
// Create mega indicator sprite.
MegaIndicator_CreateSprite(battlerId, healthboxLeftSpriteId);

// Create dynamax indicator sprites.
DynamaxIndicator_CreateSprite(battlerId, healthboxLeftSpriteId);

gBattleStruct->ballSpriteIds[0] = MAX_SPRITES;
gBattleStruct->ballSpriteIds[1] = MAX_SPRITES;

Expand Down Expand Up @@ -940,7 +937,6 @@ void SetHealthboxSpriteInvisible(u8 healthboxSpriteId)
gSprites[gSprites[healthboxSpriteId].hMain_HealthBarSpriteId].invisible = TRUE;
gSprites[gSprites[healthboxSpriteId].oam.affineParam].invisible = TRUE;
MegaIndicator_SetVisibilities(healthboxSpriteId, TRUE);
DynamaxIndicator_SetVisibilities(healthboxSpriteId, TRUE);
}

void SetHealthboxSpriteVisible(u8 healthboxSpriteId)
Expand All @@ -949,7 +945,6 @@ void SetHealthboxSpriteVisible(u8 healthboxSpriteId)
gSprites[gSprites[healthboxSpriteId].hMain_HealthBarSpriteId].invisible = FALSE;
gSprites[gSprites[healthboxSpriteId].oam.affineParam].invisible = FALSE;
MegaIndicator_SetVisibilities(healthboxSpriteId, FALSE);
DynamaxIndicator_SetVisibilities(healthboxSpriteId, FALSE);
}

static void UpdateSpritePos(u8 spriteId, s16 x, s16 y)
Expand All @@ -976,7 +971,6 @@ static void TryToggleHealboxVisibility(u32 priority, u32 healthboxLeftSpriteId,
gSprites[healthboxRightSpriteId].invisible = invisible;
gSprites[healthbarSpriteId].invisible = invisible;
MegaIndicator_SetVisibilities(healthboxLeftSpriteId, invisible);
DynamaxIndicator_SetVisibilities(healthboxLeftSpriteId, invisible);
}

void UpdateOamPriorityInAllHealthboxes(u8 priority, bool32 hideHPBoxes)
Expand All @@ -994,7 +988,6 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority, bool32 hideHPBoxes)
gSprites[healthbarSpriteId].oam.priority = priority;

MegaIndicator_UpdateOamPriority(healthboxLeftSpriteId, priority);
DynamaxIndicator_UpdateOamPriority(healthboxLeftSpriteId, priority);

if (B_HIDE_HEALTHBOX_IN_ANIMS == TRUE && hideHPBoxes && IsBattlerAlive(i))
TryToggleHealboxVisibility(priority, healthboxLeftSpriteId, healthboxRightSpriteId, healthbarSpriteId);
Expand Down Expand Up @@ -1056,8 +1049,6 @@ static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl)
xPos = 5 * (3 - (objVram - (text + 2))) - 1;
MegaIndicator_UpdateLevel(healthboxSpriteId, lvl);
MegaIndicator_SetVisibilities(healthboxSpriteId, FALSE);
DynamaxIndicator_UpdateLevel(healthboxSpriteId, lvl);
DynamaxIndicator_SetVisibilities(healthboxSpriteId, FALSE);
}
else
{
Expand Down Expand Up @@ -1623,6 +1614,7 @@ enum
INDICATOR_MEGA,
INDICATOR_ALPHA,
INDICATOR_OMEGA,
INDICATOR_DYNAMAX,
INDICATOR_COUNT,
};

Expand All @@ -1631,19 +1623,23 @@ static const u16 sMegaIndicatorPal[] = INCBIN_U16("graphics/battle_interface/meg
static const u8 ALIGNED(4) sAlphaIndicatorGfx[] = INCBIN_U8("graphics/battle_interface/alpha_indicator.4bpp");
static const u8 ALIGNED(4) sOmegaIndicatorGfx[] = INCBIN_U8("graphics/battle_interface/omega_indicator.4bpp");
static const u16 sAlphaOmegaIndicatorPal[] = INCBIN_U16("graphics/battle_interface/misc_indicator.gbapal");
static const u8 ALIGNED(4) sDynamaxIndicatorGfx[] = INCBIN_U8("graphics/battle_interface/dynamax_indicator.4bpp");
static const u16 sDynamaxIndicatorPal[] = INCBIN_U16("graphics/battle_interface/misc_indicator.gbapal");

static const struct SpriteSheet sMegaIndicator_SpriteSheets[] =
{
[INDICATOR_MEGA] = {sMegaIndicatorGfx, sizeof(sMegaIndicatorGfx), TAG_MEGA_INDICATOR_TILE},
[INDICATOR_ALPHA] = {sAlphaIndicatorGfx, sizeof(sAlphaIndicatorGfx), TAG_ALPHA_INDICATOR_TILE},
[INDICATOR_OMEGA] = {sOmegaIndicatorGfx, sizeof(sOmegaIndicatorGfx), TAG_OMEGA_INDICATOR_TILE},
[INDICATOR_DYNAMAX] = {sDynamaxIndicatorGfx, sizeof(sDynamaxIndicatorGfx), TAG_DYNAMAX_INDICATOR_TILE},
[INDICATOR_COUNT] = {0}
};
static const struct SpritePalette sMegaIndicator_SpritePalettes[] =
{
[INDICATOR_MEGA] = {sMegaIndicatorPal, TAG_MEGA_INDICATOR_PAL},
[INDICATOR_ALPHA] = {sAlphaOmegaIndicatorPal, TAG_MISC_INDICATOR_PAL},
[INDICATOR_OMEGA] = {sAlphaOmegaIndicatorPal, TAG_MISC_INDICATOR_PAL},
[INDICATOR_DYNAMAX] = {sDynamaxIndicatorPal, TAG_MISC_INDICATOR_PAL},
[INDICATOR_COUNT] = {0}
};

Expand All @@ -1670,6 +1666,7 @@ static const u16 sMegaIndicatorTags[][2] =
[INDICATOR_MEGA] = {TAG_MEGA_INDICATOR_TILE, TAG_MEGA_INDICATOR_PAL},
[INDICATOR_ALPHA] = {TAG_ALPHA_INDICATOR_TILE, TAG_MISC_INDICATOR_PAL},
[INDICATOR_OMEGA] = {TAG_OMEGA_INDICATOR_TILE, TAG_MISC_INDICATOR_PAL},
[INDICATOR_DYNAMAX] = {TAG_DYNAMAX_INDICATOR_TILE, TAG_MISC_INDICATOR_PAL},
};

static const s8 sIndicatorPositions[][2] =
Expand All @@ -1696,8 +1693,9 @@ static bool32 MegaIndicator_ShouldBeInvisible(u32 battlerId, struct Sprite *spri
{
bool32 megaEvolved = IsBattlerMegaEvolved(battlerId);
bool32 primalReverted = IsBattlerPrimalReverted(battlerId);
bool32 dynamaxed = IsDynamaxed(battlerId);

if (!megaEvolved && !primalReverted)
if (!megaEvolved && !primalReverted && !dynamaxed)
return TRUE;

if (megaEvolved)
Expand All @@ -1706,6 +1704,8 @@ static bool32 MegaIndicator_ShouldBeInvisible(u32 battlerId, struct Sprite *spri
sprite->tType = INDICATOR_ALPHA;
else if (primalReverted && gBattleMons[battlerId].species == SPECIES_GROUDON_PRIMAL)
sprite->tType = INDICATOR_OMEGA;
else if (dynamaxed)
sprite->tType = INDICATOR_DYNAMAX;

sprite->oam.tileNum = GetSpriteTileStartByTag(sMegaIndicatorTags[sprite->tType][0]);
sprite->oam.paletteNum = IndexOfSpritePaletteTag(sMegaIndicatorTags[sprite->tType][1]);
Expand Down
6 changes: 4 additions & 2 deletions src/data/pokemon/form_change_table_pointers.h
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,10 @@ const struct FormChange *const gFormChangeTablePointers[NUM_SPECIES] =
[SPECIES_CRAMORANT] = sCramorantFormChangeTable,
[SPECIES_CRAMORANT_GULPING] = sCramorantFormChangeTable,
[SPECIES_CRAMORANT_GORGING] = sCramorantFormChangeTable,
[SPECIES_TOXTRICITY] = sToxtricityFormChangeTable,
[SPECIES_TOXTRICITY_GIGANTAMAX] = sToxtricityFormChangeTable,
[SPECIES_TOXTRICITY] = sToxtricityAmpedFormChangeTable,
[SPECIES_TOXTRICITY_LOW_KEY] = sToxtricityAmpedFormChangeTable,
[SPECIES_TOXTRICITY_AMPED_GIGANTAMAX] = sToxtricityLowKeyFormChangeTable,
[SPECIES_TOXTRICITY_LOW_KEY_GIGANTAMAX] = sToxtricityLowKeyFormChangeTable,
[SPECIES_CENTISKORCH] = sCentiskorchFormChangeTable,
[SPECIES_CENTISKORCH_GIGANTAMAX] = sCentiskorchFormChangeTable,
[SPECIES_HATTERENE] = sHattereneFormChangeTable,
Expand Down
Loading

0 comments on commit 6585a62

Please sign in to comment.