draw trainer pic

This commit is contained in:
DizzyEggg 2023-08-06 21:50:59 +02:00
parent a9483c361b
commit ef8024d8c5
11 changed files with 159 additions and 330 deletions

View File

@ -266,6 +266,7 @@ void BtlController_HandleSetRawMonData(void);
void BtlController_HandleLoadMonSprite(u32 battler, struct Pokemon *party, void (*controllerCallback)(void));
void BtlController_HandleSwitchInAnim(u32 battler, bool32 isPlayerSide, void (*controllerCallback)(void));
void BtlController_HandleReturnMonToBall(void);
void BtlController_HandleDrawTrainerPic(u32 battlerId, u32 trainerPicId, bool32 isFrontPic, s16 xPos, s16 yPos, s32 subpriority);
void BtlController_HandleFaintAnimation(void);
void BtlController_HandleSuccessBallThrowAnim(u32 battler, u32 target, u32 animId, bool32 allowCriticalCapture);
void BtlController_HandleBallThrowAnim(u32 battler, u32 target, u32 animId, bool32 allowCriticalCapture);
@ -295,6 +296,7 @@ void SetControllerToPlayer(void);
void BattleControllerDummy(void);
void SetBattleEndCallbacks(void);
void PlayerHandleExpUpdate(void);
u32 LinkPlayerGetTrainerPicId(u32 multiplayerId);
void CB2_SetUpReshowBattleScreenAfterMenu(void);
void CB2_SetUpReshowBattleScreenAfterMenu2(void);
void Task_PlayerController_RestoreBgmAfterCry(u8 taskId);

View File

@ -129,12 +129,6 @@ static void LinkOpponentBufferRunCommand(void)
}
}
static void CompleteOnBattlerSpriteCallbackDummy(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
LinkOpponentBufferExecCompleted();
}
static void CompleteOnBankSpriteCallbackDummy2(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -237,7 +231,6 @@ static void Intro_TryShinyAnimShowHealthbox(void)
TryShinyAnimation(BATTLE_PARTNER(gActiveBattler), &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]);
}
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted)
@ -502,20 +495,9 @@ static void LinkOpponentHandleDrawTrainerPic(void)
}
}
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate,
xPos,
(8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40,
GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, TRUE,
xPos, 40 + 4 * (8 - gTrainerFrontPicCoords[trainerPicId].size),
-1);
}
static void LinkOpponentHandleTrainerSlide(void)

View File

@ -129,12 +129,6 @@ static void LinkPartnerBufferRunCommand(void)
}
}
static void CompleteOnBattlerSpriteCallbackDummy(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
LinkPartnerBufferExecCompleted();
}
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -272,31 +266,10 @@ static void LinkPartnerHandleDrawTrainerPic(void)
xPos = 80;
}
if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED
|| (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN)
{
trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender + TRAINER_BACK_PIC_RED;
}
else if ((gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY
|| (gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE)
{
trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender + TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN;
}
else
{
trainerPicId = gLinkPlayers[GetBattlerMultiplayerId(gActiveBattler)].gender;
}
DecompressTrainerBackPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
trainerPicId = LinkPlayerGetTrainerPicId(GetBattlerMultiplayerId(gActiveBattler));
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, FALSE,
xPos, 80 + 4 * (8 - gTrainerBackPicCoords[trainerPicId].size),
-1);
}
#undef sSpeedX

View File

