Distinguish 'virtual object' names from object events

This commit is contained in:
GriffinR 2021-11-17 23:28:43 -05:00
parent 1b35f9adad
commit b5b5d95de6
13 changed files with 205 additions and 187 deletions

View File

@ -1016,7 +1016,7 @@
@ Converts STR_VAR_1, STR_VAR_2, or STR_VAR_3 to its corresponding index into sScriptStringVars (0, 1, or 2). @ Converts STR_VAR_1, STR_VAR_2, or STR_VAR_3 to its corresponding index into sScriptStringVars (0, 1, or 2).
@ If given anything else it will output it directly. @ If given anything else it will output it directly.
@ Note: because the STR_VAR_# arguments given to this macro are not part of a processed string they are not @ Note: Because the STR_VAR_# arguments given to this macro are not part of a processed string they are not
@ replaced with their charmap values, they are just passed as the literal characters "STR_VAR_#". @ replaced with their charmap values, they are just passed as the literal characters "STR_VAR_#".
.macro stringvar id:req .macro stringvar id:req
.if \id == STR_VAR_1 .if \id == STR_VAR_1
@ -1237,9 +1237,10 @@
.byte \level .byte \level
.endm .endm
.macro messageautoscroll pointer:req @ Automatically scrolls through the message without player input and at a fixed speed.
.macro messageautoscroll text:req
.byte 0x9b .byte 0x9b
.4byte \pointer .4byte \text
.endm .endm
@ Executes the specified field effect animation (FLDEFF_*). @ Executes the specified field effect animation (FLDEFF_*).
@ -1334,19 +1335,23 @@
map \map map \map
.endm .endm
.macro createvobject sprite:req, byte2:req, x:req, y:req, elevation, direction @ Creates a sprite with object graphics. Used when creating large groups of static NPCs that exceed
@ the object event limit (e.g. Contest / Battle Dome audiences and Union Room group members).
@ The specified id can be used to refer to the sprite again later with turnvobject.
.macro createvobject graphicsId:req, id:req, x:req, y:req, elevation=3, direction=DIR_SOUTH
.byte 0xaa .byte 0xaa
.byte \sprite .byte \graphicsId
.byte \byte2 .byte \id
.2byte \x .2byte \x
.2byte \y .2byte \y
.byte \elevation .byte \elevation
.byte \direction .byte \direction
.endm .endm
.macro turnvobject index:req, direction:req @ Turns a sprite created with createvobject.
.macro turnvobject id:req, direction:req
.byte 0xab .byte 0xab
.byte \index .byte \id
.byte \direction .byte \direction
.endm .endm
@ -1515,7 +1520,7 @@
.byte 0xc5 .byte 0xc5
.endm .endm
@ Writes the name of the specified (box) PC box to the specified buffer. @ Writes the name of the specified PC box to the specified buffer.
.macro bufferboxname stringVarId:req, box:req .macro bufferboxname stringVarId:req, box:req
.byte 0xc6 .byte 0xc6
stringvar \stringVarId stringvar \stringVarId
@ -1627,10 +1632,13 @@
formatwarp \map, \a, \b, \c formatwarp \map, \a, \b, \c
.endm .endm
@ Sets the selected object to the id of the currently approaching trainer.
.macro selectapproachingtrainer .macro selectapproachingtrainer
.byte 0xd8 .byte 0xd8
.endm .endm
@ Freezes all objects immediately except the player and the approaching trainers.
@ The player and trainers are frozen once their movement is finished.
.macro lockfortrainer .macro lockfortrainer
.byte 0xd9 .byte 0xd9
.endm .endm
@ -1640,9 +1648,11 @@
.byte 0xda .byte 0xda
.endm .endm
.macro messageinstant pointer:req @ Prints and draws the message all at once rather than character by character.
@ Does not wait for player input to continue.
.macro messageinstant text:req
.byte 0xdb .byte 0xdb
.4byte \pointer .4byte \text
.endm .endm
.macro fadescreenswapbuffers mode:req .macro fadescreenswapbuffers mode:req

View File

