health bar update

This commit is contained in:
DizzyEggg 2023-08-07 10:29:02 +02:00
parent 546b0c7e97
commit b8ba6139cb
13 changed files with 54 additions and 271 deletions

View File

@ -257,6 +257,7 @@ void BtlController_Empty(void); // Empty command, does nothing, only completes t
void BtlController_TerminatorNop(void); // Dummy function at the end of the table.
void StartSendOutAnim(u32 battler, bool32 dontClearSubstituteBit);
void Controller_WaitForString(void);
void Controller_WaitForHealthBar(void);
// handlers
void BtlController_HandleGetMonData(void);
@ -274,6 +275,7 @@ void BtlController_HandleSuccessBallThrowAnim(u32 battler, u32 target, u32 animI
void BtlController_HandleBallThrowAnim(u32 battler, u32 target, u32 animId, bool32 allowCriticalCapture);
void BtlController_HandleMoveAnimation(u32 battler, bool32 updateTvData);
void BtlController_HandlePrintString(u32 battler, bool32 updateTvData, bool32 arenaPtsDeduct);
void BtlController_HandleHealthBarUpdate(u32 battler, bool32 updateHpText);
void DoStatusIconUpdate(u32 battler);
void BtlController_HandleStatusIconUpdate(void);
void BtlController_HandleStatusAnimation(void);

View File

@ -1,8 +1,6 @@
#ifndef GUARD_BATTLE_DOME_H
#define GUARD_BATTLE_DOME_H
extern u32 gPlayerPartyLostHP;
int GetDomeTrainerSelectedMons(u16 tournamentTrainerId);
int TrainerIdToDomeTournamentId(u16 trainerId);

View File

@ -301,18 +301,6 @@ static void TryShinyAnimAfterMonAnim(void)
}
}
static void CompleteOnHealthbarDone(void)
{
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1)
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, hpValue, gBattleMons[gActiveBattler].maxHP);
else
LinkOpponentBufferExecCompleted();
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -508,26 +496,7 @@ static void LinkOpponentHandlePrintString(void)
static void LinkOpponentHandleHealthBarUpdate(void)
{
s16 hpVal;
LoadBattleBarGfx(0);
hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8);
if (hpVal != INSTANT_HP_BAR_DROP)
{
u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
}
else
{
u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
BtlController_HandleHealthBarUpdate(gActiveBattler, FALSE);
}
static void LinkOpponentHandleIntroTrainerBallThrow(void)

View File

@ -131,23 +131,6 @@ static void WaitForMonAnimAfterLoad(void)
LinkPartnerBufferExecCompleted();
}
static void CompleteOnHealthbarDone(void)
{
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, hpValue, gBattleMons[gActiveBattler].maxHP);
}
else
{
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
LinkPartnerBufferExecCompleted();
}
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -272,26 +255,7 @@ static void LinkPartnerHandlePrintString(void)
static void LinkPartnerHandleHealthBarUpdate(void)
{
s16 hpVal;
LoadBattleBarGfx(0);
hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8);
if (hpVal != INSTANT_HP_BAR_DROP)
{
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
}
else
{
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
BtlController_HandleHealthBarUpdate(gActiveBattler, FALSE);
}
static void LinkPartnerHandleIntroTrainerBallThrow(void)

View File

