kill a summoned entity if summoner is hit

Aerisetta

Active member
I have enemy that casts a big magic attack

while the enemy is casting, I want him to spawn/summon a danger zone to warn the player to move out of the way

however, if the enemy gets hit during this time, the casting will stop, however, the danger zone will stay until the time is up

is there a way for the danger zone to disappear when the enemy is stopped from casting? (pain, death, grabbed)
 
Without script?

You can use summon frame to call it and add a unsummonframe in your pain and fall animations. But it could be not that useful depending on how you spawn the danger zone.

With script, there are couple ways to do that like
- making the danger zone to detect if it's parent is hit and kill it (assuming you had set the parent first)

- making the parent to use a script to controll all the danger zone entities while hit and force them to kill themselves.
 
Thanks i think spawnbind might work

I have a bunch of them, do any of these work?


Code:
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;
}


void spawnbind2(void Name, float dx, float dy, float dz, int Face)
{ // Spawn and bind other entity with facing direction control
   void self = getlocalvar("self");
   void Spawn;

   Spawn = spawn01(Name, dx, dy, dz);
   bindentity(Spawn, self, dx, dz, dy, Face, 0);
}


void spawnbind3(void Name, float dx, float dy, float dz)
{ // Spawn and bind other entity with facing direction control and same remap
   void self = getlocalvar("self");
   int map = getentityproperty(self,"map");
   void Spawn;

   Spawn = spawn01(Name, dx, dy, dz);
   changeentityproperty(Spawn, "map", map);
   bindentity(Spawn, self, dx, dz, dy, 0, 0);
}



void spawnbind4(void Name, float dx, float dy, float dz, int Dir, int Flag)
{ // Spawn entity and bind it with same animation as caller
   void self = getlocalvar("self");
   void Spawn;
   int iMap = getentityproperty(self,"map");

   Spawn = spawn01(Name, dx, dy, dz);
   changeentityproperty(Spawn, "map", iMap);
   bindentity(Spawn, self, dx, dz, dy, Dir, Flag);
}


void spawnbind5(void Name, float dx, float dy, float dz, float map)
{ // Spawn and bind other entity with map choose
   void self = getlocalvar("self");
   void Spawn;

   Spawn = spawn01(Name, dx, dy, dz);
   changeentityproperty(Spawn, "map", map);
   bindentity(Spawn, self, dx, dz, dy, 0, 0);
}


void spawnbind6(void Name, float dx, float dy, float dz, void Ani)
{ // Spawn and bind other entity with animation
   void self = getlocalvar("self");
   void Spawn;

   Spawn = spawn01(Name, dx, dy, 0);
   bindentity(Spawn, self, dx, dz, dy, 0, 0);
   performattack(Spawn, openborconstant(Ani));
}
 
How do I write it so that it will disappear? currently the spawned thing does not disappear when the spawner is hit
ah your spawnbind() funciton is incomplete, that is why.

It should be:

C-like:
void spawnbind(void name, float dx, float dy, float dz, int iDir, int iBind)
{//Spawn and bind other entity
    void self    = getlocalvar("self");
    void vSpawn    = spawn01(name, dx, dy, 0);

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

    return vSpawn;
}

and the usage would be:

@cmd spawnbind2 "danger1" 50 0 3 0 4

Keep in mind that the spawned entity must have the same animation the called is using when call it, or it will get destroyed thanks to the "4" on the command.

Bindentity has 2(3 in fact, but we are not using it here) extra settings:

bindentity(entity, target, int x, int z, int a, int direction, int bindanimation, int sortid)

  • Bind entity to target, so the target moves, the entity moves.
  • x, z, a: relative to target.
  • direction: 0 no change 1 same direction as target -1 opposite direction as target 2 always right -2 always left
  • bindanimation: 0 No effect. 1 Keep same animation as the target. 2 Also keep same frame as the target. 4 Kill the entity if the animation doesn't match.
  • sortid: -1 by default. -1 means that the binded entity is on back the target. you can set 1 to show binded entity in front of target or you can use what-you-want value.
  • To unbind a entity, use bindentity(entity, NULL());
  • Partial binding is now possible (4183+). Pass NULL() to any axis you do not want to bind.
  • Notice: You can combine those values for bindanimation, so it can be 6 which means 2 and 4.
 
@Aerisetta I had made this function long time ago to simulate Mugen "Remove On Get Hit" behaviour and maybe this could be useful for you

C-like:
void removeOnGetHit()
{
// Check the parent pain status and kill self to recreate Mugen's removeongethit behaviour
// O Ilusionista - 05/05/2021
void self = getlocalvar("self");
void parent = getentityproperty(self, "parent");
void parPain = getentityproperty(parent, "aiflag", "inpain");
void parFall = getentityproperty(parent, "aiflag", "falling");


if(parent!=NULL()){ // Valid Parent?
  if (parPain == 1 || parFall == 1){killentity(self);}
  }
}

First, our spawned entity needs to know who is its parent (check your spawn functions)
second, this is an animationscript, so either you put it on all frames or use a frame loop
 
@Aerisetta I had made this function long time ago to simulate Mugen "Remove On Get Hit" behaviour and maybe this could be useful for you

C-like:
void removeOnGetHit()
{
// Check the parent pain status and kill self to recreate Mugen's removeongethit behaviour
// O Ilusionista - 05/05/2021
void self = getlocalvar("self");
void parent = getentityproperty(self, "parent");
void parPain = getentityproperty(parent, "aiflag", "inpain");
void parFall = getentityproperty(parent, "aiflag", "falling");


if(parent!=NULL()){ // Valid Parent?
  if (parPain == 1 || parFall == 1){killentity(self);}
  }
}

First, our spawned entity needs to know who is its parent (check your spawn functions)
second, this is an animationscript, so either you put it on all frames or use a frame loop

Thanks a lot!

In the end i solved it with spawnbind

this is what it looks like in game
 
Last edited:
Back
Top Bottom