Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Pyramid location documentaion #2073

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions asm/macros/battle_frontier/battle_pyramid.inc
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@
.endm

@ VAR_RESULT is 1 if player is on a Pyramid floor, 2 if on the Pyramid peak, 0 otherwise
.macro pyramid_inchallenge
setvar VAR_0x8004, BATTLE_PYRAMID_FUNC_IS_IN
.macro pyramid_getlocation
setvar VAR_0x8004, BATTLE_PYRAMID_FUNC_CURRENT_LOCATION
special CallBattlePyramidFunction
.endm

Expand Down
6 changes: 3 additions & 3 deletions data/scripts/field_poison.inc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ EventScript_FrontierFieldWhiteOut::
waitbuttonpress
pike_inchallenge
goto_if_eq VAR_RESULT, TRUE, BattleFrontier_BattlePike_EventScript_Retire
pyramid_inchallenge
goto_if_eq VAR_RESULT, 1, BattleFrontier_BattlePyramid_EventScript_WarpToLobbyLost @ On Pyramid floor
goto_if_eq VAR_RESULT, 2, BattleFrontier_BattlePyramid_EventScript_WarpToLobbyLost @ On Pyramid peak
pyramid_getlocation
goto_if_eq VAR_RESULT, PYRAMID_LOCATION_FLOOR, BattleFrontier_BattlePyramid_EventScript_WarpToLobbyLost
goto_if_eq VAR_RESULT, PYRAMID_LOCATION_TOP, BattleFrontier_BattlePyramid_EventScript_WarpToLobbyLost
trainerhill_inchallenge
goto_if_eq VAR_RESULT, TRUE, TrainerHill_1F_EventScript_Lost
special Script_FadeOutMapMusic
Expand Down
4 changes: 2 additions & 2 deletions data/scripts/obtain_item.inc
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ EventScript_PickUpItem::
waitfanfare
waitmessage
bufferitemnameplural STR_VAR_2, VAR_0x8004, VAR_0x8005
pyramid_inchallenge
goto_if_eq VAR_RESULT, TRUE, EventScript_PutBattlePyramidItemInBag
pyramid_getlocation
goto_if_eq VAR_RESULT, PYRAMID_LOCATION_FLOOR, EventScript_PutBattlePyramidItemInBag
msgbox gText_PutItemInPocket, MSGBOX_DEFAULT
return

Expand Down
4 changes: 3 additions & 1 deletion include/battle_pyramid.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#ifndef GUARD_BATTLE_PYRAMID_H
#define GUARD_BATTLE_PYRAMID_H

#include "constants/battle_pyramid.h"

void CallBattlePyramidFunction(void);
u16 LocalIdToPyramidTrainerId(u8 localId);
bool8 GetBattlePyramidTrainerFlag(u8 eventId);
void MarkApproachingPyramidTrainersAsBattled(void);
void GenerateBattlePyramidWildMon(void);
u8 GetPyramidRunMultiplier(void);
u8 InBattlePyramid(void);
u8 CurrentBattlePyramidLocation(void);
bool8 InBattlePyramid_(void);
void PausePyramidChallenge(void);
void SoftResetInBattlePyramid(void);
Expand Down
6 changes: 5 additions & 1 deletion include/constants/battle_pyramid.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#define BATTLE_PYRAMID_FUNC_SET_TRAINERS 9
#define BATTLE_PYRAMID_FUNC_SHOW_HINT_TEXT 10
#define BATTLE_PYRAMID_FUNC_UPDATE_STREAK 11 // unused
#define BATTLE_PYRAMID_FUNC_IS_IN 12
#define BATTLE_PYRAMID_FUNC_CURRENT_LOCATION 12
#define BATTLE_PYRAMID_FUNC_UPDATE_LIGHT 13
#define BATTLE_PYRAMID_FUNC_CLEAR_HELD_ITEMS 14
#define BATTLE_PYRAMID_FUNC_SET_FLOOR_PALETTE 15
Expand All @@ -62,4 +62,8 @@
#define PYRAMID_LIGHT_SET_RADIUS 0
#define PYRAMID_LIGHT_INCR_RADIUS 1

#define PYRAMID_LOCATION_NONE 0 // Not in the Pyramid
#define PYRAMID_LOCATION_FLOOR 1
#define PYRAMID_LOCATION_TOP 2

