IntrusiveList g_clones;
STATIC_INIT(g_clones) { g_clones = IL_NEW(); }
+
+IntrusiveList g_assault_destructibles;
+STATIC_INIT(g_assault_destructibles) { g_assault_destructibles = IL_NEW(); }
+
+IntrusiveList g_assault_objectivedecreasers;
+STATIC_INIT(g_assault_objectivedecreasers) { g_assault_objectivedecreasers = IL_NEW(); }
//print("^2Activated objective ", this.targetname, "=", etos(this), "\n");
//print("Activator is ", actor.classname, "\n");
- for (entity e = NULL; (e = find(e, target, this.targetname)); )
+ IL_EACH(g_assault_objectivedecreasers, it.target == this.targetname,
{
- if (e.classname == "target_objective_decrease")
- {
- target_objective_decrease_activate(e);
- }
- }
+ target_objective_decrease_activate(it);
+ });
}
vector target_objective_spawn_evalfunc(entity this, entity player, entity spot, vector current)
if (!g_assault) { delete(this); return; }
this.classname = "target_objective_decrease";
+ IL_PUSH(g_assault_objectivedecreasers, this);
if(!this.dmg)
this.dmg = 101;
this.spawnflags = 3;
this.classname = "func_assault_destructible";
+ IL_PUSH(g_assault_destructibles, this);
if(assault_attacker_team == NUM_TEAM_1)
this.team = NUM_TEAM_2;
// legacy bot code
void havocbot_goalrating_ast_targets(entity this, float ratingscale)
{
- FOREACH_ENTITY_CLASS("func_assault_destructible", it.bot_attack,
+ IL_EACH(g_assault_destructibles, it.bot_attack,
{
if (it.target == "")
continue;
bool found = false;
- FOREACH_ENTITY_STRING(targetname, it.target,
+ entity destr = it;
+ IL_EACH(g_assault_objectivedecreasers, it.targetname == destr.target,
{
- if(it.classname != "target_objective_decrease")
- continue;
-
if(it.enemy.health > 0 && it.enemy.health < ASSAULT_VALUE_INACTIVE)
{
found = true;
this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
navigation_goalrating_start(this);
- FOREACH_ENTITY_CLASS("trigger_race_checkpoint", true,
+ IL_EACH(g_racecheckpoints, true,
{
if(it.cnt == this.race_checkpoint)
navigation_routerating(this, it, 1000000, 5000);
if(IS_DEAD(this))
return;
- entity e;
if (this.bot_strategytime < time)
{
this.bot_strategytime = time + autocvar_bot_ai_strategyinterval;
navigation_goalrating_start(this);
- for(e = NULL; (e = find(e, classname, "trigger_race_checkpoint")) != NULL; )
+ IL_EACH(g_racecheckpoints, true,
{
- if(e.cnt == this.race_checkpoint)
+ if(it.cnt == this.race_checkpoint)
{
- navigation_routerating(this, e, 1000000, 5000);
+ navigation_routerating(this, it, 1000000, 5000);
}
else if(this.race_checkpoint == -1)
{
- navigation_routerating(this, e, 1000000, 5000);
+ navigation_routerating(this, it, 1000000, 5000);
}
- }
+ });
navigation_goalrating_end(this);
}
race_timed_checkpoint = 255;
}
} else {
- for (entity cp = NULL; (cp = find(cp, classname, "trigger_race_checkpoint")); ) {
- if (cp.sprite) {
- if (cp.race_checkpoint == 0) {
- WaypointSprite_UpdateSprites(cp.sprite, WP_RaceStart, WP_Null, WP_Null);
- } else if (cp.race_checkpoint == race_timed_checkpoint) {
- WaypointSprite_UpdateSprites(cp.sprite, WP_RaceFinish, WP_Null, WP_Null);
- }
+ IL_EACH(g_racecheckpoints, it.sprite,
+ {
+ if (it.race_checkpoint == 0) {
+ WaypointSprite_UpdateSprites(it.sprite, WP_RaceStart, WP_Null, WP_Null);
+ } else if (it.race_checkpoint == race_timed_checkpoint) {
+ WaypointSprite_UpdateSprites(it.sprite, WP_RaceFinish, WP_Null, WP_Null);
}
- }
+ });
}
}
this.sprite.waypointsprite_visible_for_player = race_waypointsprite_visible_for_player;
this.spawn_evalfunc = trigger_race_checkpoint_spawn_evalfunc;
+ IL_PUSH(g_racecheckpoints, this);
+
InitializeEntity(this, trigger_race_checkpoint_verify, INITPRIO_FINDTARGET);
}
vector o0, o1;
float bestfraction, fraction;
- entity lastcp, cp0, cp1;
+ entity lastcp;
float nextcpindex, lastcpindex;
nextcpindex = max(e.race_checkpoint, 0);
return l; // finish
bestfraction = 1;
- for(cp0 = NULL; (cp0 = find(cp0, classname, "trigger_race_checkpoint")); )
+ IL_EACH(g_racecheckpoints, true,
{
- if(cp0.race_checkpoint != lastcpindex)
+ if(it.race_checkpoint != lastcpindex)
continue;
if(lastcp)
- if(cp0 != lastcp)
+ if(it != lastcp)
continue;
- o0 = (cp0.absmin + cp0.absmax) * 0.5;
- for(cp1 = NULL; (cp1 = find(cp1, classname, "trigger_race_checkpoint")); )
+ o0 = (it.absmin + it.absmax) * 0.5;
+ IL_EACH(g_racecheckpoints, true,
{
- if(cp1.race_checkpoint != nextcpindex)
+ if(it.race_checkpoint != nextcpindex)
continue;
- o1 = (cp1.absmin + cp1.absmax) * 0.5;
+ o1 = (it.absmin + it.absmax) * 0.5;
if(o0 == o1)
continue;
fraction = bound(0.0001, vlen(e.origin - o1) / vlen(o0 - o1), 1);
if(fraction < bestfraction)
bestfraction = fraction;
- }
- }
+ });
+ });
// we are at CP "nextcpindex - bestfraction"
// race_timed_checkpoint == 4: then nextcp==4 means 0.9999x, nextcp==0 means 0.0000x
.float race_respawn_checkpoint;
.entity race_respawn_spotref; // try THIS spawn in case you respawn
+IntrusiveList g_racecheckpoints;
+STATIC_INIT(g_racecheckpoints) { g_racecheckpoints = IL_NEW(); }
+
// definitions for functions used outside race.qc
float race_PreviousCheckpoint(float f);
float race_NextCheckpoint(float f);