]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Somewhat working csqc tturrets
authorJakob MG <jakob_mg@hotmail.com>
Sat, 9 Apr 2011 09:29:19 +0000 (11:29 +0200)
committerJakob MG <jakob_mg@hotmail.com>
Sat, 9 Apr 2011 09:29:19 +0000 (11:29 +0200)
qcsrc/client/Main.qc
qcsrc/client/progs.src
qcsrc/server/tturrets/include/turrets_early.qh
qcsrc/server/tturrets/system/system_damage.qc
qcsrc/server/tturrets/system/system_main.qc

index 91ce464793bcbc0f33879a90222c2934165fdb3a..4f9aa3b1279a2c99dcd2bfb5cf2b33f1c9976e10 100644 (file)
@@ -143,6 +143,7 @@ void CSQC_Init(void)
        GibSplash_Precache();
        Casings_Precache();
        DamageInfo_Precache();
+       turrets_precache();
        if(autocvar_cl_announcer != cl_announcer_prev) {
                Announcer_Precache();
                if(cl_announcer_prev)
@@ -967,6 +968,7 @@ void(float bIsNewEntity) CSQC_Ent_Update =
                case ENT_CLIENT_LGBEAM: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_LGBEAM); break;
                case ENT_CLIENT_GAUNTLET: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_GAUNTLET); break;
                case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break;
+               case ENT_CLIENT_TURRET: ent_turret(); break; 
                default:
                        error(strcat(_("unknown entity type in CSQC_Ent_Update: %d\n"), self.enttype));
                        break;
index e296a477bfbaef96accbd9074f052e6b06a01412..71f588c5bdb9ebad6d6a418b8e2893f433b9b24d 100644 (file)
@@ -29,7 +29,8 @@ movetypes.qh
 prandom.qh
 bgmscript.qh
 noise.qh
-
+tturrets.qh
+../server/tturrets/include/turrets_early.qh
 main.qh
 
 sortlist.qc
@@ -58,6 +59,7 @@ tuba.qc
 target_music.qc
 
 //vehicles/spiderbot.qc
+
 Main.qc
 View.qc
 interpolate.qc
@@ -78,5 +80,6 @@ noise.qc
 ../warpzonelib/mathlib.qc
 ../warpzonelib/common.qc
 ../warpzonelib/client.qc
+tturrets.qc
 
 ../common/if-this-file-errors-scroll-up-and-fix-the-warnings.fteqccfail
index 14173b4c82acb463fc830fac28dcb0c81d1e6a3b..8c1278e1074a09268b19d54ed77189132707e84e 100644 (file)
@@ -1,5 +1,6 @@
 // Comment out below to skip turrets
 #define TTURRETS_ENABLED
+//#define TTURRETS_CSQC
 
 #ifdef TTURRETS_ENABLED
 #ifdef SVQC
@@ -466,6 +467,7 @@ void turret_do_updates(entity e_turret);
 void turrets_precash();
 #endif // SVQC
 
+// common
 .float turret_type;
 float TID_EWHEEL        = 1;
 float TID_FLAC          = 2;
@@ -481,6 +483,13 @@ float TID_TESLA         = 11;
 float TID_WALKER        = 12;
 float TID_LAST          = 12;
 
+float TNSF_UPDATE       = 2;
+float TNSF_STATUS       = 4;
+float TNSF_SETUP        = 8;
+float TNSF_ANG          = 16;
+float TNSF_AVEL         = 32;
+float TNSF_FULL_UPDATE  = 16777215;
+
 #endif // TTURRETS_ENABLED
 
 
