Toranks
Active member
I have a script that emulates a taunt behavior. Holding down A2 executes a freespecial with
that gives a little MP if there is an enemy close enough (50 pixels around in this code).
Now the question. How could I also count the number of enemies within that distance, if there is more than one?
Code:
@cmd taunt XX
Now the question. How could I also count the number of enemies within that distance, if there is more than one?
C#:
void taunt(int add)
{
void self = getlocalvar("self");
void MP = getentityproperty(self,"mp");
void target = findtarget(self);
int x = getentityproperty(self, "x");
int z = getentityproperty(self, "z");
void enemy = getentityproperty(target,"type");
if(target != NULL() && enemy == openborconstant("TYPE_ENEMY"))
{
float Tx = getentityproperty(target, "x");
float Tz = getentityproperty(target, "z");
float Disx = Tx - x;
float Disz = Tz - z;
if( Disx >= -50 && Disx <= 50 && Disz >= -50 && Disz <= 50)
{
changeentityproperty(self, "mp", MP+add);
}
}
}