@ -145,12 +145,6 @@ static void OpponentBufferRunCommand(void)
}
}
static void CompleteOnBattlerSpriteCallbackDummy(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
OpponentBufferExecCompleted();
}
static void CompleteOnBankSpriteCallbackDummy2(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -445,12 +439,9 @@ static void OpponentHandleSwitchInAnim(void)
BtlController_HandleSwitchInAnim(gActiveBattler, FALSE, SwitchIn_TryShinyAnim);
}
#define sSpeedX data[0]
static void OpponentHandleDrawTrainerPic(void)
static u32 OpponentGetTrainerPicId(u32 battlerId)
{
u32 trainerPicId;
s16 xPos;
if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE)
{
@ -464,7 +455,7 @@ static void OpponentHandleDrawTrainerPic(void)
{
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
if (gActiveBattler == 1)
if (battlerId == 1)
trainerPicId = GetTrainerHillTrainerFrontSpriteId(gTrainerBattleOpponent_A);
else
trainerPicId = GetTrainerHillTrainerFrontSpriteId(gTrainerBattleOpponent_B);
@ -478,7 +469,7 @@ static void OpponentHandleDrawTrainerPic(void)
{
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TOWER_LINK_MULTI))
{
if (gActiveBattler == 1)
if (battlerId == 1)
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A);
else
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B);
@ -494,7 +485,7 @@ static void OpponentHandleDrawTrainerPic(void)
}
else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
if (gActiveBattler != 1)
if (battlerId != 1)
trainerPicId = gTrainers[gTrainerBattleOpponent_B].trainerPic;
else
trainerPicId = gTrainers[gTrainerBattleOpponent_A].trainerPic;
@ -504,6 +495,16 @@ static void OpponentHandleDrawTrainerPic(void)
trainerPicId = gTrainers[gTrainerBattleOpponent_A].trainerPic;
}
return trainerPicId;
}
#define sSpeedX data[0]
static void OpponentHandleDrawTrainerPic(void)
{
s16 xPos;
u32 trainerPicId = OpponentGetTrainerPicId(gActiveBattler);
if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS) && !BATTLE_TWO_VS_ONE_OPPONENT)
{
if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon
@ -516,77 +517,14 @@ static void OpponentHandleDrawTrainerPic(void)
xPos = 176;
}
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate,
xPos,
(8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40,
GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, TRUE,
xPos, 40 + 4 * (8 - gTrainerFrontPicCoords[trainerPicId].size),
-1);
}
static void OpponentHandleTrainerSlide(void)
{
u32 trainerPicId;
if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE)
{
trainerPicId = GetSecretBaseTrainerPicIndex();
}
else if (gTrainerBattleOpponent_A == TRAINER_FRONTIER_BRAIN)
{
trainerPicId = GetFrontierBrainTrainerPicIndex();
}
else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER_HILL)
{
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
if (gActiveBattler == 1)
trainerPicId = GetTrainerHillTrainerFrontSpriteId(gTrainerBattleOpponent_A);
else
trainerPicId = GetTrainerHillTrainerFrontSpriteId(gTrainerBattleOpponent_B);
}
else
{
trainerPicId = GetTrainerHillTrainerFrontSpriteId(gTrainerBattleOpponent_A);
}
}
else if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER)
{
if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_TOWER_LINK_MULTI))
{
if (gActiveBattler == 1)
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A);
else
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B);
}
else
{
trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A);
}
}
else if (gBattleTypeFlags & BATTLE_TYPE_EREADER_TRAINER)
{
trainerPicId = GetEreaderTrainerFrontSpriteId();
}
else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
{
if (gActiveBattler != 1)
trainerPicId = gTrainers[gTrainerBattleOpponent_B].trainerPic;
else
trainerPicId = gTrainers[gTrainerBattleOpponent_A].trainerPic;
}
else
{
trainerPicId = gTrainers[gTrainerBattleOpponent_A].trainerPic;
}
u32 trainerPicId = OpponentGetTrainerPicId(gActiveBattler);
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));

View File

