Skip to content

Commit

Permalink
Upgrading the debug menu's 'Poison Party' (#4235)
Browse files Browse the repository at this point in the history
* Upgrading the debug menu's 'Poison Party'

* Optimized the 'No Pokémon' check in Debug_EventScript_InflictStatus1

* Killed a pointless function call in Script_SetStatus1

* Added Frostbite support to ¡inflict status1'
  • Loading branch information
LOuroboros authored Mar 1, 2024
1 parent e3d9a19 commit 64b7cfe
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 38 deletions.
8 changes: 8 additions & 0 deletions asm/macros/event.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2164,3 +2164,11 @@
setvar VAR_RESULT, TRUE
2:
.endm

@ Inflicts \status1 to the Pokémon in \slot.
@ If \slot is greater or equal than PARTY_SIZE, the status is inflicted on each of the Player's Pokémon.
.macro setstatus1 status1:req, slot:req
callnative Script_SetStatus1
.2byte \status1
.2byte \slot
.endm
162 changes: 156 additions & 6 deletions data/scripts/debug.inc
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ Debug_BoxFilledMessage_Text:
Debug_EventScript_CheckEV::
lockall
getpartysize
goto_if_eq VAR_RESULT, 0, Debug_HatchAnEgg_NoPokemon
goto_if_eq VAR_RESULT, 0, Debug_NoPokemon
special ChoosePartyMon
waitstate
goto_if_ge VAR_0x8004, PARTY_SIZE, Debug_EventScript_CheckEV_End
Expand All @@ -119,7 +119,7 @@ Debug_EventScript_Text_DefensiveEV:
Debug_EventScript_CheckIV::
lockall
getpartysize
goto_if_eq VAR_RESULT, 0, Debug_HatchAnEgg_NoPokemon
goto_if_eq VAR_RESULT, 0, Debug_NoPokemon
special ChoosePartyMon
waitstate
goto_if_ge VAR_0x8004, PARTY_SIZE, Debug_EventScript_CheckIV_End
Expand Down Expand Up @@ -202,7 +202,7 @@ Debug_ROMSize::
Debug_HatchAnEgg::
lockall
getpartysize
goto_if_eq VAR_RESULT, 0, Debug_HatchAnEgg_NoPokemon
goto_if_eq VAR_RESULT, 0, Debug_NoPokemon
special ChoosePartyMon
waitstate
goto_if_ge VAR_0x8004, PARTY_SIZE, Debug_HatchAnEgg_End
Expand All @@ -214,8 +214,8 @@ Debug_HatchAnEgg_End::
releaseall
end

Debug_HatchAnEgg_NoPokemon::
msgbox DebugScript_HatchAnEgg_Text_EmptyParty, MSGBOX_DEFAULT
Debug_NoPokemon::
msgbox DebugScript_Text_EmptyParty, MSGBOX_DEFAULT
releaseall
end

Expand All @@ -224,7 +224,7 @@ DebugScript_HatchAnEgg_CantForceHatch::
releaseall
end

DebugScript_HatchAnEgg_Text_EmptyParty::
DebugScript_Text_EmptyParty::
.string "You have no Pokémon nor Eggs.$"

DebugScript_HatchAnEgg_Text_NotAnEgg::
Expand Down Expand Up @@ -295,3 +295,153 @@ Debug_FlagsAndVarNotSetBattleConfigMessage_Text:
.string "Feature unavailable! Please define a\n"
.string "usable flag and a usable var in:\l"
.string "'include/config/battle.h'!$"

Debug_EventScript_InflictStatus1::
lockall
getpartysize
goto_if_eq VAR_RESULT, 0, Debug_NoPokemon
dynmultipush Debug_EventScript_InflictStatus1_Text_Single, 0
dynmultipush Debug_EventScript_InflictStatus1_Text_PartyWide, 1
dynmultipush Debug_EventScript_InflictStatus1_Text_Close, 2
dynmultistack 0, 0, FALSE, 3 FALSE, 0, NULL
switch VAR_RESULT
case 0, Debug_EventScript_InflictStatus1_Single
case 1, Debug_EventScript_InflictStatus1_Party
case 2, Debug_EventScript_InflictStatus1_Close
Debug_EventScript_InflictStatus1_Close:
releaseall
end

