Solved help with spawnbind script

Question that is answered or resolved.

AlexDC22

Well-known member
so i been using the script below to add special fx to moves...problem is that i cant seem to have it unbind using 4 and or 4 at the end for the flag.
so i started to use the kill entity script...that sorta works...problem is that for example terry here..if you perform the move just before landing,...well the video will show lol...
any way to correct that? using custknife hasnt been fruitful for this and bisons psycho crusher moves, but has worked for others...anyways thanks for the advice.


Code:
void spawn01(void vName, float fX, float fY, float fZ)
{
    //spawn01 (Generic spawner)
    //Damon Vaughn Caskey
    //Spawns entity next to caller.
    //
    //vName: Model name of entity to be spawned in.
    //fX: X location adjustment.
    //fZ: Y location adjustment.
        //fY: Z location adjustment.

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int  iDirection = getentityproperty(self, "direction");
    clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

    if (iDirection == 0){ //Is entity facing left?                 
          fX = -fX; //Reverse X direction to match facing.
    }

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
    
    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
    changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
    return vSpawn; //Return spawn.
}

void spawn01m(void vName, float fX, float fY, float fZ)
{
    //spawn01 (Generic spawner)
    //Damon Vaughn Caskey
    //Spawns entity next to caller.
    //
    //vName: Model name of entity to be spawned in.
    //fX: X location adjustment.
    //fZ: Y location adjustment.
        //fY: Z location adjustment.

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int  iDirection = getentityproperty(self, "direction");
    clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

    if (iDirection == 0){ //Is entity facing left?                 
          fX = -fX; //Reverse X direction to match facing.
    }

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
    
    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
    changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
        changeentityproperty(vSpawn, "map", 3);
    return vSpawn; //Return spawn.
}

void spawn02m(void vName, float fX, float fY, float fZ)
{
    //spawn01 (Generic spawner)
    //Damon Vaughn Caskey
    //Spawns entity next to caller.
    //
    //vName: Model name of entity to be spawned in.
    //fX: X location adjustment.
    //fZ: Y location adjustment.
        //fY: Z location adjustment.

    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int  iDirection = getentityproperty(self, "direction");
    clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

    if (iDirection == 0){ //Is entity facing left?                 
          fX = -fX; //Reverse X direction to match facing.
    }

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
    
    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
    changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
        changeentityproperty(vSpawn, "map", 1);
    return vSpawn; //Return spawn.
}

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

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

void spawn02(void vName, float fX, float fY, float fZ, void Alias)
{
    //spawn02 (Generic spawner with alias)
    //Spawns entity next to caller.
    //vName: Model name of entity to be spawned in.
    //fX: X location adjustment.
    //fZ: Y location adjustment.
        //fY: Z location adjustment.
    void self = getlocalvar("self"); //Get calling entity.
    void vSpawn; //Spawn object.
    int  iDirection = getentityproperty(self, "direction");

    clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name",vName); //Acquire spawn entity by name.
    if (iDirection == 0){ //Is entity facing left?                 
          fX = -fX; //Reverse X direction to match facing.
    }

      fX = fX + getentityproperty(self, "x"); //Get X location and add adjustment.
      fY = fY + getentityproperty(self, "a"); //Get Y location and add adjustment.
      fZ = fZ + getentityproperty(self, "z"); //Get Z location and add adjustment.
    
    vSpawn = spawn(); //Spawn in entity.

    changeentityproperty(vSpawn, "position", fX, fZ, fY); //Set spawn location.
    changeentityproperty(vSpawn, "direction", iDirection); //Set direction.
        changeentityproperty(vSpawn, "name", Alias); //Set Alias to spawned entity
    return vSpawn; //Return spawn.
}

void spawnbind02(void Name, float dx, float dy, float dz)
{ // Spawn and bind other entity
   void self = getlocalvar("self");
   void frame = getentityproperty(self, "animpos");
   void Spawn;

   Spawn = spawn(Name, dx, dy, 0);
   bindentity(Spawn, self, dx, dz, dy, 0, 0);
   updateframe(Spawn, frame);
}