#endif // GUARD_CONSTANTS_BATTLE_PYRAMID_H
20 changes: 10 additions & 10 deletions src/battle_pyramid.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void HidePyramidItem(void);
static void SetPyramidFacilityTrainers(void);
static void ShowPostBattleHintText(void);
static void UpdatePyramidWinStreak(void);
static void GetInBattlePyramid(void);
static void GetCurrentBattlePyramidLocation(void);
static void UpdatePyramidLightRadius(void);
static void ClearPyramidPartyHeldItems(void);
static void SetPyramidFloorPalette(void);
Expand Down Expand Up @@ -798,7 +798,7 @@ static void (* const sBattlePyramidFunctions[])(void) =
[BATTLE_PYRAMID_FUNC_SET_TRAINERS] = SetPyramidFacilityTrainers,
[BATTLE_PYRAMID_FUNC_SHOW_HINT_TEXT] = ShowPostBattleHintText,
[BATTLE_PYRAMID_FUNC_UPDATE_STREAK] = UpdatePyramidWinStreak,
[BATTLE_PYRAMID_FUNC_IS_IN] = GetInBattlePyramid,
[BATTLE_PYRAMID_FUNC_CURRENT_LOCATION] = GetCurrentBattlePyramidLocation,
[BATTLE_PYRAMID_FUNC_UPDATE_LIGHT] = UpdatePyramidLightRadius,
[BATTLE_PYRAMID_FUNC_CLEAR_HELD_ITEMS] = ClearPyramidPartyHeldItems,
[BATTLE_PYRAMID_FUNC_SET_FLOOR_PALETTE] = SetPyramidFloorPalette,
Expand Down Expand Up @@ -1113,9 +1113,9 @@ static void UpdatePyramidWinStreak(void)
gSaveBlock2Ptr->frontier.pyramidRecordStreaks[lvlMode] = gSaveBlock2Ptr->frontier.pyramidWinStreaks[lvlMode];
}

static void GetInBattlePyramid(void)
static void GetCurrentBattlePyramidLocation(void)
{
gSpecialVar_Result = InBattlePyramid();
gSpecialVar_Result = CurrentBattlePyramidLocation();
}

static void UpdatePyramidLightRadius(void)
Expand Down Expand Up @@ -1419,14 +1419,14 @@ u8 GetPyramidRunMultiplier(void)
return sPyramidFloorTemplates[id].runMultiplier;
}

u8 InBattlePyramid(void)
u8 CurrentBattlePyramidLocation(void)
{
if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_FLOOR)
return 1;
return PYRAMID_LOCATION_FLOOR;
else if (gMapHeader.mapLayoutId == LAYOUT_BATTLE_FRONTIER_BATTLE_PYRAMID_TOP)
return 2;
return PYRAMID_LOCATION_TOP;
else
return FALSE;
return PYRAMID_LOCATION_NONE;
}

bool8 InBattlePyramid_(void)
Expand All @@ -1437,7 +1437,7 @@ bool8 InBattlePyramid_(void)

