Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trainerslide animation fix #6040

Merged
merged 2 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ struct BattleStruct
u8 padding:7;
u8 usedEjectItem;
u8 usedMicleBerry;
u8 trainerSlideSpriteIds[MAX_BATTLERS_COUNT];
hedara90 marked this conversation as resolved.
Show resolved Hide resolved
};

// The palaceFlags member of struct BattleStruct contains 1 flag per move to indicate which moves the AI should consider,
Expand Down
3 changes: 1 addition & 2 deletions include/config/battle.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@
#define B_SHOW_TYPES SHOW_TYPES_NEVER // When defined as SHOW_TYPES_ALWAYS, after selecting "Fight" in battle, the types of all Pokemon are revealed. Whe defined as SHOW_TYPES_OWN, types are only revealed if the player owns the mon in question.

// Pokémon battle sprite settings
#define B_ENEMY_MON_SHADOW_STYLE GEN_3 // In Gen4+, all enemy Pokemon will have a shadow drawn beneath them.
// Currently Gen4+ shadows don't properly work with Trainerslides
#define B_ENEMY_MON_SHADOW_STYLE GEN_LATEST // In Gen4+, all enemy Pokemon will have a shadow drawn beneath them.
Bassoonian marked this conversation as resolved.
Show resolved Hide resolved

#endif // GUARD_CONFIG_BATTLE_H
106 changes: 53 additions & 53 deletions src/battle_controllers.c
Original file line number Diff line number Diff line change
Expand Up @@ -2258,12 +2258,12 @@ static void Controller_DoMoveAnimation(u32 battler)

static void Controller_HandleTrainerSlideBack(u32 battler)
{
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
if (gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].callback == SpriteCallbackDummy)
{
if (GetBattlerSide(battler) == B_SIDE_OPPONENT)
FreeTrainerFrontPicPalette(gSprites[gBattlerSpriteIds[battler]].oam.affineParam);
FreeSpriteOamMatrix(&gSprites[gBattlerSpriteIds[battler]]);
DestroySprite(&gSprites[gBattlerSpriteIds[battler]]);
FreeTrainerFrontPicPalette(gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].oam.affineParam);
FreeSpriteOamMatrix(&gSprites[gBattleStruct->trainerSlideSpriteIds[battler]]);
DestroySprite(&gSprites[gBattleStruct->trainerSlideSpriteIds[battler]]);
BattleControllerComplete(battler);
}
}
Expand Down Expand Up @@ -2305,7 +2305,7 @@ static void Controller_WaitForStatusAnimation(u32 battler)

static void Controller_WaitForTrainerPic(u32 battler)
{
if (gSprites[gBattlerSpriteIds[battler]].callback == SpriteCallbackDummy)
if (gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].callback == SpriteCallbackDummy)
BattleControllerComplete(battler);
}

Expand Down Expand Up @@ -2495,18 +2495,18 @@ void BtlController_HandleDrawTrainerPic(u32 battler, u32 trainerPicId, bool32 is
if (GetBattlerSide(battler) == B_SIDE_OPPONENT) // Always the front sprite for the opponent.
{
DecompressTrainerFrontPic(trainerPicId, battler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(battler));
SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(battler));
if (subpriority == -1)
subpriority = GetBattlerSpriteSubpriority(battler);
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
gBattleStruct->trainerSlideSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
xPos,
yPos,
subpriority);

gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerSprites[trainerPicId].palette.tag);
gSprites[gBattlerSpriteIds[battler]].x2 = -DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[battler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[battler]].oam.affineParam = trainerPicId;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerSprites[trainerPicId].palette.tag);
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].x2 = -DISPLAY_WIDTH;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].sSpeedX = 2;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].oam.affineParam = trainerPicId;
}
else // Player's side
{
Expand All @@ -2516,36 +2516,36 @@ void BtlController_HandleDrawTrainerPic(u32 battler, u32 trainerPicId, bool32 is
SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(battler));
if (subpriority == -1)
subpriority = GetBattlerSpriteSubpriority(battler);
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
gBattleStruct->trainerSlideSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
xPos,
yPos,
subpriority);

gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerSprites[trainerPicId].palette.tag);
gSprites[gBattlerSpriteIds[battler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattlerSpriteIds[battler]].hFlip = 1;
gSprites[gBattlerSpriteIds[battler]].y2 = 48;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerSprites[trainerPicId].palette.tag);
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].hFlip = 1;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].y2 = 48;
}
else
{
DecompressTrainerBackPic(trainerPicId, battler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(battler));
if (subpriority == -1)
subpriority = GetBattlerSpriteSubpriority(battler);
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
gBattleStruct->trainerSlideSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
xPos,
yPos,
subpriority);

gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].oam.paletteNum = battler;
}
gSprites[gBattlerSpriteIds[battler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[battler]].sSpeedX = -2;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].x2 = DISPLAY_WIDTH;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].sSpeedX = -2;
}
if (B_FAST_INTRO_NO_SLIDE || gTestRunnerHeadless)
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCB_TrainerSpawn;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].callback = SpriteCB_TrainerSpawn;
else
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].callback = SpriteCB_TrainerSlideIn;