Debug_EventScript_InflictStatus1_Single:
special ChoosePartyMon
waitstate
goto_if_ge VAR_0x8004, PARTY_SIZE, Debug_EventScript_InflictStatus1_Close
specialvar VAR_RESULT, ScriptGetPartyMonSpecies
goto_if_eq VAR_RESULT, SPECIES_EGG, Debug_EventScript_InflictStatus1_Close
dynmultipush Debug_EventScript_InflictStatus1_Text_Poison, 0
dynmultipush Debug_EventScript_InflictStatus1_Text_Paralysis, 1
dynmultipush Debug_EventScript_InflictStatus1_Text_Sleep, 2
dynmultipush Debug_EventScript_InflictStatus1_Text_Burn, 3
dynmultipush Debug_EventScript_InflictStatus1_Text_Freeze, 4
dynmultipush Debug_EventScript_InflictStatus1_Text_Frostbite, 5
dynmultipush Debug_EventScript_InflictStatus1_Text_Close, 6
dynmultistack 0, 0, FALSE, 7, FALSE, 0, NULL
switch VAR_RESULT
case 0, Debug_EventScript_InflictStatus1_Single_Poison
case 1, Debug_EventScript_InflictStatus1_Single_Paralysis
case 2, Debug_EventScript_InflictStatus1_Single_Sleep
case 3, Debug_EventScript_InflictStatus1_Single_Burn
case 4, Debug_EventScript_InflictStatus1_Single_Freeze
case 5, Debug_EventScript_InflictStatus1_Single_Frostbite
case 6, Debug_EventScript_InflictStatus1_Close
case MULTI_B_PRESSED, Debug_EventScript_InflictStatus1_Close
releaseall
end

Debug_EventScript_InflictStatus1_Single_Poison:
setstatus1 STATUS1_POISON, VAR_0x8004
releaseall
end

Debug_EventScript_InflictStatus1_Single_Paralysis:
setstatus1 STATUS1_PARALYSIS, VAR_0x8004
releaseall
end

Debug_EventScript_InflictStatus1_Single_Sleep:
setstatus1 STATUS1_SLEEP, VAR_0x8004
releaseall
end

Debug_EventScript_InflictStatus1_Single_Burn:
setstatus1 STATUS1_BURN, VAR_0x8004
releaseall
end

Debug_EventScript_InflictStatus1_Single_Freeze:
setstatus1 STATUS1_FREEZE, VAR_0x8004
releaseall
end

Debug_EventScript_InflictStatus1_Single_Frostbite:
setstatus1 STATUS1_FROSTBITE, VAR_0x8004
releaseall
end

Debug_EventScript_InflictStatus1_Party:
dynmultipush Debug_EventScript_InflictStatus1_Text_Poison, 0
dynmultipush Debug_EventScript_InflictStatus1_Text_Paralysis, 1
dynmultipush Debug_EventScript_InflictStatus1_Text_Sleep, 2
dynmultipush Debug_EventScript_InflictStatus1_Text_Burn, 3
dynmultipush Debug_EventScript_InflictStatus1_Text_Freeze, 4
dynmultipush Debug_EventScript_InflictStatus1_Text_Frostbite, 5
dynmultipush Debug_EventScript_InflictStatus1_Text_Close, 6
dynmultistack 0, 0, FALSE, 7, FALSE, 0, NULL
switch VAR_RESULT
case 0, Debug_EventScript_InflictStatus1_Party_Poison
case 1, Debug_EventScript_InflictStatus1_Party_Paralysis
case 2, Debug_EventScript_InflictStatus1_Party_Sleep
case 3, Debug_EventScript_InflictStatus1_Party_Burn
case 4, Debug_EventScript_InflictStatus1_Party_Freeze
case 5, Debug_EventScript_InflictStatus1_Party_Frostbite
case 6, Debug_EventScript_InflictStatus1_Close
case MULTI_B_PRESSED, Debug_EventScript_InflictStatus1_Close
releaseall
end