void PausePyramidChallenge(void)
{
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
{
RestorePyramidPlayerParty();
gSaveBlock2Ptr->frontier.challengeStatus = CHALLENGE_STATUS_PAUSED;
Expand All @@ -1448,7 +1448,7 @@ void PausePyramidChallenge(void)

void SoftResetInBattlePyramid(void)
{
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
DoSoftReset();
}

Expand Down
2 changes: 1 addition & 1 deletion src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -9615,7 +9615,7 @@ static void Cmd_pickup(void)
{

}
else if (InBattlePyramid())
else if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
{
for (i = 0; i < PARTY_SIZE; i++)
{
Expand Down
24 changes: 12 additions & 12 deletions src/battle_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ static void DoStandardWildBattle(void)
StopPlayerAvatar();
gMain.savedCallback = CB2_EndWildBattle;
gBattleTypeFlags = 0;
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
{
VarSet(VAR_TEMP_PLAYING_PYRAMID_MUSIC, 0);
gBattleTypeFlags |= BATTLE_TYPE_PYRAMID;
Expand Down Expand Up @@ -465,7 +465,7 @@ static void DoTrainerBattle(void)

static void DoBattlePyramidTrainerHillBattle(void)
{
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
CreateBattleStartTask(GetSpecialBattleTransition(B_TRANSITION_GROUP_B_PYRAMID), 0);
else
CreateBattleStartTask(GetSpecialBattleTransition(B_TRANSITION_GROUP_TRAINER_HILL), 0);
Expand Down Expand Up @@ -603,7 +603,7 @@ static void CB2_EndWildBattle(void)
CpuFill16(0, (void *)(BG_PLTT), BG_PLTT_SIZE);
ResetOamRange(0, 128);

if (IsPlayerDefeated(gBattleOutcome) == TRUE && !InBattlePyramid() && !InBattlePike())
if (IsPlayerDefeated(gBattleOutcome) == TRUE && CurrentBattlePyramidLocation() == PYRAMID_LOCATION_NONE && !InBattlePike())
{
SetMainCallback2(CB2_WhiteOut);
}
Expand All @@ -621,7 +621,7 @@ static void CB2_EndScriptedWildBattle(void)

if (IsPlayerDefeated(gBattleOutcome) == TRUE)
{
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
else
SetMainCallback2(CB2_WhiteOut);
Expand Down Expand Up @@ -794,14 +794,14 @@ static u8 GetWildBattleTransition(void)

if (enemyLevel < playerLevel)
{
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
return B_TRANSITION_BLUR;
else
return sBattleTransitionTable_Wild[transitionType][0];
}
else
{
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
return B_TRANSITION_GRID_SQUARES;
else
return sBattleTransitionTable_Wild[transitionType][1];
Expand Down Expand Up @@ -1233,7 +1233,7 @@ u8 GetTrainerBattleMode(void)

bool8 GetTrainerFlag(void)
{
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
return GetBattlePyramidTrainerFlag(gSelectedObjectEvent);
else if (InTrainerHill())
return GetHillTrainerFlag(gSelectedObjectEvent);
Expand Down Expand Up @@ -1275,7 +1275,7 @@ void BattleSetup_StartTrainerBattle(void)
else
gBattleTypeFlags = (BATTLE_TYPE_TRAINER);

if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
{
VarSet(VAR_TEMP_PLAYING_PYRAMID_MUSIC, 0);
gBattleTypeFlags |= BATTLE_TYPE_PYRAMID;
Expand Down Expand Up @@ -1315,7 +1315,7 @@ void BattleSetup_StartTrainerBattle(void)
gWhichTrainerToFaceAfterBattle = 0;
gMain.savedCallback = CB2_EndTrainerBattle;

if (InBattlePyramid() || InTrainerHillChallenge())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE || InTrainerHillChallenge())
DoBattlePyramidTrainerHillBattle();
else
DoTrainerBattle();
Expand All @@ -1331,15 +1331,15 @@ static void CB2_EndTrainerBattle(void)
}
else if (IsPlayerDefeated(gBattleOutcome) == TRUE)
{
if (InBattlePyramid() || InTrainerHillChallenge())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE || InTrainerHillChallenge())
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
else
SetMainCallback2(CB2_WhiteOut);
}
else
{
SetMainCallback2(CB2_ReturnToFieldContinueScriptPlayMapMusic);
if (!InBattlePyramid() && !InTrainerHillChallenge())
if (CurrentBattlePyramidLocation() == PYRAMID_LOCATION_NONE && !InTrainerHillChallenge())
{
RegisterTrainerInMatchCall();
SetBattledTrainersFlags();
Expand Down Expand Up @@ -1376,7 +1376,7 @@ void BattleSetup_StartRematchBattle(void)

void ShowTrainerIntroSpeech(void)
{
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
{
if (gNoOfApproachingTrainers == 0 || gNoOfApproachingTrainers == 1)
CopyPyramidTrainerSpeechBefore(LocalIdToPyramidTrainerId(gSpecialVar_LastTalked));
Expand Down
4 changes: 2 additions & 2 deletions src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ bool8 TryRunFromBattle(u8 battler)
}
else if (gBattleMons[battler].ability == ABILITY_RUN_AWAY)
{
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
{
gBattleStruct->runTries++;
pyramidMultiplier = GetPyramidRunMultiplier();
Expand All @@ -453,7 +453,7 @@ bool8 TryRunFromBattle(u8 battler)
{
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
{
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
{
pyramidMultiplier = GetPyramidRunMultiplier();
speedVar = (gBattleMons[battler].speed * pyramidMultiplier) / (gBattleMons[BATTLE_OPPOSITE(battler)].speed) + (gBattleStruct->runTries * 30);
Expand Down
4 changes: 2 additions & 2 deletions src/event_object_movement.c
Original file line number Diff line number Diff line change
Expand Up @@ -1327,7 +1327,7 @@ u8 Unref_TryInitLocalObjectEvent(u8 localId)

if (gMapHeader.events != NULL)
{
if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
objectEventCount = GetNumBattlePyramidObjectEvents();
else if (InTrainerHill())
objectEventCount = HILL_TRAINERS_PER_FLOOR;
Expand Down Expand Up @@ -1643,7 +1643,7 @@ void TrySpawnObjectEvents(s16 cameraX, s16 cameraY)
s16 top = gSaveBlock1Ptr->pos.y;
s16 bottom = gSaveBlock1Ptr->pos.y + MAP_OFFSET_H + 2;

if (InBattlePyramid())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE)
objectCount = GetNumBattlePyramidObjectEvents();
else if (InTrainerHill())
objectCount = HILL_TRAINERS_PER_FLOOR;
Expand Down
4 changes: 2 additions & 2 deletions src/field_poison.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ static void Task_TryFieldPoisonWhiteOut(u8 taskId)
{
// Battle facilities have their own white out script to handle the challenge loss
#ifdef BUGFIX
if (InBattlePyramid() || InBattlePike() || InTrainerHillChallenge())
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE || InBattlePike() || InTrainerHillChallenge())
#else
if (InBattlePyramid() | InBattlePike() || InTrainerHillChallenge())
if (CurrentBattlePyramidLocation() | InBattlePike() || InTrainerHillChallenge())
Comment on lines +93 to +95
Copy link
Member

@GriffinRichards GriffinRichards Dec 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should be the same, otherwise it looks like the difference is significant for the bug fix (I guess in some sense it is, but then it's much easier to miss the | vs ||)

#endif
gSpecialVar_Result = FLDPSN_FRONTIER_WHITEOUT;
else
Expand Down
6 changes: 3 additions & 3 deletions src/frontier_pass.c
Original file line number Diff line number Diff line change
Expand Up @@ -917,12 +917,12 @@ static void CB2_ReturnFromRecord(void)
sPassData->cursorX = sSavedPassData.cursorX;
sPassData->cursorY = sSavedPassData.cursorY;
memset(&sSavedPassData, 0, sizeof(sSavedPassData));
switch (InBattlePyramid())
switch (CurrentBattlePyramidLocation())
{
case 1:
case PYRAMID_LOCATION_FLOOR:
PlayBGM(MUS_B_PYRAMID);
break;
case 2:
case PYRAMID_LOCATION_TOP:
PlayBGM(MUS_B_PYRAMID_TOP);
break;
default:
Expand Down
8 changes: 4 additions & 4 deletions src/item.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ bool8 CheckBagHasItem(u16 itemId, u16 count)

if (ItemId_GetPocket(itemId) == 0)
return FALSE;
if (InBattlePyramid() || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE)
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE)
return CheckPyramidBagHasItem(itemId, count);
pocket = ItemId_GetPocket(itemId) - 1;
// Check for item slots that contain the item
Expand Down Expand Up @@ -181,7 +181,7 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count)
if (ItemId_GetPocket(itemId) == POCKET_NONE)
return FALSE;

if (InBattlePyramid() || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE)
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE)
{
return CheckPyramidBagHasSpace(itemId, count);
}
Expand Down Expand Up @@ -243,7 +243,7 @@ bool8 AddBagItem(u16 itemId, u16 count)
return FALSE;

// check Battle Pyramid Bag
if (InBattlePyramid() || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE)
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE)
{
return AddPyramidBagItem(itemId, count);
}
Expand Down Expand Up @@ -351,7 +351,7 @@ bool8 RemoveBagItem(u16 itemId, u16 count)
return FALSE;

// check Battle Pyramid Bag
if (InBattlePyramid() || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE)
if (CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE || FlagGet(FLAG_STORING_ITEMS_IN_PYRAMID_BAG) == TRUE)
{
return RemovePyramidBagItem(itemId, count);
}
Expand Down
4 changes: 2 additions & 2 deletions src/item_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ void CB2_BagMenuFromStartMenu(void)

void CB2_BagMenuFromBattle(void)
{
if (!InBattlePyramid())
if (CurrentBattlePyramidLocation() == PYRAMID_LOCATION_NONE)
GoToBagMenu(ITEMMENULOCATION_BATTLE, POCKETS_COUNT, CB2_SetUpReshowBattleScreenAfterMenu2);
else
GoToBattlePyramidBagMenu(PYRAMIDBAG_LOC_BATTLE, CB2_SetUpReshowBattleScreenAfterMenu2);
Expand Down Expand Up @@ -2036,7 +2036,7 @@ bool8 UseRegisteredKeyItemOnField(void)
{
u8 taskId;

if (InUnionRoom() == TRUE || InBattlePyramid() || InBattlePike() || InMultiPartnerRoom() == TRUE)
if (InUnionRoom() == TRUE || CurrentBattlePyramidLocation() != PYRAMID_LOCATION_NONE || InBattlePike() || InMultiPartnerRoom() == TRUE)
return FALSE;
HideMapNamePopUpWindow();
ChangeBgY_ScreenOff(0, 0, BG_COORD_SET);
Expand Down
Loading
Loading