]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Make tesla coil work again
authorJakob MG <jakob_mg@hotmail.com>
Sat, 22 Oct 2011 09:07:38 +0000 (11:07 +0200)
committerJakob MG <jakob_mg@hotmail.com>
Sat, 22 Oct 2011 09:07:38 +0000 (11:07 +0200)
qcsrc/server/tturrets/units/unit_tessla.qc

index 454557010d11f8b3328aa8a5381e5ad11cdc634b..6c2cce6a73341ad4d3b80fcd25a19233b269b688 100644 (file)
@@ -46,24 +46,45 @@ entity toast(entity from, float range, float damage)
 
 float turret_tesla_firecheck()
 {
-    if not (turret_stdproc_firecheck())
-        return 0;
+    // g_turrets_targetscan_maxdelay forces a target re-scan at least this often
+    float do_target_scan;
+    
+    if((self.target_select_time + autocvar_g_turrets_targetscan_maxdelay) < time)
+        do_target_scan = 1;
+
+    // Old target (if any) invalid?
+    if(self.target_validate_time < time)
+    if (turret_validate_target(self, self.enemy, self.target_validate_flags) <= 0)
+    {
+        self.enemy = world;
+        self.target_validate_time = time + 0.5;
+        do_target_scan = 1;
+    }
 
-    self.target_select_flags = TFL_TARGETSELECT_PLAYERS | TFL_TARGETSELECT_MISSILES | TFL_TARGETSELECT_RANGELIMTS | TFL_TARGETSELECT_TEAMCHECK;
+    // But never more often then g_turrets_targetscan_mindelay!
+    if (self.target_select_time + autocvar_g_turrets_targetscan_mindelay > time)
+        do_target_scan = 0;
 
-    self.enemy = turret_select_target();
+    if(do_target_scan)
+    {
+        self.enemy = turret_select_target();
+        self.target_select_time = time;
+    }
+
+    if not (turret_stdproc_firecheck())
+        return 0;
 
     if(self.enemy)
         return 1;
 
     return 0;
-
 }
 
+
 void turret_tesla_fire()
 {
-    entity e,t;
-    float d,r,i;
+    entity e, t;
+    float d, r, i;
 
     //w_deathtypestring = "discoverd how a tesla coil works";