@ -324,16 +324,6 @@ static void TryShinyAnimAfterMonAnim(void)
}
}
static void CompleteOnHealthbarDone(void)
{
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1)
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, hpValue, gBattleMons[gActiveBattler].maxHP);
else
OpponentBufferExecCompleted();
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -724,26 +714,7 @@ static u8 CountAIAliveNonEggMonsExcept(u8 slotToIgnore)
static void OpponentHandleHealthBarUpdate(void)
{
s16 hpVal;
LoadBattleBarGfx(0);
hpVal = (gBattleResources->bufferA[gActiveBattler][3] << 8) | gBattleResources->bufferA[gActiveBattler][2];
if (hpVal != INSTANT_HP_BAR_DROP)
{
u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
}
else
{
u32 maxHP = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
BtlController_HandleHealthBarUpdate(gActiveBattler, FALSE);
}
static void OpponentHandleIntroTrainerBallThrow(void)

View File

@ -317,13 +317,6 @@ static void HandleInputChooseAction(void)
#endif
}
static void UnusedEndBounceEffect(void)
{
EndBounceEffect(gActiveBattler, BOUNCE_HEALTHBOX);
EndBounceEffect(gActiveBattler, BOUNCE_MON);
gBattlerControllerFuncs[gActiveBattler] = HandleInputChooseTarget;
}
static void HandleInputChooseTarget(void)
{
s32 i;
@ -1282,23 +1275,6 @@ void Task_PlayerController_RestoreBgmAfterCry(u8 taskId)
}
}
static void CompleteOnHealthbarDone(void)
{
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, hpValue, gBattleMons[gActiveBattler].maxHP);
}
else
{
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlayerBufferExecCompleted();
}
}
#define tExpTask_monId data[0]
#define tExpTask_battler data[2]
#define tExpTask_gainedExp_1 data[3]
@ -1955,31 +1931,7 @@ static void PlayerHandleCmd23(void)
static void PlayerHandleHealthBarUpdate(void)
{
s16 hpVal;
LoadBattleBarGfx(0);
hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8);
// gPlayerPartyLostHP used by Battle Dome, but never read
if (hpVal > 0)
gPlayerPartyLostHP += hpVal;
if (hpVal != INSTANT_HP_BAR_DROP)
{
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
}
else
{
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, 0, maxHP);
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
BtlController_HandleHealthBarUpdate(gActiveBattler, TRUE);
}
void PlayerHandleExpUpdate(void)

View File

@ -207,23 +207,6 @@ static void WaitForMonAnimAfterLoad(void)
PlayerPartnerBufferExecCompleted();
}
static void CompleteOnHealthbarDone(void)
{
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, hpValue, gBattleMons[gActiveBattler].maxHP);
}
else
{
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
PlayerPartnerBufferExecCompleted();
}
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -430,26 +413,7 @@ static void PlayerPartnerHandleChoosePokemon(void)
static void PlayerPartnerHandleHealthBarUpdate(void)
{
s16 hpVal;
LoadBattleBarGfx(0);
hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8);
if (hpVal != INSTANT_HP_BAR_DROP)
{
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
}
else
{
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
BtlController_HandleHealthBarUpdate(gActiveBattler, FALSE);
}
static void PlayerPartnerHandleIntroTrainerBallThrow(void)

View File

@ -302,18 +302,6 @@ static void TryShinyAnimAfterMonAnim(void)
}
}
static void CompleteOnHealthbarDone(void)
{
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1)
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, hpValue, gBattleMons[gActiveBattler].maxHP);
else
RecordedOpponentBufferExecCompleted();
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -539,7 +527,7 @@ static void RecordedOpponentHandleHealthBarUpdate(void)
TestRunner_Battle_RecordHP(gActiveBattler, curHP, 0);
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForHealthBar;
}
static void RecordedOpponentHandleStatusIconUpdate(void)

View File

@ -281,23 +281,6 @@ static void WaitForMonAnimAfterLoad(void)
RecordedPlayerBufferExecCompleted();
}
static void CompleteOnHealthbarDone(void)
{
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, hpValue, gBattleMons[gActiveBattler].maxHP);
}
else
{
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
RecordedPlayerBufferExecCompleted();
}
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -545,7 +528,7 @@ static void RecordedPlayerHandleHealthBarUpdate(void)
TestRunner_Battle_RecordHP(gActiveBattler, curHP, 0);
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForHealthBar;
}
static void RecordedPlayerHandleStatusIconUpdate(void)

View File

