From: Mario Date: Wed, 14 Oct 2015 22:20:49 +0000 (+1000) Subject: Make a common function for getting the player's gun alignment X-Git-Tag: xonotic-v0.8.2~1821 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=90be2534eb673958efa70156f16b2855f0b3072e;p=xonotic%2Fxonotic-data.pk3dir.git Make a common function for getting the player's gun alignment --- diff --git a/qcsrc/client/hook.qc b/qcsrc/client/hook.qc index 3f623b276..5b8d09312 100644 --- a/qcsrc/client/hook.qc +++ b/qcsrc/client/hook.qc @@ -31,7 +31,6 @@ void Draw_GrapplingHook(entity this) string tex; vector rgb; float t; - int s; vector vs; float intensity, offset; @@ -44,10 +43,8 @@ void Draw_GrapplingHook(entity this) InterpolateOrigin_Do(); - s = autocvar_cl_gunalign; - if(s != 1 && s != 2 && s != 4) - s = 3; // default value - --s; + int s = W_GetGunAlignment(world); + switch(self.HookType) { default: diff --git a/qcsrc/common/weapons/calculations.qc b/qcsrc/common/weapons/calculations.qc index 16b507d14..dcb7bbb0c 100644 --- a/qcsrc/common/weapons/calculations.qc +++ b/qcsrc/common/weapons/calculations.qc @@ -142,6 +142,20 @@ vector findperpendicular(vector v) return normalize(cliptoplane(p, v)); } +int W_GetGunAlignment(entity player) +{ +#ifdef SVQC + int gunalign = player.cvar_cl_gunalign; +#else + int gunalign = autocvar_cl_gunalign; +#endif + if(gunalign != 1 && gunalign != 2 && gunalign != 4) + gunalign = 3; // default value + --gunalign; + + return gunalign; +} + vector W_CalculateSpread(vector forward, float spread, float spreadfactor, float spreadstyle) { float sigma; diff --git a/qcsrc/common/weapons/calculations.qh b/qcsrc/common/weapons/calculations.qh index d91d22c67..4feed9fc5 100644 --- a/qcsrc/common/weapons/calculations.qh +++ b/qcsrc/common/weapons/calculations.qh @@ -2,4 +2,5 @@ #define CALCULATIONS_H vector damage_explosion_calcpush(vector explosion_f, vector target_v, float speedfactor); vector W_CalculateSpread(vector forward, float spread, float spreadfactor, float spreadstyle); +int W_GetGunAlignment(entity player); #endif diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 99eb17d03..8d8f4c43b 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -1156,11 +1156,7 @@ void Ent_ReadArcBeam(float isnew) if(isnew) { - // calculate shot origin offset from gun alignment - int gunalign = autocvar_cl_gunalign; - if(gunalign != 1 && gunalign != 2 && gunalign != 4) - gunalign = 3; // default value - --gunalign; + int gunalign = W_GetGunAlignment(world); self.beam_shotorigin = arc_shotorigin[gunalign]; diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc index 7a77d4aff..f95115a2c 100644 --- a/qcsrc/server/g_hook.qc +++ b/qcsrc/server/g_hook.qc @@ -151,10 +151,7 @@ void GrapplingHookThink() self.nextthink = time; - int s = self.realowner.cvar_cl_gunalign; - if(s != 1 && s != 2 && s != 4) - s = 3; // default value - --s; + int s = W_GetGunAlignment(self.realowner); vs = hook_shotorigin[s]; makevectors(self.realowner.v_angle); @@ -353,10 +350,7 @@ void FireGrapplingHook (void) makevectors(self.v_angle); - int s = self.cvar_cl_gunalign; - if(s != 1 && s != 2 && s != 4) - s = 3; // default value - --s; + int s = W_GetGunAlignment(self); vs = hook_shotorigin[s]; // UGLY WORKAROUND: play this on CH_WEAPON_B so it can't cut off fire sounds