////Kill entities//////



void terminate(char target_name)
{// kill any entity on the screen by the given name
//Douglas Baldan - 11.27.2016 - Really thanks for the fix, White Dragon
// Thanks Lagarto
    int i;
    for (i = 0; i < openborvariant("count_entities"); ++i)
    {
            void ent = getentity(i);
        if ( getentityproperty(ent, "exists") )
           {
                   if ( getentityproperty(ent,"model") == target_name)
            {
                killentity(ent);
                continue;
            }
        } else continue;
    }
    return;
}

void terminateAlias(char target_name)
{// kill any entity on the screen by the given name
//Douglas Baldan - 2021.06.17 - Really thanks for the fix, White Dragon
// Thanks Lagarto
  int i;
  for (i = 0; i < openborvariant("count_entities"); ++i)
  {
        void ent = getentity(i);
    if ( getentityproperty(ent, "exists") )
      {
            if ( getentityproperty(ent,"name") == target_name)
      {
        killentity(ent);
        continue;
      }
    } else continue;
  }
  return;
}



his animation code
Code:
anim runjumpattack
        loop    0
        offset    34 104
        delay   3
        sound   data/sounds/terpdunk.wav
        @cmd spawnbind "tpdunk" 55 60 2 1 4
        frame    data/chars/terry/rjatk00.gif
offset  34 118
        frame    data/chars/terry/rjatk01.gif
offset  32 118
        frame    data/chars/terry/rjatk02.gif
offset  30 120
        frame    data/chars/terry/rjatk03.gif
offset  25 121
        frame    data/chars/terry/rjatk04.gif
offset  25 121
        frame    data/chars/terry/rjatk05.gif
offset  25 120
        frame    data/chars/terry/rjatk06.gif
offset  22 114
        frame    data/chars/terry/rjatk07.gif
offset  48 121
        @cmd terminate "tpdunk"
        delay   20
        frame    data/chars/terry/rjatk08.gif
offset  48 113
        delay   3
        frame    data/chars/terry/rjatk09.gif
        frame    data/chars/terry/rjatk09.gif
 
You should kill the special fx entity at the end of it's own animation cycle instead of killing the special fx at the end of the hero's runjumpattack. whats happening in the video is the frame you've decided to terminate the special fx is not getting reached and doesn't terminate, you could fix it by using the terminate function with landframe inside runjumpattack,


Code:
anim runjumpattack
        loop    0
        offset    34 104
        delay   3
      landframe  8
        sound   data/sounds/terpdunk.wav
        @cmd spawnbind "tpdunk" 55 60 2 1 4
        frame    data/chars/terry/rjatk00.gif
offset  34 118
        frame    data/chars/terry/rjatk01.gif
offset  32 118
        frame    data/chars/terry/rjatk02.gif
offset  30 120
        frame    data/chars/terry/rjatk03.gif
offset  25 121
        frame    data/chars/terry/rjatk04.gif
offset  25 121
        frame    data/chars/terry/rjatk05.gif
offset  25 120
        frame    data/chars/terry/rjatk06.gif
offset  22 114
Delay -1000
        frame    data/chars/terry/rjatk07.gif
offset  48 121
        @cmd terminate "tpdunk"
        delay   20
        frame    data/chars/terry/rjatk08.gif  #landframe
offset  48 113
        delay   3
        frame    data/chars/terry/rjatk09.gif
        frame    data/chars/terry/rjatk09.gif



but landframe might not always be guaranteed so I personally think it would be better to kill the special fx entity once it's done it's job,

Use @cmd suicide at the end of your special fx animation

C:
void suicide()
{ // Suicide!!
    void self = getlocalvar("self");

    killentity(self); //Suicide!
}
 
thank you sir... landframe fixed it for me....
didnt know about suicide tho lol.... brings up some ideas lol
thanks again


Edit: i misunderstood and the command suicide works way better... i was adding it to the players text file instead of the special fx text file.
 
Last edited:
Back
Top Bottom