From 7f5ecd8d0f5f95d284241d83b04a33df2b02322d Mon Sep 17 00:00:00 2001 From: pkmnsnfrn Date: Sun, 11 Aug 2024 19:27:18 -0700 Subject: [PATCH] getobjectfacingdirection --- asm/macros/event.inc | 6 ++++++ data/specials.inc | 1 + src/event_object_movement.c | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/asm/macros/event.inc b/asm/macros/event.inc index da6935ed3c..f29a2dfb06 100644 --- a/asm/macros/event.inc +++ b/asm/macros/event.inc @@ -2392,3 +2392,9 @@ goto_if_eq VAR_RESULT, TRUE, \script .endif .endm + + @ Gets the facing direction of a given event object and stores it in the variable \dest. + .macro getobjectfacingdirection evObjId:req, dest:req + setvar VAR_TEMP_1, \evObjId + specialvar \dest, Script_GetObjectFacingDirection + .endm diff --git a/data/specials.inc b/data/specials.inc index 00a8c54029..5b0aa23ddd 100644 --- a/data/specials.inc +++ b/data/specials.inc @@ -562,3 +562,4 @@ gSpecials:: def_special SetCaughtMon def_special SetMonBall def_special CheckPartyForMon + def_special Script_GetObjectFacingDirection diff --git a/src/event_object_movement.c b/src/event_object_movement.c index e4732cac96..7facbab5c9 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -10632,3 +10632,10 @@ void GetDaycareGraphics(struct ScriptContext *ctx) } gSpecialVar_Result = i; } + +u8 Script_GetObjectFacingDirection(void) +{ + u8 objId = GetObjectEventIdByLocalId(VarGet(VAR_TEMP_1)); + return gObjectEvents[objId].facingDirection; +} +