-entity ons_Nearest_ControlPoint(vector pos, float max_dist)
-{SELFPARAM();
- entity tmp_entity, closest_target = world;
- tmp_entity = findchain(classname, "onslaught_controlpoint");
- while(tmp_entity)
- {
- if(SAME_TEAM(tmp_entity, self))
- if(tmp_entity.iscaptured)
- if(max_dist <= 0 || vdist(tmp_entity.origin - pos, <=, max_dist))
- if(vlen2(tmp_entity.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == world)
- closest_target = tmp_entity;
- tmp_entity = tmp_entity.chain;
- }
- tmp_entity = findchain(classname, "onslaught_generator");
- while(tmp_entity)
+entity ons_Nearest_ControlPoint(entity this, vector pos, float max_dist)
+{
+ entity closest_target = NULL;
+ FOREACH_ENTITY_CLASS("onslaught_controlpoint", true,
+ {
+ if(SAME_TEAM(it, this))
+ if(it.iscaptured)
+ if(max_dist <= 0 || vdist(it.origin - pos, <=, max_dist))
+ if(vlen2(it.origin - pos) <= vlen2(closest_target.origin - pos) || closest_target == NULL)
+ closest_target = it;
+ });
+ FOREACH_ENTITY_CLASS("onslaught_generator", true,