Finish field_control_avatar
This commit is contained in:
+1
-1
@@ -762,7 +762,7 @@ void CleanupLinkRoomState(void)
|
||||
LoadPlayerParty();
|
||||
SavePlayerBag();
|
||||
}
|
||||
copy_saved_warp2_bank_and_enter_x_to_warp1(127);
|
||||
SetWarpDestinationToDynamicWarp(127);
|
||||
}
|
||||
|
||||
void ExitLinkRoom(void)
|
||||
|
||||
+34
-32
@@ -1,46 +1,48 @@
|
||||
#include "global.h"
|
||||
#include "constants/weather.h"
|
||||
|
||||
void nullsub_27(void) {}
|
||||
void nullsub_28(void) {}
|
||||
void nullsub_29(void) {}
|
||||
void nullsub_30(void) {}
|
||||
void nullsub_31(void) {}
|
||||
void nullsub_32(void) {}
|
||||
void nullsub_33(void) {}
|
||||
void nullsub_34(void) {}
|
||||
void nullsub_35(void) {}
|
||||
void nullsub_36(void) {}
|
||||
void nullsub_37(void) {}
|
||||
void nullsub_38(void) {}
|
||||
void nullsub_39(void) {}
|
||||
// These were all dummied out because it's always sunny in Viridian
|
||||
void WeatherCoordEvent_SunnyClouds(void) {}
|
||||
void WeatherCoordEvent_Sunny(void) {}
|
||||
void WeatherCoordEvent_Rain(void) {}
|
||||
void WeatherCoordEvent_Snow(void) {}
|
||||
void WeatherCoordEvent_RainThunderstorm(void) {}
|
||||
void WeatherCoordEvent_FogHorizontal(void) {}
|
||||
void WeatherCoordEvent_VolcanicAsh(void) {}
|
||||
void WeatherCoordEvent_Sandstorm(void) {}
|
||||
void WeatherCoordEvent_FogDiagonal(void) {}
|
||||
void WeatherCoordEvent_Underwater(void) {}
|
||||
void WeatherCoordEvent_Shade(void) {}
|
||||
void WeatherCoordEvent_Route119Cycle(void) {}
|
||||
void WeatherCoordEvent_Route123Cycle(void) {}
|
||||
|
||||
struct {
|
||||
static struct {
|
||||
u8 weatherId;
|
||||
void (*callback)(void);
|
||||
} const gUnknown_83A72A8[] = {
|
||||
{0x01, nullsub_27},
|
||||
{0x02, nullsub_28},
|
||||
{0x03, nullsub_29},
|
||||
{0x04, nullsub_30},
|
||||
{0x05, nullsub_31},
|
||||
{0x06, nullsub_32},
|
||||
{0x07, nullsub_33},
|
||||
{0x08, nullsub_34},
|
||||
{0x09, nullsub_35},
|
||||
{0x0a, nullsub_36},
|
||||
{0x0b, nullsub_37},
|
||||
{0x14, nullsub_38},
|
||||
{0x15, nullsub_39}
|
||||
} const sWeatherCoordEventFuncs[] = {
|
||||
{WEATHER_SUNNY_CLOUDS, WeatherCoordEvent_SunnyClouds },
|
||||
{WEATHER_SUNNY, WeatherCoordEvent_Sunny },
|
||||
{WEATHER_RAIN, WeatherCoordEvent_Rain },
|
||||
{WEATHER_SNOW, WeatherCoordEvent_Snow },
|
||||
{WEATHER_RAIN_THUNDERSTORM, WeatherCoordEvent_RainThunderstorm},
|
||||
{WEATHER_FOG_HORIZONTAL, WeatherCoordEvent_FogHorizontal },
|
||||
{WEATHER_VOLCANIC_ASH, WeatherCoordEvent_VolcanicAsh },
|
||||
{WEATHER_SANDSTORM, WeatherCoordEvent_Sandstorm },
|
||||
{WEATHER_FOG_DIAGONAL, WeatherCoordEvent_FogDiagonal },
|
||||
{WEATHER_UNDERWATER, WeatherCoordEvent_Underwater },
|
||||
{WEATHER_SHADE, WeatherCoordEvent_Shade },
|
||||
{WEATHER_ROUTE119_CYCLE, WeatherCoordEvent_Route119Cycle },
|
||||
{WEATHER_ROUTE123_CYCLE, WeatherCoordEvent_Route123Cycle }
|
||||
};
|
||||
|
||||
void trigger_activate_weather(u8 weatherId)
|
||||
void DoCoordEventWeather(u8 weatherId)
|
||||
{
|
||||
u8 i;
|
||||
for (i = 0; i < NELEMS(gUnknown_83A72A8); i++)
|
||||
for (i = 0; i < NELEMS(sWeatherCoordEventFuncs); i++)
|
||||
{
|
||||
if (gUnknown_83A72A8[i].weatherId == weatherId)
|
||||
if (sWeatherCoordEventFuncs[i].weatherId == weatherId)
|
||||
{
|
||||
gUnknown_83A72A8[i].callback();
|
||||
sWeatherCoordEventFuncs[i].callback();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+289
-1
@@ -1,6 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "gflib.h"
|
||||
#include "bike.h"
|
||||
#include "coord_event_weather.h"
|
||||
#include "daycare.h"
|
||||
#include "event_data.h"
|
||||
#include "event_object_movement.h"
|
||||
@@ -28,6 +29,7 @@
|
||||
#include "constants/event_bg.h"
|
||||
#include "constants/event_objects.h"
|
||||
#include "constants/maps.h"
|
||||
#include "constants/metatile_behaviors.h"
|
||||
|
||||
void sub_806CA4C(struct FieldInput *input, u16 *newKeys, u16 *heldKeys);
|
||||
bool8 sub_80699D4(void);
|
||||
@@ -60,9 +62,11 @@ bool8 sub_806DB84(u16 metatileBehavior, u8 playerDirection);
|
||||
void SetupWarp(struct MapHeader * mapHeader, s8 warpId, struct MapPosition * position);
|
||||
bool8 IsArrowWarpMetatileBehavior(u16 metatileBehavior, u8 playerDirection);
|
||||
s8 GetWarpEventAtMapPosition(struct MapHeader * mapHeader, struct MapPosition * mapPosition);
|
||||
const u8 *GetCoordEventScriptAtPosition(struct MapHeader * mapHeader, u16 x, u16 y, u8 z);
|
||||
bool8 TryDoorWarp(struct MapPosition * position, u16 metatileBehavior, u8 playerDirection);
|
||||
s8 GetWarpEventAtPosition(struct MapHeader * mapHeader, u16 x, u16 y, u8 z);
|
||||
const u8 *GetCoordEventScriptAtPosition(struct MapHeader * mapHeader, u16 x, u16 y, u8 z);
|
||||
|
||||
u8 gSelectedObjectEvent;
|
||||
struct FieldInput gUnknown_3005078;
|
||||
|
||||
void FieldClearPlayerInput(struct FieldInput *input)
|
||||
@@ -889,3 +893,287 @@ bool8 TryStartWarpEventScript(struct MapPosition *position, u16 metatileBehavior
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 IsWarpMetatileBehavior(u16 metatileBehavior)
|
||||
{
|
||||
if (MetatileBehavior_IsWarpDoor(metatileBehavior) == TRUE)
|
||||
return TRUE;
|
||||
if (MetatileBehavior_IsLadder(metatileBehavior) == TRUE)
|
||||
return TRUE;
|
||||
if (MetatileBehavior_IsEscalator(metatileBehavior) == TRUE)
|
||||
return TRUE;
|
||||
if (MetatileBehavior_IsCaveDoor(metatileBehavior) == TRUE)
|
||||
return TRUE;
|
||||
if (MetatileBehavior_IsLavaridgeB1FWarp(metatileBehavior) == TRUE)
|
||||
return TRUE;
|
||||
if (MetatileBehavior_IsLavaridge1FWarp(metatileBehavior) == TRUE)
|
||||
return TRUE;
|
||||
if (MetatileBehavior_IsWarpPad(metatileBehavior) == TRUE)
|
||||
return TRUE;
|
||||
if (MetatileBehavior_IsFallWarp(metatileBehavior) == TRUE)
|
||||
return TRUE;
|
||||
if (MetatileBehavior_IsUnionRoomWarp(metatileBehavior) == TRUE)
|
||||
return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 sub_806DB84(u16 metatileBehavior, u8 playerDirection)
|
||||
{
|
||||
switch (playerDirection)
|
||||
{
|
||||
case DIR_WEST:
|
||||
if (MetatileBehavior_IsUnknownWarp6D(metatileBehavior))
|
||||
return TRUE;
|
||||
if (MetatileBehavior_IsUnknownWarp6F(metatileBehavior))
|
||||
return TRUE;
|
||||
break;
|
||||
case DIR_EAST:
|
||||
if (MetatileBehavior_IsUnknownWarp6C(metatileBehavior))
|
||||
return TRUE;
|
||||
if (MetatileBehavior_IsUnknownWarp6E(metatileBehavior))
|
||||
return TRUE;
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 IsArrowWarpMetatileBehavior(u16 metatileBehavior, u8 direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case DIR_NORTH:
|
||||
return MetatileBehavior_IsNorthArrowWarp(metatileBehavior);
|
||||
case DIR_SOUTH:
|
||||
return MetatileBehavior_IsSouthArrowWarp(metatileBehavior);
|
||||
case DIR_WEST:
|
||||
return MetatileBehavior_IsWestArrowWarp(metatileBehavior);
|
||||
case DIR_EAST:
|
||||
return MetatileBehavior_IsEastArrowWarp(metatileBehavior);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s8 GetWarpEventAtMapPosition(struct MapHeader *mapHeader, struct MapPosition *position)
|
||||
{
|
||||
return GetWarpEventAtPosition(mapHeader, position->x - 7, position->y - 7, position->height);
|
||||
}
|
||||
|
||||
void SetupWarp(struct MapHeader *unused, s8 warpEventId, struct MapPosition *position)
|
||||
{
|
||||
const struct WarpEvent *warpEvent;
|
||||
|
||||
warpEvent = &gMapHeader.events->warps[warpEventId];
|
||||
|
||||
if (warpEvent->mapNum == MAP_NUM(NONE))
|
||||
{
|
||||
SetWarpDestinationToDynamicWarp(warpEvent->warpId);
|
||||
}
|
||||
else
|
||||
{
|
||||
const struct MapHeader *mapHeader;
|
||||
|
||||
SetWarpDestinationToMapWarp(warpEvent->mapGroup, warpEvent->mapNum, warpEvent->warpId);
|
||||
UpdateEscapeWarp(position->x, position->y);
|
||||
mapHeader = Overworld_GetMapHeaderByGroupAndId(warpEvent->mapGroup, warpEvent->mapNum);
|
||||
if (mapHeader->events->warps[warpEvent->warpId].mapNum == MAP_NUM(NONE))
|
||||
SetDynamicWarp(mapHeader->events->warps[warpEventId].warpId, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, warpEventId);
|
||||
}
|
||||
}
|
||||
|
||||
bool8 TryDoorWarp(struct MapPosition *position, u16 metatileBehavior, u8 direction)
|
||||
{
|
||||
s8 warpEventId;
|
||||
|
||||
if (direction == DIR_NORTH)
|
||||
{
|
||||
if (MetatileBehavior_IsWarpDoor(metatileBehavior) == TRUE)
|
||||
{
|
||||
warpEventId = GetWarpEventAtMapPosition(&gMapHeader, position);
|
||||
if (warpEventId != -1 && IsWarpMetatileBehavior(metatileBehavior) == TRUE)
|
||||
{
|
||||
StoreInitialPlayerAvatarState();
|
||||
SetupWarp(&gMapHeader, warpEventId, position);
|
||||
DoDoorWarp();
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
s8 GetWarpEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation)
|
||||
{
|
||||
s32 i;
|
||||
struct WarpEvent *warpEvent = mapHeader->events->warps;
|
||||
u8 warpCount = mapHeader->events->warpCount;
|
||||
|
||||
for (i = 0; i < warpCount; i++, warpEvent++)
|
||||
{
|
||||
if ((u16)warpEvent->x == x && (u16)warpEvent->y == y)
|
||||
{
|
||||
if (warpEvent->elevation == elevation || warpEvent->elevation == 0)
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
const u8 *TryRunCoordEventScript(struct CoordEvent *coordEvent)
|
||||
{
|
||||
if (coordEvent != NULL)
|
||||
{
|
||||
if (coordEvent->script == NULL)
|
||||
{
|
||||
DoCoordEventWeather(coordEvent->trigger);
|
||||
return NULL;
|
||||
}
|
||||
if (coordEvent->trigger == 0)
|
||||
{
|
||||
ScriptContext2_RunNewScript(coordEvent->script);
|
||||
return NULL;
|
||||
}
|
||||
if (VarGet(coordEvent->trigger) == (u8)coordEvent->index)
|
||||
return coordEvent->script;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const u8 *GetCoordEventScriptAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation)
|
||||
{
|
||||
s32 i;
|
||||
struct CoordEvent *coordEvents = mapHeader->events->coordEvents;
|
||||
u8 coordEventCount = mapHeader->events->coordEventCount;
|
||||
|
||||
for (i = 0; i < coordEventCount; i++)
|
||||
{
|
||||
if ((u16)coordEvents[i].x == x && (u16)coordEvents[i].y == y)
|
||||
{
|
||||
if (coordEvents[i].elevation == elevation || coordEvents[i].elevation == 0)
|
||||
{
|
||||
const u8 *script = TryRunCoordEventScript(&coordEvents[i]);
|
||||
if (script != NULL)
|
||||
return script;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void sub_806DE28(struct ObjectEvent * object)
|
||||
{
|
||||
if (MapGridGetMetatileBehaviorAt(object->currentCoords.x, object->currentCoords.y) == MB_FALL_WARP)
|
||||
{
|
||||
PlaySE(SE_RU_HYUU);
|
||||
// w-why?!
|
||||
RemoveObjectEventByLocalIdAndMap(object->localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup);
|
||||
FlagClear(sub_805FCD8(object->localId, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup));
|
||||
}
|
||||
}
|
||||
|
||||
void sub_806DE70(u16 x, u16 y)
|
||||
{
|
||||
int i;
|
||||
const struct CoordEvent * events = gMapHeader.events->coordEvents;
|
||||
int n = gMapHeader.events->coordEventCount;
|
||||
|
||||
if (MapGridGetMetatileBehaviorAt(x, y) == MB_STRENGTH_BUTTON)
|
||||
{
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
if (events[i].x + 7 == x && events[i].y + 7 == y)
|
||||
{
|
||||
sub_8112364();
|
||||
ScriptContext1_SetupScript(events[i].script);
|
||||
ScriptContext2_Enable();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const u8 *GetCoordEventScriptAtMapPosition(struct MapPosition *position)
|
||||
{
|
||||
return GetCoordEventScriptAtPosition(&gMapHeader, position->x - 7, position->y - 7, position->height);
|
||||
}
|
||||
|
||||
const struct BgEvent *GetBackgroundEventAtPosition(struct MapHeader *mapHeader, u16 x, u16 y, u8 elevation)
|
||||
{
|
||||
u8 i;
|
||||
struct BgEvent *bgEvents = mapHeader->events->bgEvents;
|
||||
u8 bgEventCount = mapHeader->events->bgEventCount;
|
||||
|
||||
for (i = 0; i < bgEventCount; i++)
|
||||
{
|
||||
if ((u16)bgEvents[i].x == x && (u16)bgEvents[i].y == y)
|
||||
{
|
||||
if (bgEvents[i].elevation == elevation || bgEvents[i].elevation == 0)
|
||||
return &bgEvents[i];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool8 dive_warp(struct MapPosition *position, u16 metatileBehavior)
|
||||
{
|
||||
if (gMapHeader.mapType == MAP_TYPE_UNDERWATER && !MetatileBehavior_IsUnableToEmerge(metatileBehavior))
|
||||
{
|
||||
if (SetDiveWarpEmerge(position->x - 7, position->y - 7))
|
||||
{
|
||||
StoreInitialPlayerAvatarState();
|
||||
DoDiveWarp();
|
||||
PlaySE(SE_W291);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
else if (MetatileBehavior_IsDiveable(metatileBehavior) == TRUE)
|
||||
{
|
||||
if (SetDiveWarpDive(position->x - 7, position->y - 7))
|
||||
{
|
||||
StoreInitialPlayerAvatarState();
|
||||
DoDiveWarp();
|
||||
PlaySE(SE_W291);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u8 TrySetDiveWarp(void)
|
||||
{
|
||||
s16 x, y;
|
||||
u8 metatileBehavior;
|
||||
|
||||
PlayerGetDestCoords(&x, &y);
|
||||
metatileBehavior = MapGridGetMetatileBehaviorAt(x, y);
|
||||
if (gMapHeader.mapType == MAP_TYPE_UNDERWATER && !MetatileBehavior_IsUnableToEmerge(metatileBehavior))
|
||||
{
|
||||
if (SetDiveWarpEmerge(x - 7, y - 7) == TRUE)
|
||||
return 1;
|
||||
}
|
||||
else if (MetatileBehavior_IsDiveable(metatileBehavior) == TRUE)
|
||||
{
|
||||
if (SetDiveWarpDive(x - 7, y - 7) == TRUE)
|
||||
return 2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const u8 *GetObjectEventScriptPointerPlayerFacing(void)
|
||||
{
|
||||
u8 direction;
|
||||
struct MapPosition position;
|
||||
|
||||
direction = GetPlayerMovementDirection();
|
||||
GetInFrontOfPlayerPosition(&position);
|
||||
return GetInteractedObjectEventScript(&position, MapGridGetMetatileBehaviorAt(position.x, position.y), direction);
|
||||
}
|
||||
|
||||
int SetCableClubWarp(void)
|
||||
{
|
||||
struct MapPosition position;
|
||||
|
||||
GetPlayerMovementDirection(); //unnecessary
|
||||
GetPlayerPosition(&position);
|
||||
MapGridGetMetatileBehaviorAt(position.x, position.y); //unnecessary
|
||||
SetupWarp(&gMapHeader, GetWarpEventAtMapPosition(&gMapHeader, &position), &position);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -474,7 +474,7 @@ bool8 MetatileBehavior_IsMountain(u8 metatileBehavior)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsDeepOrSemiDeepWater(u8 metatileBehavior)
|
||||
bool8 MetatileBehavior_IsDiveable(u8 metatileBehavior)
|
||||
{
|
||||
if(metatileBehavior >= MB_SEMI_DEEP_WATER && metatileBehavior <= MB_DEEP_WATER)
|
||||
return TRUE;
|
||||
@@ -482,7 +482,7 @@ bool8 MetatileBehavior_IsDeepOrSemiDeepWater(u8 metatileBehavior)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool8 MetatileBehavior_IsMB19(u8 metatileBehavior)
|
||||
bool8 MetatileBehavior_IsUnableToEmerge(u8 metatileBehavior)
|
||||
{
|
||||
if(metatileBehavior == MB_19)
|
||||
return TRUE;
|
||||
|
||||
+1
-1
@@ -4393,7 +4393,7 @@ static void sub_80C527C(u16 mapsec)
|
||||
}
|
||||
else
|
||||
{
|
||||
warp1_set_2(sMapsecToSpawn[idx][0], sMapsecToSpawn[idx][1], -1);
|
||||
SetWarpDestinationToMapWarp(sMapsecToSpawn[idx][0], sMapsecToSpawn[idx][1], -1);
|
||||
}
|
||||
ReturnToFieldFromFlyMapSelect();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user