gBattlerControllerFuncs[battler] = Controller_WaitForTrainerPic;
}
Expand All @@ -2556,26 +2556,26 @@ void BtlController_HandleTrainerSlide(u32 battler, u32 trainerPicId)
{
DecompressTrainerBackPic(trainerPicId, battler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(battler));
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
gBattleStruct->trainerSlideSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
80,
(8 - gTrainerBacksprites[trainerPicId].coordinates.size) * 4 + 80,
30);
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattlerSpriteIds[battler]].x2 = -96;
gSprites[gBattlerSpriteIds[battler]].sSpeedX = 2;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].x2 = -96;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].sSpeedX = 2;
}
else
{
DecompressTrainerFrontPic(trainerPicId, battler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(battler));
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, 176, 40, 30);
gSprites[gBattlerSpriteIds[battler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerSprites[trainerPicId].palette.tag);
gSprites[gBattlerSpriteIds[battler]].x2 = 96;
gSprites[gBattlerSpriteIds[battler]].x += 32;
gSprites[gBattlerSpriteIds[battler]].sSpeedX = -2;
SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(battler));
gBattleStruct->trainerSlideSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate, 176, 40, 0);
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].oam.affineParam = trainerPicId;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerSprites[trainerPicId].palette.tag);
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].x2 = 96;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].x += 32;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].sSpeedX = -2;
}
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].callback = SpriteCB_TrainerSlideIn;

gBattlerControllerFuncs[battler] = Controller_WaitForTrainerPic;
}
Expand All @@ -2586,14 +2586,14 @@ void BtlController_HandleTrainerSlideBack(u32 battler, s16 data0, bool32 startAn
{
u32 side = GetBattlerSide(battler);

SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[battler]]);
gSprites[gBattlerSpriteIds[battler]].data[0] = data0;
gSprites[gBattlerSpriteIds[battler]].data[2] = (side == B_SIDE_PLAYER) ? -40 : 280;
gSprites[gBattlerSpriteIds[battler]].data[4] = gSprites[gBattlerSpriteIds[battler]].y;
gSprites[gBattlerSpriteIds[battler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[battler]], SpriteCallbackDummy);
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattleStruct->trainerSlideSpriteIds[battler]]);
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].data[0] = data0;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].data[2] = (side == B_SIDE_PLAYER) ? -40 : 280;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].data[4] = gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].y;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattleStruct->trainerSlideSpriteIds[battler]], SpriteCallbackDummy);
if (startAnim)
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], 1);
StartSpriteAnim(&gSprites[gBattleStruct->trainerSlideSpriteIds[battler]], 1);
gBattlerControllerFuncs[battler] = Controller_HandleTrainerSlideBack;
}

Expand Down Expand Up @@ -2887,34 +2887,34 @@ void BtlController_HandleIntroTrainerBallThrow(u32 battler, u16 tagTrainerPal, c
u8 paletteNum, taskId;
u32 side = GetBattlerSide(battler);

SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[battler]]);
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattleStruct->trainerSlideSpriteIds[battler]]);
if (side == B_SIDE_PLAYER)
{
gSprites[gBattlerSpriteIds[battler]].data[0] = 50;
gSprites[gBattlerSpriteIds[battler]].data[2] = -40;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].data[0] = 50;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].data[2] = -40;
}
else
{
gSprites[gBattlerSpriteIds[battler]].data[0] = 35;
gSprites[gBattlerSpriteIds[battler]].data[2] = 280;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].data[0] = 35;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].data[2] = 280;
}

gSprites[gBattlerSpriteIds[battler]].data[4] = gSprites[gBattlerSpriteIds[battler]].y;
gSprites[gBattlerSpriteIds[battler]].callback = StartAnimLinearTranslation;
gSprites[gBattlerSpriteIds[battler]].sBattlerId = battler;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].data[4] = gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].y;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].callback = StartAnimLinearTranslation;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].sBattlerId = battler;

if (side == B_SIDE_PLAYER)
{
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[battler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], ShouldDoSlideInAnim() ? 2 : 1);
StoreSpriteCallbackInData6(&gSprites[gBattleStruct->trainerSlideSpriteIds[battler]], SpriteCB_FreePlayerSpriteLoadMonSprite);
StartSpriteAnim(&gSprites[gBattleStruct->trainerSlideSpriteIds[battler]], ShouldDoSlideInAnim() ? 2 : 1);

paletteNum = AllocSpritePalette(tagTrainerPal);
LoadCompressedPalette(trainerPal, OBJ_PLTT_ID(paletteNum), PLTT_SIZE_4BPP);
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = paletteNum;
gSprites[gBattleStruct->trainerSlideSpriteIds[battler]].oam.paletteNum = paletteNum;
}
else
{
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[battler]], SpriteCB_FreeOpponentSprite);
StoreSpriteCallbackInData6(&gSprites[gBattleStruct->trainerSlideSpriteIds[battler]], SpriteCB_FreeOpponentSprite);
}

taskId = CreateTask(Task_StartSendOutAnim, 5);
Expand Down
Loading