Debug_EventScript_InflictStatus1_Party_Poison:
setstatus1 STATUS1_POISON, PARTY_SIZE
releaseall
end

Debug_EventScript_InflictStatus1_Party_Paralysis:
setstatus1 STATUS1_PARALYSIS, PARTY_SIZE
releaseall
end

Debug_EventScript_InflictStatus1_Party_Sleep:
setstatus1 STATUS1_SLEEP, PARTY_SIZE
releaseall
end

Debug_EventScript_InflictStatus1_Party_Burn:
setstatus1 STATUS1_BURN, PARTY_SIZE
releaseall
end

Debug_EventScript_InflictStatus1_Party_Freeze:
setstatus1 STATUS1_FREEZE, PARTY_SIZE
releaseall
end

Debug_EventScript_InflictStatus1_Party_Frostbite:
setstatus1 STATUS1_FROSTBITE, PARTY_SIZE
releaseall
end

Debug_EventScript_InflictStatus1_Text_Single:
.string "Single$"

Debug_EventScript_InflictStatus1_Text_PartyWide:
.string "Party-wide$"

Debug_EventScript_InflictStatus1_Text_Close:
.string "Close$"

Debug_EventScript_InflictStatus1_Text_Poison:
.string "Poison$"

Debug_EventScript_InflictStatus1_Text_Paralysis:
.string "Paralysis$"

Debug_EventScript_InflictStatus1_Text_Sleep:
.string "Sleep$"

Debug_EventScript_InflictStatus1_Text_Burn:
.string "Burn$"

Debug_EventScript_InflictStatus1_Text_Freeze:
.string "Freeze$"

