From c7d85fe6e25879695b63a3dcd40ad9602826e77d Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Sun, 10 Nov 2013 00:09:05 +0000
Subject: [PATCH] [Change] Improved collective ai.

---
 scripts/ai/collective.lua | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/scripts/ai/collective.lua b/scripts/ai/collective.lua
index c793d06..aae15b7 100644
--- a/scripts/ai/collective.lua
+++ b/scripts/ai/collective.lua
@@ -1,17 +1,23 @@
 include("../scripts/ai/include/basic.lua")
 
 -- Required control rate.
-control_rate = 2
+control_rate = 0.5
 
 function control()
- if ai.taskname() == nil then
-  enemy = ai.getenemy()
+  local task = ai.taskname()
+
+  if task == "none" then
+    local enemy = ai.getenemy()
 
   if enemey ~= 0 then
-   -- Make hostile to enemy (mainly player).
-   ai.hostile(enemy)
    ai.pushtask(0, "attack", enemy)
+  else
+    ai.pushtask(0, "hyperspace")
   end
+  elseif task == "hyperspace" then
+    ai.hyperspace()
+  else
+    attack_closestenemy()
  end
 end