Use EVENT_OBJ_ID_PLAYER in C code

This commit is contained in:
Marcus Huderle
2018-12-28 12:29:21 -06:00
parent 95dcff581b
commit 46d41d2fb9
7 changed files with 32 additions and 27 deletions
+7 -6
View File
@@ -27,6 +27,7 @@
#include "trainer_see.h"
#include "wild_encounter.h"
#include "constants/bg_event_constants.h"
#include "constants/event_objects.h"
#include "constants/map_types.h"
#include "constants/maps.h"
#include "constants/songs.h"
@@ -51,7 +52,7 @@ static bool32 TrySetupDiveDownScript(void);
static bool32 TrySetupDiveEmergeScript(void);
static bool8 TryStartStepBasedScript(struct MapPosition *, u16, u16);
static bool8 CheckStandardWildEncounter(u16);
static bool8 mapheader_run_first_tag2_script_list_match_conditionally(struct MapPosition *, u16, u8);
static bool8 TryArrowWarp(struct MapPosition *, u16, u8);
static bool8 IsWarpMetatileBehavior(u16);
static bool8 IsArrowWarpMetatileBehavior(u16, u8);
static s8 GetWarpEventAtMapPosition(struct MapHeader *, struct MapPosition *);
@@ -161,7 +162,7 @@ int ProcessPlayerFieldInput(struct FieldInput *input)
return TRUE;
if (input->input_field_0_4 && input->dpadDirection == playerDirection)
{
if (mapheader_run_first_tag2_script_list_match_conditionally(&position, metatileBehavior, playerDirection) == TRUE)
if (TryArrowWarp(&position, metatileBehavior, playerDirection) == TRUE)
return TRUE;
}
@@ -266,7 +267,7 @@ const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatil
else
eventObjectId = GetEventObjectIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height);
if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == 0xFF)
if (eventObjectId == EVENT_OBJECTS_COUNT || gEventObjects[eventObjectId].localId == EVENT_OBJ_ID_PLAYER)
return NULL;
for (i = 0; i < 4; i++)
@@ -287,14 +288,14 @@ static const u8 *GetInteractedEventObjectScript(struct MapPosition *position, u8
const u8 *script;
eventObjectId = GetEventObjectIdByXYZ(position->x, position->y, position->height);
if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == 0xFF)
if (eventObjectId == EVENT_OBJECTS_COUNT || gEventObjects[eventObjectId].localId == EVENT_OBJ_ID_PLAYER)
{
if (MetatileBehavior_IsCounter(metatileBehavior) != TRUE)
return NULL;
// Look for an event object on the other side of the counter.
eventObjectId = GetEventObjectIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height);
if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == 0xFF)
if (eventObjectId == EVENT_OBJECTS_COUNT || gEventObjects[eventObjectId].localId == EVENT_OBJ_ID_PLAYER)
return NULL;
}
@@ -686,7 +687,7 @@ static bool8 CheckStandardWildEncounter(u16 metatileBehavior)
return FALSE;
}
static bool8 mapheader_run_first_tag2_script_list_match_conditionally(struct MapPosition *position, u16 metatileBehavior, u8 direction)
static bool8 TryArrowWarp(struct MapPosition *position, u16 metatileBehavior, u8 direction)
{
s8 warpEventId = GetWarpEventAtMapPosition(&gMapHeader, position);