Death

Death post thumbnail image

Death, KO, or defeat. Whatever you you choose to call it, there are many options for handling an entity’s demise. It’s important to note that in OpenBOR, “dead” and “killed” are not the same thing at all. Make sure to understand the difference and avoid misconstruing game world vs. production nomenclature. We might say “I killed the boss!” while playing, but in actuality the boss is only dead – not killed.

Dead

Dead is a game world effect, typically triggered when an entity’s hit-points are depleted. When an entity is dead, OpenBOR activates a sequence of events in the following order. You may modify which of these events take place under varying conditions.

  1. Fall – The entity falls as if the attack knocked it down. The attack’s knockdown velocity applies.
  2. Death – The entity plays a death animation matching the attack type that finished it.
  3. Remove – Removes entity from the game.

Death Configuration

death_config <flags>

# default
death_config blink_remove_air blink_remove_ground fall_land_air fall_land_ground remove_vanish_air remove_vanish_ground source_model

Death configuration is a model and defense property that controls which behaviors from the death sequence apply. Accepts one or more of the following flags:

  • none – No configuration at all. Has no effect if you add other flags. An entity with no death configuration falls and stays down but remains in play. This will soft lock a game with groups or waits, so only use it if you intend to script custom behavior.
  • default – Shortcut for default configuration flags.
  • blink_death_air – Entity blinks from start of death sequence if defeated in the air.
  • blink_death_ground – Entity blinks from start of death sequence if defeated on its base.
  • blink_fall_air – Entity blinks from start of fall sequence if defeated in the air.
  • blink_fall_ground – Entity blinks from start of fall sequence if defeated on its base.
  • blink_remove_air – Entity blinks from start of remove sequence if defeated in the air. Vanish removal delays for approximately two seconds.
  • blink_remove_ground – Entity blinks from start of remove sequence if defeated on its base. Vanish removal delays for approximately two seconds.
  • death_air – Entity plays a death animation matching the finishing attack type if defeated in the air.
  • death_ground – Entity plays a death animation matching the finishing attack type if defeated on its base.
  • fall_land_air – Entity falls, then proceeds to next sequence immediately on landing if defeated in the air.
  • fall_land_ground – Entity falls, then proceeds to next sequence immediately on landing if defeated on its base.
  • fall_lie_air – If defeated in the air, entity falls, plays out the remainder of its fall animation after landing, then proceeds to next sequence.
  • fall_lie_ground – If defeated on its base, entity falls, plays out the remainder of its fall animation after landing, then proceeds to next sequence.
  • remove_corpse_air – Entity is flagged as a corpse (out of play) but remains on screen if defeated in the air.
  • remove_corpse_ground – Entity is flagged as a corpse (out of play) but remains on screen if defeated at its base.
  • remove_vanish_air – Entity kills itself if defeated in the air.
  • remove_vanish_ground – Entity kills itself if defeated on its base.
  • source_model – If this flag is active on a defense property, the entity uses its model death configuration instead. No effect on model death configuration.

This entity will play its death animation instantly if on the ground. If in the air, it will fall first, then play its death animation. In both cases, its body stays on screen.

death_config fall_lie_air death_air death_ground remove_corpse_air remove_corpse_ground

Tip: Flags do what they say and nothing more. For example, blink flags activate a blink effect, but they don’t remove the corpse. If you don’t include a remove flag, the entity will just stay on screen blinking forever and players will get stuck at the next wait.

Script

Death configuration is accessible as a defense and model level property. It is a bitmasked integer with the following constants:

  • openborconstant("DEATH_CONFIG_NONE")
  • openborconstant("DEATH_CONFIG_BLINK_DEATH_AIR")
  • openborconstant("DEATH_CONFIG_BLINK_DEATH_GROUND")
  • openborconstant("DEATH_CONFIG_BLINK_FALL_AIR")
  • openborconstant("DEATH_CONFIG_BLINK_FALL_GROUND")
  • openborconstant("DEATH_CONFIG_BLINK_REMOVE_AIR")
  • openborconstant("DEATH_CONFIG_BLINK_REMOVE_GROUND")
  • openborconstant("DEATH_CONFIG_DEATH_AIR")
  • openborconstant("DEATH_CONFIG_DEATH_GROUND")
  • openborconstant("DEATH_CONFIG_FALL_LAND_AIR")
  • openborconstant("DEATH_CONFIG_FALL_LAND_GROUND")
  • openborconstant("DEATH_CONFIG_FALL_LIE_AIR")
  • openborconstant("DEATH_CONFIG_FALL_LIE_GROUND")
  • openborconstant("DEATH_CONFIG_REMOVE_CORPSE_AIR")
  • openborconstant("DEATH_CONFIG_REMOVE_CORPSE_GROUND")
  • openborconstant("DEATH_CONFIG_REMOVE_CORPSE_GROUND")
  • openborconstant("DEATH_CONFIG_REMOVE_VANISH_AIR")
  • openborconstant("DEATH_CONFIG_REMOVE_VANISH_GROUND")
  • openborconstant("DEATH_CONFIG_SOURCE_MODEL")

