controller string

This commit is contained in:
DizzyEggg 2023-08-05 22:41:13 +02:00
parent f9e131b6ac
commit 18db0cb3b7
11 changed files with 43 additions and 137 deletions

View File

@ -255,6 +255,7 @@ void BtlController_EmitDebugMenu(u8 bufferId);
void BtlController_Empty(void); // Empty command, does nothing, only completes the execution.
void BtlController_TerminatorNop(void); // Dummy function at the end of the table.
void StartSendOutAnim(u32 battler, bool32 dontClearSubstituteBit);
void Controller_WaitForString(void);
// handlers
void BtlController_HandleGetMonData(void);
@ -267,6 +268,7 @@ void BtlController_HandleReturnMonToBall(void);
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);
void BtlController_HandlePrintString(u32 battler, bool32 updateTvData, bool32 arenaPtsDeduct);
void DoStatusIconUpdate(u32 battler);
void BtlController_HandleStatusIconUpdate(void);
void BtlController_HandleStatusAnimation(void);

View File

@ -348,12 +348,6 @@ static void CompleteOnHealthbarDone(void)
LinkOpponentBufferExecCompleted();
}
static void CompleteOnInactiveTextPrinter(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
LinkOpponentBufferExecCompleted();
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -640,15 +634,7 @@ static void LinkOpponentDoMoveAnimation(void)
static void LinkOpponentHandlePrintString(void)
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[gActiveBattler][2]);
BufferStringBattle(*stringId);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
BattleTv_SetDataBasedOnString(*stringId);
BtlController_HandlePrintString(gActiveBattler, TRUE, FALSE);
}
static void LinkOpponentHandleHealthBarUpdate(void)

View File

@ -241,12 +241,6 @@ static void CompleteOnHealthbarDone(void)
}
}
static void CompleteOnInactiveTextPrinter(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
LinkPartnerBufferExecCompleted();
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -461,15 +455,7 @@ static void LinkPartnerDoMoveAnimation(void)
static void LinkPartnerHandlePrintString(void)
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[gActiveBattler][2]);
BufferStringBattle(*stringId);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
BattleTv_SetDataBasedOnString(*stringId);
BtlController_HandlePrintString(gActiveBattler, TRUE, FALSE);
}
static void LinkPartnerHandleHealthBarUpdate(void)

View File

@ -375,12 +375,6 @@ static void CompleteOnHealthbarDone(void)
OpponentBufferExecCompleted();
}
static void CompleteOnInactiveTextPrinter(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
OpponentBufferExecCompleted();
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -704,15 +698,7 @@ static void OpponentDoMoveAnimation(void)
static void OpponentHandlePrintString(void)
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[gActiveBattler][2]);
BufferStringBattle(*stringId);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
BattleArena_DeductSkillPoints(gActiveBattler, *stringId);
BtlController_HandlePrintString(gActiveBattler, FALSE, TRUE);
}
static void OpponentHandleChooseAction(void)

View File

@ -87,7 +87,7 @@ static void WaitForMonSelection(void);
static void CompleteWhenChoseItem(void);
static void Task_LaunchLvlUpAnim(u8);
static void Task_PrepareToGiveExpWithExpBar(u8);
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8);
static void Task_SetControllerToWaitForString(u8);
static void Task_GiveExpWithExpBar(u8);
static void Task_UpdateLvlInHealthbox(u8);
static void PrintLinkStandbyMsg(void);
@ -1329,12 +1329,6 @@ static void CompleteOnHealthbarDone(void)
}
}
static void CompleteOnInactiveTextPrinter(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
PlayerBufferExecCompleted();
}
#define tExpTask_monId data[0]
#define tExpTask_battler data[2]
#define tExpTask_gainedExp_1 data[3]
@ -1375,13 +1369,13 @@ static void Task_GiveExpToMon(u8 taskId)
&& (monId == gBattlerPartyIndexes[battlerId] || monId == gBattlerPartyIndexes[BATTLE_PARTNER(battlerId)]))
gTasks[taskId].func = Task_LaunchLvlUpAnim;
else
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
gTasks[taskId].func = Task_SetControllerToWaitForString;
}
else
{
currExp += gainedExp;
SetMonData(mon, MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[battlerId] = Controller_WaitForString;
DestroyTask(taskId);
}
}
@ -1453,7 +1447,7 @@ static void Task_GiveExpWithExpBar(u8 taskId)
{
currExp += gainedExp;
SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp);
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[battlerId] = Controller_WaitForString;
DestroyTask(taskId);
}
}
@ -1485,23 +1479,17 @@ static void Task_UpdateLvlInHealthbox(u8 taskId)
else
UpdateHealthboxAttribute(gHealthboxSpriteIds[battlerId], &gPlayerParty[monIndex], HEALTHBOX_ALL);
gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter;
gTasks[taskId].func = Task_SetControllerToWaitForString;
}
}
static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId)
static void Task_SetControllerToWaitForString(u8 taskId)
{
u8 battlerId = gTasks[taskId].tExpTask_battler;
gBattlerControllerFuncs[battlerId] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[battlerId] = Controller_WaitForString;
DestroyTask(taskId);
}
static void CompleteOnInactiveTextPrinter2(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
PlayerBufferExecCompleted();
}
static void OpenPartyMenuToChooseMon(void)
{
if (!gPaletteFade.active)
@ -1953,16 +1941,7 @@ static void PlayerDoMoveAnimation(void)
static void PlayerHandlePrintString(void)
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[gActiveBattler][2]);
BufferStringBattle(*stringId);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2;
BattleTv_SetDataBasedOnString(*stringId);
BattleArena_DeductSkillPoints(gActiveBattler, *stringId);
BtlController_HandlePrintString(gActiveBattler, TRUE, TRUE);
}
static void PlayerHandlePrintSelectionString(void)

