Changed GetObjectPosition to callnative

This commit is contained in:
pkmnsnfrn 2024-09-12 18:41:42 -07:00
parent 22b0fdf5c3
commit 10bb349b8c
4 changed files with 36 additions and 36 deletions

View file

@ -2347,21 +2347,21 @@
@ Stores the position of the given object in VAR_0x8007 (x) and VAR_0x8008 (y). Mode CURRENT_POSITION will take the object's current position. Mode TEMPLATE_POSITION will takje the object's template position.
.macro getobjectxy localId:req, posType:req
setvar VAR_0x8000, \localId
setvar VAR_0x8001, \posType
special GetObjectPosition
callnative GetObjectPosition
.2byte \localId
.2byte \posType
.endm
.macro getobjecttemplatexy localId:req
setvar VAR_0x8000, \localId
setvar VAR_0x8001, TEMPLATE_POSITION
special GetObjectPosition
.macro getobjecttemplatexy localId:req, posType = TEMPLATE_POSITION
callnative GetObjectPosition
.2byte \localId
.2byte \posType
.endm
.macro getobjectcurrentxy localId:req
setvar VAR_0x8000, \localId
setvar VAR_0x8001, CURRENT_POSITION
special GetObjectPosition
.macro getobjectcurrentxy localId:req, posType = CURRENT_POSITION
callnative GetObjectPosition
.2byte \localId
.2byte \posType
.endm
@ checks if there is any object at a given position

View file

@ -554,7 +554,6 @@ gSpecials::
def_special Script_GetChosenMonDefensiveEVs
def_special Script_GetChosenMonOffensiveIVs
def_special Script_GetChosenMonDefensiveIVs
def_special GetObjectPosition
def_special CheckObjectAtXY
def_special Script_GetSetPokedexFlag
def_special CheckPartyHasSpecie

View file

@ -4278,30 +4278,6 @@ void PreparePartyForSkyBattle(void)
CompactPartySlots();
}
void GetObjectPosition(void)
{
u32 localId = gSpecialVar_0x8000;
u32 useTemplate = gSpecialVar_0x8001;
u32 objectId;
struct ObjectEvent* objEvent;
u16 *x = &gSpecialVar_0x8007;
u16 *y = &gSpecialVar_0x8008;
if (useTemplate)
{
const struct ObjectEventTemplate *objTemplate = FindObjectEventTemplateByLocalId(localId, gSaveBlock1Ptr->objectEventTemplates, gMapHeader.events->objectEventCount);
*x = objTemplate->x;
*y = objTemplate->y;
return;
}
objectId = GetObjectEventIdByLocalId(localId);
objEvent = &gObjectEvents[objectId];
*x = objEvent->currentCoords.x - 7;
*y = objEvent->currentCoords.y - 7;
}
bool32 CheckObjectAtXY(void)
{
u32 x = gSpecialVar_0x8005 + 7;

View file

@ -2481,3 +2481,28 @@ void RemoveAllItem(struct ScriptContext *ctx)
gSpecialVar_Result = count;
RemoveBagItem(itemId, count);
}
void GetObjectPosition(struct ScriptContext *ctx)
{
u32 localId = VarGet(ScriptReadHalfword(ctx));
u32 useTemplate = gSpecialVar_0x8001;
u32 objectId;
struct ObjectEvent* objEvent;
u16 *x = &gSpecialVar_0x8007;
u16 *y = &gSpecialVar_0x8008;
if (useTemplate)
{
const struct ObjectEventTemplate *objTemplate = FindObjectEventTemplateByLocalId(localId, gSaveBlock1Ptr->objectEventTemplates, gMapHeader.events->objectEventCount);
*x = objTemplate->x;
*y = objTemplate->y;
return;
}
objectId = GetObjectEventIdByLocalId(localId);
objEvent = &gObjectEvents[objectId];
*x = objEvent->currentCoords.x - 7;
*y = objEvent->currentCoords.y - 7;
}