X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fcl_weaponsystem.qc;h=b3b0e6ea06f6d81123acf8ebb0ce60d06412f4e0;hb=60ed95fe707decf91bb54393d4c11ee4faa2e418;hp=3d7a33278d15201ce89b789f1a03f9441e0d0be8;hpb=74f87fc1a53f84b248b57660c105da0d84e2ca41;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/cl_weaponsystem.qc b/qcsrc/server/cl_weaponsystem.qc index 3d7a33278..b3b0e6ea0 100644 --- a/qcsrc/server/cl_weaponsystem.qc +++ b/qcsrc/server/cl_weaponsystem.qc @@ -34,10 +34,6 @@ float W_WeaponRateFactor() void W_SwitchWeapon_Force(entity e, float w) { - // don't switch to another weapon if we're not allowed to - if(e.weapon_forbidchange) - return; - e.cnt = e.switchweapon; e.switchweapon = w; e.selectweapon = w; @@ -131,11 +127,24 @@ vector w_shotorg; vector w_shotdir; vector w_shotend; +.float prevstrengthsound; +.float prevstrengthsoundattempt; +void W_PlayStrengthSound(entity player) // void W_PlayStrengthSound +{ + if((!g_minstagib) + && (player.items & IT_STRENGTH) + && ((time > player.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) // prevent insane sound spam + || (time > player.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold))) + { + sound(player, CH_TRIGGER, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM); + player.prevstrengthsound = time; + } + player.prevstrengthsoundattempt = time; +} + // 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 chan, float maxdamage, float range) { float nudge = 1; // added to traceline target and subtracted from result @@ -245,20 +254,10 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m ent.punchangle_x = recoil * -1; if (snd != "") - sound (ent, chan, snd, VOL_BASE, ATTN_NORM); - - if(ent.items & IT_STRENGTH) - if(!g_minstagib) - if( - (time > ent.prevstrengthsound + autocvar_sv_strengthsound_antispam_time) - || - (time > ent.prevstrengthsoundattempt + autocvar_sv_strengthsound_antispam_refire_threshold) - ) // prevent insane sound spam { - sound(ent, CH_TRIGGER, "weapons/strength_fire.wav", VOL_BASE, ATTN_NORM); - ent.prevstrengthsound = time; + sound (ent, chan, snd, VOL_BASE, ATTN_NORM); + W_PlayStrengthSound(ent); } - ent.prevstrengthsoundattempt = time; // nudge w_shotend so a trace to w_shotend hits w_shotend = w_shotend + normalize(w_shotend - w_shotorg) * nudge; @@ -297,7 +296,6 @@ vector weapon_adjust = '10 0 -15'; .vector weapon_morph4origin; .vector weapon_morph4angles; .float weapon_morph4time; -.string weaponname; #define QCWEAPONANIMATION_ORIGIN(e) ((weapon_offset_x + e.view_ofs_x) * v_forward - (weapon_offset_y + e.view_ofs_y) * v_right + (weapon_offset_z + e.view_ofs_z) * v_up + weapon_adjust) /* @@ -587,9 +585,9 @@ void CL_Weaponentity_Think() self.weaponentity.model = ""; return; } - if (self.cnt != self.owner.weapon || self.dmg != self.owner.modelindex || self.deadflag != self.owner.deadflag) + if (self.weaponname != self.owner.weaponname || self.dmg != self.owner.modelindex || self.deadflag != self.owner.deadflag) { - self.cnt = self.owner.weapon; + self.weaponname = self.owner.weaponname; self.dmg = self.owner.modelindex; self.deadflag = self.owner.deadflag; @@ -793,9 +791,9 @@ void CL_ExteriorWeaponentity_Think() self.model = ""; return; } - if (self.cnt != self.owner.weapon || self.dmg != self.owner.modelindex || self.deadflag != self.owner.deadflag) + if (self.weaponname != self.owner.weaponname || self.dmg != self.owner.modelindex || self.deadflag != self.owner.deadflag) { - self.cnt = self.owner.weapon; + self.weaponname = self.owner.weaponname; self.dmg = self.owner.modelindex; self.deadflag = self.owner.deadflag; if (self.owner.weaponname != "") @@ -858,6 +856,27 @@ void CL_ExteriorWeaponentity_Think() ang_x = -/* don't ask */ang_x; self.angles = ang; } + + if(autocvar_g_loituma) + { + vector moddir, modup; + vector modangles; + float t; + + t = time * autocvar_g_loituma; + + modangles_x = t * 360; + modangles_y = 90; + modangles_z = 0; + + self.angles = + AnglesTransform_ToAngles( + AnglesTransform_Multiply( + AnglesTransform_FromAngles(self.angles), + AnglesTransform_FromAngles(modangles) + ) + ); + } } self.glowmod = self.owner.weaponentity_glowmod; @@ -1007,7 +1026,10 @@ float client_hasweapon(entity cl, float wpn, float andammo, float complain) void w_clear() { if (self.weapon != -1) + { self.weapon = 0; + self.switchingweapon = 0; + } if (self.weaponentity) { self.weaponentity.state = WS_CLEAR; @@ -1033,6 +1055,7 @@ void weapon_setup(float windex) // the two weapon entities will notice this has changed and update their models self.weapon = windex; + self.switchingweapon = windex; // to make sure self.weaponname = e.mdl; self.bulletcounter = 0; }; @@ -1274,6 +1297,12 @@ void weapon_thinkf(float fr, float t, void() func) anim_z = anim_y / (t + sys_frametime); setanim(self, anim, FALSE, TRUE, TRUE); } + else if (self.animstate_startframe == self.anim_idle_x) // only allow shoot anim to override idle animation until we have animation blending + { + anim = self.anim_shoot; + anim_z = anim_y / (t + sys_frametime); + setanim(self, anim, FALSE, TRUE, TRUE); + } } }; @@ -1634,7 +1663,7 @@ void W_DecreaseAmmo(.float ammo_type, float ammo_use, float ammo_reload) if(ammo_reload) { self.clip_load -= ammo_use; - self.weapon_load[self.weapon] = self.clip_load; + self.(weapon_load[self.weapon]) = self.clip_load; } else self.(self.current_ammo) -= ammo_use; @@ -1663,7 +1692,7 @@ void W_ReloadedAndReady() self.(self.current_ammo) -= 1; } } - self.weapon_load[self.weapon] = self.clip_load; + self.(weapon_load[self.weapon]) = self.clip_load; // do not set ATTACK_FINISHED in reload code any more. This causes annoying delays if eg: You start reloading a weapon, // then quickly switch to another weapon and back. Reloading is canceled, but the reload delay is still there, @@ -1746,5 +1775,5 @@ void W_Reload(float sent_ammo_min, float sent_ammo_amount, float sent_time, stri if(self.clip_load < 0) self.clip_load = 0; self.old_clip_load = self.clip_load; - self.clip_load = self.weapon_load[self.weapon] = -1; + self.clip_load = self.(weapon_load[self.weapon]) = -1; }