index 4c8b1c2c8bf347c885156f4ccbc36f2748ebdd00..587457b3d02678fa64baa2003b250710775ead06 100644 (file)
@@ -297,6 +297,10 @@ void turret_stdproc_damage (entity inflictor, entity attacker, float damage, flo
     {
         self.tur_head.angles_x = self.tur_head.angles_x + (-0.5 + random()) * damage;
         self.tur_head.angles_y = self.tur_head.angles_y + (-0.5 + random()) * damage;
+        
+        if(self.SendEntity)
+            self.SendFlags  |= TNSF_ANG;
+
     }
 
     if (self.turrcaps_flags & TFL_TURRCAPS_MOVE)
@@ -315,6 +319,6 @@ void turret_stdproc_damage (entity inflictor, entity attacker, float damage, flo
     
     // CSQC
     if(self.SendEntity)
-        self.SendFlags  = TNSF_STATUS;
+        self.SendFlags  |= TNSF_STATUS;
 
 }
index e65d3897e774435a87861a5151208963fbdd7505..702af575844250f3972fd90935a6412fa481d310 100644 (file)
@@ -1,15 +1,5 @@
 #define cvar_base "g_turrets_unit_"
 
-float TNSF_UPDATE       = 2;
-float TNSF_STATUS       = 4;
-float TNSF_SETUP        = 8;
-
-float TNSF_ANG1         = 16;
-float TNSF_AVEL1        = 32;
-float TNSF_ANG2         = 64;
-float TNSF_AVEL2        = 128;
-
-float TNSF_FULL_UPDATE  = 16777215;
 float turret_send(entity to, float sf)
 {
        WriteByte(MSG_ENTITY, ENT_CLIENT_TURRET);
@@ -27,10 +17,14 @@ float turret_send(entity to, float sf)
            WriteAngle(MSG_ENTITY, self.angles_y);
     }
     
-    if(sf & TNSF_UPDATE)
+    if(sf & TNSF_ANG)
     {        
         WriteAngle(MSG_ENTITY, self.tur_head.angles_x);
            WriteAngle(MSG_ENTITY, self.tur_head.angles_y);         
+    }
+    
+    if(sf & TNSF_AVEL)
+    {        
            WriteAngle(MSG_ENTITY, self.tur_head.avelocity_x);
            WriteAngle(MSG_ENTITY, self.tur_head.avelocity_y);
     }
@@ -222,6 +216,7 @@ vector turret_fovsearch_random()
 ** Handles head rotation according to
 ** the units .track_type and .track_flags
 **/
+.float turret_framecounter;
 void turret_stdproc_track()
 {
     vector target_angle; // This is where we want to aim
@@ -281,7 +276,8 @@ void turret_stdproc_track()
             
             // CSQC
             if(self.SendEntity)
-                self.SendFlags  = TNSF_STATUS;
+                self.SendFlags  = TNSF_ANG;
+            
             return;
 
         case TFL_TRACKTYPE_FLUIDINERTIA:
@@ -307,12 +303,18 @@ void turret_stdproc_track()
         {
             self.tur_head.avelocity_x = 0;
             self.tur_head.angles_x = self.aim_maxpitch;
+            
+            if(self.SendEntity)
+                self.SendFlags  |= TNSF_ANG | TNSF_AVEL;
         }
         
         if((self.tur_head.angles_x + self.tur_head.avelocity_x * self.ticrate) < -self.aim_maxpitch)
         {
             self.tur_head.avelocity_x = 0;
             self.tur_head.angles_x = -self.aim_maxpitch;
+            
+            if(self.SendEntity)
+                self.SendFlags  |= TNSF_ANG | TNSF_AVEL;
         }
     }
 
@@ -325,14 +327,34 @@ void turret_stdproc_track()
         {
             self.tur_head.avelocity_y = 0;
             self.tur_head.angles_y = self.aim_maxrot;
+            
+            if(self.SendEntity)
+                self.SendFlags  |= TNSF_ANG | TNSF_AVEL;
         }
 
         if((self.tur_head.angles_y + self.tur_head.avelocity_y * self.ticrate) < -self.aim_maxrot)
         {
             self.tur_head.avelocity_y = 0;
             self.tur_head.angles_y = -self.aim_maxrot;
+            
+            if(self.SendEntity)
+                self.SendFlags  |= TNSF_ANG | TNSF_AVEL;
         }
     }
+    
+    if(self.SendEntity)
+    {        
+        self.turret_framecounter += 1;
+        if(self.turret_framecounter >= 4)
+        {
+            self.SendFlags  |= TNSF_ANG | TNSF_AVEL;
+            self.turret_framecounter = 0;
+        }
+        else
+            self.SendFlags |= TNSF_AVEL;
+    }
+            
+
 }
 
 
@@ -636,7 +658,8 @@ void turret_think()
     entity e;
 
     self.nextthink = time + self.ticrate;
-
+    self.SendFlags = TNSF_UPDATE | TNSF_STATUS | TNSF_ANG | TNSF_AVEL;
+    
     // ONS uses somewhat backwards linking.
     if (teams_matter)
     {
@@ -929,7 +952,9 @@ float turret_stdproc_init (string cvar_base_name, float csqc_shared, string base
         e.think = turrets_manager_think;
         e.nextthink = time + 2;
     }
-
+#ifndef TTURRETS_CSQC
+    csqc_shared = 0;
+#endif
     /*
     if(csqc_shared)
     {
@@ -1278,14 +1303,16 @@ float turret_stdproc_init (string cvar_base_name, float csqc_shared, string base
         self.use();
     }
     
+    Net_LinkEntity(self, TRUE, 0, turret_send);
        turret_stdproc_respawn();
        
     // Initiate the main AI loop
+    /*self.nextthink = time;
     if(csqc_shared)
         self.think     = turret_link;
     else
         self.think     = turret_think;
-
+    */
     return 1;
 }