From a509f28038663b63eaaec88ba665695833db54e9 Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Sat, 14 Sep 2024 06:32:47 -0700 Subject: [PATCH] Changed Scripot_GetObjectFacingDirection to callnative --- asm/macros/event.inc | 11 +++++++++-- data/specials.inc | 1 - src/event_object_movement.c | 5 ----- src/scrcmd.c | 6 ++++++ 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index 73d0d07526..9a99ae3756 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -2421,6 +2421,13 @@ @ Gets the facing direction of a given event object and stores it in the variable \dest. .macro getobjectfacingdirection localId:req, dest:req - setvar VAR_0x8005, \localId - specialvar \dest, Script_GetObjectFacingDirection + callnative Script_GetObjectFacingDirection + .2byte \localId + .byte \dest .endm + + @ .macro checkobjectat x:req, y:req, dest = VAR_RESULT + @ callnative Script_CheckObjectAtXY + @ .2byte \x + @ .2byte \y + @ .2byte \dest diff --git a/data/specials.inc b/data/specials.inc index 8233deda59..f02497d603 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -554,4 +554,3 @@ gSpecials:: def_special Script_GetChosenMonDefensiveEVs def_special Script_GetChosenMonOffensiveIVs def_special Script_GetChosenMonDefensiveIVs - def_special Script_GetObjectFacingDirection diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 646d2323fb..8fa688fdf6 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -10633,8 +10633,3 @@ void GetDaycareGraphics(struct ScriptContext *ctx) gSpecialVar_Result = i; } -u32 Script_GetObjectFacingDirection(void) -{ - return gObjectEvents[GetObjectEventIdByLocalId(gSpecialVar_0x8005)].facingDirection; -} - diff --git a/src/scrcmd.c b/src/scrcmd.c index 974b223f26..fc34720683 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -2520,4 +2520,10 @@ void Script_CheckChosenMonMatchDesiredSpecie(struct ScriptContext *ctx) gSpecialVar_Result = (GetMonData(&gPlayerParty[gSpecialVar_0x8004], MON_DATA_SPECIES) == givenSpecies); } +void Script_GetObjectFacingDirection(struct ScriptContext *ctx) +{ + u32 objectId = VarGet(ScriptReadHalfword(ctx)); + u16 *varPointer = GetVarPointer(ScriptReadHalfword(ctx)); + *varPointer = gObjectEvents[GetObjectEventIdByLocalId(objectId)].facingDirection; +}