Debug_EventScript_InflictStatus1_Text_Frostbite:
.string "Frostbite$"
52 changes: 20 additions & 32 deletions src/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ enum PartyDebugMenu
DEBUG_PARTY_MENU_ITEM_MOVE_REMINDER,
DEBUG_PARTY_MENU_ITEM_HATCH_AN_EGG,
DEBUG_PARTY_MENU_ITEM_HEAL_PARTY,
DEBUG_PARTY_MENU_ITEM_POISON_MONS,
DEBUG_PARTY_MENU_ITEM_INFLICT_STATUS1,
DEBUG_PARTY_MENU_ITEM_CHECK_EV,
DEBUG_PARTY_MENU_ITEM_CHECK_IV,
DEBUG_PARTY_MENU_ITEM_CLEAR_PARTY,
Expand Down Expand Up @@ -391,7 +391,7 @@ static void DebugAction_PCBag_ClearBoxes(u8 taskId);
static void DebugAction_Party_MoveReminder(u8 taskId);
static void DebugAction_Party_HatchAnEgg(u8 taskId);
static void DebugAction_Party_HealParty(u8 taskId);
static void DebugAction_Party_PoisonMons(u8 taskId);
static void DebugAction_Party_InflictStatus1(u8 taskId);
static void DebugAction_Party_CheckEV(u8 taskId);
static void DebugAction_Party_CheckIV(u8 taskId);
static void DebugAction_Party_ClearParty(u8 taskId);
Expand Down Expand Up @@ -454,6 +454,7 @@ extern const u8 Debug_FlagsNotSetBattleConfigMessage[];
extern const u8 Debug_FlagsAndVarNotSetBattleConfigMessage[];
extern const u8 Debug_EventScript_CheckEV[];
extern const u8 Debug_EventScript_CheckIV[];
extern const u8 Debug_EventScript_InflictStatus1[];
extern const u8 Debug_EventScript_Script_1[];
extern const u8 Debug_EventScript_Script_2[];
extern const u8 Debug_EventScript_Script_3[];
Expand Down Expand Up @@ -548,7 +549,7 @@ static const u8 sDebugText_PCBag_ClearBoxes[] = _("Clear Storage Bo
static const u8 sDebugText_Party_MoveReminder[] = _("Move Reminder");
static const u8 sDebugText_Party_HatchAnEgg[] = _("Hatch an Egg");
static const u8 sDebugText_Party_HealParty[] = _("Heal party");
static const u8 sDebugText_Party_PoisonParty[] = _("Poison party");
static const u8 sDebugText_Party_InflictStatus1[] = _("Inflict Status1");
static const u8 sDebugText_Party_CheckEV[] = _("Check EV");
static const u8 sDebugText_Party_CheckIV[] = _("Check IV");
static const u8 sDebugText_Party_ClearParty[] = _("Clear Party");
Expand Down Expand Up @@ -743,13 +744,13 @@ static const struct ListMenuItem sDebugMenu_Items_PCBag_Fill[] =

static const struct ListMenuItem sDebugMenu_Items_Party[] =
{
[DEBUG_PARTY_MENU_ITEM_MOVE_REMINDER] = {sDebugText_Party_MoveReminder, DEBUG_PARTY_MENU_ITEM_MOVE_REMINDER},
[DEBUG_PARTY_MENU_ITEM_HATCH_AN_EGG] = {sDebugText_Party_HatchAnEgg, DEBUG_PARTY_MENU_ITEM_HATCH_AN_EGG},
[DEBUG_PARTY_MENU_ITEM_HEAL_PARTY] = {sDebugText_Party_HealParty, DEBUG_PARTY_MENU_ITEM_HEAL_PARTY},
[DEBUG_PARTY_MENU_ITEM_POISON_MONS] = {sDebugText_Party_PoisonParty, DEBUG_PARTY_MENU_ITEM_POISON_MONS},
[DEBUG_PARTY_MENU_ITEM_CHECK_EV] = {sDebugText_Party_CheckEV, DEBUG_PARTY_MENU_ITEM_CHECK_EV},
[DEBUG_PARTY_MENU_ITEM_CHECK_IV] = {sDebugText_Party_CheckIV, DEBUG_PARTY_MENU_ITEM_CHECK_IV},
[DEBUG_PARTY_MENU_ITEM_CLEAR_PARTY] = {sDebugText_Party_ClearParty, DEBUG_PARTY_MENU_ITEM_CLEAR_PARTY},
[DEBUG_PARTY_MENU_ITEM_MOVE_REMINDER] = {sDebugText_Party_MoveReminder, DEBUG_PARTY_MENU_ITEM_MOVE_REMINDER},
[DEBUG_PARTY_MENU_ITEM_HATCH_AN_EGG] = {sDebugText_Party_HatchAnEgg, DEBUG_PARTY_MENU_ITEM_HATCH_AN_EGG},
[DEBUG_PARTY_MENU_ITEM_HEAL_PARTY] = {sDebugText_Party_HealParty, DEBUG_PARTY_MENU_ITEM_HEAL_PARTY},
[DEBUG_PARTY_MENU_ITEM_INFLICT_STATUS1] = {sDebugText_Party_InflictStatus1, DEBUG_PARTY_MENU_ITEM_INFLICT_STATUS1},
[DEBUG_PARTY_MENU_ITEM_CHECK_EV] = {sDebugText_Party_CheckEV, DEBUG_PARTY_MENU_ITEM_CHECK_EV},
[DEBUG_PARTY_MENU_ITEM_CHECK_IV] = {sDebugText_Party_CheckIV, DEBUG_PARTY_MENU_ITEM_CHECK_IV},
[DEBUG_PARTY_MENU_ITEM_CLEAR_PARTY] = {sDebugText_Party_ClearParty, DEBUG_PARTY_MENU_ITEM_CLEAR_PARTY},
};

static const struct ListMenuItem sDebugMenu_Items_Scripts[] =
Expand Down Expand Up @@ -912,13 +913,13 @@ static void (*const sDebugMenu_Actions_PCBag_Fill[])(u8) =

static void (*const sDebugMenu_Actions_Party[])(u8) =
{
[DEBUG_PARTY_MENU_ITEM_MOVE_REMINDER] = DebugAction_Party_MoveReminder,
[DEBUG_PARTY_MENU_ITEM_HATCH_AN_EGG] = DebugAction_Party_HatchAnEgg,
[DEBUG_PARTY_MENU_ITEM_HEAL_PARTY] = DebugAction_Party_HealParty,
[DEBUG_PARTY_MENU_ITEM_POISON_MONS] = DebugAction_Party_PoisonMons,
[DEBUG_PARTY_MENU_ITEM_CHECK_EV] = DebugAction_Party_CheckEV,
[DEBUG_PARTY_MENU_ITEM_CHECK_IV] = DebugAction_Party_CheckIV,
[DEBUG_PARTY_MENU_ITEM_CLEAR_PARTY] = DebugAction_Party_ClearParty,
[DEBUG_PARTY_MENU_ITEM_MOVE_REMINDER] = DebugAction_Party_MoveReminder,
[DEBUG_PARTY_MENU_ITEM_HATCH_AN_EGG] = DebugAction_Party_HatchAnEgg,
[DEBUG_PARTY_MENU_ITEM_HEAL_PARTY] = DebugAction_Party_HealParty,
[DEBUG_PARTY_MENU_ITEM_INFLICT_STATUS1] = DebugAction_Party_InflictStatus1,
[DEBUG_PARTY_MENU_ITEM_CHECK_EV] = DebugAction_Party_CheckEV,
[DEBUG_PARTY_MENU_ITEM_CHECK_IV] = DebugAction_Party_CheckIV,
[DEBUG_PARTY_MENU_ITEM_CLEAR_PARTY] = DebugAction_Party_ClearParty,
};

static void (*const sDebugMenu_Actions_Scripts[])(u8) =
Expand Down Expand Up @@ -5084,22 +5085,9 @@ static void DebugAction_Party_HealParty(u8 taskId)
Debug_DestroyMenu_Full(taskId);
}

