Skip to content

Commit

Permalink
Ported TheXaman's latest changes to the Debug Menu (#2815)
Browse files Browse the repository at this point in the history
* Added option for generating incrementing pokemon in pc boxes

# Conflicts:
#	src/debug.c

* added submenu arrows, increased menu high to full screen

# Conflicts:
#	src/debug.c

* combined flags and vars into one submenu

# Conflicts:
#	src/debug.c

* added new window to flags/vars showing the current state and added submenu indicator

# Conflicts:
#	src/debug.c

* added alligned arrows for debug submenus

# Conflicts:
#	src/debug.c

* used {CLEAR_TO X} instead of manual spaces

# Conflicts:
#	src/debug.c

* renamed gDebugText to proper sDebugText

# Conflicts:
#	src/debug.c

* added Fill submenu, added fill function for PC items and all bag pockets  @LOuroboros

# Conflicts:
#	src/debug.c

* put cheat start into utility

# Conflicts:
#	src/debug.c

* put fill submenu into main menu

# Conflicts:
#	src/debug.c

* tiny fix

* renaming and reordering

# Conflicts:
#	src/debug.c

* Added reset pokedex flags for @AsparagusEduardo

* made flag toggle list dynamic

# Conflicts:
#	src/debug.c

* initial battle debug menu WIP

# Conflicts:
#	src/debug.c
#	src/wild_encounter.c

* fix visual bug

* added battle start

# Conflicts:
#	include/debug.h
#	src/battle_ai_script_commands.c

* Added faster way to add initial movesets to mon

* Added waiting music for the slow box filling

* Simplified the call to scripts

* Simplified debug scripts

* Disabled Battle Test for now

* Fixed personality on fast PC fill being always 0

* Removed BATTLE_ENGINE instances + added AI_FLAG_COUNT

* Added missing return TRUE

* Sets nickname

* Changed how GetSpeciesName to how it's used upstream

---------

Co-authored-by: TheXaman <48356183+TheXaman@users.noreply.github.com>
  • Loading branch information
AsparagusEduardo and TheXaman authored Jul 18, 2023
1 parent 43ad1a4 commit 6fec0e4
Show file tree
Hide file tree
Showing 12 changed files with 1,524 additions and 630 deletions.
28 changes: 14 additions & 14 deletions data/scripts/debug.inc
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
.if DEBUG_OVERWORLD_MENU == TRUE

Debug_ShowFieldMessageStringVar4::
special ShowFieldMessageStringVar4
Debug_MessageEnd:
waitmessage
waitbuttonpress
releaseall
end

Debug_ShowFieldMessageStringVar4::
special ShowFieldMessageStringVar4
goto Debug_MessageEnd

Debug_CheatStart::
lockall
setflag FLAG_SYS_POKEMON_GET
setflag FLAG_RESCUED_BIRCH
setflag FLAG_HIDE_ROUTE_101_BIRCH_ZIGZAGOON_BATTLE
Expand Down Expand Up @@ -44,31 +45,30 @@ Debug_CheatStart::
end

Debug_FlagsNotSetOverworldConfigMessage::
lockall
message Debug_FlagsNotSetOverworldConfigMessage_Text
waitmessage
waitbuttonpress
releaseall
end
goto Debug_MessageEnd

Debug_FlagsNotSetOverworldConfigMessage_Text:
.string "Feature unavailable!\n"
.string "Please define a usable flag in:\l"
.string "'include/config/overworld.h'!$"

Debug_FlagsNotSetBattleConfigMessage::
lockall
message Debug_FlagsNotSetBattleConfigMessage_Text
waitmessage
waitbuttonpress
releaseall
end
goto Debug_MessageEnd

Debug_FlagsNotSetBattleConfigMessage_Text:
.string "Feature unavailable!\n"
.string "Please define a usable flag in:\l"
.string "'include/config/battle.h'!$"

Debug_BoxFilledMessage::
message Debug_BoxFilledMessage_Text
goto Debug_MessageEnd