Death State

The Death State property is a bitmasked entity property OpenBOR uses to flag entities dead.

  • openborconstant("DEATH_STATE_NONE") – The entity has no death state. This is the default until an entity dies.
  • openborconstant("DEATH_STATE_AIR") – The entity took a finishing blow while in the air.
  • openborconstant("DEATH_STATE_BACK") – The entity took a finishing blow from behind.
  • openborconstant("DEATH_STATE_CORPSE") – The entity is an on screen corpse. It is out of play and most logic routines ignore it (ex. groups, waits, and hostile AI). Set by the remove_corpse options in Death Configuration.
  • openborconstant("DEATH_STATE_DEAD") – The entity is dead.

Tip: Bringing a dead entity “back to life” with script is easy to do. You just need to restore some or all of the entity’s hit points, and unset the death state flags, and reactivate AI control.

void ent = getlocalvar("self");

int new_hp = 5;


/* Restore hitpoints. */
set_entity_property(ent, openborconstant("ENTITY_PROPERTY_HP"), new_hp );

/* Re-enable AI control. */
set_entity_property(ent, openborconstant("ENTITY_PROPERTY_AI_DISABLE"), 0);

/* Reset the death state.... "RESURRECTION!!!!"  >:)  */
set_entity_property(ent, openborconstant("ENTITY_PROPERTY_DEATH_STATE"), openborconstant("DEATH_STATE_NONE"));

Killed

Killing is an action, not a status. Killed entities cease to exist. All properties and associated entity variables are deleted from memory. OpenBOR kills entities automatically as a result of various events:

  • After default death routine (fall down, flash, and disappear). The entity is killed after last flash.
  • Entities reach a predetermined (adjustable) distance out of the screen boundary.
  • The current level unloads (all entities are killed, including player controlled entities).
  • The entity’s autokill flag is set, in which case the entity is killed when its current animation completes. This is mainly used for dust and hit flash effects.
  • Most types of projectiles hit another entity or a wall.

Script

When OpenBOR runs kills an entity, that entity fires its onkill script (if any) just before the entity is removed from play. To find out why the entity is being killed, access the local variable trigger, and compare it to the following constants.

