X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;ds=sidebyside;f=qcsrc%2Fserver%2Fcl_weaponsystem.qc;h=907f1788196e56adc947c9a0180fb00694231790;hb=70e0121c311b23e870c263ef672e9778cb519c3e;hp=925d53fa7e3cc218cfeba460f432969db25d7a47;hpb=ca4b93ed723cab84606033100e7a75e842222780;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 925d53fa7..907f17881 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -130,6 +130,8 @@ vector w_shotend; // this function calculates w_shotorg and w_shotdir based on the weapon model // offset, trueaim and antilag, and won't put w_shotorg inside a wall. // make sure you call makevectors first (FIXME?) +.float prevstrengthsound; +.float prevstrengthsoundattempt; void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector mi, vector ma, float antilag, float recoil, string snd, float maxdamage, float range) { float nudge = 1; // added to traceline target and subtracted from result @@ -245,9 +247,18 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m sound (ent, CHAN_WEAPON, snd, VOL_BASE, ATTN_NORM); } - if (ent.items & IT_STRENGTH) - if (!g_minstagib) - sound (ent, CHAN_AUTO, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM); + if(ent.items & IT_STRENGTH) + if(!g_minstagib) + if( + (time > ent.prevstrengthsound + cvar("sv_strengthsound_antispam_time")) + || + (time > ent.prevstrengthsoundattempt + cvar("sv_strengthsound_antispam_refire_threshold")) + ) // prevent insane sound spam + { + sound(ent, CHAN_AUTO, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM); + ent.prevstrengthsound = time; + } + ent.prevstrengthsoundattempt = time; // nudge w_shotend so a trace to w_shotend hits w_shotend = w_shotend + normalize(w_shotend - w_shotorg) * nudge; @@ -259,67 +270,6 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m #define W_SetupShot(ent,antilag,recoil,snd,maxdamage) W_SetupShot_ProjectileSize(ent, '0 0 0', '0 0 0', antilag, recoil, snd, maxdamage) #define W_SetupShot_Range(ent,antilag,recoil,snd,maxdamage,range) W_SetupShot_Dir_ProjectileSize_Range(ent, v_forward, '0 0 0', '0 0 0', antilag, recoil, snd, maxdamage, range) -void LaserTarget_Think() -{ - entity e; - vector offset; - float uselaser; - uselaser = 0; - - // list of weapons that will use the laser, and the options that enable it - if(self.owner.laser_on && self.owner.weapon == WEP_ROCKET_LAUNCHER && g_laserguided_missile) - uselaser = 1; - // example - //if(self.owner.weapon == WEP_ELECTRO && cvar("g_laserguided_electro")) - // uselaser = 1; - - - - // if a laser-enabled weapon isn't selected, delete any existing laser and quit - if(!uselaser) - { - // rocket launcher isn't selected, so no laser target. - if(self.lasertarget != world) - { - remove(self.lasertarget); - self.lasertarget = world; - } - return; - } - - if(!self.lasertarget) - { - // we don't have a lasertarget entity, so spawn one - //bprint("create laser target\n"); - e = self.lasertarget = spawn(); - e.owner = self.owner; // Its owner is my owner - e.classname = "laser_target"; - e.movetype = MOVETYPE_NOCLIP; // don't touch things - setmodel(e, "models/laser_dot.mdl"); // what it looks like, precision set below - e.scale = 1.25; // make it larger - e.alpha = 0.25; // transparency - e.colormod = '255 0 0' * (1/255) * 8; // change colors - e.effects = EF_FULLBRIGHT | EF_LOWPRECISION; - // make it dynamically glow - // you should avoid over-using this, as it can slow down the player's computer. - e.glow_color = 251; // red color - e.glow_size = 12; - } - else - e = self.lasertarget; - - // move the laser dot to where the player is looking - - makevectors(self.owner.v_angle); // set v_forward etc to the direction the player is looking - offset = '0 0 26' + v_right*3; - traceline(self.owner.origin + offset, self.owner.origin + offset + v_forward * MAX_SHOT_DISTANCE, FALSE, self); // trace forward until you hit something, like a player or wall - setorigin(e, trace_endpos + v_forward*8); // move me to where the traceline ended - if(trace_plane_normal != '0 0 0') - e.angles = vectoangles(trace_plane_normal); - else - e.angles = vectoangles(v_forward); -} - float CL_Weaponentity_CustomizeEntityForClient() { self.viewmodelforclient = self.owner; @@ -824,9 +774,6 @@ void CL_Weaponentity_Think() self.owner.weapon_morph4origin = QCWEAPONANIMATION_ORIGIN(self); } - - // create or update the lasertarget entity - LaserTarget_Think(); }; void CL_ExteriorWeaponentity_Think() @@ -981,6 +928,13 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) self = cl; f = weapon_action(wpn, WR_CHECKAMMO1); f = f + weapon_action(wpn, WR_CHECKAMMO2); + + // always allow selecting the Mine Layer if we placed mines, so that we can detonate them + local entity mine; + if(wpn == WEP_MINE_LAYER) + for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self) + f = 1; + self = oldself; } if (!f) @@ -1093,6 +1047,15 @@ float weapon_prepareattack_checkammo(float secondary) if not(self.items & IT_UNLIMITED_WEAPON_AMMO) if (!weapon_action(self.weapon, WR_CHECKAMMO1 + secondary)) { + // always keep the Mine Layer if we placed mines, so that we can detonate them + local entity mine; + if(self.weapon == WEP_MINE_LAYER) + for(mine = world; (mine = find(mine, classname, "mine")); ) if(mine.owner == self) + return FALSE; + + if(self.weapon == self.switchweapon) // only play once BEFORE starting to switch weapons + sound (self, CHAN_AUTO, "weapons/dryfire.wav", VOL_BASE, ATTN_NORM); + W_SwitchToOtherWeapon(self); return FALSE; }