Modified getobjectxy to allow for custom destinations
This commit is contained in:
parent
1665423e52
commit
60fb0b34fd
4 changed files with 19 additions and 15 deletions
|
@ -2345,23 +2345,29 @@
|
|||
.2byte \itemId
|
||||
.endm
|
||||
|
||||
@ 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 take the object's template position.
|
||||
.macro getobjectxy localId:req, posType:req
|
||||
@ Stores the position of the given object in destX and destY. Mode CURRENT_POSITION will take the object's current position. Mode TEMPLATE_POSITION will take the object's template position.
|
||||
.macro getobjectxy localId:req, posType:req, destX:req, destY:req
|
||||
callnative ScrCmd_getobjectxy
|
||||
.2byte \localId
|
||||
.2byte \posType
|
||||
.2byte \destX
|
||||
.2byte \destY
|
||||
.endm
|
||||
|
||||
.macro getobjecttemplatexy localId:req, posType = TEMPLATE_POSITION
|
||||
.macro getobjecttemplatexy localId:req, posType = TEMPLATE_POSITION, destX:req, destY:req
|
||||
callnative ScrCmd_getobjectxy
|
||||
.2byte \localId
|
||||
.2byte \posType
|
||||
.2byte \destX
|
||||
.2byte \destY
|
||||
.endm
|
||||
|
||||
.macro getobjectcurrentxy localId:req, posType = CURRENT_POSITION
|
||||
.macro getobjectcurrentxy localId:req, posType = CURRENT_POSITION, destX:req, destY:req
|
||||
callnative ScrCmd_getobjectxy
|
||||
.2byte \localId
|
||||
.2byte \posType
|
||||
.2byte \destX
|
||||
.2byte \destY
|
||||
.endm
|
||||
|
||||
@ Return TRUE to dest if there is an object at the position x and y.
|
||||
|
|
|
@ -33,7 +33,7 @@ void ResetFanClub(void);
|
|||
bool8 ShouldShowBoxWasFullMessage(void);
|
||||
void SetPCBoxToSendMon(u8 boxId);
|
||||
void PreparePartyForSkyBattle(void);
|
||||
void GetObjectPosition(u32, u32);
|
||||
void GetObjectPosition(u16*, u16*, u32, u32);
|
||||
bool32 CheckObjectAtXY(u32, u32);
|
||||
bool32 CheckPartyHasSpecie(u32);
|
||||
|
||||
|
|
|
@ -4278,26 +4278,23 @@ void PreparePartyForSkyBattle(void)
|
|||
CompactPartySlots();
|
||||
}
|
||||
|
||||
void GetObjectPosition(u32 localId, u32 useTemplate)
|
||||
void GetObjectPosition(u16* xPointer, u16* yPointer, u32 localId, u32 useTemplate)
|
||||
{
|
||||
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;
|
||||
*xPointer = objTemplate->x;
|
||||
*yPointer = objTemplate->y;
|
||||
return;
|
||||
}
|
||||
|
||||
objectId = GetObjectEventIdByLocalId(localId);
|
||||
objEvent = &gObjectEvents[objectId];
|
||||
*x = objEvent->currentCoords.x - 7;
|
||||
*y = objEvent->currentCoords.y - 7;
|
||||
*xPointer = objEvent->currentCoords.x - 7;
|
||||
*yPointer = objEvent->currentCoords.y - 7;
|
||||
}
|
||||
|
||||
bool32 CheckObjectAtXY(u32 x, u32 y)
|
||||
|
|
|
@ -2489,8 +2489,9 @@ bool8 ScrCmd_getobjectxy(struct ScriptContext *ctx)
|
|||
{
|
||||
u32 localId = VarGet(ScriptReadHalfword(ctx));
|
||||
u32 useTemplate = VarGet(ScriptReadHalfword(ctx));
|
||||
|
||||
GetObjectPosition(localId,useTemplate);
|
||||
u16 *pX = GetVarPointer(ScriptReadHalfword(ctx));
|
||||
u16 *pY = GetVarPointer(ScriptReadHalfword(ctx));
|
||||
GetObjectPosition(pX,pY,localId,useTemplate);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue