Document battle_controller_opponent.c

This commit is contained in:
GriffinR 2021-01-22 21:35:16 -05:00
parent d1878f933b
commit c106f7f130
3 changed files with 60 additions and 59 deletions

View File

@ -700,8 +700,8 @@ extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
extern u8 gPlayerDpadHoldFrames;
extern struct BattleSpriteData *gBattleSpritesDataPtr;
extern struct MonSpritesGfx *gMonSpritesGfxPtr;
extern struct BattleHealthboxInfo *gUnknown_020244D8;
extern struct BattleHealthboxInfo *gUnknown_020244DC;
extern struct BattleHealthboxInfo *gBattleControllerOpponentHealthboxData;
extern struct BattleHealthboxInfo *gBattleControllerOpponentFlankHealthboxData;
extern u16 gBattleMovePower;
extern u16 gMoveToLearn;
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];

View File

@ -97,14 +97,14 @@ static void OpponentCmdEnd(void);
static void OpponentBufferRunCommand(void);
static void OpponentBufferExecCompleted(void);
static void sub_805FC80(void);
static void SwitchIn_HandleSoundAndEnd(void);
static u32 GetOpponentMonData(u8 monId, u8 *dst);
static void SetOpponentMonData(u8 monId);
static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit);
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit);
static void DoSwitchOutAnimation(void);
static void OpponentDoMoveAnimation(void);
static void sub_806280C(struct Sprite *sprite);
static void sub_8062828(u8 taskId);
static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite);
static void Task_StartSendOutAnim(u8 taskId);
static void EndDrawPartyStatusSummary(void);
static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
@ -171,7 +171,7 @@ static void (*const sOpponentBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
// unknown unused data
static const u8 sUnused[] = {0xB0, 0xB0, 0xC8, 0x98, 0x28, 0x28, 0x28, 0x20};
static void nullsub_26(void)
static void OpponentDummy(void)
{
}
@ -203,7 +203,7 @@ static void CompleteOnBankSpriteCallbackDummy2(void)
OpponentBufferExecCompleted();
}
static void sub_805F240(void)
static void FreeTrainerSpriteAfterSlide(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
@ -214,7 +214,7 @@ static void sub_805F240(void)
}
}
static void sub_805F2A8(void)
static void Intro_DelayAndEnd(void)
{
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay == (u8)-1)
{
@ -223,31 +223,31 @@ static void sub_805F2A8(void)
}
}
static void sub_805F2F0(void)
static void Intro_WaitForShinyAnimAndHealthbox(void)
{
bool8 var = FALSE;
bool8 var2;
bool8 healthboxAnimDone = FALSE;
bool8 twoMons;
if (!IsDoubleBattle() || ((IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)) || (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)))
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
var = TRUE;
var2 = FALSE;
healthboxAnimDone = TRUE;
twoMons = FALSE;
}
else
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
var = TRUE;
var2 = TRUE;
healthboxAnimDone = TRUE;
twoMons = TRUE;
}
gUnknown_020244D8 = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler];
gUnknown_020244DC = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK];
gBattleControllerOpponentHealthboxData = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler];
gBattleControllerOpponentFlankHealthboxData = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK];
if (var)
if (healthboxAnimDone)
{
if (var2 == TRUE)
if (twoMons == TRUE)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].finishedShinyMonAnim)
@ -282,14 +282,14 @@ static void sub_805F2F0(void)
return;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].introEndDelay = 3;
gBattlerControllerFuncs[gActiveBattler] = sub_805F2A8;
gBattlerControllerFuncs[gActiveBattler] = Intro_DelayAndEnd;
}
}
static void sub_805F560(void)
static void Intro_TryShinyAnimShowHealthbox(void)
{
bool32 sp = FALSE;
bool32 r10 = FALSE;
bool32 bgmRestored = FALSE;
bool32 battlerAnimsDone = FALSE;
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive
@ -337,7 +337,7 @@ static void sub_805F560(void)
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
}
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = TRUE;
sp = TRUE;
bgmRestored = TRUE;
}
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
@ -345,7 +345,7 @@ static void sub_805F560(void)
if (gSprites[gBattleControllerData[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
r10 = TRUE;
battlerAnimsDone = TRUE;
}
}
else
@ -355,11 +355,11 @@ static void sub_805F560(void)
&& gSprites[gBattleControllerData[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy)
{
r10 = TRUE;
battlerAnimsDone = TRUE;
}
}
if (sp && r10)
if (bgmRestored && battlerAnimsDone)
{
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
@ -373,11 +373,11 @@ static void sub_805F560(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].bgmRestored = FALSE;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].healthboxSlideInStarted = FALSE;
gBattlerControllerFuncs[gActiveBattler] = sub_805F2F0;
gBattlerControllerFuncs[gActiveBattler] = Intro_WaitForShinyAnimAndHealthbox;
}
}
static void sub_805F994(void)
static void TryShinyAnimAfterMonAnim(void)
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].pos2.x == 0
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
@ -407,7 +407,7 @@ static void CompleteOnHealthbarDone(void)
OpponentBufferExecCompleted();
}
static void sub_805FAC4(void)
static void HideHealthboxAfterMonFaint(void)
{
if (!gSprites[gBattlerSpriteIds[gActiveBattler]].inUse)
{
@ -416,7 +416,7 @@ static void sub_805FAC4(void)
}
}
static void sub_805FB08(void)
static void FreeMonSpriteAfterSwitchOutAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
{
@ -453,21 +453,22 @@ static void DoHitAnimBlinkSpriteEffect(void)
}
}
static void sub_805FC10(void)
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{
if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_805FC80;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_HandleSoundAndEnd;
}
}
static void sub_805FC80(void)
static void SwitchIn_HandleSoundAndEnd(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs())
{
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy || gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
if (gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
|| gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2)
{
m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100);
OpponentBufferExecCompleted();
@ -475,7 +476,7 @@ static void sub_805FC80(void)
}
}
static void sub_805FD00(void)
static void SwitchIn_ShowHealthbox(void)
{
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].finishedShinyMonAnim
&& gSprites[gBattlerSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -489,11 +490,11 @@ static void sub_805FD00(void)
StartHealthboxSlideIn(gActiveBattler);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
CopyBattleSpriteInvisibility(gActiveBattler);
gBattlerControllerFuncs[gActiveBattler] = sub_805FC10;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowSubstitute;
}
}
static void sub_805FDF0(void)
static void SwitchIn_TryShinyAnim(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].triedShinyMonAnim
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive)
@ -504,7 +505,7 @@ static void sub_805FDF0(void)
{
DestroySprite(&gSprites[gBattleControllerData[gActiveBattler]]);
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_805FD00;
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_ShowHealthbox;
}
}
@ -1150,18 +1151,18 @@ static void OpponentHandleLoadMonSprite(void)
SetBattlerShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES));
gBattlerControllerFuncs[gActiveBattler] = sub_805F994;
gBattlerControllerFuncs[gActiveBattler] = TryShinyAnimAfterMonAnim;
}
static void OpponentHandleSwitchInAnim(void)
{
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6;
gBattlerPartyIndexes[gActiveBattler] = gBattleBufferA[gActiveBattler][1];
sub_80613DC(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = sub_805FDF0;
StartSendOutAnim(gActiveBattler, gBattleBufferA[gActiveBattler][2]);
gBattlerControllerFuncs[gActiveBattler] = SwitchIn_TryShinyAnim;
}
static void sub_80613DC(u8 battlerId, bool8 dontClearSubstituteBit)
static void StartSendOutAnim(u8 battlerId, bool8 dontClearSubstituteBit)
{
u16 species;
@ -1225,7 +1226,7 @@ static void DoSwitchOutAnimation(void)
{
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON);
gBattlerControllerFuncs[gActiveBattler] = sub_805FB08;
gBattlerControllerFuncs[gActiveBattler] = FreeMonSpriteAfterSwitchOutAnim;
}
break;
}
@ -1398,7 +1399,7 @@ static void OpponentHandleTrainerSlideBack(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCallbackDummy);
gBattlerControllerFuncs[gActiveBattler] = sub_805F240;
gBattlerControllerFuncs[gActiveBattler] = FreeTrainerSpriteAfterSlide;
}
static void OpponentHandleFaintAnimation(void)
@ -1416,7 +1417,7 @@ static void OpponentHandleFaintAnimation(void)
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0;
PlaySE12WithPanning(SE_FAINT, SOUND_PAN_TARGET);
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = SpriteCB_FaintOpponentMon;
gBattlerControllerFuncs[gActiveBattler] = sub_805FAC4;
gBattlerControllerFuncs[gActiveBattler] = HideHealthboxAfterMonFaint;
}
}
}
@ -1871,26 +1872,26 @@ static void OpponentHandleIntroTrainerBallThrow(void)
gSprites[gBattlerSpriteIds[gActiveBattler]].data[4] = gSprites[gBattlerSpriteIds[gActiveBattler]].pos1.y;
gSprites[gBattlerSpriteIds[gActiveBattler]].callback = StartAnimLinearTranslation;
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], sub_806280C);
StoreSpriteCallbackInData6(&gSprites[gBattlerSpriteIds[gActiveBattler]], SpriteCB_FreeOpponentSprite);
taskId = CreateTask(sub_8062828, 5);
taskId = CreateTask(Task_StartSendOutAnim, 5);
gTasks[taskId].data[0] = gActiveBattler;
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].partyStatusSummaryShown)
gTasks[gBattlerStatusSummaryTaskId[gActiveBattler]].func = Task_HidePartyStatusSummary;
gBattleSpritesDataPtr->animationData->introAnimActive = TRUE;
gBattlerControllerFuncs[gActiveBattler] = nullsub_26;
gBattlerControllerFuncs[gActiveBattler] = OpponentDummy;
}
static void sub_806280C(struct Sprite *sprite)
static void SpriteCB_FreeOpponentSprite(struct Sprite *sprite)
{
FreeTrainerFrontPicPalette(sprite->oam.affineParam);
FreeSpriteOamMatrix(sprite);
DestroySprite(sprite);
}
static void sub_8062828(u8 taskId)
static void Task_StartSendOutAnim(u8 taskId)
{
u8 savedActiveBank = gActiveBattler;
@ -1898,23 +1899,23 @@ static void sub_8062828(u8 taskId)
if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI))
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
}
else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
}
else
{
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_80613DC(gActiveBattler, FALSE);
StartSendOutAnim(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK;
}
gBattlerControllerFuncs[gActiveBattler] = sub_805F560;
gBattlerControllerFuncs[gActiveBattler] = Intro_TryShinyAnimShowHealthbox;
gActiveBattler = savedActiveBank;
DestroyTask(taskId);
}

View File

@ -233,8 +233,8 @@ EWRAM_DATA u32 gTransformedPersonalities[MAX_BATTLERS_COUNT] = {0};
EWRAM_DATA u8 gPlayerDpadHoldFrames = 0;
EWRAM_DATA struct BattleSpriteData *gBattleSpritesDataPtr = NULL;
EWRAM_DATA struct MonSpritesGfx *gMonSpritesGfxPtr = NULL;
EWRAM_DATA struct BattleHealthboxInfo *gUnknown_020244D8 = NULL;
EWRAM_DATA struct BattleHealthboxInfo *gUnknown_020244DC = NULL;
EWRAM_DATA struct BattleHealthboxInfo *gBattleControllerOpponentHealthboxData = NULL; // Never read
EWRAM_DATA struct BattleHealthboxInfo *gBattleControllerOpponentFlankHealthboxData = NULL; // Never read
EWRAM_DATA u16 gBattleMovePower = 0;
EWRAM_DATA u16 gMoveToLearn = 0;
EWRAM_DATA u8 gBattleMonForms[MAX_BATTLERS_COUNT] = {0};