static void DebugAction_Party_PoisonMons(u8 taskId)
static void DebugAction_Party_InflictStatus1(u8 taskId)
{
int i;
for (i = 0; i < PARTY_SIZE; i++)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES, 0)
&& GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_NONE
&& GetMonData(&gPlayerParty[i], MON_DATA_SPECIES_OR_EGG) != SPECIES_EGG)
{
u32 curStatus = STATUS1_POISON;
SetMonData(&gPlayerParty[i], MON_DATA_STATUS, &curStatus);
}
}
PlaySE(SE_FIELD_POISON);
ScriptContext_Enable();
Debug_DestroyMenu_Full(taskId);
Debug_DestroyMenu_Full_Script(taskId, Debug_EventScript_InflictStatus1);
}

static void DebugAction_Party_CheckEV(u8 taskId)
Expand Down
24 changes: 24 additions & 0 deletions src/script_pokemon_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,3 +486,27 @@ void Script_GetChosenMonDefensiveIV(void)
ConvertIntToDecimalStringN(gStringVar2, GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_DEF_IV), STR_CONV_MODE_LEFT_ALIGN, 3);
ConvertIntToDecimalStringN(gStringVar3, GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPDEF_IV), STR_CONV_MODE_LEFT_ALIGN, 3);
}

void Script_SetStatus1(struct ScriptContext *ctx)
{
u32 status1 = VarGet(ScriptReadHalfword(ctx));
u32 slot = VarGet(ScriptReadHalfword(ctx));

if (slot >= PARTY_SIZE)
{
u16 species;

for (slot = 0; slot < PARTY_SIZE; slot++)
{
species = GetMonData(&gPlayerParty[slot], MON_DATA_SPECIES);
if (species != SPECIES_NONE
&& species != SPECIES_EGG
&& GetMonData(&gPlayerParty[slot], MON_DATA_HP) != 0)
SetMonData(&gPlayerParty[slot], MON_DATA_STATUS, &status1);
}
}
else
{
SetMonData(&gPlayerParty[slot], MON_DATA_STATUS, &status1);
}
}

0 comments on commit 64b7cfe

Please sign in to comment.