X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fmutators%2Fmutator%2Fnades%2Fnades.qc;h=a5cbab32bdf06af141309a244ab35763ea46dda4;hb=9c3e1026151c97ff534d76900e80e8b139539b4c;hp=12997c0b51f4211f87793e0db6890556521a0bf3;hpb=407b5610c6fe23e78c30696cb2fc514823897d7e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 12997c0b5..a5cbab32b 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -39,13 +39,10 @@ entity Nade_TrailEffect(int proj, int nade_team) } #endif -REGISTER_NET_TEMP(TE_CSQC_DARKBLINKING); #ifdef CSQC #include #include -float dark_appeartime; -float dark_fadetime; bool darkblink; void HUD_DarkBlinking() @@ -59,25 +56,18 @@ MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay) { if (STAT(NADE_DARKNESS_TIME) > time) { + if (!darkblink) + localcmd("play2 sound/misc/blind\n"); + darkblink = true; M_ARGV(0, vector) = NADE_TYPE_DARKNESS.m_color; HUD_DarkBlinking(); return true; } + else + darkblink = false; return false; } -NET_HANDLE(TE_CSQC_DARKBLINKING, bool isNew) -{ - return = true; - - if(darkblink) return; - - localcmd("play2 sound/misc/blind\n"); - darkblink = true; - dark_appeartime = time; - dark_fadetime = STAT(NADE_DARKNESS_TIME); -} - MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile) { entity proj = M_ARGV(0, entity); @@ -471,24 +461,20 @@ void nade_ice_think(entity this) 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) @@ -802,19 +788,6 @@ void nade_ammo_boom(entity this) orb.colormod = '0.66 0.33 0'; } -void DarkBlinking(entity e) -{ - if(e == NULL) return; - - int accepted = VerifyClientEntity(e, true, false); - - if(accepted > 0) - { - msg_entity = e; - WriteHeader(MSG_ONE, TE_CSQC_DARKBLINKING); - } -} - void nade_darkness_think(entity this) { if(round_handler_IsActive()) @@ -861,28 +834,22 @@ void nade_darkness_think(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; }); -#undef DARK_NADE_RADIUS_TEAMCHECK } void nade_darkness_boom(entity this) @@ -1424,10 +1391,9 @@ void nades_Clear(entity player) 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) { @@ -1442,7 +1408,7 @@ int nades_CheckTypes(entity player, int 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 }