]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
More correct aim for spiderbot. make raptor's gun aim right
authorJakob MG <jakob_mg@hotmail.com>
Sun, 19 Jun 2011 19:53:20 +0000 (21:53 +0200)
committerJakob MG <jakob_mg@hotmail.com>
Sun, 19 Jun 2011 19:53:20 +0000 (21:53 +0200)
qcsrc/server/vehicles/raptor.qc
qcsrc/server/vehicles/spiderbot.qc

index b9ef204957e6d4333b0802c7a69a75812aa7fb75..d80bd7b43766a1872a87bf3df2e3cee942ba3f81 100644 (file)
@@ -315,7 +315,7 @@ float raptor_frame()
 {
     entity player, raptor;
     float ftmp, ftmp2;
-    vector df, ra;
+    vector df;
     
        if(intermission_running)
                return 1;
@@ -466,8 +466,6 @@ float raptor_frame()
         }
     }
 
-    ra = raptor.angles;
-    ra_z = 0;
     // Aim the gunz
     ftmp2 = autocvar_g_vehicle_raptor_cannon_turnspeed * frametime;
     ftmp = -ftmp2;
@@ -476,13 +474,9 @@ float raptor_frame()
     df = gettaginfo(raptor.gun1, gettagindex(raptor.gun1, "fire1"));
     ad = df;
     vf = v_forward;
-    //if(self.lock_strength == 1)
-    //{
-        df = vectoangles(normalize(trace_endpos - df)); // Find the direction & angle
-        df = shortangle_vxy(df - (ra + raptor.gun1.angles), ra + raptor.gun1.angles);     // Find aim offset        
-    //}
-    //else    
-    //    df = '0 0 0';
+    df = vectoangles(normalize(trace_endpos - df)); // Find the direction & angle    
+    df = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(raptor.angles), AnglesTransform_FromAngles(df))) - raptor.gun1.angles;
+    df = shortangle_vxy(df, raptor.gun1.angles);
         
     // Bind to aimspeed
     df_x = bound(ftmp, df_x, ftmp2);
@@ -495,14 +489,10 @@ float raptor_frame()
     df = gettaginfo(raptor.gun2, gettagindex(raptor.gun2, "fire1"));
     ad += df;
     vf += v_forward;
-    //if(self.lock_strength == 1)
-    //{
-        df = vectoangles(normalize(trace_endpos - df)); // Find the direction & angle
-        df = shortangle_vxy(df - (ra + raptor.gun2.angles), ra + raptor.gun2.angles);     // Find aim offset        
-    //}
-    //else    
-    //    df = '0 0 0';
-        
+    df = vectoangles(normalize(trace_endpos - df)); // Find the direction & angle    
+    df = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(raptor.angles), AnglesTransform_FromAngles(df))) - raptor.gun2.angles;
+    df = shortangle_vxy(df, raptor.gun2.angles);
+    
     // Bind to aimspeed
     df_x = bound(ftmp, df_x, ftmp2);
     df_y = bound(ftmp, df_y, ftmp2);
index 36863d8e2a65002383cc8b35bcd7a12a11f373ab..dbaac0cce175392b41454ef4871db6b874f4c93a 100644 (file)
@@ -191,11 +191,13 @@ float spiderbot_frame()
     crosshair_trace(player);
     //UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
 
-    player.v_angle_x *= -1;
-    gettaginfo(spider.tur_head, 0);
-    ad = player.v_angle - vectoangles2(v_forward, v_up);
+    //player.v_angle_x *= -1;
+    //gettaginfo(spider.tur_head, 0);
+    //ad = player.v_angle - vectoangles2(v_forward, v_up);
     //ad = player.v_angle - (spider.tur_head.angles + spider.angles);
-    player.v_angle_x *= -1;
+    //player.v_angle_x *= -1;
+    ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(spider.angles), AnglesTransform_FromVAngles(player.v_angle))) - spider.tur_head.angles;
+
     if(ad_x > 180)  ad_x -= 360;
     if(ad_x < -180) ad_x += 360;
     if(ad_y > 180)  ad_y -= 360;