self.enemy = world;
}
+entity warpzone_first; .entity warpzone_next;
void WarpZone_InitStep_FindTarget()
{
float i;
entity e, e2;
+ if(self.enemy)
+ return;
+
// this way only one of the two ents needs to target
if(self.target != "")
{
+ self.enemy = self; // so the if(!e.enemy) check also skips self, saves one IF
+
e2 = world;
- for(e = world; (e = find(e, targetname, self.target)); )
+ for(e = world, i = 0; (e = find(e, targetname, self.target)); )
if(!e.enemy)
- if(random() * ++i < 1)
- e2 = e;
+ if(e.classname == self.classname) // possibly non-warpzones may use the same targetname!
+ if(random() * ++i < 1)
+ e2 = e;
if(!e2)
{
+ self.enemy = world;
error("Warpzone with non-existing target");
return;
}