Solved bindentity

Question that is answered or resolved.

Gurtag

Member
hey guys, is there a step by step tutorial/guide of how to set up a bindentity script? i mean the actual script code how and where to put it, i am trying to get a fire trail with alpha on a character anim, normally spawnframe would do the trick but this time i need the spawned entity to get attached/binded to the desired anim/parent anim.
 
Solution
Have you loaded FireA entity before?

If you haven't, you can:
1. Use load instead of know in models.txt for FireA entry
OR
2. Declare load FireA in enemy's text

Use #1 if FireA is used by others or use #2 if it's only used by specific enemy.
This is bindentity function:

Code:
bindentity(entity, target, int x, int z, int a, int direction, int bindanimation)
~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.
~To unbind a entity, use bindentity(entity, NULL());
~Notice: You can combine those values for bindanimation, so it can be 6 which means 2 and 4.

If you want to code script yourself, that's the function. But there's an example on spawning + binding function:
Code:
void spawnbind(void Name, float dx, float dy, float dz, int Dir, int Flag)
{ // Spawn entity and bind it
   void self = getlocalvar("self");
   void Spawn;

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

void spawn01(void vName, float fX, float fY, float fZ)
{
	//spawn01 (Generic spawner)
	//Damon Vaughn Caskey
	//07/06/2007
	//
	//Spawns entity next to caller.
	//
	//vName: Model name of entity to be spawned in.
	//fX: X location adjustment.
	//fY: Y location adjustment.
      //fZ: 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.
}

I had to include spawn01 function cause spawnbind function calls the former
Usually those functions are in script library declared in character's header so they can be called when needed
Do you know how to use animationscript?

i am trying to get a fire trail with alpha on a character anim

Hmmm.... that might require some setting in fire trail's entity so it removes itself if the character changes animation
Anyways, if you have animationscript set, you can spawn the trail like this:
Code:
@cmd spawnbind "FireTrail" 0 0 0 1 4
frame {path}

Last parameter is set to 4 to set autoremoving feature
 
at first didnt work, changing that last parameter 4 to 0 maded it work but it doesnt get binded, actually it works exactly the same as normal spawnframe, see test video to see what i mean


 
Gurtag to bindentity to work using the option 4, both entities must have the same animation or the spawned entity will be killed instantly.
For example, if Scorpion is executing the animation FREESPECIAL5, the flame needs to have the animation FREESPECIAL5 or it will get killed instantly.
 
it is jumpattack2 anim, it now spawns with that last parameter 4 but still doesnt match/bind eventhough the effect entity is the same in terms of frames, gif names, delay etc. it does seems to match with 2 instead of 4 but then the anim doesnt get killed if scorpion lands before jumpattack2 complete it´s anim
 
I have an enemy wielding a stick:
Idle-01A.png

I have a fire effect:
FireA-03.png

I want to make the stick look like a torch:
Idle-01B.png

Is spawnbind the correct tool to do the job in this case?

I tried to use spawnbind like this:
Code:
anim spawn
     delay 1
     offset 85 155
     @cmd spawnBind "FireA" 0 0 0 1 0
     frame  Data/Entities/Enemies/Shone/Idle-01.png

But nothing happened. My guy is still wielding a stick, not a torch.

The fire script:

Code:
name      FireA
type      none
alpha      6
gfxshadow 1

anim idle
     loop   1
     delay  15
     offset 26 45
     drawmethod channel 0.75
     frame  Data\Effects\FireA\FireA-01.png
     frame  Data\Effects\FireA\FireA-02.png
     frame  Data\Effects\FireA\FireA-03.png
     frame  Data\Effects\FireA\FireA-04.png
     frame  Data\Effects\FireA\FireA-05.png

anim walk
     loop   1
     delay  15
     offset 26 45
     drawmethod channel 0.75
     frame  Data\Effects\FireA\FireA-01.png
     frame  Data\Effects\FireA\FireA-02.png
     frame  Data\Effects\FireA\FireA-03.png
     frame  Data\Effects\FireA\FireA-04.png
     frame  Data\Effects\FireA\FireA-05.png

anim attack1
     loop   1
     delay  15
     offset 26 45
     drawmethod channel 0.75
     frame  Data\Effects\FireA\FireA-01.png
     frame  Data\Effects\FireA\FireA-02.png
     frame  Data\Effects\FireA\FireA-03.png
     frame  Data\Effects\FireA\FireA-04.png
     frame  Data\Effects\FireA\FireA-05.png

What am I doing wrong?
 

Attachments

  • Idle-01A.png
    Idle-01A.png
    3.3 KB · Views: 1
Have you loaded FireA entity before?

If you haven't, you can:
1. Use load instead of know in models.txt for FireA entry
OR
2. Declare load FireA in enemy's text

Use #1 if FireA is used by others or use #2 if it's only used by specific enemy.
 
Solution
How about changing the flame's position according to the enemy's animation?

Idle-01B.png
--> WalkA-02B.png

I tried a few things using move, changeentityproperty("position") and even bindentity again, but the best result I got was making the fire entity drop to the ground.

Any ideas or references on that?
 
think you might need a script where the entity moves along a declared hitbox data for the animation or something similar to hit-box data.
(this means you need a hitbox/position script or data for every frame of animation on the flame area)



the aestetics of a bound entity are really nice, but the positioning of it is a pain in the butt, there might be some kind of semi automatic script out there to help position these things.... i don't know
 
You'd need to use different function to store spawned entity after spawning it so you can move it later.
C:
void spawnBind(void Name, float dx, float dy, float dz, int Dir, int Flag, int Num)
{ // Spawn entity, bind it and store each other
   void self = getlocalvar("self");
   void Spawn;

   Spawn = spawn01(Name, dx, dy, dz);
   bindentity(Spawn, self, dx, dz, dy, Dir, Flag);
   setentityvar(self, Num, Spawn);
   setentityvar(Spawn, Num, self);

   return Spawn; //Return spawn
}

This function stores each other on defined entity variable. Useful if spawned entity needs to acquire something from the spawner and vice versa.
Then use this function to reposition the spawned entity's position.
C:
void postgun(int Num, float dx, float dy, float dz)
{ // Reposition bound gun based on number
    void self = getlocalvar("self");
    void Gun = getentityvar(self, Num);

    if(Gun){
      bindentity(Gun, self, dx, dz, dy, 1, 0);
    }
}

I was thinking of Super C's chopper boss guns when I coded this function so I used the name Gun.
Anyways, declare postgun function after spawnBind has been declared in previous frame.

HTH
 
Hey, thanks again!

I was almost correct in my attempt, all I missed was that bindanimation flag parameter. I was using 1 (keep same animation as the target) instead of 0 (no effect).

Spawnbind worked beautifully when I changed that.
 
Back
Top Bottom