dsekai
World engine for retrocomputers.
Loading...
Searching...
No Matches
Mobile MP/HP

Details of how the MOBILE::mp_hp field works. More...

Collaboration diagram for Mobile MP/HP:

Macros

#define MOBILE_HP_MASK   0x00ff
 Bitmask denoting half of MOBILE::mp_hp devoted to MP.
 
#define MOBILE_MP_MASK   0xff00
 Bitmask denoting half of MOBILE::mp_hp devoted to HP.
 
#define MOBILE_HP_DEATH   -10
 Value to set MOBILE::hp to on death but before deactivation.
 
#define mobile_incr_hp(m, v)
 Increment just the HP half of MOBILE::mp_hp.
 

Detailed Description

Details of how the MOBILE::mp_hp field works.

dsekai_mobiles_mp_hp

Access and Modification

These fields are combined to save space in an expected 16-bit struct alignment.

Use mobile_incr_hp() to modify.

Death Handling

Death occurs when the HP half reaches 0.

This value should be set to MOBILE_HP_DEATH on this mobile's death blow. From there, the engine will increment it up to its final value, -1, where the mobile will be deleted.

This allows for a relatively simple "blinking" death animation to occur by hiding frames for mobiles on negative even HP values.

Macro Definition Documentation

◆ mobile_incr_hp

#define mobile_incr_hp ( m,
v )
related
Value:
(m)->mp_hp = (((m)->mp_hp & MOBILE_MP_MASK) | (((((m)->mp_hp & MOBILE_HP_MASK) + (v)) & MOBILE_HP_MASK) & MOBILE_HP_MASK))
#define MOBILE_MP_MASK
Bitmask denoting half of MOBILE::mp_hp devoted to HP.
Definition mobile.h:73
#define MOBILE_HP_MASK
Bitmask denoting half of MOBILE::mp_hp devoted to MP.
Definition mobile.h:68
int16_t mp_hp
The combined dsekai_mobiles_mp_hp field.
Definition mobile.h:271

Increment just the HP half of MOBILE::mp_hp.