Respawn Body

danno

Moderator
Staff member
In OpenBor version 4 of the engine I'm using death_config, I had to check the source code for it.

C-like:
    DEATH_CONFIG_NONE                                            = 0,        // No death sequence at all.
    DEATH_CONFIG_BLINK_DEATH_AIR                         = (1 << 0), // Blink at start of death animation if killed in air.
    DEATH_CONFIG_BLINK_DEATH_GROUND                = (1 << 1), // Blink at start of death animation if killed at base.
    DEATH_CONFIG_BLINK_FALL_AIR                             = (1 << 2), // Blink at start of fall if killed in air.
    DEATH_CONFIG_BLINK_FALL_GROUND                   = (1 << 3), // Blink at start of fall if killed at base.
    DEATH_CONFIG_BLINK_REMOVE_AIR                      = (1 << 4), // Blink at start of removal if killed in ait.
    DEATH_CONFIG_BLINK_REMOVE_GROUND            = (1 << 5), // Blinka t start of removal if killed on ground.
    DEATH_CONFIG_DEATH_AIR                                    = (1 << 6), // Play death animation if killed in the air.
    DEATH_CONFIG_DEATH_GROUND                          = (1 << 7), // Play death animation if killed at base height.
    DEATH_CONFIG_FALL_LAND_AIR                            = (1 << 8), // Fall if killd in the air.
    DEATH_CONFIG_FALL_LAND_GROUND                   = (1 << 9), // Fall if killed at base.
    DEATH_CONFIG_FALL_LIE_AIR                                 = (1 << 10), // Fall and play entire animation if killed in air.
    DEATH_CONFIG_FALL_LIE_GROUND                        = (1 << 11), // Fall and play entire animation if killed at base height.
    DEATH_CONFIG_REMOVE_CORPSE_AIR                  = (1 << 12), // Entity is out of play, but remains on screen if killed in air.
    DEATH_CONFIG_REMOVE_CORPSE_GROUND        = (1 << 13), // Entity is out of play, but remains on screen if killed at base.
    DEATH_CONFIG_REMOVE_VANISH_AIR                  = (1 << 14), // Remove with no trace if killed in air.
    DEATH_CONFIG_REMOVE_VANISH_GROUND        = (1 << 15), // Remove with no trace if killed on ground.
    DEATH_CONFIG_SOURCE_MODEL                          = (1 << 16), // Always use model elvel property.

How I have my death config set up

C:
jumpmove 7 0
atchain 1 1 2 3 4

death_config FALL_LIE_AIR FALL_LIE_GROUND DEATH_AIR DEATH_GROUND REMOVE_CORPSE_AIR REMOVE_CORPSE_GROUND

onspawnscript      data/scripts/body.c
animationscript    data/scripts/main.c
keyscript               data/chars/tony/tonykey.c

It's not working, I don't know if I have something else missing in death config or do I have to change something in dc_respawn_body or both

video reference

OpenBor Engine 3


OpenBor Engine 4


original respawn body code

C:
#import "data/scripts/dc_respawn_body.c"

void main()
{
    void acting_entity = getlocalvar("self");

    int animation_id = openborconstant("ANI_FOLLOW9");

    /*
    * Find our body, remove it and play the
    * rise animation. "That's all you got?!"
    */
    dc_respawn_body(acting_entity, animation_id);
}

C-like:
void dc_respawn_body(void entity, int animation)
{
    int i = 0;
    void target = NULL();
    int entity_count = openborvariant("count_entities");
    char entity_default_name = getentityproperty(entity, "defaultname");
    int resolution_h = openborvariant("hresolution");
    int scroll_h = openborvariant("xpos");

    float target_direction = openborconstant("DIRECTION_LEFT");
    float target_pos_x = 0.0;
    float target_pos_y = 0.0;
    float target_pos_z = 0.0;

    for (i = 0; i < entity_count; i++)
    {
       target = getentity(i);
        if (!target)
        {
            continue;
        }
        if (!getentityproperty(target, "exists"))
        {
            continue;
        }
        if (!getentityproperty(target, "dead"))
        {
            continue;
        }
        if (getentityproperty(target, "defaultname") != entity_default_name)
        {
            continue;
        }
        target_pos_x = getentityproperty(target, "x");
        target_pos_y = getentityproperty(target, "y");
        target_pos_z = getentityproperty(target, "z");
        if (checkhole(target_pos_x, target_pos_z))
        {
            continue;
        }
        if (checkwall(target_pos_x, target_pos_z))
        {
            continue;
        }
        if (target_pos_x <= scroll_h)
        {
            continue;
        }
        if (target_pos_x >= scroll_h + resolution_h)
        {
            continue;
        }
        target_direction = getentityproperty(target, "direction");
        killentity(target);
        changeentityproperty(entity, "direction", target_direction);
        changeentityproperty(entity, "position", target_pos_x, target_pos_z, target_pos_y);
        if (getentityproperty(entity, "animvalid", animation))
        {
            performattack(entity, animation);
        }

        
        return;
    }
}
 
Back
Top Bottom