binding object by alias & distance

oldyz

Well-known member
well, here is a  script but i can't get it to work...

Code:
void bindobjectv3(char target_name,int RxMin, int RxMax, int Rz, float dx, float dy, float dz, int Dir, int Flag)
{// bind any entity on the screen by the given name, plus closest distance
//Douglas Baldan - 11.27.2016 - Really thanks for the fix, White Dragon
// Thanks Lagarto
   void self = getlocalvar("self");
    void target = findtarget(self); //Get nearest player
    float x = getentityproperty(self, "x");
    float z = getentityproperty(self, "z");
    int dir = getentityproperty(self, "direction");

	int i;
	for (i = 0; i < openborvariant("count_entities"); ++i)
	{
    		void ent = getentity(i);
		if ( getentityproperty(ent, "exists") )
	   	{
       			if ( getentityproperty(ent,"name") == target_name)
    if(target!=ent()){
      float Tx = getentityproperty(target, "x");
      float Tz = getentityproperty(target, "z");
      float Disx = Tx - x;
      float Disz = Tz - z;
			{
 changeentityproperty(ent, "name", "Ron");
				 if(Disz < 0){
        Disz = -Disz;
      }

      if( Disx >= RxMin && Disx <= RxMax && Disz <= Rz && dir == 1) // Target within range on right facing?
      {
                                bindentity(ent, self, dx, dz, dy, Dir, Flag);
				continue;
 } else if( Disx >= -RxMax && Disx <= -RxMin && Disz <= Rz && dir == 0) // Target within range on left facing?
      {
        bindentity(ent, self, dx, dz, dy, Dir, Flag);
				continue;
			}
		} else continue;
	}
	return;	
}

//checkrange(entity, target, int animid)///

you are supposed to enter the name of the alias, & the a range limit so it does not go binding using the whole screen... (that is the only stop-gap measure i can think of.

the best would be to just bind the spawner to the spawned & make sure its permanent even if another copy of the spawner is present, i just cant finda way to prevent that

 
Back
Top Bottom