@ -237,14 +237,6 @@ static void SafariBufferExecCompleted(void)
}
}
static void CompleteOnFinishedStatusAnimation(void)
{
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive)
SafariBufferExecCompleted();
}
#define sSpeedX data[0]
static void SafariHandleDrawTrainerPic(void)
{
u32 trainerPicId = gSaveBlock2Ptr->playerGender + TRAINER_BACK_PIC_BRENDAN;
@ -254,8 +246,6 @@ static void SafariHandleDrawTrainerPic(void)
30);
}
#undef sSpeedX
static void SafariHandleSuccessBallThrowAnim(void)
{
BtlController_HandleSuccessBallThrowAnim(gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW_WITH_TRAINER, FALSE);

View File

@ -282,23 +282,6 @@ static void Intro_WaitForShinyAnimAndHealthbox(void)
}
}
static void CompleteOnHealthbarDone(void)
{
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, hpValue, gBattleMons[gActiveBattler].maxHP);
}
else
{
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
WallyBufferExecCompleted();
}
}
static void WallyBufferExecCompleted(void)
{
gBattlerControllerFuncs[gActiveBattler] = WallyBufferRunCommand;
@ -421,27 +404,7 @@ static void WallyHandleChooseItem(void)
static void WallyHandleHealthBarUpdate(void)
{
s16 hpVal;
LoadBattleBarGfx(0);
hpVal = gBattleResources->bufferA[gActiveBattler][2] | (gBattleResources->bufferA[gActiveBattler][3] << 8);
if (hpVal != INSTANT_HP_BAR_DROP)
{
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, curHP, hpVal);
}
else
{
u32 maxHP = GetMonData(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_MAX_HP);
SetBattleBarStruct(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], maxHP, 0, hpVal);
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, 0, maxHP);
}
gBattlerControllerFuncs[gActiveBattler] = CompleteOnHealthbarDone;
BtlController_HandleHealthBarUpdate(gActiveBattler, TRUE);
}
// For some reason Wally's SE don't take side into account and pan is always the same. Possibly a bug

View File

@ -2247,6 +2247,23 @@ static void Controller_HandleTrainerSlideBack(void)
}
}
void Controller_WaitForHealthBar(void)
{
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], HP_CURRENT, hpValue, gBattleMons[gActiveBattler].maxHP);
}
else
{
if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER)
HandleLowHpMusicChange(&gPlayerParty[gBattlerPartyIndexes[gActiveBattler]], gActiveBattler);
BattleControllerComplete(gActiveBattler);
}
}
static void Controller_WaitForBallThrow(void)
{
if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive)
@ -2658,6 +2675,33 @@ void BtlController_HandlePrintString(u32 battler, bool32 updateTvData, bool32 ar
BattleArena_DeductSkillPoints(battler, *stringId);
}
void BtlController_HandleHealthBarUpdate(u32 battler, bool32 updateHpText)
{
s16 hpVal;
struct Pokemon *party = GetBattlerParty(battler);
LoadBattleBarGfx(0);
hpVal = gBattleResources->bufferA[battler][2] | (gBattleResources->bufferA[battler][3] << 8);
if (hpVal != INSTANT_HP_BAR_DROP)
{
u32 maxHP = GetMonData(&party[gBattlerPartyIndexes[battler]], MON_DATA_MAX_HP);
u32 curHP = GetMonData(&party[gBattlerPartyIndexes[battler]], MON_DATA_HP);
SetBattleBarStruct(battler, gHealthboxSpriteIds[battler], maxHP, curHP, hpVal);
}
else
{
u32 maxHP = GetMonData(&party[gBattlerPartyIndexes[battler]], MON_DATA_MAX_HP);
SetBattleBarStruct(battler, gHealthboxSpriteIds[battler], maxHP, 0, hpVal);
if (updateHpText)
UpdateHpTextInHealthbox(gHealthboxSpriteIds[battler], HP_CURRENT, 0, maxHP);
}
gBattlerControllerFuncs[battler] = Controller_WaitForHealthBar;
}
void DoStatusIconUpdate(u32 battler)
{
struct Pokemon *party = GetBattlerParty(battler);

View File

@ -157,8 +157,6 @@ static void BufferLastDomeWinnerName(void);
static void InitRandomTourneyTreeResults(void);
static void InitDomeTrainers(void);
EWRAM_DATA u32 gPlayerPartyLostHP = 0; // never read
static EWRAM_DATA u32 sPlayerPartyMaxHP = 0; // never read
static EWRAM_DATA struct TourneyTreeInfoCard *sInfoCard = {0};
static EWRAM_DATA u8 *sTilemapBuffer = NULL;
@ -2544,9 +2542,6 @@ static void BufferDomeOpponentName(void)
static void InitDomeOpponentParty(void)
{
gPlayerPartyLostHP = 0;
sPlayerPartyMaxHP = GetMonData(&gPlayerParty[0], MON_DATA_MAX_HP, NULL);
sPlayerPartyMaxHP += GetMonData(&gPlayerParty[1], MON_DATA_MAX_HP, NULL);
CalculatePlayerPartyCount();
CreateDomeOpponentMons(TrainerIdToTournamentId(gTrainerBattleOpponent_A));
}