]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
try fixing issues with cl_gunalign
authorRudolf Polzer <divverent@alientrap.org>
Mon, 19 Jul 2010 10:37:00 +0000 (12:37 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Mon, 19 Jul 2010 10:37:00 +0000 (12:37 +0200)
qcsrc/client/Defs.qc
qcsrc/client/Main.qc
qcsrc/client/hook.qc
qcsrc/server/cl_client.qc
qcsrc/server/g_hook.qc
qcsrc/server/g_hook.qh
qcsrc/server/miscfunctions.qc
qcsrc/server/w_electro.qc
qcsrc/server/w_electro.qh

index 7a0881aaa7c6ec2c0af704b0849231689f538e1c..2aaf9cb0c65b4d7331b6bd484d85663fdc32a4d5 100644 (file)
@@ -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;
index 3c42098e98747a1abec7789fe0c033eda21b7296..7f6b9ea238a18f22db08529b738e6fb7ace80da5 100644 (file)
@@ -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);
index e30b7d905d4729cc18032e829d9eb4119bebaf7b..690d3249b1ff001731f4dcc1e1f12593569d9875 100644 (file)
@@ -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;
index 339b236c441df9b8e89ea89681fbdd8c96ca3080..8b95a3a4ab524ecc0b8b307105f43dbf9529b0f8 100644 (file)
@@ -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
index 2bc542ef70c45438668105b3cc1437e5910ae0ef..47c5e0568efd7ea89475691e3309f600cf78884e 100644 (file)
@@ -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);
        }
 }
 
index 1ebbb9b8f1984037c5c2acda9c9b4efdb3357c3b..b8e0da557d8358c3b2e9f7ba68c4ef447eea4849 100644 (file)
@@ -14,4 +14,4 @@ float HOOK_WAITING_FOR_RELEASE = 16;
 .float hook_state;
 
 void GrappleHookInit();
-vector hook_shotorigin;
+vector hook_shotorigin[4];
index aeee9cecbac843cc4e6203e29de494a0b8e41374..5b0fa2b8caabc429fd3bdae394326bffb1ef616b 100644 (file)
@@ -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)
index f44c0ba0528f7fc22584a0ae4c1c4004252b91b8..ea0daa7b5c41fcad373767539c8024eaac03cf07 100644 (file)
@@ -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)
index 724489570ef740482155ee5a5808c8bb99cefa6a..98c0be13ec3a9dbc1ea501eb5b35315580c1f76a 100644 (file)
@@ -1,2 +1,2 @@
 void ElectroInit();
-vector electro_shotorigin;
+vector electro_shotorigin[4];