From d5276c31c0843c85c0e517e786194930ec369cd7 Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Mon, 19 Jul 2010 12:37:00 +0200 Subject: [PATCH] try fixing issues with cl_gunalign --- qcsrc/client/Defs.qc | 4 ++-- qcsrc/client/Main.qc | 14 ++++++++------ qcsrc/client/hook.qc | 18 ++++++++++++++++-- qcsrc/server/cl_client.qc | 14 ++++++++------ qcsrc/server/g_hook.qc | 34 ++++++++++++++++++++++++++++------ qcsrc/server/g_hook.qh | 2 +- qcsrc/server/miscfunctions.qc | 16 ++++++++++------ qcsrc/server/w_electro.qc | 5 ++++- qcsrc/server/w_electro.qh | 2 +- 9 files changed, 78 insertions(+), 31 deletions(-) diff --git a/qcsrc/client/Defs.qc b/qcsrc/client/Defs.qc index 7a0881aaa7..2aaf9cb0c6 100644 --- a/qcsrc/client/Defs.qc +++ b/qcsrc/client/Defs.qc @@ -232,8 +232,8 @@ float announcer_5min; // database for misc stuff float tempdb; float ClientProgsDB; -vector hook_shotorigin; -vector electro_shotorigin; +vector hook_shotorigin[4]; +vector electro_shotorigin[4]; #ifdef BLURTEST float blurtest_time0, blurtest_time1, blurtest_radius, blurtest_power; diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 3c42098e98..7f6b9ea238 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -1022,12 +1022,14 @@ void Ent_Init() nb_pb_period = ReadByte() / 32; //Accuracy of 1/32th - hook_shotorigin_x = ReadCoord(); - hook_shotorigin_y = ReadCoord(); - hook_shotorigin_z = ReadCoord(); - electro_shotorigin_x = ReadCoord(); - electro_shotorigin_y = ReadCoord(); - electro_shotorigin_z = ReadCoord(); + hook_shotorigin[0] = decompressShotOrigin(ReadInt24_t()); + hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t()); + hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t()); + hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t()); + electro_shotorigin[0] = decompressShotOrigin(ReadInt24_t()); + electro_shotorigin[1] = decompressShotOrigin(ReadInt24_t()); + electro_shotorigin[2] = decompressShotOrigin(ReadInt24_t()); + electro_shotorigin[3] = decompressShotOrigin(ReadInt24_t()); if(forcefog) strunzone(forcefog); diff --git a/qcsrc/client/hook.qc b/qcsrc/client/hook.qc index e30b7d905d..690d3249b1 100644 --- a/qcsrc/client/hook.qc +++ b/qcsrc/client/hook.qc @@ -55,11 +55,19 @@ void Draw_GrapplingHook() string tex; vector rgb; float t; + float s; + vector vs; if(time < self.HookKillTime) { + s = cvar("cl_gunalign"); + if(s != 1 && s != 2 && s != 4) + s = 3; // default value + --s; + vs = hook_shotorigin[s]; + if(self.sv_entnum == player_localentnum - 1) - a = view_origin + view_forward * hook_shotorigin_x + view_right * hook_shotorigin_y + view_up * hook_shotorigin_z; + a = view_origin + view_forward * vs_x + view_right * vs_y + view_up * vs_z; else a = self.HookStart; b = self.HookEnd; @@ -100,8 +108,14 @@ void Draw_GrapplingHook() if(time < self.LGBeamKillTime) { + s = cvar("cl_gunalign"); + if(s != 1 && s != 2 && s != 4) + s = 3; // default value + --s; + vs = electro_shotorigin[s]; + if(self.sv_entnum == player_localentnum - 1) - a = view_origin + view_forward * electro_shotorigin_x + view_right * electro_shotorigin_y + view_up * electro_shotorigin_z; + a = view_origin + view_forward * vs_x + view_right * vs_y + view_up * vs_z; else a = self.LGBeamStart; b = self.LGBeamEnd; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 339b236c44..8b95a3a4ab 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1063,12 +1063,14 @@ float ClientInit_SendEntity(entity to, float sf) { WriteByte(MSG_ENTITY, ENT_CLIENT_INIT); WriteByte(MSG_ENTITY, g_nexball_meter_period * 32); - WriteCoord(MSG_ENTITY, hook_shotorigin_x); - WriteCoord(MSG_ENTITY, hook_shotorigin_y); - WriteCoord(MSG_ENTITY, hook_shotorigin_z); - WriteCoord(MSG_ENTITY, electro_shotorigin_x); - WriteCoord(MSG_ENTITY, electro_shotorigin_y); - WriteCoord(MSG_ENTITY, electro_shotorigin_z); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[0])); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[1])); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[2])); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(hook_shotorigin[3])); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[0])); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[1])); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[2])); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[3])); if(sv_foginterval && world.fog != "") WriteString(MSG_ENTITY, world.fog); else diff --git a/qcsrc/server/g_hook.qc b/qcsrc/server/g_hook.qc index 2bc542ef70..47c5e0568e 100644 --- a/qcsrc/server/g_hook.qc +++ b/qcsrc/server/g_hook.qc @@ -116,8 +116,8 @@ void GrapplingHook_Stop() void GrapplingHookThink() { - float spd, dist, minlength, pullspeed, ropestretch, ropeairfriction, rubberforce, newlength, rubberforce_overstretch; - vector dir, org, end, v0, dv, v, myorg; + float spd, dist, minlength, pullspeed, ropestretch, ropeairfriction, rubberforce, newlength, rubberforce_overstretch, s; + vector dir, org, end, v0, dv, v, myorg, vs; if(self.owner.health <= 0 || self.owner.hook != self) // how did that happen? { // well, better fix it anyway remove(self); @@ -133,8 +133,14 @@ void GrapplingHookThink() self.nextthink = time; + s = self.owner.cvar_cl_gunalign; + if(s != 1 && s != 2 && s != 4) + s = 3; // default value + --s; + vs = hook_shotorigin[s]; + makevectors(self.owner.v_angle); - org = self.owner.origin + self.owner.view_ofs + v_forward * hook_shotorigin_x + v_right * hook_shotorigin_y + v_up * hook_shotorigin_z; + org = self.owner.origin + self.owner.view_ofs + v_forward * vs_x + v_right * vs_y + v_up * vs_z; myorg = WarpZone_RefSys_TransformOrigin(self.owner, self, org); if(self.hook_length < 0) @@ -294,15 +300,23 @@ void FireGrapplingHook (void) { local entity missile; local vector org; + float s; + vector vs; if((arena_roundbased && time < warmup) || (time < game_starttime)) return; makevectors(self.v_angle); + s = self.cvar_cl_gunalign; + if(s != 1 && s != 2 && s != 4) + s = 3; // default value + --s; + vs = hook_shotorigin[s]; + // UGLY WORKAROUND: play this on CHAN_WEAPON2 so it can't cut off fire sounds sound (self, CHAN_WEAPON2, "weapons/hook_fire.wav", VOL_BASE, ATTN_NORM); - org = self.origin + self.view_ofs + v_forward * hook_shotorigin_x + v_right * hook_shotorigin_y + v_up * hook_shotorigin_z; + org = self.origin + self.view_ofs + v_forward * vs_x + v_right * vs_y + v_up * vs_z; pointparticles(particleeffectnum("grapple_muzzleflash"), org, '0 0 0', 1); missile = WarpZone_RefSys_SpawnSameRefSys(self); @@ -446,11 +460,19 @@ void GrapplingHookFrame() void GrappleHookInit() { if(g_grappling_hook) - hook_shotorigin = '8 -8 -12'; + { + hook_shotorigin[0] = '8 -8 -12'; + hook_shotorigin[1] = '8 -8 -12'; + hook_shotorigin[2] = '8 -8 -12'; + hook_shotorigin[3] = '8 -8 -12'; + } else { weapon_action(WEP_HOOK, WR_PRECACHE); - hook_shotorigin = shotorg_adjust(CL_Weapon_GetShotOrg(WEP_HOOK), TRUE, FALSE); + hook_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK), TRUE, FALSE, 1); + hook_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK), TRUE, FALSE, 2); + hook_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK), TRUE, FALSE, 3); + hook_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_HOOK), TRUE, FALSE, 4); } } diff --git a/qcsrc/server/g_hook.qh b/qcsrc/server/g_hook.qh index 1ebbb9b8f1..b8e0da557d 100644 --- a/qcsrc/server/g_hook.qh +++ b/qcsrc/server/g_hook.qh @@ -14,4 +14,4 @@ float HOOK_WAITING_FOR_RELEASE = 16; .float hook_state; void GrappleHookInit(); -vector hook_shotorigin; +vector hook_shotorigin[4]; diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index aeee9cecba..5b0fa2b8ca 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -2330,9 +2330,9 @@ void write_recordmarker(entity pl, float tstart, float dt) " ", ftos(tstart), " ", ftos(dt), "\n")); } -vector shotorg_adjustfromclient(vector vecs, float y_is_right, float allowcenter) +vector shotorg_adjustfromclient(vector vecs, float y_is_right, float allowcenter, float algn) { - switch(self.owner.cvar_cl_gunalign) + switch(algn) { case 1: // right break; @@ -2372,7 +2372,7 @@ vector shotorg_adjustfromclient(vector vecs, float y_is_right, float allowcenter return vecs; } -vector shotorg_adjust(vector vecs, float y_is_right, float visual) +vector shotorg_adjust_values(vector vecs, float y_is_right, float visual, float algn) { string s; vector v; @@ -2381,7 +2381,7 @@ vector shotorg_adjust(vector vecs, float y_is_right, float visual) { if (visual) { - vecs = shotorg_adjustfromclient(vecs, y_is_right, TRUE); + vecs = shotorg_adjustfromclient(vecs, y_is_right, TRUE, algn); } else { @@ -2393,7 +2393,7 @@ vector shotorg_adjust(vector vecs, float y_is_right, float visual) { if (visual) { - vecs = shotorg_adjustfromclient(vecs, y_is_right, TRUE); + vecs = shotorg_adjustfromclient(vecs, y_is_right, TRUE, algn); } else { @@ -2413,11 +2413,15 @@ vector shotorg_adjust(vector vecs, float y_is_right, float visual) } else if (cvar("g_shootfromclient")) { - vecs = shotorg_adjustfromclient(vecs, y_is_right, (cvar("g_shootfromclient") >= 2)); + vecs = shotorg_adjustfromclient(vecs, y_is_right, (cvar("g_shootfromclient") >= 2), algn); } return vecs; } +vector shotorg_adjust(vector vecs, float y_is_right, float visual) +{ + return shotorg_adjust_values(vecs, y_is_right, visual, self.owner.cvar_cl_gunalign); +} void attach_sameorigin(entity e, entity to, string tag) diff --git a/qcsrc/server/w_electro.qc b/qcsrc/server/w_electro.qc index f44c0ba052..ea0daa7b5c 100644 --- a/qcsrc/server/w_electro.qc +++ b/qcsrc/server/w_electro.qc @@ -263,7 +263,10 @@ void W_Electro_Attack3 (void) void ElectroInit() { weapon_action(WEP_ELECTRO, WR_PRECACHE); - electro_shotorigin = shotorg_adjust(CL_Weapon_GetShotOrg(WEP_ELECTRO), TRUE, FALSE); + electro_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), TRUE, FALSE, 1); + electro_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), TRUE, FALSE, 2); + electro_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), TRUE, FALSE, 3); + electro_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), TRUE, FALSE, 4); } void spawnfunc_weapon_electro (void) diff --git a/qcsrc/server/w_electro.qh b/qcsrc/server/w_electro.qh index 724489570e..98c0be13ec 100644 --- a/qcsrc/server/w_electro.qh +++ b/qcsrc/server/w_electro.qh @@ -1,2 +1,2 @@ void ElectroInit(); -vector electro_shotorigin; +vector electro_shotorigin[4]; -- 2.39.2