]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Begin reintroducing old gun alignment hack
authorMario <mario@smbclan.net>
Thu, 29 Sep 2016 02:10:47 +0000 (12:10 +1000)
committerMario <mario@smbclan.net>
Thu, 29 Sep 2016 02:10:47 +0000 (12:10 +1000)
qcsrc/common/weapons/calculations.qc
qcsrc/common/weapons/calculations.qh
qcsrc/common/weapons/weapon/arc.qc
qcsrc/common/weapons/weapon/hook.qc
qcsrc/server/client.qc
qcsrc/server/g_hook.qc

index c35b1930c44672995718ab746454da9aabfcd243..a8587b1ab3167ea24242590a35b714b8ace98fe4 100644 (file)
@@ -144,6 +144,54 @@ vector findperpendicular(vector v)
        return normalize(cliptoplane(p, v));
 }
 
+#ifdef SVQC
+       int W_GunAlign(entity this, int preferred_align)
+       {
+               entity own = this.owner;
+               // using wasfreed, as we don't actually clear .gunaligns yet
+               if(!own.gunaligns[preferred_align] || wasfreed(own.gunaligns[preferred_align]) || own.gunaligns[preferred_align] == this)
+               {
+                       own.gunaligns[preferred_align] = this;
+                       return preferred_align; // fall back if the good one is already choosable
+               }
+
+               for(int j = 4; j > 0; --j) // start from left and try the others
+               {
+                       if(!own.gunaligns[j] || wasfreed(own.gunaligns[j]) || own.gunaligns[j] == this)
+                       {
+                               own.gunaligns[j] = this;
+                               return j;
+                       }
+               }
+
+               own.gunaligns[preferred_align] = this;
+               return preferred_align; // no other choice
+       }
+#else
+       int W_GunAlign(entity this, int preferred_align)
+       {
+               // using wasfreed, as we don't actually clear gunaligns yet
+               if(!gunaligns[preferred_align] || wasfreed(gunaligns[preferred_align]) || gunaligns[preferred_align] == this)
+               {
+                       gunaligns[preferred_align] = this;
+                       return preferred_align; // fall back if the good one is already choosable
+               }
+
+               for(int j = 4; j > 0; --j)
+               {
+                       if(!gunaligns[j] || wasfreed(gunaligns[j]) || gunaligns[j] == this)
+                       {
+                               gunaligns[j] = this;
+                               return j;
+                       }
+               }
+
+               gunaligns[preferred_align] = this;
+               return preferred_align; // no other choice
+       }
+#endif
+
+#if 0
 int W_GetGunAlignment(entity player)
 {
        int gunalign = STAT(GUNALIGN, player);
@@ -153,6 +201,7 @@ int W_GetGunAlignment(entity player)
 
        return gunalign;
 }
+#endif
 
 vector W_CalculateSpread(vector forward, float spread, float spreadfactor, float spreadstyle)
 {
index c349eeca4f355a3b8b55ee588e65cfaf5471739e..d749cc15eea53f9d89595941ce82c58e1de0538e 100644 (file)
@@ -2,5 +2,6 @@
 
 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);
+int W_GunAlign(entity this, int preferred_align);
+//int W_GetGunAlignment(entity player);
 float explosion_calcpush_getmultiplier(vector explosion_v, vector target_v);
index 5d2e9e240ab4dadd996c077f45a519da56c5bb1d..0a2754f065cc835ae1d4a74bfad66d96b052ac91 100644 (file)
@@ -1301,7 +1301,7 @@ NET_HANDLE(ENT_CLIENT_ARC_BEAM, bool isnew)
 
        if(isnew)
        {
-               int gunalign = W_GetGunAlignment(NULL);
+               int gunalign = W_GunAlign(NULL, STAT(GUNALIGN));
 
                this.beam_shotorigin = arc_shotorigin[gunalign];
 
index 38a416383320c8b71c2fe8b39a321df5c83adbd4..2b322f76031f931dd5128e35f03d2191ae7d204e 100644 (file)
@@ -370,7 +370,7 @@ void Draw_GrapplingHook(entity this)
 
        InterpolateOrigin_Do(this);
 
-       int s = W_GetGunAlignment(NULL);
+       int s = W_GunAlign(NULL, STAT(GUNALIGN));
 
        switch(this.HookType)
        {
index ccb658e737d3a15070165277ebabfb9bb0c0ef99..ddb23f0b13d859962e48ad6b3997f6f49e20ee7a 100644 (file)
@@ -695,10 +695,10 @@ void PutClientInServer(entity this)
                for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
                {
                        .entity weaponentity = weaponentities[slot];
-                       if(slot == 0)
+                       //if(slot == 0)
                                this.(weaponentity).m_switchweapon = w_getbestweapon(this);
-                       else
-                               this.(weaponentity).m_switchweapon = WEP_Null;
+                       //else
+                               //this.(weaponentity).m_switchweapon = WEP_Null;
                        this.(weaponentity).weaponname = "";
                        this.(weaponentity).m_switchingweapon = WEP_Null;
                        this.cnt = -1;
index 90266189b83c1adf5f4ea6f7db111c9780e3c24c..92d6ccac4140b2a34fb707b82ae2533f55e0dab9 100644 (file)
@@ -153,7 +153,7 @@ void GrapplingHookThink(entity this)
 
        this.nextthink = time;
 
-       int s = W_GetGunAlignment(this.realowner);
+       int s = W_GunAlign(this.realowner, STAT(GUNALIGN, this.realowner));
        vs = hook_shotorigin[s];
 
        makevectors(this.realowner.v_angle);
@@ -352,7 +352,7 @@ void FireGrapplingHook(entity actor)
 
        makevectors(actor.v_angle);
 
-       int s = W_GetGunAlignment(actor);
+       int s = W_GunAlign(actor, STAT(GUNALIGN, actor));
        vs = hook_shotorigin[s];
 
        // UGLY WORKAROUND: play this on CH_WEAPON_B so it can't cut off fire sounds