Spawnbind or Bindtoentity

NONAME01150

New member
So which is better or how does each one work?
because i've found the latter in openborstats v0.62 but i haven't tried neither of the two.
PS i am using openborstats v0.53 despite having a updated version.
 
You should see spawnbind 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);
}

I believe when you say Bindtoentity , you meant bindentity.
spawnbind works like this: it spawns an entity then binds it to spawner. bindentity is the function who does the binding.

None is better than the other. You just need to use each properly :)
 
Thanks for the explanation of the spawnbind function!
Also, once i am able to open openborstats 0.62 i will post the script and see it's name.

edit: It's found in the misc section of the script section in openborstats.

void bindtoentity(void self, void target, int lock, int x, int y, int z)
{
  // Binds self to the target
  // V 0.01

  if ( checkent(self) == 1 ) {
    void Health = getentityproperty(target,"health");
    int cancon = 0;

    if ( target != NULL() && Health > 0 )
    {

      if (lock == 1)
      {
        bindentity(self, target , x, z, y, 0, 0);
      }else {
      if (lock == 0)
      {
        bindentity( self, NULL());
      }
      }
    }
    if (Health < 1)
    {
      killentity(target);
      //changeentityproperty( self, "health", 0 );
      //changeentityproperty( self, "aiflag", "autokill", 1 );
    }
  }
}

also while on the topic, can i use more than one spawnbind to spawn and bind more entities?
 
Ah so that's bindtoentity function. As name implies, it binds self to other entity.

Back to your question, IMO spawnbind is better cause it's easier to use. bindtoentity is best used with other function cause it requires acquiring the other entity before binding. It's not that simple.
Moreover, bindtoentity has extra lines for other purpose (not sure what or why) so it's not easy to use.

can i use more than one spawnbind to spawn and bind more entities?

Yes of course :).

That reminds me, spawnbind is usually used to spawn effects which should move together with entity.
For instance, hero performs electro jump kick. Electric FX is created as seperate entity. Then it's spawnbound in jump kick's animation.
The FX has short lifespan so it will remove itself when it's done showing the effect.
 
Back to your question, IMO spawnbind is better cause it's easier to use. bindtoentity is best used with other function cause it requires acquiring the other entity before binding. It's not that simple.
Moreover, bindtoentity has extra lines for other purpose (not sure what or why) so it's not easy to use.
Yes of course :).

That reminds me, spawnbind is usually used to spawn effects which should move together with entity.
For instance, hero performs electro jump kick. Electric FX is created as seperate entity. Then it's spawnbound in jump kick's animation.
The FX has short lifespan so it will remove itself when it's done showing the effect.
thanks for these informations. they will help me avoid some mistakes when using spawnbind.
also just one more question:
can i bind entities onto a entity that is type player and make those binded entities act as they were part of the main entity?
an example being: a playable character that is a tank but only servers as the treads of the character and the binded entities being the main cannon and two small cannons who can fire, like, when i press attack 1, the main cannon shots a projectile and when i press attack 2, the two small cannons shots projectiles? can i do it?
 
can i bind entities onto a entity that is type player and make those binded entities act as they were part of the main entity?

You can but you need to link those bound entities so main entity can control them and they can transfer damage to main entity.
If the binding structure is simple, it should be easy to do the former and there's an easy workaround for the latter.
 
You can but you need to link those bound entities so main entity can control them and they can transfer damage to main entity.
When you say link those bound entities, do you mean like, i just use spawnbind and the engine already does the things such as making the bound entity use ANI_ATTACK when i press attack 1 or is this more complicated than it sounds? Because i was trying to, like, grab an enemy from metal slug and put it in openbor as a playable character and the enemy more or less makes itself has the treads as the main body and a cannon who's sprites are separated from the treads. It's name is Girida-O.
 
i just use spawnbind and the engine already does the things such as making the bound entity use ANI_ATTACK when i press attack 1 or is this more complicated than it sounds?

Well, it is slightly more complicated. I'll quote spawnbind again:
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);
}

See Flag parameter? it directly sets bindentity function. Here's description of bindentity's parameters:
Code:
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.

See the line with bindanimation in it. If you set it to 1, bound entity will perform same animation as binder or main entity who spawnbinds it.
Just that simple :).

Actually, what I meant with link is more complicated than that, however...

grab an enemy from metal slug and put it in openbor as a playable character and the enemy more or less makes itself has the treads as the main body and a cannon who's sprites are separated from the treads

Ah, I know that generic tank :).
Since the tank has simple generic structure, you don't have to worry about setting bbox and attackbox.
 
sorry for dumping all this but...
after my last question, i was experimenting with spawnbind and managed to make the cannon stay on top of the tank but everytime i move the tank to the right the cannon disappears.
empty%20-%200002.png

this is when the stage starts.
empty%20-%200003.png

this is when i move left, the cannon doesn't disappear but when i move right.
empty%20-%200004.png

the cannon disappears even if i have a walk animation to the cannon.
empty%20-%200007.png

and if i change the flag to 3, the cannon just falls flat to the ground when i go right, up or down and the cannon doesn't respond anymore.

edit: what i wanted to show is what happened with the cannon but it seems the images doesn't appear.
when the tank spawns, he spawns together with the cannon.
when i move the tank to the left, the cannon also goes with the char but when i move him to the right the cannon just falls flat to the ground if i have flag 3 because when i have flag 4, the cannon disappears.

i'm thinking of giving up on spawnbind.
 
I will upload the tank and it's cannon once i'm able to go to the computer, i will upload the entities.

edit: https://www.mediafire.com/file/dfb762c0z2652ws/tank.zip/file
this link contains the tank, the cannon and the scripts used.
i also know that the Girida-O is with wrong color or with cut parts of his sprites and of the cannon sprites.
 
Thank you for uploading, I have checked the tank and found the problem.

Main body has BACKWALK animation but the turret doesn't have it. I've added that animation and the binding works. Moving right and left doesn't remove the turret as expected :).

I noticed that you set binding flag to 5 or 1+4. I suggest to just set 1 since the turret lasts together with main body. Setting to 4 or 5 is only suggested for binding effects such as aura and flashy effects. These effects last when certain animation is run but don't appear in other animations, that's why setting 4 or 5 is suggested to automatically remove them when animation change.
 
thank you for finding the problem!
I suggest to just set 1 since the turret lasts together with main body. Setting to 4 or 5 is only suggested for binding effects such as aura and flashy effects. These effects last when certain animation is run but don't appear in other animations, that's why setting 4 or 5 is suggested to automatically remove them when animation change.
and thank you for this information, you have been a great help during this time!
 
Back
Top Bottom