View File

@ -88,7 +88,7 @@ static void (*const sPlayerPartnerBufferCommands[CONTROLLER_CMDS_COUNT])(void) =
[CONTROLLER_CHOOSEPOKEMON] = PlayerPartnerHandleChoosePokemon,
[CONTROLLER_23] = BtlController_Empty,
[CONTROLLER_HEALTHBARUPDATE] = PlayerPartnerHandleHealthBarUpdate,
[CONTROLLER_EXPUPDATE] = PlayerHandleExpUpdate,
[CONTROLLER_EXPUPDATE] = PlayerHandleExpUpdate, // Partner's player gets experience the same way as the player.
[CONTROLLER_STATUSICONUPDATE] = BtlController_HandleStatusIconUpdate,
[CONTROLLER_STATUSANIMATION] = BtlController_HandleStatusAnimation,
[CONTROLLER_STATUSXOR] = BtlController_Empty,
@ -250,18 +250,6 @@ static void CompleteOnHealthbarDone(void)
}
}
static void CompleteOnInactiveTextPrinter(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
PlayerPartnerBufferExecCompleted();
}
static void CompleteOnInactiveTextPrinter2(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
PlayerPartnerBufferExecCompleted();
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -488,14 +476,7 @@ static void PlayerPartnerDoMoveAnimation(void)
static void PlayerPartnerHandlePrintString(void)
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[gActiveBattler][2]);
BufferStringBattle(*stringId);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2;
BtlController_HandlePrintString(gActiveBattler, FALSE, FALSE);
}
static void PlayerPartnerHandleChooseAction(void)

View File

@ -342,12 +342,6 @@ static void CompleteOnHealthbarDone(void)
RecordedOpponentBufferExecCompleted();
}
static void CompleteOnInactiveTextPrinter(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
RecordedOpponentBufferExecCompleted();
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -591,7 +585,7 @@ static void RecordedOpponentHandlePrintString(void)
}
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForString;
}
static void RecordedOpponentHandleChooseAction(void)

View File

@ -324,12 +324,6 @@ static void CompleteOnHealthbarDone(void)
}
}
static void CompleteOnInactiveTextPrinter(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
RecordedPlayerBufferExecCompleted();
}
static void SwitchIn_ShowSubstitute(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -588,7 +582,7 @@ static void RecordedPlayerHandlePrintString(void)
}
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
gBattlerControllerFuncs[gActiveBattler] = Controller_WaitForString;
}
static void ChooseActionInBattlePalace(void)

View File

@ -192,12 +192,6 @@ static void CompleteOnBattlerSpriteCallbackDummy(void)
SafariBufferExecCompleted();
}
static void CompleteOnInactiveTextPrinter(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
SafariBufferExecCompleted();
}
static void CompleteOnHealthboxSpriteCallbackDummy(void)
{
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
@ -287,14 +281,7 @@ static void SafariHandleBallThrowAnim(void)
static void SafariHandlePrintString(void)
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[gActiveBattler][2]);
BufferStringBattle(*stringId);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
BtlController_HandlePrintString(gActiveBattler, FALSE, FALSE);
}
static void SafariHandlePrintSelectionString(void)

View File

@ -212,12 +212,6 @@ static void CompleteOnBattlerSpriteCallbackDummy(void)
WallyBufferExecCompleted();
}
static void CompleteOnInactiveTextPrinter(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
WallyBufferExecCompleted();
}
static void OpenBagAfterPaletteFade(void)
{
if (!gPaletteFade.active)
@ -443,14 +437,7 @@ static void WallyDoMoveAnimation(void)
static void WallyHandlePrintString(void)
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[gActiveBattler][2]);
BufferStringBattle(*stringId);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
gBattlerControllerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter;
BtlController_HandlePrintString(gActiveBattler, FALSE, FALSE);
}
static void WallyHandlePrintSelectionString(void)

View File

@ -1,6 +1,7 @@
#include "global.h"
#include "battle.h"
#include "battle_ai_main.h"
#include "battle_arena.h"
#include "battle_anim.h"
#include "battle_controllers.h"
#include "battle_gfx_sfx_util.h"
@ -17,6 +18,7 @@
#include "sound.h"
#include "task.h"
#include "util.h"
#include "text.h"
#include "constants/abilities.h"
#include "constants/songs.h"
@ -2197,6 +2199,12 @@ static void Controller_WaitForStatusAnimation(void)
BattleControllerComplete(gActiveBattler);
}
void Controller_WaitForString(void)
{
if (!IsTextPrinterActive(B_WIN_MSG))
BattleControllerComplete(gActiveBattler);
}
static void Controller_HitAnimation(void)
{
u32 spriteId = gBattlerSpriteIds[gActiveBattler];
@ -2419,6 +2427,22 @@ void BtlController_HandleBallThrowAnim(u32 battler, u32 target, u32 animId, bool
HandleBallThrow(battler, target, animId, allowCriticalCapture);
}
void BtlController_HandlePrintString(u32 battler, bool32 updateTvData, bool32 arenaPtsDeduct)
{
u16 *stringId;
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0;
stringId = (u16 *)(&gBattleResources->bufferA[battler][2]);
BufferStringBattle(*stringId);
BattlePutTextOnWindow(gDisplayedStringBattle, B_WIN_MSG);
gBattlerControllerFuncs[battler] = Controller_WaitForString;
if (updateTvData)
BattleTv_SetDataBasedOnString(*stringId);
if (arenaPtsDeduct)
BattleArena_DeductSkillPoints(battler, *stringId);
}
void DoStatusIconUpdate(u32 battler)
{
struct Pokemon *party = GetBattlerParty(battler);