Debug_BoxFilledMessage_Text:
.string "Storage boxes filled!$"

Debug_Script_1::
end

Expand Down
3 changes: 3 additions & 0 deletions include/battle_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,7 @@ bool8 IsTrainerReadyForRematch(void);
void ShouldTryGetTrainerScript(void);
u16 CountBattledRematchTeams(u16 trainerId);

void DoStandardWildBattle_Debug(void);
void BattleSetup_StartTrainerBattle_Debug(void);

#endif // GUARD_BATTLE_SETUP_H
2 changes: 2 additions & 0 deletions include/constants/battle_ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@
#define AI_FLAG_ACE_POKEMON (1 << 16) // AI has an Ace Pokemon. The last Pokemon in the party will not be used until it's the last one remaining.
#define AI_FLAG_OMNISCIENT (1 << 17) // AI has full knowledge of player moves, abilities, hold items

#define AI_FLAG_COUNT 18

// 'other' ai logic flags
#define AI_FLAG_ROAMING (1 << 29)
#define AI_FLAG_SAFARI (1 << 30)
Expand Down
3 changes: 3 additions & 0 deletions include/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@

void Debug_ShowMainMenu(void);

extern EWRAM_DATA bool8 gIsDebugBattle;
extern EWRAM_DATA u32 gDebugAIFlags;

#endif // GUARD_DEBUG_H
2 changes: 2 additions & 0 deletions include/pokemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,8 @@ void SetMonMoveSlot(struct Pokemon *mon, u16 move, u8 slot);
void SetBattleMonMoveSlot(struct BattlePokemon *mon, u16 move, u8 slot);
void GiveMonInitialMoveset(struct Pokemon *mon);
void GiveBoxMonInitialMoveset(struct BoxPokemon *boxMon);
void GiveMonInitialMoveset_Fast(struct Pokemon *mon);
void GiveBoxMonInitialMoveset_Fast(struct BoxPokemon *boxMon);
u16 MonTryLearningNewMove(struct Pokemon *mon, bool8 firstMove);
void DeleteFirstMoveAndGiveMoveToMon(struct Pokemon *mon, u16 move);
void DeleteFirstMoveAndGiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move);
Expand Down
1 change: 1 addition & 0 deletions include/wild_encounter.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ u16 GetLocalWildMon(bool8 *isWaterMon);
u16 GetLocalWaterMon(void);
bool8 UpdateRepelCounter(void);
bool8 TryDoDoubleWildBattle(void);
bool8 StandardWildEncounter_Debug(void);

#endif // GUARD_WILD_ENCOUNTER_H
6 changes: 6 additions & 0 deletions src/battle_ai_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "battle_setup.h"
#include "battle_z_move.h"
#include "data.h"
#include "debug.h"
#include "event_data.h"
#include "item.h"
#include "pokemon.h"
Expand Down Expand Up @@ -152,6 +153,11 @@ static u32 GetWildAiFlags(void)

void BattleAI_SetupFlags(void)
{
#if DEBUG_OVERWORLD_MENU == TRUE
if (gIsDebugBattle)
AI_THINKING_STRUCT->aiFlags = gDebugAIFlags;
else
#endif
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
AI_THINKING_STRUCT->aiFlags = GetAiScriptsInRecordedBattle();
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
Expand Down
20 changes: 20 additions & 0 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "berry.h"
#include "bg.h"
#include "data.h"
#include "debug.h"
#include "decompress.h"
#include "dma3.h"
#include "event_data.h"
Expand Down Expand Up @@ -565,7 +566,13 @@ static void CB2_InitBattleInternal(void)
gBattle_BG3_X = 0;
gBattle_BG3_Y = 0;

#if DEBUG_OVERWORLD_MENU == FALSE

gBattleTerrain = BattleSetup_GetTerrainId();
#else
if (!gIsDebugBattle)
gBattleTerrain = BattleSetup_GetTerrainId();
#endif
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
gBattleTerrain = BATTLE_TERRAIN_BUILDING;

Expand All @@ -588,6 +595,7 @@ static void CB2_InitBattleInternal(void)
else
SetMainCallback2(CB2_HandleStartBattle);

#if DEBUG_OVERWORLD_MENU == FALSE
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED)))
{
CreateNPCTrainerParty(&gEnemyParty[0], gTrainerBattleOpponent_A, TRUE);
Expand All @@ -596,6 +604,18 @@ static void CB2_InitBattleInternal(void)
SetWildMonHeldItem();
CalculateEnemyPartyCount();
}
#else
if (!gIsDebugBattle)
{
if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_RECORDED)))
{
CreateNPCTrainerParty(&gEnemyParty[0], gTrainerBattleOpponent_A, TRUE);
if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)
CreateNPCTrainerParty(&gEnemyParty[PARTY_SIZE / 2], gTrainerBattleOpponent_B, FALSE);
SetWildMonHeldItem();
}
}
#endif

