diff --git a/asm/macros/event.inc b/asm/macros/event.inc index b2a2d46159..a4f22f817a 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -2365,10 +2365,11 @@ .endm @ checks if there is any object at a given position - .macro checkobjectat x:req, y:req - setorcopyvar VAR_0x8005, \x - setorcopyvar VAR_0x8006, \y - specialvar VAR_RESULT, CheckObjectAtXY + .macro checkobjectat x:req, y:req, dest = VAR_RESULT + callnative CheckObjectAtXY + .2byte \x + .2byte \y + .2byte \dest .endm @ Checks the state of the Pokédex Seen flag of the specified Pokemon diff --git a/data/specials.inc b/data/specials.inc index 3232dca7af..91fed72d78 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -554,7 +554,6 @@ gSpecials:: def_special Script_GetChosenMonDefensiveEVs def_special Script_GetChosenMonOffensiveIVs def_special Script_GetChosenMonDefensiveIVs - def_special CheckObjectAtXY def_special Script_GetSetPokedexFlag def_special CheckPartyHasSpecie def_special CheckChosenMonMatchDesiredSpecie diff --git a/src/field_specials.c b/src/field_specials.c index 3c27ade570..0f1854b3b5 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -4278,27 +4278,6 @@ void PreparePartyForSkyBattle(void) CompactPartySlots(); } -bool32 CheckObjectAtXY(void) -{ - u32 x = gSpecialVar_0x8005 + 7; - u32 y = gSpecialVar_0x8006 + 7; - u32 i; - - for (i = 0; i < OBJECT_EVENTS_COUNT; i++) - { - if (!gObjectEvents[i].active) - continue; - - if (gObjectEvents[i].currentCoords.x != x) - continue; - - if (gObjectEvents[i].currentCoords.y != y) - continue; - return TRUE; - } - return FALSE; -} - bool32 Script_GetSetPokedexFlag(void) { u32 speciesId = SpeciesToNationalPokedexNum(gSpecialVar_0x8005); diff --git a/src/scrcmd.c b/src/scrcmd.c index 7bcedb89bb..d68e2dbd86 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2485,12 +2485,12 @@ void RemoveAllItem(struct ScriptContext *ctx) void GetObjectPosition(struct ScriptContext *ctx) { u32 localId = VarGet(ScriptReadHalfword(ctx)); - u32 useTemplate = gSpecialVar_0x8001; + u32 useTemplate = VarGet(ScriptReadHalfword(ctx)); + u16 *x = &gSpecialVar_0x8007; + u16 *y = &gSpecialVar_0x8008; u32 objectId; struct ObjectEvent* objEvent; - u16 *x = &gSpecialVar_0x8007; - u16 *y = &gSpecialVar_0x8008; if (useTemplate) { @@ -2506,3 +2506,24 @@ void GetObjectPosition(struct ScriptContext *ctx) *y = objEvent->currentCoords.y - 7; } +bool32 CheckObjectAtXY(struct ScriptContext *ctx) +{ + u32 x = VarGet(ScriptReadHalfword(ctx)) + 7; + u32 y = VarGet(ScriptReadHalfword(ctx)) + 7; + u32 i; + + for (i = 0; i < OBJECT_EVENTS_COUNT; i++) + { + if (!gObjectEvents[i].active) + continue; + + if (gObjectEvents[i].currentCoords.x != x) + continue; + + if (gObjectEvents[i].currentCoords.y != y) + continue; + return TRUE; + } + return FALSE; +} +