through SetContinueGameWarpToDynamicWarp

This commit is contained in:
PikalaxALT
2020-03-27 17:21:00 -04:00
parent 71c003dcdb
commit a03906a1a3
14 changed files with 201 additions and 722 deletions
+2 -2
View File
@@ -2064,7 +2064,7 @@ static void EscapeRopeFieldEffect_Step1(struct Task * task)
if (data[4] == 1 && !gPaletteFade.active && BGMusicStopped() == TRUE)
{
SetObjectEventDirection(playerObj, task->data[15]);
sub_80555E0();
SetWarpDestinationToEscapeWarp();
WarpIntoMap();
gFieldCallback = FieldCallback_EscapeRopeExit;
SetMainCallback2(CB2_LoadMap);
@@ -2331,7 +2331,7 @@ static void TeleportFieldEffectTask4(struct Task * task)
{
if (BGMusicStopped() == TRUE)
{
copy_saved_warp3_bank_and_enter_x_to_warp1();
SetWarpDestinationToLastHealLocation();
WarpIntoMap();
SetMainCallback2(CB2_LoadMap);
gFieldCallback = FieldCallback_TeleportIn;
+1 -1
View File
@@ -399,7 +399,7 @@ static void sub_807F45C(u8 taskId)
FillWindowPixelBuffer(windowId, PIXEL_FILL(0));
PutWindowTilemap(windowId);
CopyWindowToVram(windowId, 3);
loc = GetHealLocationPointer(1);
loc = GetHealLocation(1);
if (gSaveBlock1Ptr->lastHealLocation.mapGroup == loc->group
&& gSaveBlock1Ptr->lastHealLocation.mapNum == loc->map
&& gSaveBlock1Ptr->lastHealLocation.warpId == -1
+12 -12
View File
@@ -840,9 +840,9 @@ static const u8 sElevatorWindowAnimDuration[] = {
void GetElevatorFloor(void)
{
u16 floor = 4;
if (gSaveBlock1Ptr->warp2.mapGroup == MAP_GROUP(ROCKET_HIDEOUT_B1F))
if (gSaveBlock1Ptr->dynamicWarp.mapGroup == MAP_GROUP(ROCKET_HIDEOUT_B1F))
{
switch (gSaveBlock1Ptr->warp2.mapNum)
switch (gSaveBlock1Ptr->dynamicWarp.mapNum)
{
case MAP_NUM(SILPH_CO_1F):
floor = 4;
@@ -888,9 +888,9 @@ void GetElevatorFloor(void)
break;
}
}
if (gSaveBlock1Ptr->warp2.mapGroup == MAP_GROUP(CELADON_CITY_DEPARTMENT_STORE_1F))
if (gSaveBlock1Ptr->dynamicWarp.mapGroup == MAP_GROUP(CELADON_CITY_DEPARTMENT_STORE_1F))
{
switch (gSaveBlock1Ptr->warp2.mapNum)
switch (gSaveBlock1Ptr->dynamicWarp.mapNum)
{
case MAP_NUM(CELADON_CITY_DEPARTMENT_STORE_1F):
floor = 4;
@@ -909,9 +909,9 @@ void GetElevatorFloor(void)
break;
}
}
if (gSaveBlock1Ptr->warp2.mapGroup == MAP_GROUP(TRAINER_TOWER_1F))
if (gSaveBlock1Ptr->dynamicWarp.mapGroup == MAP_GROUP(TRAINER_TOWER_1F))
{
switch (gSaveBlock1Ptr->warp2.mapNum)
switch (gSaveBlock1Ptr->dynamicWarp.mapNum)
{
case MAP_NUM(TRAINER_TOWER_1F):
case MAP_NUM(TRAINER_TOWER_2F):
@@ -937,9 +937,9 @@ u16 InitElevatorFloorSelectMenuPos(void)
sElevatorScroll = 0;
sElevatorCursorPos = 0;
if (gSaveBlock1Ptr->warp2.mapGroup == MAP_GROUP(ROCKET_HIDEOUT_B1F))
if (gSaveBlock1Ptr->dynamicWarp.mapGroup == MAP_GROUP(ROCKET_HIDEOUT_B1F))
{
switch (gSaveBlock1Ptr->warp2.mapNum)
switch (gSaveBlock1Ptr->dynamicWarp.mapNum)
{
case MAP_NUM(SILPH_CO_11F):
sElevatorScroll = 0;
@@ -999,9 +999,9 @@ u16 InitElevatorFloorSelectMenuPos(void)
break;
}
}
if (gSaveBlock1Ptr->warp2.mapGroup == MAP_GROUP(CELADON_CITY_DEPARTMENT_STORE_1F))
if (gSaveBlock1Ptr->dynamicWarp.mapGroup == MAP_GROUP(CELADON_CITY_DEPARTMENT_STORE_1F))
{
switch (gSaveBlock1Ptr->warp2.mapNum)
switch (gSaveBlock1Ptr->dynamicWarp.mapNum)
{
case MAP_NUM(CELADON_CITY_DEPARTMENT_STORE_5F):
sElevatorScroll = 0;
@@ -1025,9 +1025,9 @@ u16 InitElevatorFloorSelectMenuPos(void)
break;
}
}
if (gSaveBlock1Ptr->warp2.mapGroup == MAP_GROUP(TRAINER_TOWER_1F))
if (gSaveBlock1Ptr->dynamicWarp.mapGroup == MAP_GROUP(TRAINER_TOWER_1F))
{
switch (gSaveBlock1Ptr->warp2.mapNum)
switch (gSaveBlock1Ptr->dynamicWarp.mapNum)
{
case MAP_NUM(TRAINER_TOWER_1F):
case MAP_NUM(TRAINER_TOWER_2F):
+1 -1
View File
@@ -50,7 +50,7 @@ static const struct HealLocation * GetHealLocationPointerFromMapGroupAndNum(u16
return &sSpawnPoints[i - 1];
}
const struct HealLocation * GetHealLocationPointer(u32 idx)
const struct HealLocation * GetHealLocation(u32 idx)
{
if (idx == 0)
return NULL;
+1 -1
View File
@@ -144,7 +144,7 @@ void sub_804C1AC(void)
void SetContinueGameWarpStatusToDynamicWarp(void)
{
sub_8055778(0);
SetContinueGameWarpToDynamicWarp(0);
gSaveBlock2Ptr->specialSaveWarpFlags |= CONTINUE_GAME_WARP;
}
+157
View File
@@ -3,8 +3,10 @@
#include "event_data.h"
#include "event_scripts.h"
#include "field_camera.h"
#include "field_player_avatar.h"
#include "field_specials.h"
#include "fieldmap.h"
#include "heal_location.h"
#include "load_save.h"
#include "money.h"
#include "overworld.h"
@@ -14,6 +16,7 @@
#include "tileset_anims.h"
#include "constants/maps.h"
#include "constants/flags.h"
#include "constants/species.h"
struct InitialPlayerAvatarState
{
@@ -27,6 +30,18 @@ EWRAM_DATA struct WarpData sWarpDestination = {};
EWRAM_DATA struct WarpData gFixedDiveWarp = {};
EWRAM_DATA struct WarpData gFixedHoleWarp = {};
EWRAM_DATA struct InitialPlayerAvatarState gUnknown_2031DD4 = {};
EWRAM_DATA bool8 gDisableMapMusicChangeOnMapLoad = FALSE;
EWRAM_DATA u16 gUnknown_2031DDA = SPECIES_NONE;
EWRAM_DATA bool8 gUnknown_2031DDC = FALSE;
// File boundary perhaps?
ALIGNED(4) EWRAM_DATA bool8 gUnknown_2031DE0 = FALSE;
EWRAM_DATA const struct CreditsOverworldCmd *gUnknown_2031DE4 = NULL;
EWRAM_DATA s16 gUnknown_2031DE8 = 0;
EWRAM_DATA s16 gUnknown_2031DEA = 0;
// File boundary perhaps?
EWRAM_DATA struct LinkPlayerObjectEvent gLinkPlayerObjectEvents[4] = {};
u8 CountBadgesForOverworldWhiteOutLossCalculation(void);
void Overworld_ResetStateAfterWhitingOut(void);
@@ -367,3 +382,145 @@ void LoadSaveblockMapHeader(void)
gMapHeader = *Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum);
gMapHeader.mapLayout = GetMapLayout();
}
void SetPlayerCoordsFromWarp(void)
{
if (gSaveBlock1Ptr->location.warpId >= 0 && gSaveBlock1Ptr->location.warpId < gMapHeader.events->warpCount)
{
gSaveBlock1Ptr->pos.x = gMapHeader.events->warps[gSaveBlock1Ptr->location.warpId].x;
gSaveBlock1Ptr->pos.y = gMapHeader.events->warps[gSaveBlock1Ptr->location.warpId].y;
}
else if (gSaveBlock1Ptr->location.x >= 0 && gSaveBlock1Ptr->location.y >= 0)
{
gSaveBlock1Ptr->pos.x = gSaveBlock1Ptr->location.x;
gSaveBlock1Ptr->pos.y = gSaveBlock1Ptr->location.y;
}
else
{
gSaveBlock1Ptr->pos.x = gMapHeader.mapLayout->width / 2;
gSaveBlock1Ptr->pos.y = gMapHeader.mapLayout->height / 2;
}
}
void WarpIntoMap(void)
{
ApplyCurrentWarp();
LoadCurrentMapData();
SetPlayerCoordsFromWarp();
}
void SetWarpDestination(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
SetWarpData(&sWarpDestination, mapGroup, mapNum, warpId, x, y);
}
void SetWarpDestinationToMapWarp(s8 mapGroup, s8 mapNum, s8 warpId)
{
SetWarpDestination(mapGroup, mapNum, warpId, -1, -1);
}
void SetDynamicWarp(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId)
{
SetWarpData(&gSaveBlock1Ptr->dynamicWarp, mapGroup, mapNum, warpId, gSaveBlock1Ptr->pos.x, gSaveBlock1Ptr->pos.y);
}
void SetDynamicWarpWithCoords(s32 unused, s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
SetWarpData(&gSaveBlock1Ptr->dynamicWarp, mapGroup, mapNum, warpId, x, y);
}
void SetWarpDestinationToDynamicWarp(u8 unusedWarpId)
{
sWarpDestination = gSaveBlock1Ptr->dynamicWarp;
}
void SetWarpDestinationToHealLocation(u8 healLocationId)
{
const struct HealLocation *warp = GetHealLocation(healLocationId);
if (warp)
SetWarpDestination(warp->group, warp->map, -1, warp->x, warp->y);
}
void SetWarpDestinationToLastHealLocation(void)
{
sWarpDestination = gSaveBlock1Ptr->lastHealLocation;
}
void Overworld_SetWhiteoutRespawnPoint(void)
{
SetWhiteoutRespawnWarpAndHealerNpc(&sWarpDestination);
}
void SetLastHealLocationWarp(u8 healLocationId)
{
const struct HealLocation *healLocation = GetHealLocation(healLocationId);
if (healLocation)
SetWarpData(&gSaveBlock1Ptr->lastHealLocation, healLocation->group, healLocation->map, -1, healLocation->x, healLocation->y);
}
void UpdateEscapeWarp(s16 x, s16 y)
{
u8 currMapType = GetCurrentMapType();
u8 destMapType = GetMapTypeByGroupAndId(sWarpDestination.mapGroup, sWarpDestination.mapNum);
u8 delta;
if (IsMapTypeOutdoors(currMapType) && IsMapTypeOutdoors(destMapType) != TRUE && !(gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(VIRIDIAN_FOREST) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(VIRIDIAN_FOREST)))
{
delta = GetPlayerFacingDirection() != DIR_SOUTH;
SetEscapeWarp(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1, x - 7, y - 7 + delta);
}
}
void SetEscapeWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
SetWarpData(&gSaveBlock1Ptr->escapeWarp, mapGroup, mapNum, warpId, x, y);
}
void SetWarpDestinationToEscapeWarp(void)
{
sWarpDestination = gSaveBlock1Ptr->escapeWarp;
}
void SetFixedDiveWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
SetWarpData(&gFixedDiveWarp, mapGroup, mapNum, warpId, x, y);
}
void SetWarpDestinationToDiveWarp(void)
{
sWarpDestination = gFixedDiveWarp;
}
void SetFixedHoleWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
SetWarpData(&gFixedHoleWarp, mapGroup, mapNum, warpId, x, y);
}
void SetWarpDestinationToFixedHoleWarp(s16 x, s16 y)
{
if (IsDummyWarp(&gFixedHoleWarp) == TRUE)
sWarpDestination = gLastUsedWarp;
else
SetWarpDestination(gFixedHoleWarp.mapGroup, gFixedHoleWarp.mapNum, -1, x, y);
}
void SetWarpDestinationToContinueGameWarp(void)
{
sWarpDestination = gSaveBlock1Ptr->continueGameWarp;
}
void SetContinueGameWarp(s8 mapGroup, s8 mapNum, s8 warpId, s8 x, s8 y)
{
SetWarpData(&gSaveBlock1Ptr->continueGameWarp, mapGroup, mapNum, warpId, x, y);
}
void SetContinueGameWarpToHealLocation(u8 healLocationId)
{
const struct HealLocation *warp = GetHealLocation(healLocationId);
if (warp)
SetWarpData(&gSaveBlock1Ptr->continueGameWarp, warp->group, warp->map, -1, warp->x, warp->y);
}
void SetContinueGameWarpToDynamicWarp(int unused)
{
gSaveBlock1Ptr->continueGameWarp = gSaveBlock1Ptr->dynamicWarp;
}
+1 -1
View File
@@ -29,7 +29,7 @@ bool8 EnterHallOfFame(void)
SetGameStat(GAME_STAT_FIRST_HOF_PLAY_TIME, (gSaveBlock2Ptr->playTimeHours << 16) | (gSaveBlock2Ptr->playTimeMinutes << 8) | gSaveBlock2Ptr->playTimeSeconds);
}
sub_804C1AC();
sub_8055738(SPAWN_PALLET_TOWN);
SetContinueGameWarpToHealLocation(SPAWN_PALLET_TOWN);
gaveAtLeastOneRibbon = FALSE;
for (i = 0, r7 = &ribbonState; i < PARTY_SIZE; i++)
{
+7 -7
View File
@@ -3471,7 +3471,7 @@ static void GetPlayerPositionOnRegionMap(void)
const struct MapHeader * mapHeader;
struct WarpData * warp;
switch (get_map_light_level_by_bank_and_number(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum))
switch (GetMapTypeByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum))
{
default:
case 1:
@@ -3495,12 +3495,12 @@ static void GetPlayerPositionOnRegionMap(void)
y = gSaveBlock1Ptr->escapeWarp.y;
break;
case 9:
mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->warp2.mapGroup, gSaveBlock1Ptr->warp2.mapNum);
mapHeader = Overworld_GetMapHeaderByGroupAndId(gSaveBlock1Ptr->dynamicWarp.mapGroup, gSaveBlock1Ptr->dynamicWarp.mapNum);
gUnknown_20399E4->field_014 = mapHeader->regionMapSectionId;
width = mapHeader->mapLayout->width;
height = mapHeader->mapLayout->height;
x = gSaveBlock1Ptr->warp2.x;
y = gSaveBlock1Ptr->warp2.y;
x = gSaveBlock1Ptr->dynamicWarp.x;
y = gSaveBlock1Ptr->dynamicWarp.y;
break;
case 8:
if ((gUnknown_20399E4->field_014 = gMapHeader.regionMapSectionId) != MAPSEC_SPECIAL_AREA)
@@ -3510,7 +3510,7 @@ static void GetPlayerPositionOnRegionMap(void)
}
else
{
warp = &gSaveBlock1Ptr->warp2;
warp = &gSaveBlock1Ptr->dynamicWarp;
mapHeader = Overworld_GetMapHeaderByGroupAndId(warp->mapGroup, warp->mapNum);
gUnknown_20399E4->field_014 = mapHeader->regionMapSectionId;
}
@@ -4318,7 +4318,7 @@ static void sub_80C4F08(u8 taskId)
case 4:
if ((sub_80C3AC8(0) == 2 || sub_80C3AC8(0) == 4) && GetRegionMapPermission(MAPPERM_3) == TRUE)
{
switch (get_map_light_level_by_bank_and_number(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum))
switch (GetMapTypeByGroupAndId(gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum))
{
case 4:
case 8:
@@ -4388,7 +4388,7 @@ static void sub_80C527C(u16 mapsec)
u16 idx = mapsec - MAPSECS_KANTO;
if (sMapsecToSpawn[idx][2])
{
sub_805546C(sMapsecToSpawn[idx][2]);
SetWarpDestinationToHealLocation(sMapsecToSpawn[idx][2]);
SetUsedFlyQuestLogEvent(sMapsecToSpawn[idx]);
}
else