@ -529,76 +529,76 @@ BattleFrontier_BattleDomeBattleRoom_EventScript_AddRound1Audience::
return return
BattleFrontier_BattleDomeBattleRoom_EventScript_AddRound2Audience:: BattleFrontier_BattleDomeBattleRoom_EventScript_AddRound2Audience::
createvobject OBJ_EVENT_GFX_SCIENTIST_1, 1, 3, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCIENTIST_1, 1, 3, 0
createvobject OBJ_EVENT_GFX_EXPERT_F, 4, 6, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_EXPERT_F, 4, 6, 0
createvobject OBJ_EVENT_GFX_NINJA_BOY, 6, 8, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_NINJA_BOY, 6, 8, 0
createvobject OBJ_EVENT_GFX_LITTLE_GIRL, 9, 11, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_LITTLE_GIRL, 9, 11, 0
createvobject OBJ_EVENT_GFX_SCIENTIST_1, 11, 13, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCIENTIST_1, 11, 13, 0
createvobject OBJ_EVENT_GFX_MAN_5, 13, 15, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_MAN_5, 13, 15, 0
createvobject OBJ_EVENT_GFX_BEAUTY, 19, 7, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_BEAUTY, 19, 7, 1
createvobject OBJ_EVENT_GFX_WOMAN_5, 22, 11, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_WOMAN_5, 22, 11, 1
createvobject OBJ_EVENT_GFX_LITTLE_BOY, 25, 15, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_LITTLE_BOY, 25, 15, 1
createvobject OBJ_EVENT_GFX_YOUNGSTER, 26, 2, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_YOUNGSTER, 26, 2, 2
createvobject OBJ_EVENT_GFX_SCHOOL_KID_M, 29, 5, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCHOOL_KID_M, 29, 5, 1
return return
BattleFrontier_BattleDomeBattleRoom_EventScript_AddSemifinalAudience:: BattleFrontier_BattleDomeBattleRoom_EventScript_AddSemifinalAudience::
createvobject OBJ_EVENT_GFX_SCIENTIST_1, 1, 3, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCIENTIST_1, 1, 3, 0
createvobject OBJ_EVENT_GFX_EXPERT_F, 4, 6, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_EXPERT_F, 4, 6, 0
createvobject OBJ_EVENT_GFX_NINJA_BOY, 6, 8, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_NINJA_BOY, 6, 8, 0
createvobject OBJ_EVENT_GFX_WOMAN_2, 7, 9, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_WOMAN_2, 7, 9, 0
createvobject OBJ_EVENT_GFX_LITTLE_GIRL, 9, 11, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_LITTLE_GIRL, 9, 11, 0
createvobject OBJ_EVENT_GFX_LASS, 10, 12, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_LASS, 10, 12, 0
createvobject OBJ_EVENT_GFX_SCIENTIST_1, 11, 13, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCIENTIST_1, 11, 13, 0
createvobject OBJ_EVENT_GFX_MAN_5, 13, 15, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_MAN_5, 13, 15, 0
createvobject OBJ_EVENT_GFX_GENTLEMAN, 15, 2, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_GENTLEMAN, 15, 2, 1
createvobject OBJ_EVENT_GFX_NINJA_BOY, 16, 3, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_NINJA_BOY, 16, 3, 1
createvobject OBJ_EVENT_GFX_WOMAN_2, 17, 4, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_WOMAN_2, 17, 4, 1
createvobject OBJ_EVENT_GFX_BEAUTY, 19, 7, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_BEAUTY, 19, 7, 1
createvobject OBJ_EVENT_GFX_EXPERT_F, 20, 9, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_EXPERT_F, 20, 9, 1
createvobject OBJ_EVENT_GFX_WOMAN_5, 22, 11, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_WOMAN_5, 22, 11, 1
createvobject OBJ_EVENT_GFX_SCIENTIST_1, 23, 13, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCIENTIST_1, 23, 13, 1
createvobject OBJ_EVENT_GFX_LITTLE_BOY, 25, 15, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_LITTLE_BOY, 25, 15, 1
createvobject OBJ_EVENT_GFX_YOUNGSTER, 26, 2, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_YOUNGSTER, 26, 2, 2
createvobject OBJ_EVENT_GFX_HEX_MANIAC, 28, 5, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_HEX_MANIAC, 28, 5, 2
createvobject OBJ_EVENT_GFX_SCHOOL_KID_M, 29, 5, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCHOOL_KID_M, 29, 5, 1
createvobject OBJ_EVENT_GFX_MART_EMPLOYEE, 30, 6, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_MART_EMPLOYEE, 30, 6, 2
createvobject OBJ_EVENT_GFX_WOMAN_5, 31, 8, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_WOMAN_5, 31, 8, 2
return return
BattleFrontier_BattleDomeBattleRoom_EventScript_AddFinalAudience:: BattleFrontier_BattleDomeBattleRoom_EventScript_AddFinalAudience::
createvobject OBJ_EVENT_GFX_NINJA_BOY, 0, 2, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_NINJA_BOY, 0, 2, 0
createvobject OBJ_EVENT_GFX_SCIENTIST_1, 1, 3, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCIENTIST_1, 1, 3, 0
createvobject OBJ_EVENT_GFX_BEAUTY, 2, 15, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_BEAUTY, 2, 15, 0
createvobject OBJ_EVENT_GFX_MAN_5, 3, 5, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_MAN_5, 3, 5, 0
createvobject OBJ_EVENT_GFX_EXPERT_F, 4, 6, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_EXPERT_F, 4, 6, 0
createvobject OBJ_EVENT_GFX_SCIENTIST_1, 5, 7, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCIENTIST_1, 5, 7, 0
createvobject OBJ_EVENT_GFX_NINJA_BOY, 6, 8, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_NINJA_BOY, 6, 8, 0
createvobject OBJ_EVENT_GFX_WOMAN_2, 7, 9, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_WOMAN_2, 7, 9, 0
createvobject OBJ_EVENT_GFX_WOMAN_3, 8, 10, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_WOMAN_3, 8, 10, 0
createvobject OBJ_EVENT_GFX_LITTLE_GIRL, 9, 11, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_LITTLE_GIRL, 9, 11, 0
createvobject OBJ_EVENT_GFX_LASS, 10, 12, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_LASS, 10, 12, 0
createvobject OBJ_EVENT_GFX_SCIENTIST_1, 11, 13, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCIENTIST_1, 11, 13, 0
createvobject OBJ_EVENT_GFX_BEAUTY, 12, 14, 0, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_BEAUTY, 12, 14, 0
createvobject OBJ_EVENT_GFX_MAN_5, 13, 15, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_MAN_5, 13, 15, 2
createvobject OBJ_EVENT_GFX_HIKER, 14, 12, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_HIKER, 14, 12, 2
createvobject OBJ_EVENT_GFX_GENTLEMAN, 15, 2, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_GENTLEMAN, 15, 2, 1
createvobject OBJ_EVENT_GFX_NINJA_BOY, 16, 3, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_NINJA_BOY, 16, 3, 1
createvobject OBJ_EVENT_GFX_WOMAN_2, 17, 4, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_WOMAN_2, 17, 4, 1
createvobject OBJ_EVENT_GFX_WOMAN_3, 18, 6, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_WOMAN_3, 18, 6, 1
createvobject OBJ_EVENT_GFX_BEAUTY, 19, 7, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_BEAUTY, 19, 7, 1
createvobject OBJ_EVENT_GFX_EXPERT_F, 20, 9, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_EXPERT_F, 20, 9, 1
createvobject OBJ_EVENT_GFX_MAN_2, 21, 10, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_MAN_2, 21, 10, 1
createvobject OBJ_EVENT_GFX_WOMAN_5, 22, 11, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_WOMAN_5, 22, 11, 1
createvobject OBJ_EVENT_GFX_SCIENTIST_1, 23, 13, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCIENTIST_1, 23, 13, 1
createvobject OBJ_EVENT_GFX_GENTLEMAN, 24, 14, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_GENTLEMAN, 24, 14, 1
createvobject OBJ_EVENT_GFX_LITTLE_BOY, 25, 15, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_LITTLE_BOY, 25, 15, 1
createvobject OBJ_EVENT_GFX_YOUNGSTER, 26, 2, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_YOUNGSTER, 26, 2, 2
createvobject OBJ_EVENT_GFX_FAT_MAN, 27, 3, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_FAT_MAN, 27, 3, 2
createvobject OBJ_EVENT_GFX_HEX_MANIAC, 28, 5, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_HEX_MANIAC, 28, 5, 2
createvobject OBJ_EVENT_GFX_SCHOOL_KID_M, 29, 5, 1, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_SCHOOL_KID_M, 29, 5, 1
createvobject OBJ_EVENT_GFX_MART_EMPLOYEE, 30, 6, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_MART_EMPLOYEE, 30, 6, 2
createvobject OBJ_EVENT_GFX_WOMAN_5, 31, 8, 2, 3, DIR_SOUTH createvobject OBJ_EVENT_GFX_WOMAN_5, 31, 8, 2
return return
BattleFrontier_BattleDomeBattleRoom_Movement_SetInvisible: BattleFrontier_BattleDomeBattleRoom_Movement_SetInvisible:

View File

