binding question ?

msmalik681

OpenBOR Developer
Staff member
when a player grabs a enemy in the scripts the enemy becomes the "target". If a script is written from there binded enemy would the player become the "target" ? if not how do i identify the entity the enemy is binded to ?
 
AFAIK bind function doesn't record who entity is bound to/binds. In Crime Busterv2.5 slam scripts, I record grabbed opponent to ensure the next scripts are run at correct entity.

If you want to identify the player enemy is bound to, you can try getting with this:

getentityproperty(self, "opponent");

This will return last entity or in detail, last player the enemy interacted with.

BTW are you trying to make counter slam (grabbed enemy counters the slam by turning player into grabbed victim and perform his/her own slam)?
 
No nothing to do with slams just wanted to bind a entity to enemy everytime they enter pain or fall animation so it checks their hp and shows bar with close to equal percentage.  That's another question can you check hp by percentage rather then raw numbers as 100 or 100% can be very different depending on how much life the enemy has.
 
No, if you want to get percentage, you would need to acquire maximum health too then compare it with current health to get percentage.

      void self = getlocalvar("self");
      int MHealth = getentityproperty(self,"maxhealth");
      int Health = getentityproperty(self,"health");
 
I was excited about getting this working but after getting a script that has no crashes it's still not working  :'(

name HP
type none
shadow 0
lifespan 2
facing 1
antigravity 100

anim idle
loop      0
delay    -1
offset    0 0
@script
void self = getlocalvar("self");
void enemy = getentityproperty(self,"opponent");
int MHealth = getentityproperty(enemy,"maxhealth");
int Health = getentityproperty(enemy,"health");
int PHealth = Health/MHealth*100;
if(PHealth>10){
    changeentityproperty(self,"animation",openborconstant("ANI_FREESPECIAL1"));
}
@end_script
frame    data/chars/0gamefx/hp/100.png
frame    data/chars/0gamefx/empty.png

anim FREESPECIAL1
loop      0
delay    -1
offset    0 0
frame    data/chars/0gamefx/hp/50.png
frame    data/chars/0gamefx/empty.png


this is just a test script but every time i hit the enemy it just shows the normal idle animation but the script should force it to freespecial1.
 
There is no "FREESPECIAL1", it's just "FREESPECIAL". Only FREESPECIAL2 and onward have a number at the end.

DC
 
I am aware there is no such animation but this method works fine with "freespecial1" for my generic portal so i am sure that's not the problem.
 
That may not be the specific problem but it's still wrong - in the future it may not work. Fix it or you'll have issues down the road.

DC
 
If this will cause compatibility issues I will be sure to fix it.  As for my problem I thought of a work around I could do all the HP calculations from the enemy at the start of damage then spawnbind the HP entity with an alias then the HP entity can jump to a frame that corresponds with the alias.

My next roadblock is the spawnbind script I am using has no alias option and I would not know how to add it.
 
Hmmm.... this looks like workaround IMO. But let's skip that one and observe this one:

int PHealth = Health/MHealth*100;
if(PHealth>10){

Why do you run animation change when percentage is more than 10%? I'm not sure what IDLE and FREESPECIAL actually show but I believe it should be:

if(PHealth<=50)

I'm assuming IDLE is for HP 50 to 100 while FREESPECIAL is for 0 to 50.
 
It was a test script to see if the script was working. So to test just had to hit enemy once not beat down to 50% if it was working then I would have put correct figures in.

I have asked utunnels for help with the alias option as he made the spawnbind script if I can get that I'm sure I can make this work !
 
finally figured this out decided to share if anyone else wants to spawn entity with a custom alias this was based on DC's spawn script.  here is the script code:

void spawn02(void vName, float fX, float fY, float fZ, void Alias)
{
  //spawn02 (Generic spawner with alias)
  //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, "name", Alias); //Set Alias to spawned entity
  return vSpawn; //Return spawn.
}


and here is a example how to use: @cmd spawn02 "hanzoatk" 0 0 0 "Ninja"  (this will spawn hanzoatk with the alias ninja)
 
looks like i am still having a problem with this code the highlighted code always returns "working" with any < value and returns "not working" with any > value.  I have changed the script so it changes the enemys name did this so i can check what the code is returning.

void hpbar(void vName, float fx, float fy, float fz)
{
void self = getlocalvar("self"); //Get calling entity.
void vSpawn; //Spawn object.
void Alias;
int Health = getentityproperty(self,"health");
int MHealth = getentityproperty(self,"maxhealth");
int PHealth = (Health/MHealth*100);
clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name",vName); //Acquire spawn entity by name.
      int dx = getentityproperty(self, "x"); //Get X location and add adjustment.
      int dy = getentityproperty(self, "a"); //Get Y location and add adjustment.
      int dz = getentityproperty(self, "z"); //Get Z location and add adjustment.
if(PHealth>10)Alias="working";
else{
Alias = "not working";
}

vSpawn = spawn(); //Spawn in entity.
changeentityproperty(vSpawn, "position", dx, dy, dz); //Set spawn location.
bindentity(vSpawn, self, fx, fz, fy, 0, 0);
    changeentityproperty(self, "name", Alias); //Set Alias to spawned entity
return vSpawn; //Return spawn.
}


if anyone has any ideas what i am doing wrong please share.
 
Back
Top Bottom