Note that in many cases, the kill effect is an alternate that only occurs on entities that lack a damage routine. For example, Smartbombs damage entities. This damage may cause the entity to die, and then be killed by the default death routine, but the Smartbomb itself does not kill the entity. In this case, the entity’s kill trigger is openborconstant("KILL_ENTITY_TRIGGER_SUICIDE"). However, some rare types of entities lack a damage taking routine, in which case the smartbomb kills them and the kill trigger is openborconstant("KILL_ENTITY_TRIGGER_SMARTBOMB").

  • openborconstant("KILL_ENTITY_TRIGGER_NONE") – Not used.
  • openborconstant("KILL_ENTITY_TRIGGER_ALL") – All entities removed from play (i.e. starting a new level/game).
  • openborconstant("KILL_ENTITY_TRIGGER_ANIMAL_RUN_OUT_OF_BOUNDS") – Running animal leaves coded boundary.
  • openborconstant("KILL_ENTITY_TRIGGER_AUTOKILL_ATTACK_HIT") – Entity (usually a projectile) hits with remove on hit enabled.
  • openborconstant("KILL_ENTITY_TRIGGER_AUTOKILL_ANIMATION_COMPLETE_DEFINED_LOOP_MAX") – An animation with a defined end frame plays its last frame.
  • openborconstant("KILL_ENTITY_TRIGGER_AUTOKILL_ANIMATION_COMPLETE_UNDEFINED_LOOP_MAX") – An animation with no end for loops plays its last frame.
  • openborconstant("KILL_ENTITY_TRIGGER_BOMB_EXPLODE_ANIMATION_COMPLETE") – Bomb type projectile plays last frame of its explode animation.
  • openborconstant("KILL_ENTITY_TRIGGER_BOMB_EXPLODE_ANIMATION_UNAVAILABLE") – Bomb type projectile plays last frame of its explode animation.
  • openborconstant("KILL_ENTITY_TRIGGER_BIND_ANIMATION_MATCH") – Entity binding itself to another entity’s animations and set to die otherwise cannot match animations.
  • openborconstant("KILL_ENTITY_TRIGGER_BIND_FRAME_MATCH") – Entity binding itself to another entity’s frame and set to die otherwise cannot match frame.
  • openborconstant("KILL_ENTITY_TRIGGER_DAMAGE_ON_LANDING") – Entity takes damage on landing.
  • openborconstant("KILL_ENTITY_TRIGGER_DROP_NO_HEALTH") – Entity drops into screen but has 0 health.
  • openborconstant("KILL_ENTITY_TRIGGER_LEVEL_GAME_OVER") – Game ends.
  • openborconstant("KILL_ENTITY_TRIGGER_LIFESPAN") – Lifespan counter expires.
  • openborconstant("KILL_ENTITY_TRIGGER_OBSTACLE_FALL_NO_DEATH_ANIMATION") – Obstacle without a death animation takes lethal damage.
  • openborconstant("KILL_ENTITY_TRIGGER_OBSTACLE_FLY_OUT_OF_BOUNDS") – Obstacle flying away leaves coded boundary.
  • openborconstant("KILL_ENTITY_TRIGGER_OUT_OF_BOUNDS") – Entity leaves leaves coded boundary.
  • openborconstant("KILL_ENTITY_TRIGGER_RECURSIVE_DAMAGE") – Entity dies from recursive damage.
  • openborconstant("KILL_ENTITY_TRIGGER_PARENT_KILL_ALL") – Entity spawned by another dies along with parent (i.e. summonkill 2).
  • openborconstant("KILL_ENTITY_TRIGGER_PARENT_KILL_SUMMON") – Entity summon by another dies with parent.
  • openborconstant("KILL_ENTITY_TRIGGER_PIT") – Entity is in a pit.
  • openborconstant("KILL_ENTITY_TRIGGER_PLAYER_DEATH") – Player dies.
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_DAMAGEENTITY") – Script damageentity() function attempts to damage entity.
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_UNDEFINED") – Script killentity() runs without a designated trigger.
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_USER_0") – User defined trigger for killentity() function.
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_USER_1")
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_USER_2")
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_USER_3")
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_USER_4")
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_USER_5")
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_USER_6")
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_USER_7")
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_USER_8")
  • openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_USER_9")
  • openborconstant("KILL_ENTITY_TRIGGER_SMARTBOMB") – Killed by smartbomb.
  • openborconstant("KILL_ENTITY_TRIGGER_SPAWN_OVERRIDE") – Identical model spawns into play when spawn override enabled.
  • openborconstant("KILL_ENTITY_TRIGGER_STAR_OUT_OF_BOUNDS") – Legacy star projectile leaves coded boundary.
  • openborconstant("KILL_ENTITY_TRIGGER_STEAM_ANIMATION_COMPLETE") – Steam spawn plays last frame of animation.
  • openborconstant("KILL_ENTITY_TRIGGER_SUICIDE") – Native suicide function runs. This is the typical means entities are killed after death by damage.
  • openborconstant("KILL_ENTITY_TRIGGER_TAKE_DAMAGE_BIKER_PIT") – Legacy biker in pit.
  • openborconstant("KILL_ENTITY_TRIGGER_TAKE_DAMAGE_COMMON_FALL") – Sets fall animation.
  • openborconstant("KILL_ENTITY_TRIGGER_TAKE_DAMAGE_COMMON_PIT") – Entity falls into pit.
  • openborconstant("KILL_ENTITY_TRIGGER_TEXT_ANIMATION_COMPLETE") – Text entity plays last frame of animation.
  • openborconstant("KILL_ENTITY_TRIGGER_TAKE_DAMAGE_OBSTACLE_PIT") – Obstacle falls into pit.
  • openborconstant("KILL_ENTITY_TRIGGER_UNSUMMON") – Entity is target of unsummonframe.
  • openborconstant("KILL_ENTITY_TRIGGER_WALK_OUT_OF_BOUNDS") – Walking routine detects entity leaving coded boundary.

You may also use the script function killentity(pointer <entity>, optional int trigger) to manually run the engine’s kill routine and instantly remove an entity.

void ent = getlocalvar("self");

killentity(ent, openborconstant("KILL_ENTITY_TRIGGER_SCRIPT_KILLENTITY_USER_0"));

Tip: If it isn’t clear already, there’s no way to restore a killed entity. The only way to bring it back is spawning a new replacement.

Related Post