20#define MOBILE_COORDS_QUEUE_SZ 5
68#define MOBILE_HP_MASK 0x00ff
73#define MOBILE_MP_MASK 0xff00
78#define MOBILE_HP_DEATH -10
84#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))
92#define mobile_get_dir( m ) ((m)->flags & MOBILE_DIR_MASK)
101#define mobile_set_dir( m, v ) (m)->flags = (((m)->flags & ~MOBILE_DIR_MASK) | ((v) & MOBILE_DIR_MASK))
108#define mobile_get_icount( m ) (((m)->flags & MOBILE_ICOUNT_MASK) >> 12)
116#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))
129#define mobile_get_gid( m ) (MOBILE_GID)((((MOBILE_GID)((m)->map_gid)) << (sizeof( TILEMAP_GID ) * 8)) & (m)->spawner_gid)
138#define mobile_get_map_gid( m, state ) ((MOBILE_GID_PLAYER == mobile_get_gid( m )) ? (state)->tilemap->gid : (m)->map_gid)
151#define MOBILE_ICOUNT_MASK 0xf000
157#define MOBILE_DIR_MASK 0x0007
168#define MOBILE_TYPE_NORMAL 0x0000
173#define MOBILE_TYPE_SPECIAL 0x0008
176#define MOBILE_TYPE_RES1 0x0010
179#define MOBILE_TYPE_RES2 0x0018
187#define MOBILE_TYPE_MASK 0x0018
192#define MOBILE_FLAG_ACTIVE 0x0100
197#define MOBILE_FLAG_PLAYER 0x0200
202#define MOBILE_FLAG_DISABLED 0x0400
211#define MOBILE_FLAG_NOT_LAST 0x0800
215#ifdef PLATFORM_CURSES
216# define mobile_get_sprite( m ) ((m)->ascii)
222# define mobile_get_sprite( m ) ((m)->sprite_cache_id)
225#define mobile_get_tx( m ) ((m)->coords[1].x)
226#define mobile_get_ty( m ) ((m)->coords[1].y)
228#define mobile_break_if_last( m ) if( MOBILE_FLAG_NOT_LAST != (MOBILE_FLAG_NOT_LAST & (m)->flags) ) { debug_printf( 0, "breaking early on mobile" ); break; }
230#define mobile_is_active( m ) (MOBILE_FLAG_ACTIVE == (MOBILE_FLAG_ACTIVE & (m)->flags))
232#define mobile_is_walking( m ) ((m)->coords[1].y != (m)->coords[0].y || (m)->coords[1].x != (m)->coords[0].x)
243#define MOBILE_ERROR_BLOCKED -1
266 char name[TILEMAP_SPAWN_NAME_SZ];
343#define MOBILE_DIR_SOUTH 0
345#define MOBILE_DIR_NORTH 1
347#define MOBILE_DIR_EAST 2
349#define MOBILE_DIR_WEST 3
372 uint8_t x, uint8_t y, uint8_t dir,
struct DSEKAI_STATE* state );
439int16_t mobile_spawner_match(
450# ifndef NO_SMOOTH_WALK
467# ifndef NO_SMOOTH_WALK
uint16_t TILEMAP_GID
Globally unique identifier for TILEMAP objects.
Definition: gid.h:26
uint32_t MOBILE_GID
Globally unique identifier for MOBILE objects.
Definition: gid.h:22
uint16_t SPAWN_GID
Globally unique identifier for TILEMAP_SPAWN objects.
Definition: gid.h:24
void mobile_stack_push(struct MOBILE *m, int8_t v) SECTION_MOBILE
Push a value onto MOBILE::script_stack.
Definition: mobile.c:113
const int8_t gc_mobile_step_table_normal_pos[16]
Lookup table for next walking offset to assign to MOBILE::steps_remaining based on current offset.
void mobile_animate(struct MOBILE *m, struct DSEKAI_STATE *state)
Perform animation frame for the given MOBILE.
Definition: mobile.c:335
struct MOBILE * mobile_get_facing(uint8_t x, uint8_t y, uint8_t dir, struct DSEKAI_STATE *state)
Get a MEMORY_PTR to the mobile m is currently facing.
Definition: mobile.c:26
const int8_t gc_mobile_x_offsets[4]
Lookup table for horizontal offset based on mobile_get_dir().
void mobile_spawns(struct DSEKAI_STATE *state) SECTION_MOBILE
Spawn from ::TILEMAP::spawners according to spawner rules.
Definition: mobile.c:479
uint8_t mobile_walk_start(struct MOBILE *m, uint8_t dir) SECTION_MOBILE
Have the given MOBILE attempt to begin walking movement/animation.
Definition: mobile.c:5
void mobile_state_animate(struct DSEKAI_STATE *state)
Map MOBILE animation frames to a number of real frames elapsed.
Definition: mobile.c:99
const int8_t gc_mobile_y_offsets[4]
Lookup table for vertical offset based on mobile_get_dir().
struct MOBILE * mobile_spawn_single(uint16_t flags, struct DSEKAI_STATE *state) SECTION_MOBILE
Allocate a mobile or select player mobile slot and initialize it with configuration generic to ALL mo...
Definition: mobile.c:382
#define SCRIPT_STACK_DEPTH
Maximum depth of available local stack for each MOBILE executing a script. Each stack is individual t...
Definition: src/config.h:123
struct MOBILE * mobile_interact(struct MOBILE *actor, struct MOBILE *actee, struct DSEKAI_STATE *state) SECTION_MOBILE
Force a MOBILE to jump to the SCRIPT_ACTION_INTERACT in its SCRIPT.
Definition: mobile.c:147
int8_t mobile_stack_pop(struct MOBILE *m) SECTION_MOBILE
Pop a value from a MOBILE::script_stack.
Definition: mobile.c:128
void mobile_deactivate(struct MOBILE *m, struct DSEKAI_STATE *state) SECTION_MOBILE
Prepare a MOBILE for deallocation.
Definition: mobile.c:324
void mobile_execute(struct MOBILE *m, struct DSEKAI_STATE *state)
Execute the next available SCRIPT_STEP in the currently running SCRIPT on a MOBILE.
Definition: mobile.c:233
General/shared state of the running engine in memory.
Definition: engines.h:196
A moving/interactive object in the world.
Definition: mobile.h:248
int16_t script_id
Index currently executing behavior script in TILEMAP::scripts.
Definition: mobile.h:314
int8_t script_stack[SCRIPT_STACK_DEPTH]
Local stack used to store state for this mobile's SCRIPT.
Definition: mobile.h:325
int16_t script_pc
Position in currently executing behavior script.
Definition: mobile.h:316
uint8_t steps_remaining
Number of steps remaining in current walk animation.
Definition: mobile.h:312
int16_t screen_py
Current on-screen pixel left of sprite. -1 if off-screen.
Definition: mobile.h:285
uint16_t flags
Mobile Object Flags affecting this mobile's display and behavior.
Definition: mobile.h:253
int16_t sprite_cache_id
Index of the mobile's Mobile Spritesheets loaded in the Unilayer Graphics Cache.
Definition: mobile.h:292
#define MOBILE_COORDS_QUEUE_SZ
Number of positions available in the MOBILE::coords queue.
Definition: mobile.h:20
int8_t coords_sz
Number of coordinates in MOBILE::coords.
Definition: mobile.h:295
int16_t screen_px
Current on-screen pixel left of sprite. -1 if off-screen.
Definition: mobile.h:278
SPAWN_GID spawner_gid
TILEMAP_SPAWN::gid of the spawner that spawned this mobile.
Definition: mobile.h:259
TILEMAP_GID map_gid
TILEMAP::gid of the tilemap this mobile was spawned on.
Definition: mobile.h:265
int16_t mp_hp
The combined dsekai_mobiles_mp_hp field.
Definition: mobile.h:271
uint16_t script_wait_frames
Delay script for this many frames.
Definition: mobile.h:332
struct TILEMAP_COORDS coords[MOBILE_COORDS_QUEUE_SZ]
The mobile's current location (in tiles) as well as queued future locations.
Definition: mobile.h:305
X/Y coordinates of a tile on the current map.
Definition: tmstruct.h:33
Defines a spawner to create mobiles in the world.
Definition: tmstruct.h:59
#define RESOURCE_NAME_MAX
Definition: unilayer.h:54