// weapon switching impulses
+bool autocvar_g_weaponswitch_debug;
+
#define X(slot) \
IMPULSE(weapon_group_##slot) \
{ \
this.impulse = IMP_weapon_group_##slot.impulse; \
return; \
} \
- W_NextWeaponOnImpulse(this, slot); \
+ for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot) \
+ { \
+ .entity weaponentity = weaponentities[wepslot]; \
+ W_NextWeaponOnImpulse(this, slot, weaponentity); \
+ if(wepslot == 0 && !autocvar_g_weaponswitch_debug) \
+ break; \
+ } \
}
X(1)
X(2)
noref int prev = -1; \
noref int best = 0; \
noref int next = +1; \
- W_CycleWeapon(this, this.cvar_cl_weaponpriorities[slot], dir); \
+ for(int wepslot = 0; wepslot < MAX_WEAPONSLOTS; ++wepslot) \
+ { \
+ .entity weaponentity = weaponentities[wepslot]; \
+ W_CycleWeapon(this, this.cvar_cl_weaponpriorities[slot], dir, weaponentity); \
+ if(wepslot == 0 && !autocvar_g_weaponswitch_debug) \
+ break; \
+ } \
}
X(0, prev)
X(1, prev)
this.impulse = IMP_weapon_byid_##i.impulse; \
return; \
} \
- W_SwitchWeapon(this, Weapons_from(WEP_FIRST + i)); \
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot) \
+ { \
+ .entity weaponentity = weaponentities[slot]; \
+ W_SwitchWeapon(this, Weapons_from(WEP_FIRST + i), weaponentity); \
+ if(slot == 0 && !autocvar_g_weaponswitch_debug) \
+ break; \
+ } \
}
X(0)
X(1)
this.impulse = IMP_weapon_next_byid.impulse;
return;
}
- W_NextWeapon(this, 0);
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ W_NextWeapon(this, 0, weaponentity);
+
+ if(slot == 0 && !autocvar_g_weaponswitch_debug)
+ break;
+ }
}
IMPULSE(weapon_prev_byid)
this.impulse = IMP_weapon_prev_byid.impulse;
return;
}
- W_PreviousWeapon(this, 0);
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ W_PreviousWeapon(this, 0, weaponentity);
+
+ if(slot == 0 && !autocvar_g_weaponswitch_debug)
+ break;
+ }
}
IMPULSE(weapon_next_bygroup)
this.impulse = IMP_weapon_next_bygroup.impulse;
return;
}
- W_NextWeapon(this, 1);
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ W_NextWeapon(this, 1, weaponentity);
+
+ if(slot == 0 && !autocvar_g_weaponswitch_debug)
+ break;
+ }
}
IMPULSE(weapon_prev_bygroup)
this.impulse = IMP_weapon_prev_bygroup.impulse;
return;
}
- W_PreviousWeapon(this, 1);
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ W_PreviousWeapon(this, 1, weaponentity);
+
+ if(slot == 0 && !autocvar_g_weaponswitch_debug)
+ break;
+ }
}
IMPULSE(weapon_next_bypriority)
this.impulse = IMP_weapon_next_bypriority.impulse;
return;
}
- W_NextWeapon(this, 2);
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ W_NextWeapon(this, 2, weaponentity);
+
+ if(slot == 0 && !autocvar_g_weaponswitch_debug)
+ break;
+ }
}
IMPULSE(weapon_prev_bypriority)
this.impulse = IMP_weapon_prev_bypriority.impulse;
return;
}
- W_PreviousWeapon(this, 2);
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ W_PreviousWeapon(this, 2, weaponentity);
+
+ if(slot == 0 && !autocvar_g_weaponswitch_debug)
+ break;
+ }
}
IMPULSE(weapon_last)
{
if (this.vehicle) return;
if (IS_DEAD(this)) return;
- W_LastWeapon(this);
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ W_LastWeapon(this, weaponentity);
+
+ if(slot == 0 && !autocvar_g_weaponswitch_debug)
+ break;
+ }
}
IMPULSE(weapon_best)
{
if (this.vehicle) return;
if (IS_DEAD(this)) return;
- W_SwitchWeapon(this, w_getbestweapon(this));
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ W_SwitchWeapon(this, w_getbestweapon(this, weaponentity), weaponentity);
+
+ if(slot == 0 && !autocvar_g_weaponswitch_debug)
+ break;
+ }
}
IMPULSE(weapon_drop)
{
if (this.vehicle) return;
if (IS_DEAD(this)) return;
- W_ThrowWeapon(this, weaponentities[0], W_CalculateProjectileVelocity(this, this.velocity, v_forward * 750, false), '0 0 0', true);
+ for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
+ {
+ .entity weaponentity = weaponentities[slot];
+ W_ThrowWeapon(this, weaponentity, W_CalculateProjectileVelocity(this, this.velocity, v_forward * 750, false), '0 0 0', true);
+
+ if(slot == 0 && !autocvar_g_weaponswitch_debug)
+ break;
+ }
}
IMPULSE(weapon_reload)
if (this.vehicle) return;
if (IS_DEAD(this)) return;
if (forbidWeaponUse(this)) return;
- Weapon w = PS(this).m_weapon;
entity actor = this;
for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
{
.entity weaponentity = weaponentities[slot];
+ Weapon w = this.(weaponentity).m_weapon;
w.wr_reload(w, actor, weaponentity);
+
+ if(slot == 0 && !autocvar_g_weaponswitch_debug)
+ break;
}
}
if (m) LOG_INFOF("%d waypoints have been marked total\n", m);
j = 0;
- FOREACH_ENTITY_CLASS("info_player_deathmatch", true,
+ IL_EACH(g_spawnpoints, true,
{
vector org = it.origin;
- tracebox(it.origin, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), it.origin - '0 0 512', MOVE_NOMONSTERS, NULL);
+ tracebox(it.origin, PL_MIN_CONST, PL_MAX_CONST, it.origin - '0 0 512', MOVE_NOMONSTERS, NULL);
setorigin(it, trace_endpos);
if (navigation_findnearestwaypoint(it, false))
{
if (j) LOG_INFOF("%d spawnpoints have no nearest waypoint (marked by player model)\n", j);
j = 0;
- FOREACH_ENTITY_FLAGS(flags, FL_ITEM,
+ IL_EACH(g_items, true,
{
it.effects &= ~(EF_NODEPTHTEST | EF_RED | EF_BLUE);
it.colormod = '0.5 0.5 0.5';
});
- FOREACH_ENTITY_FLAGS(flags, FL_ITEM,
+ IL_EACH(g_items, true,
{
if (navigation_findnearestwaypoint(it, false)) continue;
LOG_INFO("item without waypoint: ", etos(it), " ", vtos(it.origin), "\n");
if (j) LOG_INFOF("%d items have no nearest waypoint and cannot be walked away from (marked with red light)\n", j);
j = 0;
- FOREACH_ENTITY_FLAGS(flags, FL_ITEM,
+ IL_EACH(g_items, true,
{
if (navigation_findnearestwaypoint(it, true)) continue;
LOG_INFO("item without waypoint: ", etos(it), " ", vtos(it.origin), "\n");