gMain.inBattle = TRUE;
gSaveBlock2Ptr->frontier.disableRecordBattle = FALSE;
Expand Down
67 changes: 67 additions & 0 deletions src/battle_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,41 @@ static void CreateBattleStartTask(u8 transition, u16 song)
PlayMapChosenOrBattleBGM(song);
}

static void Task_BattleStart_Debug(u8 taskId)
{
s16 *data = gTasks[taskId].data;

switch (tState)
{
case 0:
if (!FldEffPoison_IsActive()) // is poison not active?
{
BattleTransition_StartOnField(tTransition);
ClearMirageTowerPulseBlendEffect();
tState++; // go to case 1.
}
break;
case 1:
if (IsBattleTransitionDone() == TRUE)
{
CleanupOverworldWindowsAndTilemaps();
SetMainCallback2(CB2_InitBattle);
RestartWildEncounterImmunitySteps();
ClearPoisonStepCounter();
DestroyTask(taskId);
}
break;
}
}

static void CreateBattleStartTask_Debug(u8 transition, u16 song)
{
u8 taskId = CreateTask(Task_BattleStart_Debug, 1);

gTasks[taskId].tTransition = transition;
PlayMapChosenOrBattleBGM(song);
}

#undef tState
#undef tTransition

Expand Down Expand Up @@ -422,6 +457,25 @@ static void DoStandardWildBattle(bool32 isDouble)
TryUpdateGymLeaderRematchFromWild();
}

void DoStandardWildBattle_Debug(void)
{
LockPlayerFieldControls();
FreezeObjectEvents();
StopPlayerAvatar();
gMain.savedCallback = CB2_EndWildBattle;
gBattleTypeFlags = 0;
if (InBattlePyramid())
{
VarSet(VAR_TEMP_E, 0);
gBattleTypeFlags |= BATTLE_TYPE_PYRAMID;
}
CreateBattleStartTask_Debug(GetWildBattleTransition(), 0);
//IncrementGameStat(GAME_STAT_TOTAL_BATTLES);
//IncrementGameStat(GAME_STAT_WILD_BATTLES);
//IncrementDailyWildBattles();
//TryUpdateGymLeaderRematchFromWild();
}

void BattleSetup_StartRoamerBattle(void)
{
LockPlayerFieldControls();
Expand Down Expand Up @@ -1349,6 +1403,19 @@ void BattleSetup_StartTrainerBattle(void)
ScriptContext_Stop();
}

void BattleSetup_StartTrainerBattle_Debug(void)
{
sNoOfPossibleTrainerRetScripts = gNoOfApproachingTrainers;
gNoOfApproachingTrainers = 0;
sShouldCheckTrainerBScript = FALSE;
gWhichTrainerToFaceAfterBattle = 0;
gMain.savedCallback = CB2_EndTrainerBattle;

CreateBattleStartTask_Debug(GetWildBattleTransition(), 0);

ScriptContext_Stop();
}

static void CB2_EndTrainerBattle(void)
{
if (gTrainerBattleOpponent_A == TRAINER_SECRET_BASE)
Expand Down
Loading

0 comments on commit 6fec0e4

Please sign in to comment.