![]() |
dsekai
World engine for retrocomputers.
|
A moving/interactive object in the world. More...
#include <mobile.h>
Data Fields | |
uint16_t | flags |
Mobile Object Flags affecting this mobile's display and behavior. | |
SPAWN_GID | spawner_gid |
TILEMAP_SPAWN::gid of the spawner that spawned this mobile. | |
TILEMAP_GID | map_gid |
TILEMAP::gid of the tilemap this mobile was spawned on. | |
char | name [TILEMAP_SPAWN_NAME_SZ] |
char | sprite_name [RESOURCE_NAME_MAX] |
int16_t | mp_hp |
The combined dsekai_mobiles_mp_hp field. | |
int16_t | screen_px |
Current on-screen pixel left of sprite. -1 if off-screen. | |
int16_t | screen_py |
Current on-screen pixel left of sprite. -1 if off-screen. | |
int16_t | sprite_cache_id |
Index of the mobile's Mobile Spritesheets loaded in the Unilayer Graphics Cache. | |
unsigned char | ascii |
int8_t | coords_sz |
Number of coordinates in MOBILE::coords. | |
struct TILEMAP_COORDS | coords [MOBILE_COORDS_QUEUE_SZ] |
The mobile's current location (in tiles) as well as queued future locations. | |
uint8_t | steps_remaining |
Number of steps remaining in current walk animation. | |
int16_t | script_id |
Index currently executing behavior script in TILEMAP::scripts. | |
int16_t | script_pc |
Position in currently executing behavior script. | |
int8_t | script_stack [SCRIPT_STACK_DEPTH] |
Local stack used to store state for this mobile's SCRIPT. | |
uint16_t | script_wait_frames |
Delay script for this many frames. | |
Related Functions | |
(Note that these are not member functions.) | |
#define | MOBILE_MAP_GID_ALL 0xffff |
MOBILE::map_gid value indicating mobile is present on all tilemaps. | |
#define | MOBILE_GID_FMT "%04d:%04d" |
Insert into logging format strings when a mobile's Globally Unique Identifiers is needed. | |
#define | mobile_get_gid_fmt(m) (m)->map_gid, (m)->spawner_gid |
Insert into the args provided to a format string using MOBILE_GID_FMT. | |
#define | MOBILE_COORDS_QUEUE_SZ 5 |
Number of positions available in the MOBILE::coords queue. | |
#define | mobile_incr_hp(m, v) (m)->mp_hp = (((m)->mp_hp & MOBILE_MP_MASK) | (((((m)->mp_hp & MOBILE_HP_MASK) + (v)) & MOBILE_HP_MASK) & MOBILE_HP_MASK)) |
Increment just the HP half of MOBILE::mp_hp. | |
#define | mobile_get_dir(m) ((m)->flags & MOBILE_DIR_MASK) |
Get the Cardinal Directions the mobile is facing. | |
#define | mobile_set_dir(m, v) (m)->flags = (((m)->flags & ~MOBILE_DIR_MASK) | ((v) & MOBILE_DIR_MASK)) |
Set MOBILE_DIR_MASK in MOBILE::flags to the specified Cardinal Directions. | |
#define | mobile_get_icount(m) (((m)->flags & MOBILE_ICOUNT_MASK) >> 12) |
Get the current interaction count of the specified MOBILE. | |
#define | mobile_incr_icount(m, v) (m)->flags = (((m)->flags & ~MOBILE_ICOUNT_MASK) | ((mobile_get_icount( m ) + (((v) << 12) & MOBILE_ICOUNT_MASK)) & MOBILE_ICOUNT_MASK)) |
Increment MOBILE_ICOUNT_MASK by a given value. | |
#define | mobile_get_gid(m) (MOBILE_GID)((((MOBILE_GID)((m)->map_gid)) << (sizeof( TILEMAP_GID ) * 8)) & (m)->spawner_gid) |
Get the globally unique identifier of the given MOBILE. | |
#define | mobile_get_map_gid(m, state) ((MOBILE_GID_PLAYER == mobile_get_gid( m )) ? (state)->tilemap->gid : (m)->map_gid) |
Get the GID of the TILEMAP the given MOBILE is currently on. | |
#define | mobile_get_sprite(m) ((m)->sprite_cache_id) |
Get the pointer to the sprite graphic to use for a MOBILE. | |
A moving/interactive object in the world.
|
related |
Get the globally unique identifier of the given MOBILE.
This identifier is/must be unique among all ::MOBILEs in DSEKAI_STATE::mobiles_handle and persists between Engine Locking cycles.
m | Locked MEMORY_PTR to MOBILE to query. |
|
related |
Insert into the args provided to a format string using MOBILE_GID_FMT.
m | Locked MEMORY_PTR to the mobile to examine. |
|
related |
Get the current interaction count of the specified MOBILE.
m | Locked MEMORY_PTR to MOBILE to query. |
|
related |
Get the GID of the TILEMAP the given MOBILE is currently on.
m | Locked MEMORY_PTR to MOBILE to query. |
|
related |
Increment MOBILE_ICOUNT_MASK by a given value.
m | Locked MEMORY_PTR to MOBILE to modify. |
v | Value to increment counter by. |
|
related |
MOBILE::map_gid value indicating mobile is present on all tilemaps.
This is generally only used for the player.
|
related |
Set MOBILE_DIR_MASK in MOBILE::flags to the specified Cardinal Directions.
m | Locked MEMORY_PTR to MOBILE to modify. |
v | Cardinal Directions to set the mobile facing. |
struct TILEMAP_COORDS MOBILE::coords[MOBILE_COORDS_QUEUE_SZ] |
The mobile's current location (in tiles) as well as queued future locations.
The first two location indexes (0 and 1) should be equal if the mobile is standing still. Otherwise, 1 contains the location the mobile is moving to and 0 contains the location it is moving from. This allows 0 to become 1 and if MOBILE::coords_sz > 2, then 2 can be moved down to 1.
TILEMAP_GID MOBILE::map_gid |
TILEMAP::gid of the tilemap this mobile was spawned on.
This is part of the MOBILE_GID.
int16_t MOBILE::screen_px |
Current on-screen pixel left of sprite. -1 if off-screen.
This may vary, depending on the engine type, but is also used to place animations over the mobile.
int16_t MOBILE::screen_py |
Current on-screen pixel left of sprite. -1 if off-screen.
This may vary, depending on the engine type, but is also used to place animations over the mobile.
int8_t MOBILE::script_stack[SCRIPT_STACK_DEPTH] |
Local stack used to store state for this mobile's SCRIPT.
This should only be manipulated directly via mobile_stack_push() and mobile_stack_pop().
Values stored on the stack can go up to SCRIPT_STACK_MAX.
uint16_t MOBILE::script_wait_frames |
Delay script for this many frames.
This is an absolute value of frames to count down and may be safely serialized.
SPAWN_GID MOBILE::spawner_gid |
TILEMAP_SPAWN::gid of the spawner that spawned this mobile.
This is part of the MOBILE_GID.
int16_t MOBILE::sprite_cache_id |
Index of the mobile's Mobile Spritesheets loaded in the Unilayer Graphics Cache.
uint8_t MOBILE::steps_remaining |
Number of steps remaining in current walk animation.
This is set to SPRITE_W to start and then incrementally determined using the table gc_mobile_step_table_normal_pos on each tick.