script help

Gurtag

Member
hey guys i am using this script as timer to kill entities on demand at the desired laps of time, but i need to to just remove the entity instead of playing death anim, what piece of code am i missing..?

Code:
void lifespan(int Value){
    void self = getlocalvar("self");

    changeentityproperty(self, "lifespancountdown", Value);
}
 
hey guys i am using this script as timer to kill entities on demand at the desired laps of time, but i need to to just remove the entity instead of playing death anim, what piece of code am i missing..?

Code:
void lifespan(int Value){
    void self = getlocalvar("self");

    changeentityproperty(self, "lifespancountdown", Value);
}

If you just want to outright remove an entity on the spot, you kill it.

Note, the version matters - OpenBOR 3.x doesn't have the optional "trigger" flag mentioned, but the kill function is the same otherwise.

DC
 
hey guys i am using this script as timer to kill entities on demand at the desired laps of time, but i need to to just remove the entity instead of playing death anim, what piece of code am i missing..?

Do you want to have entities to remove themselves on their own? or do you want to remove certain entities at certain time?
 
you mean like adding a timer to the killentity script? would try it out

You could do that, but the engine already has a timer and gives you access to it.

C:
int current_time = openborvariant("elapsed_time");

It's an incremental counter that starts at 0 at each level and goes up every engine update. It's how pretty much everything works in the engine that is time related. Animations, lifespans, you name it - and you can use it in your scripts the same way. You set a value of current_time + YOUR_DELAY, then on update, you compare current time to that value. When current time catches up, you take your action.

C:
// Kill supplied entity after X time.

void dc_example_suicide(void acting_entity, int delay_time)
{
    /* Guards */
    if(typeof(acting_entity) != openborconstant("VT_PTR")
    || typeof(delay_time) != openborconstant("VT_INTEGER"))
    {
        shutdown(1, "ERROR: dc_example_suicide(" + acting_entity + ", " + delay_time + ") - Missing or invalid parameter.");
    }

    int current_time = openborvariant("elapsed_time");
    void kill_time = getentityvar(acting_entity, "kill_time");

    // Timer has not been set yet.
    if(typeof(kill_time) != openborconstant("VT_INTEGER"))
    {
        setentityvar(acting_entity, "kill_time", current_time + delay_time);
    }
    else
    {
        // Timer expired. Kill entity.
        if(current_time >= kill_time)
        {
            killentity(acting_entity);
        }
    }
}

Use (typically in the entity update):
C:
// Kill entity after 3 seconds.
void acting_entity = getlocalvar("self");

dc_example_suicide(acting_entity, 300);

HTH,
DC
 
Back
Top Bottom