if((teamplay && trace_ent.team == this.team) || !teamplay)
{
- if(trace_ent.vehicle_flags & VHF_ISVEHICLE)
+ if(IS_VEHICLE(trace_ent))
{
if(autocvar_g_vehicle_bumblebee_healgun_sps && trace_ent.vehicle_health <= trace_ent.max_health)
trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * frametime, trace_ent.tur_head.max_health);
this.aistatus |= AI_STATUS_WAYPOINT_PERSONAL_LINKING;
// if pos is inside a teleport, then let's mark it as teleport waypoint
- entity head;
- for(head = NULL; (head = find(head, classname, "trigger_teleport")); )
+ FOREACH_ENTITY_CLASS("trigger_teleport", WarpZoneLib_BoxTouchesBrush(pos, pos, it, NULL),
{
- if(WarpZoneLib_BoxTouchesBrush(pos, pos, head, NULL))
- {
- wp.wpflags |= WAYPOINTFLAG_TELEPORT;
- this.lastteleporttime = 0;
- }
- }
+ wp.wpflags |= WAYPOINTFLAG_TELEPORT;
+ this.lastteleporttime = 0;
+ });
/*
if(wp.wpflags & WAYPOINTFLAG_TELEPORT)
{
float killtime;
float starttime;
- entity e;
if (gameover)
return;
this.killindicator.count = bound(0, ceil(killtime), 10);
//sprint(this, strcat("^1You'll be dead in ", ftos(this.killindicator.cnt), " seconds\n"));
- for(e = NULL; (e = find(e, classname, "body")) != NULL; )
+ FOREACH_ENTITY_ENT(enemy, this,
{
- if(e.enemy != this)
+ if(it.classname != "body")
continue;
- e.killindicator = spawn();
- e.killindicator.owner = e;
- e.killindicator.scale = 0.5;
- setattachment(e.killindicator, e, "");
- setorigin(e.killindicator, '0 0 52');
- setthink(e.killindicator, KillIndicator_Think);
- e.killindicator.nextthink = starttime + (e.lip) * 0.05;
- clientkilltime = max(clientkilltime, e.killindicator.nextthink + 0.05);
- e.killindicator.cnt = ceil(killtime);
- }
+ it.killindicator = spawn();
+ it.killindicator.owner = it;
+ it.killindicator.scale = 0.5;
+ setattachment(it.killindicator, it, "");
+ setorigin(it.killindicator, '0 0 52');
+ setthink(it.killindicator, KillIndicator_Think);
+ it.killindicator.nextthink = starttime + (it.lip) * 0.05;
+ clientkilltime = max(clientkilltime, it.killindicator.nextthink + 0.05);
+ it.killindicator.cnt = ceil(killtime);
+ });
this.lip = 0;
}
}
while(head) // find the closest acceptable target to enter
{
- if(head.vehicle_flags & VHF_ISVEHICLE)
+ if(IS_VEHICLE(head))
if(!IS_DEAD(head))
if(!head.owner || ((head.vehicle_flags & VHF_MULTISLOT) && SAME_TEAM(head.owner, this)))
if(head.takedamage != DAMAGE_NO)
void assault_setenemytoobjective(entity this)
{
- entity objective;
- for(objective = NULL; (objective = find(objective, targetname, this.target)); )
+ FOREACH_ENTITY_STRING(targetname, this.target,
{
- if(objective.classname == "target_objective")
+ if(it.classname == "target_objective")
{
if(this.enemy == NULL)
- this.enemy = objective;
+ this.enemy = it;
else
objerror(this, "more than one objective as target - fix the map!");
break;
}
- }
+ });
if(this.enemy == NULL)
objerror(this, "no objective as target - fix the map!");
void target_objective_decrease_activate(entity this)
{
- entity ent, spr;
+ entity spr;
this.owner = NULL;
- for(ent = NULL; (ent = find(ent, target, this.targetname)); )
+ FOREACH_ENTITY_STRING(target, this.targetname,
{
- if(ent.assault_sprite != NULL)
+ if(it.assault_sprite != NULL)
{
- WaypointSprite_Disown(ent.assault_sprite, waypointsprite_deadlifetime);
- if(ent.classname == "func_assault_destructible")
- ent.sprite = NULL; // TODO: just unsetting it?!
+ WaypointSprite_Disown(it.assault_sprite, waypointsprite_deadlifetime);
+ if(it.classname == "func_assault_destructible")
+ it.sprite = NULL; // TODO: just unsetting it?!
}
- spr = WaypointSprite_SpawnFixed(WP_Assault, 0.5 * (ent.absmin + ent.absmax), ent, assault_sprite, RADARICON_OBJECTIVE);
+ spr = WaypointSprite_SpawnFixed(WP_Assault, 0.5 * (it.absmin + it.absmax), it, assault_sprite, RADARICON_OBJECTIVE);
spr.assault_decreaser = this;
spr.waypointsprite_visible_for_player = assault_decreaser_sprite_visible;
spr.classname = "sprite_waypoint";
WaypointSprite_UpdateRule(spr, assault_attacker_team, SPRITERULE_TEAMPLAY);
- if(ent.classname == "func_assault_destructible")
+ if(it.classname == "func_assault_destructible")
{
WaypointSprite_UpdateSprites(spr, WP_AssaultDefend, WP_AssaultDestroy, WP_AssaultDestroy);
- WaypointSprite_UpdateMaxHealth(spr, ent.max_health);
- WaypointSprite_UpdateHealth(spr, ent.health);
- ent.sprite = spr;
+ WaypointSprite_UpdateMaxHealth(spr, it.max_health);
+ WaypointSprite_UpdateHealth(spr, it.health);
+ it.sprite = spr;
}
else
WaypointSprite_UpdateSprites(spr, WP_AssaultDefend, WP_AssaultPush, WP_AssaultPush);
- }
+ });
}
void target_objective_decrease_findtarget(entity this)
// legacy bot code
void havocbot_goalrating_ast_targets(entity this, float ratingscale)
{
- entity ad, best, wp, tod;
- float radius, found, bestvalue;
+ entity ad, best, wp;
+ float radius, bestvalue;
+ bool found;
vector p;
ad = findchain(classname, "func_assault_destructible");
continue;
found = false;
- for(tod = NULL; (tod = find(tod, targetname, ad.target)); )
+ FOREACH_ENTITY_STRING(targetname, ad.target,
{
- if(tod.classname == "target_objective_decrease")
+ if(it.classname == "target_objective_decrease")
{
- if(tod.enemy.health > 0 && tod.enemy.health < ASSAULT_VALUE_INACTIVE)
+ if(it.enemy.health > 0 && it.enemy.health < ASSAULT_VALUE_INACTIVE)
{
// dprint(etos(ad),"\n");
found = true;
break;
}
}
- }
+ });
if(!found)
{
WaypointSprite_UpdateSprites(this.sprite, msg, WP_Null, WP_Null);
total_pps = 0, pps_red = 0, pps_blue = 0, pps_yellow = 0, pps_pink = 0;
- for(head = NULL; (head = find(head, classname, "dom_controlpoint")) != NULL; )
FOREACH_ENTITY_CLASS("dom_controlpoint", true, LAMBDA(
if (autocvar_g_domination_point_amt)
points = autocvar_g_domination_point_amt;
float total_controlpoints;
void Domination_count_controlpoints()
{
- entity e;
total_controlpoints = redowned = blueowned = yellowowned = pinkowned = 0;
- for(e = NULL; (e = find(e, classname, "dom_controlpoint")) != NULL; )
+ FOREACH_ENTITY_CLASS("dom_controlpoint", true,
{
++total_controlpoints;
- redowned += (e.goalentity.team == NUM_TEAM_1);
- blueowned += (e.goalentity.team == NUM_TEAM_2);
- yellowowned += (e.goalentity.team == NUM_TEAM_3);
- pinkowned += (e.goalentity.team == NUM_TEAM_4);
- }
+ redowned += (it.goalentity.team == NUM_TEAM_1);
+ blueowned += (it.goalentity.team == NUM_TEAM_2);
+ yellowowned += (it.goalentity.team == NUM_TEAM_3);
+ pinkowned += (it.goalentity.team == NUM_TEAM_4);
+ });
}
float Domination_GetWinnerTeam()
entity invasion_PickSpawn()
{
- entity e;
-
RandomSelection_Init();
- for(e = NULL;(e = find(e, classname, "invasion_spawnpoint")); )
+ FOREACH_ENTITY_CLASS("invasion_spawnpoint", true,
{
- RandomSelection_Add(e, 0, string_null, 1, ((time >= e.spawnshieldtime) ? 0.2 : 1)); // give recently used spawnpoints a very low rating
- e.spawnshieldtime = time + autocvar_g_invasion_spawnpoint_spawn_delay;
- }
+ RandomSelection_Add(it, 0, string_null, 1, ((time >= it.spawnshieldtime) ? 0.2 : 1)); // give recently used spawnpoints a very low rating
+ it.spawnshieldtime = time + autocvar_g_invasion_spawnpoint_spawn_delay;
+ });
return RandomSelection_chosen_ent;
}
return; // handled by think
if(!autocvar_g_vehicles_teleportable)
- if(other.vehicle_flags & VHF_ISVEHICLE)
+ if(IS_VEHICLE(other))
return; // no teleporting vehicles?
if(!this.enemy)
vector spawn_score = prio * '1 0 0' + shortest * '0 1 0';
// filter out spots for assault
- if(spot.target != "") {
- entity ent;
- float found;
-
- found = 0;
- for(ent = NULL; (ent = find(ent, targetname, spot.target)); )
+ if(spot.target != "")
+ {
+ int found = 0;
+ FOREACH_ENTITY_STRING(targetname, spot.target,
{
++found;
- if(ent.spawn_evalfunc)
+ if(it.spawn_evalfunc)
{
- spawn_score = ent.spawn_evalfunc(ent, this, spot, spawn_score);
+ spawn_score = it.spawn_evalfunc(it, this, spot, spawn_score);
if(spawn_score.x < 0)
return spawn_score;
}
- }
+ });
if(!found)
{
void Weapon_whereis(Weapon this, entity cl)
{
if (!autocvar_g_showweaponspawns) return;
- for (entity it = NULL; (it = findfloat(it, weapon, this.m_id)); )
+ FOREACH_ENTITY_FLOAT(weapon, this.m_id,
{
if (it.classname == "droppedweapon" && autocvar_g_showweaponspawns < 2)
continue;
RADARICON_NONE
);
wp.wp_extra = this.m_id;
- }
+ });
}
bool client_hasweapon(entity this, Weapon wpn, float andammo, bool complain)
if (ammo) return true;
// always keep the Mine Layer if we placed mines, so that we can detonate them
if (thiswep == WEP_MINE_LAYER)
- for (entity mine; (mine = find(mine, classname, "mine")); )
- if (mine.owner == actor) return false;
+ {
+ FOREACH_ENTITY_ENT(owner, actor,
+ {
+ if(it.classname != "mine") continue;
+ if(it.owner == actor) return false;
+ });
+ }
if (thiswep == WEP_SHOTGUN)
if (!secondary && WEP_CVAR(shotgun, secondary) == 1) return false; // no clicking, just allow