@ -1087,12 +1087,6 @@ void SetBattleEndCallbacks(void)
}
}
static void CompleteOnBattlerSpriteCallbackDummy(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
PlayerBufferExecCompleted();
}
static void CompleteOnBankSpriteCallbackDummy2(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -1699,35 +1693,43 @@ static void PlayerHandleSwitchInAnim(void)
#define sSpeedX data[0]
u32 LinkPlayerGetTrainerPicId(u32 multiplayerId)
{
u32 trainerPicId;
u8 gender = gLinkPlayers[multiplayerId].gender;
u8 version = gLinkPlayers[multiplayerId].version & 0xFF;
if (version == VERSION_FIRE_RED || version == VERSION_LEAF_GREEN)
trainerPicId = gender + TRAINER_BACK_PIC_RED;
else if (version == VERSION_RUBY || version == VERSION_SAPPHIRE)
trainerPicId = gender + TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN;
else
trainerPicId = gender + TRAINER_BACK_PIC_BRENDAN;
return trainerPicId;
}
static u32 PlayerGetTrainerBackPicId(void)
{
u32 trainerPicId;
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
trainerPicId = LinkPlayerGetTrainerPicId(GetMultiplayerId());
else
trainerPicId = gSaveBlock2Ptr->playerGender + TRAINER_BACK_PIC_BRENDAN;
return trainerPicId;
}
// In emerald it's possible to have a tag battle in the battle frontier facilities with AI
// which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven)
// that use an animated back pic.
static void PlayerHandleDrawTrainerPic(void)
{
bool32 isFrontPic;
s16 xPos, yPos;
u32 trainerPicId;
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_FIRE_RED
|| (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_LEAF_GREEN)
{
trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + TRAINER_BACK_PIC_RED;
}
else if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_RUBY
|| (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_SAPPHIRE)
{
trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN;
}
else
{
trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + TRAINER_BACK_PIC_BRENDAN;
}
}
else
{
trainerPicId = gSaveBlock2Ptr->playerGender;
}
u32 trainerPicId, gender;
if (gBattleTypeFlags & BATTLE_TYPE_MULTI)
{
@ -1753,63 +1755,24 @@ static void PlayerHandleDrawTrainerPic(void)
yPos = (8 - gTrainerBackPicCoords[trainerPicId].size) * 4 + 80;
}
// Use front pic table for any tag battles unless your partner is Steven.
// Use front pic table for any tag battles unless your partner is Steven or a custom partner.
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId != TRAINER_STEVEN_PARTNER && gPartnerTrainerId < TRAINER_CUSTOM_PARTNER)
{
trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender);
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].y2 = 48;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
isFrontPic = TRUE;
}
// Use the back pic in any other scenario.
else
else // Use back pic in all the other usual circumstances.
{
DecompressTrainerBackPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
trainerPicId = PlayerGetTrainerBackPicId();
isFrontPic = FALSE;
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, isFrontPic, xPos, yPos, -1);
}
static void PlayerHandleTrainerSlide(void)
{
u32 trainerPicId;
if (gBattleTypeFlags & BATTLE_TYPE_LINK)
{
if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_FIRE_RED
|| (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_LEAF_GREEN)
{
trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + TRAINER_BACK_PIC_RED;
}
else if ((gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_RUBY
|| (gLinkPlayers[GetMultiplayerId()].version & 0xFF) == VERSION_SAPPHIRE)
{
trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN;
}
else
{
trainerPicId = gLinkPlayers[GetMultiplayerId()].gender + TRAINER_BACK_PIC_BRENDAN;
}
}
else
{
trainerPicId = gSaveBlock2Ptr->playerGender + TRAINER_BACK_PIC_BRENDAN;
}
u32 trainerPicId = PlayerGetTrainerBackPicId();
DecompressTrainerBackPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));

View File

@ -138,12 +138,6 @@ static void PlayerPartnerBufferRunCommand(void)
}
}
static void CompleteOnBattlerSpriteCallbackDummy(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
PlayerPartnerBufferExecCompleted();
}
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -336,6 +330,7 @@ static void PlayerPartnerHandleSwitchInAnim(void)
// which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven) that use the back pic as well as animate it
static void PlayerPartnerHandleDrawTrainerPic(void)
{
bool32 isFrontPic;
s16 xPos, yPos;
u32 trainerPicId;
@ -358,34 +353,13 @@ static void PlayerPartnerHandleDrawTrainerPic(void)
yPos = (8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 80;
}
// Use back pic only if the partner is Steven
// Use back pic only if the partner is Steven or a custom partner.
if (gPartnerTrainerId == TRAINER_STEVEN_PARTNER || gPartnerTrainerId >= TRAINER_CUSTOM_PARTNER)
{
DecompressTrainerBackPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
isFrontPic = FALSE;
else
isFrontPic = TRUE;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
}
else // otherwise use front sprite
{
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].y2 = 48;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, isFrontPic, xPos, yPos, -1);
}
#undef sSpeedX

