• All, I am currently in the process of migrating domain registrations. During this time there may be some intermittent outages or slowdowns. Please contact staff if you have any questions.

Kill Spawnbind entity when parent dies

Aerisetta

Active member
I have a creature that spawns a VFX entity on spawn using spawnbind so the VFX will loop and stick with the creature

However, when the creature dies, the spawnbind item stays in the field and continue to loop.

How can I make the spawnbind entity disappear when the parent dies?
 
You can define the creature as a VFX entity's parent inside the spawnbind script, and then add a suicide script inside the animation loop or in some engine cycle events like update/ondraw/think.

C:
void spawnBind(void name, float dx, float dy, float dz)
{//Spawn and bind other entity
    void self    = getlocalvar("self");
    void vSpawn    = spawn01(name, dx, dy, 0);

    bindentity(vSpawn, self, dx, dz, dy, 0, 0);
    changeentityproperty(vSpawn, "parent", self);

    return vSpawn;
}

C:
void suicideP()
{//Suicide if your caller is a Parent and if are dead
    void self    = getlocalvar("self");
    void parent    = getentityproperty(self, "parent");
    int dead    = getentityproperty(parent, "dead");
   
    if(parent != NULL()){
        if(dead){
            killentity(self);
        }
    }
}

anim idle
loop 1
delay 16
offset 25 25
frame data/bgs/sor1/st2a/drop00.png
frame data/bgs/sor1/st2a/drop01.png
frame data/bgs/sor1/st2a/drop02.png
@cmd suicideP
frame data/bgs/sor1/st2a/drop03.png
 
Last edited:
Back
Top Bottom