Enemy API¶
Enemy extends Character with AI state, targeting, movement intent, and enemy-specific counters. It also exposes item and sub-item fields through flattening.
Identity And General AI¶
| Property | Type | Read/Write | Detail |
|---|---|---|---|
is_alive |
bool |
read | True when the slot exists and either health or extra health bars (lives) remain. Does not require the item/projectile is_active flag. Exact bridge name is IsAlive. |
is_commoner |
bool |
read | True when the entity logic marks this as a common enemy. Exact bridge name is IsCommoner. |
entity_type |
int |
read | Enemy entity type. Exact bridge name is EntityType; entity_type from SubItem is also available and writable. |
character |
Character |
read | Same object, exposed for interface symmetry. |
pack_hash |
int |
read | Pack hash inherited from SubItem. |
pack_name |
string |
read | Pack name inherited from SubItem. |
mode |
int |
read/write | Current AI/behaviour mode. |
mode_timer |
int |
read/write | Frames remaining or elapsed for the current mode, depending on controller. |
moving_dinrection |
int |
read/write | Original field name contains the typo Dinrection. Snake-case scripts should use moving_dinrection. |
distance |
int |
read/write | Target distance or mode distance parameter. |
movement_speed |
int |
read/write | Base movement speed. |
enemy_status |
EnemyStatus |
read/write | Overall AI status enum/bitfield. |
is_boss |
bool |
read/write | Boss mode. When the last boss in boss mode dies, every other enemy dies with it and its body stays longer before the wave can end. Set it right after spawning a scripted boss. |
enemy_agressiveness |
int |
read/write | Aggressiveness value. The bridge and source use the misspelling agressiveness. |
homing_target_id |
int |
read/write | Target object ID. Usually a player ID. |
homing_timer |
int |
read/write | Retargeting or homing timer. |
Enemy-Specific Values¶
These fields mirror original enemy memory slots. They are useful when extending a matching behaviour mode, but they are not general-purpose storage. Prefer custom_value_* for new script state.
| Property | Type | Read/Write | Detail |
|---|---|---|---|
enemySpecific_C0 |
int |
read/write | Generic enemy-specific slot. Use exact spelling. |
abadedeSpecific_C1 |
int |
read/write | Boss-specific slot. Use exact spelling. |
abadedeSpecific_C2 |
int |
read/write | Boss-specific slot. Use exact spelling. |
enemySpecific_C3 |
int |
read/write | Generic enemy-specific slot. Use exact spelling. |
enemySpecific_C4 |
int |
read/write | Generic enemy-specific slot. Use exact spelling. |
enemySpecificCounter_C5 |
int |
read/write | Generic counter slot. Use exact spelling. |
abadedeSpecific_C6 |
int |
read/write | Boss-specific slot. Use exact spelling. |
abadedeSpecific_C7 |
int |
read/write | Boss-specific slot. Use exact spelling. |
abadedeSpecificTargetId_C8 |
int |
read/write | Boss-specific target ID. Use exact spelling. |
abadedeSpecificCounter_CC |
int |
read/write | Boss-specific counter. Use exact spelling. |
shivaSpecific_B0 |
int |
read/write | Boss-specific slot. Use exact spelling. |
isBikerRidingBike_CA |
bool |
read/write | Bike-riding state. Use exact spelling. |
bikerSpecialCounter_CB |
int |
read/write | Biker-specific counter. Use exact spelling. |
biker_next_animation_id |
int |
read/write | Biker next-animation helper. |
use_biker_pipe |
bool |
read/write | Requests biker pipe behaviour. |
initial_ninja_hook_heigh |
int |
read/write | Ninja hook height field. Name follows source spelling. |
AI Override Values¶
Override fields are writable; probability, timer, speed, and distance fields are read-only values from AI data.
The read-only values come from the enemy logic's aiData table: one row per aggressiveness level (enemy_agressiveness, clamped to the last row), one column per value. The suffix is the original RAM offset; the number after Mode_ is the AI mode the value belongs to. An entity with no AI data reads 0 everywhere.
When the native AI picks a random mode it rolls 0..99 and subtracts ProbabilityMode_E0, then E1, E2, E3 and E4 in turn: the first value that takes the roll below zero selects modes 0 to 4, so each is that mode's chance in percent. Writing a non-zero override_aiData_En replaces column n for this enemy only (some native bosses do this at runtime); 0 restores the table value.
| Property | Type | Read/Write |
|---|---|---|
override_aiData_E0, override_aiData_E1, override_aiData_E2, override_aiData_E3, override_aiData_E4 |
int |
read/write |
ProbabilityMode_E0, ProbabilityMode_E1, ProbabilityMode_E2, ProbabilityMode_E3, ProbabilityMode_E4 |
int |
read |
MinTimerMode_0_E6, RandomTimerMode_0_E7 |
int |
read |
MinTimerMode_1_E8, RandomTimerMode_1_E9 |
int |
read |
MinSpeedMode_1_EA, RandomSpeedMode_1_EB |
int |
read |
TimerMode_2_EC, MinSpeedMode_2_ED, RandomSpeedMode_2_EE |
int |
read |
MinDistanceMode_3_EF, RandomDistanceMode_3_F0, MinTimerMode_3_F1, RandomTimerMode_3_F2, SpeedMode_3_F3 |
int |
read |
MinTimerMode_4_F4, RandomTimerMode_4_F5, MinSpeedMode_4_F6, RandomSpeedMode_4_F7 |
int |
read |
MinTimerMode_5_F8, RandomTimerMode_5_F9, MinSpeedMode_5_FA, RandomSpeedMode_5_FB |
int |
read |
MinTimerMode_6_FC, RandomTimerMode_6_FD |
int |
read |
MinTimerMode_7_FE, RandomTimerMode_7_FF |
int |
read |
Boss AI Read-Only Values¶
| Property | Type | Read/Write |
|---|---|---|
ShivaAI_C0, ShivaAI_C1, ShivaAI_C2, ShivaAI_C3, ShivaAI_C4, ShivaAI_C5, ShivaAI_C6, ShivaAI_C7 |
int |
read |
AI data columns 0x20..0x27 of the same row, used by Shiva's native controller: C0, C1 and C2 set the length of his waits (each wait lasts between the value and twice the value, in frames), C3 and C4 are 0..255 thresholds compared against a random byte to choose his next action. C5..C7 are read from the table but not used by the native controller, so a custom boss script can use them as its own tuning values.
Methods¶
return_to_standing()¶
Resets the enemy to its standing state through the original enemy controller helper.
return function()
local enemy = game.this_enemy
if enemy ~= nil and enemy.is_animation_over then
enemy.return_to_standing()
return false
end
return true
end
Enemies also inherit all character, item, and sub-item methods.
Example: Retarget And Attack¶
return function()
local enemy = game.this_enemy
if enemy == nil then
return true
end
local target = enemy.get_nearest_opponent(true, true, true)
if target ~= nil then
enemy.homing_target_id = target.object_index
enemy.is_facing_right = target.position_x > enemy.position_x
if enemy.mode_timer <= 0 then
enemy.set_animation(12)
enemy.mode_timer = 60
return false
end
end
return true
end
the inherited ten custom variables. These are signed integer fields in EnemyModel, with no native AI meaning. They participate in snapshot copies and serialization, and reset when an enemy slot is cleared. Coordinate ownership with other scripts.