@ -96,8 +96,7 @@ void SetSpritePosToOffsetMapCoords(s16 *, s16 *, s16, s16);
void ObjectEventClearHeldMovement(struct ObjectEvent *); void ObjectEventClearHeldMovement(struct ObjectEvent *);
void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *); void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *);
void TrySpawnObjectEvents(s16, s16); void TrySpawnObjectEvents(s16, s16);
u8 CreateObjectSprite(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction); u8 CreateObjectGraphicsSprite(u16, void (*)(struct Sprite *), s16 x, s16 y, u8 subpriority);
u8 AddPseudoObjectEvent(u16, void (*)(struct Sprite *), s16 x, s16 y, u8 subpriority);
u8 TrySpawnObjectEvent(u8, u8, u8); u8 TrySpawnObjectEvent(u8, u8, u8);
u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 z); u8 SpawnSpecialObjectEventParameterized(u8 graphicsId, u8 movementBehavior, u8 localId, s16 x, s16 y, u8 z);
u8 SpawnSpecialObjectEvent(struct ObjectEventTemplate *); u8 SpawnSpecialObjectEvent(struct ObjectEventTemplate *);
@ -180,7 +179,6 @@ void SetAndStartSpriteAnim(struct Sprite *, u8, u8);
bool8 SpriteAnimEnded(struct Sprite *); bool8 SpriteAnimEnded(struct Sprite *);
void UnfreezeObjectEvents(void); void UnfreezeObjectEvents(void);
void FreezeObjectEventsExceptOne(u8 objectEventId); void FreezeObjectEventsExceptOne(u8 objectEventId);
void TurnObjectEventSprite(u8, u8);
void FreezeObjectEventsExceptTwo(u8 objectEventId1, u8 objectEventId2); void FreezeObjectEventsExceptTwo(u8 objectEventId1, u8 objectEventId2);
void FreezeObjectEvents(void); void FreezeObjectEvents(void);
bool8 FreezeObjectEvent(struct ObjectEvent *objectEvent); bool8 FreezeObjectEvent(struct ObjectEvent *objectEvent);
@ -414,10 +412,13 @@ u8 MovementType_RunInPlace_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementType_Invisible_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementType_Invisible_Step0(struct ObjectEvent *, struct Sprite *);
u8 MovementType_Invisible_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementType_Invisible_Step1(struct ObjectEvent *, struct Sprite *);
u8 MovementType_Invisible_Step2(struct ObjectEvent *, struct Sprite *); u8 MovementType_Invisible_Step2(struct ObjectEvent *, struct Sprite *);
void SetObjectEventSpriteInvisibility(u8 objectEventId, bool32 invisible);
bool32 IsObjectEventSpriteInvisible(u8 objectEventId); u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 z, u8 direction);
void SetObjectEventSpriteGraphics(u8 objectEventId, u8 graphicsId); void TurnVirtualObject(u8 virtualObjId, u8 direction);
void SetObjectEventSpriteAnim(u8 objectEventId, u8 animNum); void SetVirtualObjectGraphics(u8 virtualObjId, u8 graphicsId);
bool32 IsObjectEventSpriteAnimating(u8 objectEventId); void SetVirtualObjectInvisibility(u8 virtualObjId, bool32 invisible);
bool32 IsVirtualObjectInvisible(u8 virtualObjId);
void SetVirtualObjectSpriteAnim(u8 virtualObjId, u8 animNum);
bool32 IsVirtualObjectAnimating(u8 virtualObjId);
#endif //GUARD_EVENT_OBJECT_MOVEMENT_H #endif //GUARD_EVENT_OBJECT_MOVEMENT_H

View File

@ -826,7 +826,7 @@ static void CreateCableCarSprites(void)
case FALSE: case FALSE:
default: default:
// Create player sprite // Create player sprite
spriteId = AddPseudoObjectEvent(playerGraphicsIds[gSaveBlock2Ptr->playerGender], SpriteCB_Player, 200, 73, 102); spriteId = CreateObjectGraphicsSprite(playerGraphicsIds[gSaveBlock2Ptr->playerGender], SpriteCB_Player, 200, 73, 102);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
{ {
gSprites[spriteId].oam.priority = 2; gSprites[spriteId].oam.priority = 2;
@ -854,7 +854,7 @@ static void CreateCableCarSprites(void)
case TRUE: case TRUE:
CopyToBgTilemapBufferRect_ChangePalette(0, sCableCar->groundTilemap + 0x24, 24, 26, 12, 3, 17); CopyToBgTilemapBufferRect_ChangePalette(0, sCableCar->groundTilemap + 0x24, 24, 26, 12, 3, 17);
// Create player sprite // Create player sprite
spriteId = AddPseudoObjectEvent(playerGraphicsIds[gSaveBlock2Ptr->playerGender], SpriteCB_Player, 128, 39, 102); spriteId = CreateObjectGraphicsSprite(playerGraphicsIds[gSaveBlock2Ptr->playerGender], SpriteCB_Player, 128, 39, 102);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
{ {
gSprites[spriteId].oam.priority = 2; gSprites[spriteId].oam.priority = 2;
@ -891,7 +891,7 @@ static void CreateCableCarSprites(void)
if ((rval % 64) == 0) if ((rval % 64) == 0)
{ {
// Unclear if this was intentional, but the - 1 in the below ARRAY_COUNT means the Zigzagoon is never used // Unclear if this was intentional, but the - 1 in the below ARRAY_COUNT means the Zigzagoon is never used
spriteId = AddPseudoObjectEvent(hikerGraphicsIds[rval % (ARRAY_COUNT(hikerGraphicsIds) - 1)], hikerCallbacks[GOING_DOWN], hikerCoords[GOING_DOWN][0], hikerCoords[GOING_DOWN][1], 106); spriteId = CreateObjectGraphicsSprite(hikerGraphicsIds[rval % (ARRAY_COUNT(hikerGraphicsIds) - 1)], hikerCallbacks[GOING_DOWN], hikerCoords[GOING_DOWN][0], hikerCoords[GOING_DOWN][1], 106);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
{ {
gSprites[spriteId].oam.priority = 2; gSprites[spriteId].oam.priority = 2;

View File

@ -1395,9 +1395,9 @@ static void SetUpPlacingDecorationPlayerAvatar(u8 taskId, struct PlaceDecoration
x -= 8; x -= 8;
if (gSaveBlock2Ptr->playerGender == MALE) if (gSaveBlock2Ptr->playerGender == MALE)
sDecor_CameraSpriteObjectIdx2 = AddPseudoObjectEvent(OBJ_EVENT_GFX_BRENDAN_DECORATING, SpriteCallbackDummy, x, 72, 0); sDecor_CameraSpriteObjectIdx2 = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_BRENDAN_DECORATING, SpriteCallbackDummy, x, 72, 0);
else else
sDecor_CameraSpriteObjectIdx2 = AddPseudoObjectEvent(OBJ_EVENT_GFX_MAY_DECORATING, SpriteCallbackDummy, x, 72, 0); sDecor_CameraSpriteObjectIdx2 = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_MAY_DECORATING, SpriteCallbackDummy, x, 72, 0);
gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1; gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1;
DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]); DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]);
@ -2027,7 +2027,7 @@ static u8 gpu_pal_decompress_alloc_tag_and_upload(struct PlaceDecorationGraphics
ClearPlaceDecorationGraphicsDataBuffer(data); ClearPlaceDecorationGraphicsDataBuffer(data);
data->decoration = &gDecorations[decor]; data->decoration = &gDecorations[decor];
if (data->decoration->permission == DECORPERM_SPRITE) if (data->decoration->permission == DECORPERM_SPRITE)
return AddPseudoObjectEvent(data->decoration->tiles[0], SpriteCallbackDummy, 0, 0, 1); return CreateObjectGraphicsSprite(data->decoration->tiles[0], SpriteCallbackDummy, 0, 0, 1);
FreeSpritePaletteByTag(PLACE_DECORATION_SELECTOR_TAG); FreeSpritePaletteByTag(PLACE_DECORATION_SELECTOR_TAG);
SetDecorSelectionMetatiles(data); SetDecorSelectionMetatiles(data);
@ -2106,7 +2106,7 @@ static u8 AddDecorationIconObjectFromObjectEvent(u16 tilesTag, u16 paletteTag, u
} }
else else
{ {
spriteId = AddPseudoObjectEvent(sPlaceDecorationGraphicsDataBuffer.decoration->tiles[0], SpriteCallbackDummy, 0, 0, 1); spriteId = CreateObjectGraphicsSprite(sPlaceDecorationGraphicsDataBuffer.decoration->tiles[0], SpriteCallbackDummy, 0, 0, 1);
} }
return spriteId; return spriteId;
} }
@ -2285,9 +2285,9 @@ static void SetUpPuttingAwayDecorationPlayerAvatar(void)
LoadPlayerSpritePalette(); LoadPlayerSpritePalette();
gFieldCamera.spriteId = CreateSprite(&sPuttingAwayCursorSpriteTemplate, 120, 80, 0); gFieldCamera.spriteId = CreateSprite(&sPuttingAwayCursorSpriteTemplate, 120, 80, 0);
if (gSaveBlock2Ptr->playerGender == MALE) if (gSaveBlock2Ptr->playerGender == MALE)
sDecor_CameraSpriteObjectIdx2 = AddPseudoObjectEvent(OBJ_EVENT_GFX_BRENDAN_DECORATING, SpriteCallbackDummy, 136, 72, 0); sDecor_CameraSpriteObjectIdx2 = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_BRENDAN_DECORATING, SpriteCallbackDummy, 136, 72, 0);
else else
sDecor_CameraSpriteObjectIdx2 = AddPseudoObjectEvent(OBJ_EVENT_GFX_MAY_DECORATING, SpriteCallbackDummy, 136, 72, 0); sDecor_CameraSpriteObjectIdx2 = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_MAY_DECORATING, SpriteCallbackDummy, 136, 72, 0);
gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1; gSprites[sDecor_CameraSpriteObjectIdx2].oam.priority = 1;
DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]); DestroySprite(&gSprites[sDecor_CameraSpriteObjectIdx1]);

