void M_Mage_Defend_Heal(entity this)
{
- entity head;
float washealed = false;
- for(head = findradius(this.origin, (autocvar_g_monster_mage_heal_range)); head; head = head.chain) if(M_Mage_Defend_Heal_Check(this, head))
+ FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_monster_mage_heal_range, M_Mage_Defend_Heal_Check(this, it),
{
washealed = true;
string fx = "";
- if(IS_PLAYER(head))
+ if(IS_PLAYER(it))
{
switch(this.skin)
{
case 0:
- if(head.health < autocvar_g_balance_health_regenstable) head.health = bound(0, head.health + (autocvar_g_monster_mage_heal_allies), autocvar_g_balance_health_regenstable);
+ if(it.health < autocvar_g_balance_health_regenstable) it.health = bound(0, it.health + (autocvar_g_monster_mage_heal_allies), autocvar_g_balance_health_regenstable);
fx = EFFECT_HEALING.eent_eff_name;
break;
case 1:
- if(head.ammo_cells) head.ammo_cells = bound(head.ammo_cells, head.ammo_cells + 1, g_pickup_cells_max);
- if(head.ammo_plasma) head.ammo_plasma = bound(head.ammo_plasma, head.ammo_plasma + 1, g_pickup_plasma_max);
- if(head.ammo_rockets) head.ammo_rockets = bound(head.ammo_rockets, head.ammo_rockets + 1, g_pickup_rockets_max);
- if(head.ammo_shells) head.ammo_shells = bound(head.ammo_shells, head.ammo_shells + 2, g_pickup_shells_max);
- if(head.ammo_nails) head.ammo_nails = bound(head.ammo_nails, head.ammo_nails + 5, g_pickup_nails_max);
+ if(it.ammo_cells) it.ammo_cells = bound(it.ammo_cells, it.ammo_cells + 1, g_pickup_cells_max);
+ if(it.ammo_plasma) it.ammo_plasma = bound(it.ammo_plasma, it.ammo_plasma + 1, g_pickup_plasma_max);
+ if(it.ammo_rockets) it.ammo_rockets = bound(it.ammo_rockets, it.ammo_rockets + 1, g_pickup_rockets_max);
+ if(it.ammo_shells) it.ammo_shells = bound(it.ammo_shells, it.ammo_shells + 2, g_pickup_shells_max);
+ if(it.ammo_nails) it.ammo_nails = bound(it.ammo_nails, it.ammo_nails + 5, g_pickup_nails_max);
fx = "ammoregen_fx";
break;
case 2:
- if(head.armorvalue < autocvar_g_balance_armor_regenstable)
+ if(it.armorvalue < autocvar_g_balance_armor_regenstable)
{
- head.armorvalue = bound(0, head.armorvalue + (autocvar_g_monster_mage_heal_allies), autocvar_g_balance_armor_regenstable);
+ it.armorvalue = bound(0, it.armorvalue + (autocvar_g_monster_mage_heal_allies), autocvar_g_balance_armor_regenstable);
fx = "armorrepair_fx";
}
break;
case 3:
- head.health = bound(0, head.health - ((head == this) ? (autocvar_g_monster_mage_heal_self) : (autocvar_g_monster_mage_heal_allies)), autocvar_g_balance_health_regenstable);
+ it.health = bound(0, it.health - ((it == this) ? (autocvar_g_monster_mage_heal_self) : (autocvar_g_monster_mage_heal_allies)), autocvar_g_balance_health_regenstable);
fx = EFFECT_RAGE.eent_eff_name;
break;
}
- Send_Effect_(fx, head.origin, '0 0 0', 1);
+ Send_Effect_(fx, it.origin, '0 0 0', 1);
}
else
{
- Send_Effect(EFFECT_HEALING, head.origin, '0 0 0', 1);
- head.health = bound(0, head.health + (autocvar_g_monster_mage_heal_allies), head.max_health);
- if(!(head.spawnflags & MONSTERFLAG_INVINCIBLE) && head.sprite)
- WaypointSprite_UpdateHealth(head.sprite, head.health);
+ Send_Effect(EFFECT_HEALING, it.origin, '0 0 0', 1);
+ it.health = bound(0, it.health + (autocvar_g_monster_mage_heal_allies), it.max_health);
+ if(!(it.spawnflags & MONSTERFLAG_INVINCIBLE) && it.sprite)
+ WaypointSprite_UpdateHealth(it.sprite, it.health);
}
- }
+ });
if(washealed)
{
void M_Shambler_Attack_Lightning_Explode(entity this)
{
- entity head;
-
sound(this, CH_SHOTS, SND_ELECTRO_IMPACT, VOL_BASE, ATTEN_NORM);
Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
RadiusDamage (this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_damage), (autocvar_g_monster_shambler_attack_lightning_radius), NULL, NULL, (autocvar_g_monster_shambler_attack_lightning_force), this.projectiledeathtype, other);
- for(head = findradius(this.origin, (autocvar_g_monster_shambler_attack_lightning_radius_zap)); head; head = head.chain) if(head != this.realowner) if(head.takedamage)
+ FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_monster_shambler_attack_lightning_radius_zap, it != this.realowner && it.takedamage,
{
- te_csqc_lightningarc(this.origin, head.origin);
- Damage(head, this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage_zap) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_ZAP.m_id, head.origin, '0 0 0');
- }
+ te_csqc_lightningarc(this.origin, it.origin);
+ Damage(it, this, this.realowner, (autocvar_g_monster_shambler_attack_lightning_damage_zap) * MONSTER_SKILLMOD(this), DEATH_MONSTER_SHAMBLER_ZAP.m_id, it.origin, '0 0 0');
+ });
setthink(this, SUB_Remove);
this.nextthink = time + 0.2;
Send_Effect(EFFECT_ELECTRO_IMPACT, this.origin, '0 0 0', 1);
RadiusDamage(this, this.realowner, 0, 0, 25, NULL, NULL, 25, this.projectiledeathtype, NULL);
- for(entity e = findradius(this.origin, 25); e; e = e.chain) if(e != this) if(e.takedamage && !IS_DEAD(e)) if(e.health > 0) if(e.monsterid != MON_SPIDER.monsterid)
- e.spider_slowness = time + (autocvar_g_monster_spider_attack_web_damagetime);
+ FOREACH_ENTITY_RADIUS(this.origin, 25, it != this && it.takedamage && !IS_DEAD(it) && it.health > 0 && it.monsterid != MON_SPIDER.monsterid,
+ {
+ it.spider_slowness = time + (autocvar_g_monster_spider_attack_web_damagetime);
+ });
remove(this);
}
{
if(MUTATOR_CALLHOOK(MonsterFindTarget)) { return mon.enemy; } // Handled by a mutator
- entity head, closest_target = NULL;
- head = findradius(mon.origin, mon.target_range);
+ entity closest_target = NULL;
- while(head) // find the closest acceptable target to pass to
+ // find the closest acceptable target to pass to
+ FOREACH_ENTITY_RADIUS(mon.origin, mon.target_range, it.monster_attack,
{
- if(head.monster_attack)
- if(Monster_ValidTarget(mon, head))
+ if(Monster_ValidTarget(mon, it))
{
// if it's a player, use the view origin as reference (stolen from RadiusDamage functions in g_damage.qc)
- vector head_center = CENTER_OR_VIEWOFS(head);
+ vector head_center = CENTER_OR_VIEWOFS(it);
vector ent_center = CENTER_OR_VIEWOFS(mon);
if(closest_target)
{
vector closest_target_center = CENTER_OR_VIEWOFS(closest_target);
if(vlen2(ent_center - head_center) < vlen2(ent_center - closest_target_center))
- { closest_target = head; }
+ { closest_target = it; }
}
- else { closest_target = head; }
+ else { closest_target = it; }
}
-
- head = head.chain;
- }
+ });
return closest_target;
}
float current_freeze_time = this.ltime - time - 0.1;
- entity e;
- for(e = findradius(this.origin, autocvar_g_nades_nade_radius); e; e = e.chain)
- if(e != this)
- if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(e, this.realowner) || e == this.realowner))
- if(e.takedamage && !IS_DEAD(e))
- if(e.health > 0)
- if(!e.revival_time || ((time - e.revival_time) >= 1.5))
- if(!STAT(FROZEN, e))
- if(current_freeze_time > 0)
- nade_ice_freeze(this, e, current_freeze_time);
+ FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && it.health > 0 && current_freeze_time > 0,
+ {
+ if(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner))
+ if(!it.revival_time || ((time - it.revival_time) >= 1.5))
+ if(!STAT(FROZEN, it))
+ nade_ice_freeze(this, it, current_freeze_time);
+ });
}
void nade_ice_boom(entity this)
if(this.team)
{
RandomSelection_Init();
- for(entity head = NULL; (head = findfloat(head, team, this.team)); )
+ FOREACH_ENTITY_FLAGS(flags, FL_ITEM,
{
- if(head.flags & FL_ITEM)
- if(head.classname != "item_flag_team" && head.classname != "item_key_team")
+ if(it.team == this.team)
+ if(it.classname != "item_flag_team" && it.classname != "item_key_team")
{
- Item_Show(head, -1);
- RandomSelection_Add(head, 0, string_null, head.cnt, 0);
+ Item_Show(it, -1);
+ RandomSelection_Add(it, 0, string_null, it.cnt, 0);
}
- }
+ });
e = RandomSelection_chosen_ent;
}
this.move_time = time;
if(dt <= 0) { return; }
#endif
- entity e;
// set mythis as current conveyor where possible
- for(e = NULL; (e = findentity(e, conveyor, this)); )
- e.conveyor = NULL;
+ FOREACH_ENTITY_ENT(conveyor, this,
+ {
+ it.conveyor = NULL;
+ });
if(this.state)
{
- for(e = findradius((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1); e; e = e.chain)
- if(!e.conveyor.state)
- if(isPushable(e))
- {
- vector emin = e.absmin;
- vector emax = e.absmax;
- if(this.solid == SOLID_BSP)
- {
- emin -= '1 1 1';
- emax += '1 1 1';
- }
- if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
- if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, e)) // accurate
- e.conveyor = this;
- }
-
- for(e = NULL; (e = findentity(e, conveyor, this)); )
+ FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, !it.conveyor.state && isPushable(it),
+ {
+ vector emin = it.absmin;
+ vector emax = it.absmax;
+ if(this.solid == SOLID_BSP)
+ {
+ emin -= '1 1 1';
+ emax += '1 1 1';
+ }
+ if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
+ if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, it)) // accurate
+ it.conveyor = this;
+ });
+
+ FOREACH_ENTITY_ENT(conveyor, this,
{
- if(IS_CLIENT(e)) // doing it via velocity has quite some advantages
+ if(IS_CLIENT(it)) // doing it via velocity has quite some advantages
continue; // done in SV_PlayerPhysics continue;
- setorigin(e, e.origin + this.movedir * PHYS_INPUT_FRAMETIME);
- move_out_of_solid(e);
+ setorigin(it, it.origin + this.movedir * PHYS_INPUT_FRAMETIME);
+ move_out_of_solid(it);
#ifdef SVQC
- UpdateCSQCProjectile(e);
+ UpdateCSQCProjectile(it);
#endif
/*
// stupid conveyor code
- tracebox(e.origin, e.mins, e.maxs, e.origin + this.movedir * sys_frametime, MOVE_NORMAL, e);
+ tracebox(it.origin, it.mins, it.maxs, it.origin + this.movedir * sys_frametime, MOVE_NORMAL, it);
if(trace_fraction > 0)
- setorigin(e, trace_endpos);
+ setorigin(it, trace_endpos);
*/
- }
+ });
}
#ifdef SVQC
}
void TargetMusic_RestoreGame()
{
- for(entity e = NULL; (e = find(e, classname, "target_music")); )
+ FOREACH_ENTITY_CLASS("target_music", true,
{
- if(e.targetname == "")
- target_music_sendto(e, MSG_INIT, 1);
+ if(it.targetname == "")
+ target_music_sendto(it, MSG_INIT, 1);
else
- target_music_sendto(e, MSG_INIT, 0);
- }
+ target_music_sendto(it, MSG_INIT, 0);
+ });
}
// values:
// volume
else
{
// edit entity
- for(entity e = NULL; (e = find(e, targetname, this.target)); )
- target_spawn_useon(e, this, actor, trigger);
+ FOREACH_ENTITY_STRING(targetname, this.target,
+ {
+ target_spawn_useon(it, this, actor, trigger);
+ });
}
}
else
{
RandomSelection_Init();
- for(e = NULL; (e = find(e, targetname, teleporter.target)); )
+ FOREACH_ENTITY_STRING(targetname, teleporter.target,
{
p = 1;
if(STAT(TELEPORT_TELEFRAG_AVOID, player))
{
#ifdef SVQC
- locout = e.origin + '0 0 1' * (1 - player.mins.z - 24);
+ locout = it.origin + '0 0 1' * (1 - player.mins.z - 24);
#elif defined(CSQC)
- locout = e.origin + '0 0 1' * (1 - player.mins.z - 24);
+ locout = it.origin + '0 0 1' * (1 - player.mins.z - 24);
#endif
if(check_tdeath(player, locout, '0 0 0', '0 0 0'))
p = 0;
}
- RandomSelection_Add(e, 0, string_null, (e.cnt ? e.cnt : 1), p);
- }
+ RandomSelection_Add(it, 0, string_null, (it.cnt ? it.cnt : 1), p);
+ });
e = RandomSelection_chosen_ent;
}