Added checkobjectat

This commit is contained in:
pkmnsnfrn 2024-08-10 21:40:57 -07:00
parent 811b5d286e
commit 0784f9fa74
3 changed files with 24 additions and 0 deletions

View File

@ -2334,3 +2334,10 @@
setvar VAR_0x8001, \posType
special GetObjectPosition
.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
.endm

View File

@ -555,3 +555,4 @@ gSpecials::
def_special Script_GetChosenMonOffensiveIVs
def_special Script_GetChosenMonDefensiveIVs
def_special GetObjectPosition
def_special CheckObjectAtXY

View File

@ -4294,3 +4294,19 @@ void GetObjectPosition(void)
*y = objTemplate->y;
}
}
// special to check if there is any object at a given position
u16 CheckObjectAtXY(void)
{
u16 x = gSpecialVar_0x8005 + 7;
u16 y = gSpecialVar_0x8006 + 7;
u32 i;
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
{
if (gObjectEvents[i].active && gObjectEvents[i].currentCoords.x == x && gObjectEvents[i].currentCoords.y == y)
return TRUE;
}
return FALSE;
}