View File

@ -5011,7 +5011,7 @@ static void TryAddInterviewObjectEvents(void)
return; return;
// Add object for reporter/interviewing fan (facing left) // Add object for reporter/interviewing fan (facing left)
spriteId = AddPseudoObjectEvent(graphicsId, SpriteCallbackDummy, 76, 40, 0); spriteId = CreateObjectGraphicsSprite(graphicsId, SpriteCallbackDummy, 76, 40, 0);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
{ {
gSprites[spriteId].oam.priority = 0; gSprites[spriteId].oam.priority = 0;
@ -5019,7 +5019,7 @@ static void TryAddInterviewObjectEvents(void)
} }
// Add object for player (facing right) // Add object for player (facing right)
spriteId = AddPseudoObjectEvent( spriteId = CreateObjectGraphicsSprite(
gSaveBlock2Ptr->playerGender == MALE ? OBJ_EVENT_GFX_RIVAL_BRENDAN_NORMAL : OBJ_EVENT_GFX_RIVAL_MAY_NORMAL, gSaveBlock2Ptr->playerGender == MALE ? OBJ_EVENT_GFX_RIVAL_BRENDAN_NORMAL : OBJ_EVENT_GFX_RIVAL_MAY_NORMAL,
SpriteCallbackDummy, SpriteCallbackDummy,
52, 52,

View File

@ -114,7 +114,7 @@ static void DoRippleFieldEffect(struct ObjectEvent*, struct Sprite*);
static void DoGroundEffects_OnSpawn(struct ObjectEvent*, struct Sprite*); static void DoGroundEffects_OnSpawn(struct ObjectEvent*, struct Sprite*);
static void DoGroundEffects_OnBeginStep(struct ObjectEvent*, struct Sprite*); static void DoGroundEffects_OnBeginStep(struct ObjectEvent*, struct Sprite*);
static void DoGroundEffects_OnFinishStep(struct ObjectEvent*, struct Sprite*); static void DoGroundEffects_OnFinishStep(struct ObjectEvent*, struct Sprite*);
static void UpdateObjectEventSpritePosition(struct Sprite*); static void VirtualObject_UpdateAnim(struct Sprite*);
static void ApplyLevitateMovement(u8); static void ApplyLevitateMovement(u8);
static bool8 MovementType_Disguise_Callback(struct ObjectEvent *, struct Sprite *); static bool8 MovementType_Disguise_Callback(struct ObjectEvent *, struct Sprite *);
static bool8 MovementType_Buried_Callback(struct ObjectEvent *, struct Sprite *); static bool8 MovementType_Buried_Callback(struct ObjectEvent *, struct Sprite *);
@ -126,7 +126,7 @@ static void SetObjectEventDynamicGraphicsId(struct ObjectEvent *);
static void RemoveObjectEventInternal(struct ObjectEvent *); static void RemoveObjectEventInternal(struct ObjectEvent *);
static u16 GetObjectEventFlagIdByObjectEventId(u8); static u16 GetObjectEventFlagIdByObjectEventId(u8);
static void UpdateObjectEventVisibility(struct ObjectEvent *, struct Sprite *); static void UpdateObjectEventVisibility(struct ObjectEvent *, struct Sprite *);
static void MakeObjectTemplateFromObjectEventTemplate(struct ObjectEventTemplate *, struct SpriteTemplate *, const struct SubspriteTable **); static void MakeSpriteTemplateFromObjectEventTemplate(struct ObjectEventTemplate *, struct SpriteTemplate *, const struct SubspriteTable **);
static void GetObjectEventMovingCameraOffset(s16 *, s16 *); static void GetObjectEventMovingCameraOffset(s16 *, s16 *);
static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8); static struct ObjectEventTemplate *GetObjectEventTemplateByLocalIdAndMap(u8, u8, u8);
static void LoadObjectEventPalette(u16); static void LoadObjectEventPalette(u16);
@ -148,7 +148,7 @@ static void ObjectEventSetSingleMovement(struct ObjectEvent *, struct Sprite *,
static void SetSpriteDataForNormalStep(struct Sprite *, u8, u8); static void SetSpriteDataForNormalStep(struct Sprite *, u8, u8);
static void InitSpriteForFigure8Anim(struct Sprite *sprite); static void InitSpriteForFigure8Anim(struct Sprite *sprite);
static bool8 AnimateSpriteInFigure8(struct Sprite *sprite); static bool8 AnimateSpriteInFigure8(struct Sprite *sprite);
static void UpdateObjectEventSprite(struct Sprite *); static void SpriteCB_VirtualObject(struct Sprite *);
static void DoShadowFieldEffect(struct ObjectEvent *); static void DoShadowFieldEffect(struct ObjectEvent *);
static void SetJumpSpriteData(struct Sprite *, u8, u8, u8); static void SetJumpSpriteData(struct Sprite *, u8, u8, u8);
static void SetWalkSlowSpriteData(struct Sprite *sprite, u8 direction); static void SetWalkSlowSpriteData(struct Sprite *sprite, u8 direction);
@ -1442,7 +1442,7 @@ static u8 TrySpawnObjectEventTemplate(struct ObjectEventTemplate *objectEventTem
const struct SubspriteTable *subspriteTables = NULL; const struct SubspriteTable *subspriteTables = NULL;
graphicsInfo = GetObjectEventGraphicsInfo(objectEventTemplate->graphicsId); graphicsInfo = GetObjectEventGraphicsInfo(objectEventTemplate->graphicsId);
MakeObjectTemplateFromObjectEventTemplate(objectEventTemplate, &spriteTemplate, &subspriteTables); MakeSpriteTemplateFromObjectEventTemplate(objectEventTemplate, &spriteTemplate, &subspriteTables);
spriteFrameImage.size = graphicsInfo->size; spriteFrameImage.size = graphicsInfo->size;
spriteTemplate.images = &spriteFrameImage; spriteTemplate.images = &spriteFrameImage;
objectEventId = TrySetupObjectEventSprite(objectEventTemplate, &spriteTemplate, mapNum, mapGroup, cameraX, cameraY); objectEventId = TrySetupObjectEventSprite(objectEventTemplate, &spriteTemplate, mapNum, mapGroup, cameraX, cameraY);
@ -1498,7 +1498,7 @@ u8 TrySpawnObjectEvent(u8 localId, u8 mapNum, u8 mapGroup)
return TrySpawnObjectEventTemplate(objectEventTemplate, mapNum, mapGroup, cameraX, cameraY); return TrySpawnObjectEventTemplate(objectEventTemplate, mapNum, mapGroup, cameraX, cameraY);
} }
static void MakeObjectTemplateFromObjectEventGraphicsInfo(u16 graphicsId, void (*callback)(struct Sprite *), struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) static void CopyObjectGraphicsInfoToSpriteTemplate(u16 graphicsId, void (*callback)(struct Sprite *), struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables)
{ {
const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(graphicsId); const struct ObjectEventGraphicsInfo *graphicsInfo = GetObjectEventGraphicsInfo(graphicsId);
@ -1512,17 +1512,18 @@ static void MakeObjectTemplateFromObjectEventGraphicsInfo(u16 graphicsId, void (
*subspriteTables = graphicsInfo->subspriteTables; *subspriteTables = graphicsInfo->subspriteTables;
} }
static void MakeObjectTemplateFromObjectEventGraphicsInfoWithCallbackIndex(u16 graphicsId, u16 callbackIndex, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) static void CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(u16 graphicsId, u16 movementType, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables)
{ {
MakeObjectTemplateFromObjectEventGraphicsInfo(graphicsId, sMovementTypeCallbacks[callbackIndex], spriteTemplate, subspriteTables); CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, sMovementTypeCallbacks[movementType], spriteTemplate, subspriteTables);
} }
static void MakeObjectTemplateFromObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables) static void MakeSpriteTemplateFromObjectEventTemplate(struct ObjectEventTemplate *objectEventTemplate, struct SpriteTemplate *spriteTemplate, const struct SubspriteTable **subspriteTables)
{ {
MakeObjectTemplateFromObjectEventGraphicsInfoWithCallbackIndex(objectEventTemplate->graphicsId, objectEventTemplate->movementType, spriteTemplate, subspriteTables); CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(objectEventTemplate->graphicsId, objectEventTemplate->movementType, spriteTemplate, subspriteTables);
} }
u8 AddPseudoObjectEvent(u16 graphicsId, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority) // Used to create a sprite using a graphicsId associated with object events.
u8 CreateObjectGraphicsSprite(u16 graphicsId, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority)
{ {
struct SpriteTemplate *spriteTemplate; struct SpriteTemplate *spriteTemplate;
const struct SubspriteTable *subspriteTables; const struct SubspriteTable *subspriteTables;
@ -1530,7 +1531,7 @@ u8 AddPseudoObjectEvent(u16 graphicsId, void (*callback)(struct Sprite *), s16 x
u8 spriteId; u8 spriteId;
spriteTemplate = malloc(sizeof(struct SpriteTemplate)); spriteTemplate = malloc(sizeof(struct SpriteTemplate));
MakeObjectTemplateFromObjectEventGraphicsInfo(graphicsId, callback, spriteTemplate, &subspriteTables); CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, callback, spriteTemplate, &subspriteTables);
if (spriteTemplate->paletteTag != TAG_NONE) if (spriteTemplate->paletteTag != TAG_NONE)
LoadObjectEventPalette(spriteTemplate->paletteTag); LoadObjectEventPalette(spriteTemplate->paletteTag);
@ -1546,9 +1547,15 @@ u8 AddPseudoObjectEvent(u16 graphicsId, void (*callback)(struct Sprite *), s16 x
return spriteId; return spriteId;
} }
// Used to create sprite object events instead of a full object event #define sVirtualObjId data[0]
// Used when resources are limiting, e.g. for the audience in contests or group members in Union Room #define sVirtualObjElev data[1]
u8 CreateObjectSprite(u8 graphicsId, u8 objectEventId, s16 x, s16 y, u8 z, u8 direction)
// "Virtual Objects" are a class of sprites used instead of a full object event.
// Used when more objects are needed than the object event limit (for Contest / Battle Dome audiences and group members in Union Room).
// A unique id is given as an argument and stored in the sprite data to allow referring back to the same virtual object.
// They can be turned (and, in the case of the Union Room, animated teleporting in and out) but do not have movement types
// or any of the other data normally associated with object events.
u8 CreateVirtualObject(u8 graphicsId, u8 virtualObjId, s16 x, s16 y, u8 z, u8 direction)
{ {
u8 spriteId; u8 spriteId;
struct Sprite *sprite; struct Sprite *sprite;
@ -1557,7 +1564,7 @@ u8 CreateObjectSprite(u8 graphicsId, u8 objectEventId, s16 x, s16 y, u8 z, u8 di
const struct ObjectEventGraphicsInfo *graphicsInfo; const struct ObjectEventGraphicsInfo *graphicsInfo;
graphicsInfo = GetObjectEventGraphicsInfo(graphicsId); graphicsInfo = GetObjectEventGraphicsInfo(graphicsId);
MakeObjectTemplateFromObjectEventGraphicsInfo(graphicsId, UpdateObjectEventSprite, &spriteTemplate, &subspriteTables); CopyObjectGraphicsInfoToSpriteTemplate(graphicsId, SpriteCB_VirtualObject, &spriteTemplate, &subspriteTables);
*(u16 *)&spriteTemplate.paletteTag = TAG_NONE; *(u16 *)&spriteTemplate.paletteTag = TAG_NONE;
x += MAP_OFFSET; x += MAP_OFFSET;
y += MAP_OFFSET; y += MAP_OFFSET;
@ -1574,8 +1581,8 @@ u8 CreateObjectSprite(u8 graphicsId, u8 objectEventId, s16 x, s16 y, u8 z, u8 di
sprite->oam.paletteNum -= 16; sprite->oam.paletteNum -= 16;
sprite->coordOffsetEnabled = TRUE; sprite->coordOffsetEnabled = TRUE;
sprite->sObjEventId = objectEventId; sprite->sVirtualObjId = virtualObjId;
sprite->data[1] = z; sprite->sVirtualObjElev = z;
if (graphicsInfo->paletteSlot == 10) if (graphicsInfo->paletteSlot == 10)
LoadSpecialObjectReflectionPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot); LoadSpecialObjectReflectionPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot);
else if (graphicsInfo->paletteSlot >= 16) else if (graphicsInfo->paletteSlot >= 16)
@ -1697,7 +1704,7 @@ static void SpawnObjectEventOnReturnToField(u8 objectEventId, s16 x, s16 y)
subspriteTables = NULL; subspriteTables = NULL;
graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId); graphicsInfo = GetObjectEventGraphicsInfo(objectEvent->graphicsId);
spriteFrameImage.size = graphicsInfo->size; spriteFrameImage.size = graphicsInfo->size;
MakeObjectTemplateFromObjectEventGraphicsInfoWithCallbackIndex(objectEvent->graphicsId, objectEvent->movementType, &spriteTemplate, &subspriteTables); CopyObjectGraphicsInfoToSpriteTemplate_WithMovementType(objectEvent->graphicsId, objectEvent->movementType, &spriteTemplate, &subspriteTables);
spriteTemplate.images = &spriteFrameImage; spriteTemplate.images = &spriteFrameImage;
*(u16 *)&spriteTemplate.paletteTag = TAG_NONE; *(u16 *)&spriteTemplate.paletteTag = TAG_NONE;
@ -8510,50 +8517,50 @@ void UpdateObjectEventSpriteInvisibility(struct Sprite *sprite, bool8 invisible)
#define sAnimNum data[3] #define sAnimNum data[3]
#define sAnimState data[4] #define sAnimState data[4]
static void UpdateObjectEventSprite(struct Sprite *sprite) static void SpriteCB_VirtualObject(struct Sprite *sprite)
{ {
UpdateObjectEventSpritePosition(sprite); VirtualObject_UpdateAnim(sprite);
SetObjectSubpriorityByZCoord(sprite->data[1], sprite, 1); SetObjectSubpriorityByZCoord(sprite->sVirtualObjElev, sprite, 1);
UpdateObjectEventSpriteInvisibility(sprite, sprite->sInvisible); UpdateObjectEventSpriteInvisibility(sprite, sprite->sInvisible);
} }
// Unused // Unused
static void DestroyObjectEventSprites(void) static void DestroyVirtualObjects(void)
{ {
int i; int i;
for (i = 0; i < MAX_SPRITES; i++) for (i = 0; i < MAX_SPRITES; i++)
{ {
struct Sprite *sprite = &gSprites[i]; struct Sprite *sprite = &gSprites[i];
if(sprite->inUse && sprite->callback == UpdateObjectEventSprite) if(sprite->inUse && sprite->callback == SpriteCB_VirtualObject)
DestroySprite(sprite); DestroySprite(sprite);
} }
} }
static int GetObjectEventSpriteId(u8 objectEventId) // this should return a u8, because all that call this shifts to u8, but it wont match because it doesnt shift u8 at the end. static int GetVirtualObjectSpriteId(u8 virtualObjId)
{ {
int i; int i;
for (i = 0; i < MAX_SPRITES; i++) for (i = 0; i < MAX_SPRITES; i++)
{ {
struct Sprite *sprite = &gSprites[i]; struct Sprite *sprite = &gSprites[i];
if (sprite->inUse && sprite->callback == UpdateObjectEventSprite && (u8)sprite->sObjEventId == objectEventId) if (sprite->inUse && sprite->callback == SpriteCB_VirtualObject && (u8)sprite->sVirtualObjId == virtualObjId)
return i; return i;
} }
return MAX_SPRITES; return MAX_SPRITES;
} }
void TurnObjectEventSprite(u8 objectEventId, u8 direction) void TurnVirtualObject(u8 virtualObjId, u8 direction)
{ {
u8 spriteId = GetObjectEventSpriteId(objectEventId); u8 spriteId = GetVirtualObjectSpriteId(virtualObjId);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
StartSpriteAnim(&gSprites[spriteId], GetFaceDirectionAnimNum(direction)); StartSpriteAnim(&gSprites[spriteId], GetFaceDirectionAnimNum(direction));
} }
void SetObjectEventSpriteGraphics(u8 objectEventId, u8 graphicsId) void SetVirtualObjectGraphics(u8 virtualObjId, u8 graphicsId)
{ {
int spriteId = GetObjectEventSpriteId(objectEventId); int spriteId = GetVirtualObjectSpriteId(virtualObjId);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
{ {
@ -8581,9 +8588,9 @@ void SetObjectEventSpriteGraphics(u8 objectEventId, u8 graphicsId)
} }
} }
void SetObjectEventSpriteInvisibility(u8 objectEventId, bool32 invisible) void SetVirtualObjectInvisibility(u8 virtualObjId, bool32 invisible)
{ {
u8 spriteId = GetObjectEventSpriteId(objectEventId); u8 spriteId = GetVirtualObjectSpriteId(virtualObjId);
if (spriteId == MAX_SPRITES) if (spriteId == MAX_SPRITES)
return; return;
@ -8594,9 +8601,9 @@ void SetObjectEventSpriteInvisibility(u8 objectEventId, bool32 invisible)
gSprites[spriteId].sInvisible = FALSE; gSprites[spriteId].sInvisible = FALSE;
} }
bool32 IsObjectEventSpriteInvisible(u8 objectEventId) bool32 IsVirtualObjectInvisible(u8 virtualObjId)
{ {
u8 spriteId = GetObjectEventSpriteId(objectEventId); u8 spriteId = GetVirtualObjectSpriteId(virtualObjId);
if (spriteId == MAX_SPRITES) if (spriteId == MAX_SPRITES)
return FALSE; return FALSE;
@ -8604,9 +8611,9 @@ bool32 IsObjectEventSpriteInvisible(u8 objectEventId)
return (gSprites[spriteId].sInvisible == TRUE); return (gSprites[spriteId].sInvisible == TRUE);
} }
void SetObjectEventSpriteAnim(u8 objectEventId, u8 animNum) void SetVirtualObjectSpriteAnim(u8 virtualObjId, u8 animNum)
{ {
u8 spriteId = GetObjectEventSpriteId(objectEventId); u8 spriteId = GetVirtualObjectSpriteId(virtualObjId);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
{ {
@ -8619,18 +8626,18 @@ static void MoveUnionRoomObjectUp(struct Sprite *sprite)
{ {
switch(sprite->sAnimState) switch(sprite->sAnimState)
{ {
case 0: case 0:
sprite->y2 = 0;
sprite->sAnimState++;
case 1:
sprite->y2 -= 8;
if (sprite->y2 == -DISPLAY_HEIGHT)
{
sprite->y2 = 0; sprite->y2 = 0;
sprite->sAnimState++; sprite->sInvisible = TRUE;
case 1: sprite->sAnimNum = 0;
sprite->y2 -= 8; sprite->sAnimState = 0;
if (sprite->y2 == -DISPLAY_HEIGHT) }
{
sprite->y2 = 0;
sprite->sInvisible = TRUE;
sprite->sAnimNum = 0;
sprite->sAnimState = 0;
}
} }
} }
@ -8638,40 +8645,40 @@ static void MoveUnionRoomObjectDown(struct Sprite *sprite)
{ {
switch(sprite->sAnimState) switch(sprite->sAnimState)
{ {
case 0: case 0:
sprite->y2 = -DISPLAY_HEIGHT; sprite->y2 = -DISPLAY_HEIGHT;
sprite->sAnimState++; sprite->sAnimState++;
case 1: case 1:
sprite->y2 += 8; sprite->y2 += 8;
if(sprite->y2 == 0) if(sprite->y2 == 0)
{ {
sprite->sAnimNum = 0; sprite->sAnimNum = 0;
sprite->sAnimState = 0; sprite->sAnimState = 0;
} }
} }
} }
static void UpdateObjectEventSpritePosition(struct Sprite *sprite) static void VirtualObject_UpdateAnim(struct Sprite *sprite)
{ {
switch(sprite->sAnimNum) switch(sprite->sAnimNum)
{ {
case UNION_ROOM_SPAWN_IN: case UNION_ROOM_SPAWN_IN:
MoveUnionRoomObjectDown(sprite); MoveUnionRoomObjectDown(sprite);
break; break;
case UNION_ROOM_SPAWN_OUT: case UNION_ROOM_SPAWN_OUT:
MoveUnionRoomObjectUp(sprite); MoveUnionRoomObjectUp(sprite);
break; break;
case 0: case 0:
break; break;
default: default:
sprite->sAnimNum = 0; sprite->sAnimNum = 0;
break; break;
} }
} }
bool32 IsObjectEventSpriteAnimating(u8 objectEventId) bool32 IsVirtualObjectAnimating(u8 virtualObjId)
{ {
u8 spriteId = GetObjectEventSpriteId(objectEventId); u8 spriteId = GetVirtualObjectSpriteId(virtualObjId);
if (spriteId == MAX_SPRITES) if (spriteId == MAX_SPRITES)
return FALSE; return FALSE;

View File

@ -325,7 +325,7 @@ void Task_HandlePorthole(u8 taskId)
static void ShowSSTidalWhileSailing(void) static void ShowSSTidalWhileSailing(void)
{ {
u8 spriteId = AddPseudoObjectEvent(OBJ_EVENT_GFX_SS_TIDAL, SpriteCallbackDummy, 112, 80, 0); u8 spriteId = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_SS_TIDAL, SpriteCallbackDummy, 112, 80, 0);
gSprites[spriteId].coordOffsetEnabled = FALSE; gSprites[spriteId].coordOffsetEnabled = FALSE;

View File

@ -1409,7 +1409,7 @@ static void NamingScreen_CreatePlayerIcon(void)
u8 spriteId; u8 spriteId;
rivalGfxId = GetRivalAvatarGraphicsIdByStateIdAndGender(0, sNamingScreen->monSpecies); rivalGfxId = GetRivalAvatarGraphicsIdByStateIdAndGender(0, sNamingScreen->monSpecies);
spriteId = AddPseudoObjectEvent(rivalGfxId, SpriteCallbackDummy, 56, 37, 0); spriteId = CreateObjectGraphicsSprite(rivalGfxId, SpriteCallbackDummy, 56, 37, 0);
gSprites[spriteId].oam.priority = 3; gSprites[spriteId].oam.priority = 3;
StartSpriteAnim(&gSprites[spriteId], 4); StartSpriteAnim(&gSprites[spriteId], 4);
} }
@ -1436,7 +1436,7 @@ static void NamingScreen_CreateWaldaDadIcon(void)
{ {
u8 spriteId; u8 spriteId;
spriteId = AddPseudoObjectEvent(OBJ_EVENT_GFX_MAN_1, SpriteCallbackDummy, 56, 37, 0); spriteId = CreateObjectGraphicsSprite(OBJ_EVENT_GFX_MAN_1, SpriteCallbackDummy, 56, 37, 0);
gSprites[spriteId].oam.priority = 3; gSprites[spriteId].oam.priority = 3;
StartSpriteAnim(&gSprites[spriteId], 4); StartSpriteAnim(&gSprites[spriteId], 4);
} }

View File

@ -3180,14 +3180,14 @@ static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion)
{ {
case VERSION_FIRE_RED: case VERSION_FIRE_RED:
case VERSION_LEAF_GREEN: case VERSION_LEAF_GREEN:
objEvent->spriteId = AddPseudoObjectEvent(GetFRLGAvatarGraphicsIdByGender(linkGender(objEvent)), SpriteCB_LinkPlayer, 0, 0, 0); objEvent->spriteId = CreateObjectGraphicsSprite(GetFRLGAvatarGraphicsIdByGender(linkGender(objEvent)), SpriteCB_LinkPlayer, 0, 0, 0);
break; break;
case VERSION_RUBY: case VERSION_RUBY:
case VERSION_SAPPHIRE: case VERSION_SAPPHIRE:
objEvent->spriteId = AddPseudoObjectEvent(GetRSAvatarGraphicsIdByGender(linkGender(objEvent)), SpriteCB_LinkPlayer, 0, 0, 0); objEvent->spriteId = CreateObjectGraphicsSprite(GetRSAvatarGraphicsIdByGender(linkGender(objEvent)), SpriteCB_LinkPlayer, 0, 0, 0);
break; break;
case VERSION_EMERALD: case VERSION_EMERALD:
objEvent->spriteId = AddPseudoObjectEvent(GetRivalAvatarGraphicsIdByStateIdAndGender(PLAYER_AVATAR_STATE_NORMAL, linkGender(objEvent)), SpriteCB_LinkPlayer, 0, 0, 0); objEvent->spriteId = CreateObjectGraphicsSprite(GetRivalAvatarGraphicsIdByStateIdAndGender(PLAYER_AVATAR_STATE_NORMAL, linkGender(objEvent)), SpriteCB_LinkPlayer, 0, 0, 0);
break; break;
} }

View File

@ -1180,22 +1180,22 @@ bool8 ScrCmd_setobjectmovementtype(struct ScriptContext *ctx)
bool8 ScrCmd_createvobject(struct ScriptContext *ctx) bool8 ScrCmd_createvobject(struct ScriptContext *ctx)
{ {
u8 graphicsId = ScriptReadByte(ctx); u8 graphicsId = ScriptReadByte(ctx);
u8 objectEventId = ScriptReadByte(ctx); u8 virtualObjId = ScriptReadByte(ctx);
u16 x = VarGet(ScriptReadHalfword(ctx)); u16 x = VarGet(ScriptReadHalfword(ctx));
u32 y = VarGet(ScriptReadHalfword(ctx)); u32 y = VarGet(ScriptReadHalfword(ctx));
u8 elevation = ScriptReadByte(ctx); u8 elevation = ScriptReadByte(ctx);
u8 direction = ScriptReadByte(ctx); u8 direction = ScriptReadByte(ctx);
CreateObjectSprite(graphicsId, objectEventId, x, y, elevation, direction); CreateVirtualObject(graphicsId, virtualObjId, x, y, elevation, direction);
return FALSE; return FALSE;
} }
bool8 ScrCmd_turnvobject(struct ScriptContext *ctx) bool8 ScrCmd_turnvobject(struct ScriptContext *ctx)
{ {
u8 objectEventId = ScriptReadByte(ctx); u8 virtualObjId = ScriptReadByte(ctx);
u8 direction = ScriptReadByte(ctx); u8 direction = ScriptReadByte(ctx);
TurnObjectEventSprite(objectEventId, direction); TurnVirtualObject(virtualObjId, direction);
return FALSE; return FALSE;
} }

View File

@ -847,7 +847,7 @@ static void BuyMenuDrawObjectEvents(void)
graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId); graphicsInfo = GetObjectEventGraphicsInfo(gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId);
spriteId = AddPseudoObjectEvent( spriteId = CreateObjectGraphicsSprite(
gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId, gObjectEvents[sShopData->viewportObjects[i][OBJ_EVENT_ID]].graphicsId,
SpriteCallbackDummy, SpriteCallbackDummy,
(u16)sShopData->viewportObjects[i][X_COORD] * 16 + 8, (u16)sShopData->viewportObjects[i][X_COORD] * 16 + 8,

View File

@ -400,12 +400,12 @@ void CreateUnionRoomPlayerSprites(u8 * spriteIds, s32 leaderId)
for (memberId = 0; memberId < MAX_RFU_PLAYERS; memberId++) for (memberId = 0; memberId < MAX_RFU_PLAYERS; memberId++)
{ {
s32 id = UR_PLAYER_SPRITE_ID(leaderId, memberId); s32 id = UR_PLAYER_SPRITE_ID(leaderId, memberId);
spriteIds[id] = CreateObjectSprite(OBJ_EVENT_GFX_MAN_4, spriteIds[id] = CreateVirtualObject(OBJ_EVENT_GFX_MAN_4,
id - UR_SPRITE_START_ID, id - UR_SPRITE_START_ID,
sUnionRoomPlayerCoords[leaderId][0] + sUnionRoomGroupOffsets[memberId][0], sUnionRoomPlayerCoords[leaderId][0] + sUnionRoomGroupOffsets[memberId][0],
sUnionRoomPlayerCoords[leaderId][1] + sUnionRoomGroupOffsets[memberId][1], sUnionRoomPlayerCoords[leaderId][1] + sUnionRoomGroupOffsets[memberId][1],
3, 1); 3, 1);
SetObjectEventSpriteInvisibility(id - UR_SPRITE_START_ID, TRUE); SetVirtualObjectInvisibility(id - UR_SPRITE_START_ID, TRUE);
} }
} }
@ -443,7 +443,7 @@ static u8 GetNewFacingDirectionForUnionRoomPlayer(u32 memberId, u32 leaderId, st
static bool32 IsUnionRoomPlayerInvisible(u32 leaderId, u32 memberId) static bool32 IsUnionRoomPlayerInvisible(u32 leaderId, u32 memberId)
{ {
return IsObjectEventSpriteInvisible(UR_PLAYER_SPRITE_ID(leaderId, memberId) - UR_SPRITE_START_ID); return IsVirtualObjectInvisible(UR_PLAYER_SPRITE_ID(leaderId, memberId) - UR_SPRITE_START_ID);
} }
static void SpawnGroupMember(u32 leaderId, u32 memberId, u8 graphicsId, struct RfuGameData * gameData) static void SpawnGroupMember(u32 leaderId, u32 memberId, u8 graphicsId, struct RfuGameData * gameData)
@ -452,10 +452,10 @@ static void SpawnGroupMember(u32 leaderId, u32 memberId, u8 graphicsId, struct R
s32 id = UR_PLAYER_SPRITE_ID(leaderId, memberId); s32 id = UR_PLAYER_SPRITE_ID(leaderId, memberId);
if (IsUnionRoomPlayerInvisible(leaderId, memberId) == TRUE) if (IsUnionRoomPlayerInvisible(leaderId, memberId) == TRUE)
{ {
SetObjectEventSpriteInvisibility(id - UR_SPRITE_START_ID, FALSE); SetVirtualObjectInvisibility(id - UR_SPRITE_START_ID, FALSE);
SetObjectEventSpriteAnim(id - UR_SPRITE_START_ID, UNION_ROOM_SPAWN_IN); SetVirtualObjectSpriteAnim(id - UR_SPRITE_START_ID, UNION_ROOM_SPAWN_IN);
} }
SetObjectEventSpriteGraphics(id - UR_SPRITE_START_ID, graphicsId); SetVirtualObjectGraphics(id - UR_SPRITE_START_ID, graphicsId);
SetUnionRoomObjectFacingDirection(memberId, leaderId, GetNewFacingDirectionForUnionRoomPlayer(memberId, leaderId, gameData)); SetUnionRoomObjectFacingDirection(memberId, leaderId, GetNewFacingDirectionForUnionRoomPlayer(memberId, leaderId, gameData));
GetUnionRoomPlayerCoords(leaderId, memberId, &x, &y); GetUnionRoomPlayerCoords(leaderId, memberId, &x, &y);
MapGridSetMetatileImpassabilityAt(x, y, TRUE); MapGridSetMetatileImpassabilityAt(x, y, TRUE);
@ -464,7 +464,7 @@ static void SpawnGroupMember(u32 leaderId, u32 memberId, u8 graphicsId, struct R
static void DespawnGroupMember(u32 leaderId, u32 memberId) static void DespawnGroupMember(u32 leaderId, u32 memberId)
{ {
s32 x, y; s32 x, y;
SetObjectEventSpriteAnim(UR_PLAYER_SPRITE_ID(leaderId, memberId) - UR_SPRITE_START_ID, UNION_ROOM_SPAWN_OUT); SetVirtualObjectSpriteAnim(UR_PLAYER_SPRITE_ID(leaderId, memberId) - UR_SPRITE_START_ID, UNION_ROOM_SPAWN_OUT);
GetUnionRoomPlayerCoords(leaderId, memberId, &x, &y); GetUnionRoomPlayerCoords(leaderId, memberId, &x, &y);
MapGridSetMetatileImpassabilityAt(x, y, FALSE); MapGridSetMetatileImpassabilityAt(x, y, FALSE);
} }
@ -476,7 +476,7 @@ static void AssembleGroup(u32 leaderId, struct RfuGameData * gameData)
PlayerGetDestCoords(&x, &y); PlayerGetDestCoords(&x, &y);
player_get_pos_including_state_based_drift(&x2, &y2); player_get_pos_including_state_based_drift(&x2, &y2);
if (IsObjectEventSpriteInvisible(UR_PLAYER_SPRITE_ID(leaderId, 0) - UR_SPRITE_START_ID) == TRUE) if (IsVirtualObjectInvisible(UR_PLAYER_SPRITE_ID(leaderId, 0) - UR_SPRITE_START_ID) == TRUE)
{ {
if (IsUnionRoomPlayerAt(leaderId, 0, x, y) == TRUE || IsUnionRoomPlayerAt(leaderId, 0, x2, y2) == TRUE) if (IsUnionRoomPlayerAt(leaderId, 0, x, y) == TRUE || IsUnionRoomPlayerAt(leaderId, 0, x2, y2) == TRUE)
return; return;
@ -576,9 +576,9 @@ bool32 TryInteractWithUnionRoomMember(struct RfuPlayerList *list, s16 *memberIdP
continue; continue;
// Has a group member spawned at this position? // Has a group member spawned at this position?
if (IsObjectEventSpriteInvisible(id - UR_SPRITE_START_ID)) if (IsVirtualObjectInvisible(id - UR_SPRITE_START_ID))
continue; continue;
if (IsObjectEventSpriteAnimating(id - UR_SPRITE_START_ID)) if (IsVirtualObjectAnimating(id - UR_SPRITE_START_ID))
continue; continue;
if (leaders[i].groupScheduledAnim != UNION_ROOM_SPAWN_IN) if (leaders[i].groupScheduledAnim != UNION_ROOM_SPAWN_IN)
continue; continue;
@ -595,9 +595,9 @@ bool32 TryInteractWithUnionRoomMember(struct RfuPlayerList *list, s16 *memberIdP
static void SetUnionRoomObjectFacingDirection(s32 memberId, s32 leaderId, u8 newDirection) static void SetUnionRoomObjectFacingDirection(s32 memberId, s32 leaderId, u8 newDirection)
{ {
TurnObjectEventSprite(MAX_RFU_PLAYERS * leaderId - UR_SPRITE_START_ID + memberId, newDirection); TurnVirtualObject(MAX_RFU_PLAYERS * leaderId - UR_SPRITE_START_ID + memberId, newDirection);
// should be line below, but order is swapped here // should be line below, but order is swapped here
// TurnObjectEventSprite(UR_PLAYER_SPRITE_ID(leaderId, memberId) - UR_SPRITE_START_ID, newDirection); // TurnVirtualObject(UR_PLAYER_SPRITE_ID(leaderId, memberId) - UR_SPRITE_START_ID, newDirection);
} }
void UpdateUnionRoomMemberFacing(u32 memberId, u32 leaderId, struct RfuPlayerList *list) void UpdateUnionRoomMemberFacing(u32 memberId, u32 leaderId, struct RfuPlayerList *list)