View File

@ -137,12 +137,6 @@ static void RecordedOpponentBufferRunCommand(void)
}
}
static void CompleteOnBattlerSpriteCallbackDummy(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
RecordedOpponentBufferExecCompleted();
}
static void CompleteOnBankSpriteCallbackDummy2(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -461,20 +455,9 @@ static void RecordedOpponentHandleDrawTrainerPic(void)
}
}
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate,
xPos,
(8 - gTrainerFrontPicCoords[trainerPicId].size) * 4 + 40,
GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, TRUE,
xPos, 40 + 4 * (8 - gTrainerFrontPicCoords[trainerPicId].size),
-1);
}
#undef sSpeedX

View File

@ -134,12 +134,6 @@ static void RecordedPlayerBufferRunCommand(void)
}
}
static void CompleteOnBattlerSpriteCallbackDummy(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
RecordedPlayerBufferExecCompleted();
}
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -403,10 +397,9 @@ static void RecordedPlayerHandleSwitchInAnim(void)
BtlController_HandleSwitchInAnim(gActiveBattler, TRUE, SwitchIn_TryShinyAnim);
}
#define sSpeedX data[0]
static void RecordedPlayerHandleDrawTrainerPic(void)
{
bool32 isFrontPic;
s16 xPos, yPos;
u32 trainerPicId;
@ -447,37 +440,13 @@ static void RecordedPlayerHandleDrawTrainerPic(void)
}
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
{
trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender);
DecompressTrainerFrontPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].y2 = 48;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattlerSpriteIds[gActiveBattler]].hFlip = 1;
}
isFrontPic = TRUE;
else
{
DecompressTrainerBackPic(trainerPicId, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate, xPos, yPos, GetBattlerSpriteSubpriority(gActiveBattler));
isFrontPic = FALSE;
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, isFrontPic, xPos, yPos, -1);
}
#undef sSpeedX
static void RecordedPlayerHandleTrainerSlideBack(void)
{
SetSpritePrimaryCoordsFromSecondaryCoords(&gSprites[gBattlerSpriteIds[gActiveBattler]]);

View File

@ -22,6 +22,7 @@
#include "window.h"
#include "constants/battle_anim.h"
#include "constants/songs.h"
#include "constants/trainers.h"
#include "constants/rgb.h"
static void SafariHandleDrawTrainerPic(void);
@ -185,12 +186,6 @@ static void HandleInputChooseAction(void)
}
}
static void Controller_WaitForTrainerPic(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
SafariBufferExecCompleted();
}
static void Controller_WaitForHealthbox(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -252,18 +247,11 @@ static void CompleteOnFinishedStatusAnimation(void)
static void SafariHandleDrawTrainerPic(void)
{
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(gSaveBlock2Ptr->playerGender, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(
&gMultiuseSpriteTemplate,
80,
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].size) * 4 + 80,
30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForTrainerPic;
u32 trainerPicId = gSaveBlock2Ptr->playerGender + TRAINER_BACK_PIC_BRENDAN;
BtlController_HandleDrawTrainerPic(gActiveBattler, trainerPicId, FALSE,
80, 80 + 4 * (8 - gTrainerBackPicCoords[trainerPicId].size),
30);
}
#undef sSpeedX

View File

@ -302,12 +302,6 @@ static void CompleteOnHealthbarDone(void)
}
}
static void CompleteOnBankSpriteCallbackDummy2(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
WallyBufferExecCompleted();
}
static void WallyBufferExecCompleted(void)
{
gBattlerControllerFuncs[gActiveBattler] = WallyBufferRunCommand;
@ -328,17 +322,9 @@ static void WallyBufferExecCompleted(void)
static void WallyHandleDrawTrainerPic(void)
{
DecompressTrainerBackPic(TRAINER_BACK_PIC_WALLY, gActiveBattler);
SetMultiuseSpriteTemplateToTrainerBack(TRAINER_BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler));
gBattlerSpriteIds[gActiveBattler] = CreateSprite(&gMultiuseSpriteTemplate,
80,
80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size),
30);
gSprites[gBattlerSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler;
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = -2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBattlerSpriteCallbackDummy;
BtlController_HandleDrawTrainerPic(gActiveBattler, TRAINER_BACK_PIC_WALLY, FALSE,
80, 80 + 4 * (8 - gTrainerBackPicCoords[TRAINER_BACK_PIC_WALLY].size),
30);
}
static void WallyHandleTrainerSlide(void)
@ -353,7 +339,7 @@ static void WallyHandleTrainerSlide(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].x2 = -96;
gSprites[gBattlerSpriteIds[gActiveBattler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
//gBattlerControllerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2;
}
#undef sSpeedX

View File

@ -2203,6 +2203,12 @@ static void Controller_WaitForStatusAnimation(void)
BattleControllerComplete(gActiveBattler);
}
static void Controller_WaitForTrainerPic(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
BattleControllerComplete(gActiveBattler);
}
void Controller_WaitForString(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
@ -2377,6 +2383,71 @@ void BtlController_HandleReturnMonToBall(void)
}
}
// In emerald it's possible to have a tag battle in the battle frontier facilities with AI
// which use the front sprite for both the player and the partner as opposed to any other battles (including the one with Steven)
// that use an animated back pic.
#define sSpeedX data[0]
void BtlController_HandleDrawTrainerPic(u32 battler, u32 trainerPicId, bool32 isFrontPic, s16 xPos, s16 yPos, s32 subpriority)
{
if (GetBattlerSide(battler) == B_SIDE_OPPONENT) // Always the front sprite for the opponent.
{
DecompressTrainerFrontPic(trainerPicId, battler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(battler));
if (subpriority == -1)
subpriority = GetBattlerSpriteSubpriority(battler);
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
xPos,
yPos,
subpriority);
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[battler]].x2 = -DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[battler]].sSpeedX = 2;
gSprites[gBattlerSpriteIds[battler]].oam.affineParam = trainerPicId;
}
else // Player's side
{
if (isFrontPic)
{
DecompressTrainerFrontPic(trainerPicId, battler);
SetMultiuseSpriteTemplateToTrainerFront(trainerPicId, GetBattlerPosition(battler));
if (subpriority == -1)
subpriority = GetBattlerSpriteSubpriority(battler);
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
xPos,
yPos,
subpriority);
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag);
gSprites[gBattlerSpriteIds[battler]].oam.affineMode = ST_OAM_AFFINE_OFF;
gSprites[gBattlerSpriteIds[battler]].hFlip = 1;
gSprites[gBattlerSpriteIds[battler]].y2 = 48;
}
else
{
DecompressTrainerBackPic(trainerPicId, battler);
SetMultiuseSpriteTemplateToTrainerBack(trainerPicId, GetBattlerPosition(battler));
if (subpriority == -1)
subpriority = GetBattlerSpriteSubpriority(battler);
gBattlerSpriteIds[battler] = CreateSprite(&gMultiuseSpriteTemplate,
xPos,
yPos,
subpriority);
gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
}
gSprites[gBattlerSpriteIds[battler]].x2 = DISPLAY_WIDTH;
gSprites[gBattlerSpriteIds[battler]].sSpeedX = -2;
}
gSprites[gBattlerSpriteIds[battler]].callback = SpriteCB_TrainerSlideIn;
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForTrainerPic;
}
#undef sSpeedX
#define sSpeedX data[1]
#define sSpeedY data[2]