set g_nades_nade_type 1 "Type of the off-hand grenade. 1:normal 2:napalm 3:ice 4:translocate 5:spawn 6:heal 7:pokenade 8:entrap 9:veil, 10:ammo, 11:darkness"
seta cl_nade_timer 1 "show a visual timer for nades, 1 = only circle, 2 = circle with text"
-seta cl_nade_type 3 "selected type of the off-hand grenade. 1:normal 2:napalm 3:ice 4:translocate 5:spawn 6:heal 7:pokenade 8:entrap 9:veil 10:ammo 11:dark"
+seta cl_nade_type 3 "selected type of the off-hand grenade. 1:normal 2:napalm 3:ice 4:translocate 5:spawn 6:heal 7:pokenade 8:entrap 9:veil 10:ammo 11:darkness"
seta cl_pokenade_type "zombie" "monster to spawn"
// ------------
set g_nades_ice_freeze_time 3 "How long the ice field will last"
set g_nades_ice_health 0 "How much health the player will have after being unfrozen"
set g_nades_ice_explode 0 "Whether the ice nade should explode again once the ice field dissipated"
-set g_nades_ice_teamcheck 2 "0: friendly fire, 1: nade owner isn't affected, 2: don't freeze teammates"
+set g_nades_ice_teamcheck 2 "0: freezes everyone including the player who threw the nade, 1: freezes enemies and teammates, 2: freezes only enemies"
// Translocate (4)
set g_nades_translocate 1 "Translocate nade: teleports into explosion nade location"
set g_nades_darkness 0 "Darkness nade: blinds enemies"
set g_nades_darkness_time 4 "How long the dark field will last"
set g_nades_darkness_explode 0 "Whether the darkness nade should explode again once the dark field dissipated"
-set g_nades_darkness_teamcheck 2 "0: friendly fire, 1: nade owner isn't affected, 2: don't blind teammates"
+set g_nades_darkness_teamcheck 2 "0: blinds everyone including the player who threw the nade, 1: blinds enemies and teammates, 2: blinds only enemies"
// ============
// camp check
float current_freeze_time = this.ltime - time - 0.1;
-#define ICE_NADE_RADIUS_TEAMCHECK(checked) \
- if (checked) \
- if (!it.revival_time || ((time - it.revival_time) >= 1.5)) \
- if (!STAT(FROZEN, it)) \
- nade_ice_freeze(this, it, current_freeze_time); \
- break;
-
- FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && current_freeze_time > 0,
+ FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage
+ && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && current_freeze_time > 0
+ && (!it.revival_time || ((time - it.revival_time) >= 1.5)) && !STAT(FROZEN, it),
{
switch (autocvar_g_nades_ice_teamcheck)
{
- // 1: nade owner isn't affected; 2: no teammate is affected; any other number than 1 and 2: friendly fire
- case 1: ICE_NADE_RADIUS_TEAMCHECK(it != this.realowner);
- case 2: ICE_NADE_RADIUS_TEAMCHECK(DIFF_TEAM(it, this.realowner) && it != this.realowner);
- default: ICE_NADE_RADIUS_TEAMCHECK(!autocvar_g_nades_ice_teamcheck || (DIFF_TEAM(it, this.realowner) || it == this.realowner));
+ case 0: break; // affect everyone
+ default:
+ case 2: if(SAME_TEAM(it, this.realowner)) continue; // don't affect teammates
+ // fall through (check case 1 condition too)
+ case 1: if(it == this.realowner) continue; // don't affect the player who threw the nade
}
+ nade_ice_freeze(this, it, current_freeze_time);
});
-#undef ICE_NADE_RADIUS_TEAMCHECK
}
void nade_ice_boom(entity this)
Send_Effect(EFFECT_DARKFIELD, this.origin, '0 0 0', 1);
}
- float current_dark_time = this.ltime - time - 0.1;
-#define DARK_NADE_RADIUS_TEAMCHECK(checked) \
- if (checked) \
- if ( IS_REAL_CLIENT(it) ) \
- { \
- STAT(NADE_DARKNESS_TIME, it) = time + 0.1; \
- DarkBlinking(it); \
- } \
- break;
+ float current_dark_time = this.ltime - time - 0.1;
- FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && current_dark_time > 0,
+ FOREACH_ENTITY_RADIUS(this.origin, autocvar_g_nades_nade_radius, it != this && it.takedamage
+ && !IS_DEAD(it) && GetResource(it, RES_HEALTH) > 0 && current_dark_time > 0 && IS_REAL_CLIENT(it),
{
switch (autocvar_g_nades_darkness_teamcheck)
{
- // 1: nade owner isn't affected; 2: no teammate is affected; any other number than 1 and 2: friendly fire
- case 1: DARK_NADE_RADIUS_TEAMCHECK(it != this.realowner);
- case 2: DARK_NADE_RADIUS_TEAMCHECK(DIFF_TEAM(it, this.realowner) && it != this.realowner);
- default: DARK_NADE_RADIUS_TEAMCHECK(!autocvar_g_nades_darkness_teamcheck || (DIFF_TEAM(it, this.realowner) && it != this.realowner));
+ case 0: break; // affect everyone
+ default:
+ case 2: if(SAME_TEAM(it, this.realowner)) continue; // don't affect teammates
+ // fall through (check case 1 condition too)
+ case 1: if(it == this.realowner) continue; // don't affect the player who threw the nade
}
+ STAT(NADE_DARKNESS_TIME, it) = time + 0.1;
+ DarkBlinking(it);
});
-#undef DARK_NADE_RADIUS_TEAMCHECK
}
void nade_darkness_boom(entity this)
int nades_CheckTypes(entity player, int cl_ntype)
{
-#define CL_NADE_TYPE_CHECK(cl_ntype, cvar) \
- case cl_ntype.m_id: \
- if (!cvar) return NADE_TYPE_NORMAL.m_id; \
- break
+ // TODO check what happens without this patch
+#define CL_NADE_TYPE_CHECK(nade_ent, nade_cvar) \
+ case nade_ent.m_id: if (nade_cvar) return cl_ntype
switch (cl_ntype)
{
CL_NADE_TYPE_CHECK(NADE_TYPE_AMMO, autocvar_g_nades_ammo);
CL_NADE_TYPE_CHECK(NADE_TYPE_DARKNESS, autocvar_g_nades_darkness);
}
- return cl_ntype;
+ return NADE_TYPE_NORMAL.m_id; // default to NADE_TYPE_NORMAL for unknown nade types
#undef CL_NADE_TYPE_CHECK
}