Index: /code/branches/AI_HS15/data/levels/AITest.oxw
===================================================================
--- /code/branches/AI_HS15/data/levels/AITest.oxw	(revision 10708)
+++ /code/branches/AI_HS15/data/levels/AITest.oxw	(revision 10709)
@@ -33,8 +33,10 @@
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
     <SpawnPoint team=0 position="-2000,-1000,3000" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipassff />
-    
+    <!-->
+
     <?lua
       for i = 0, 5, 1 do
     ?>
+
     <StaticEntity position="0,-10000,0" direction="0,-1,0" >
      <controller>
@@ -59,5 +61,35 @@
     </SpaceShip>
     <?lua end ?>
-
+  </!-->
+    
+    <SpaceShip position = "-1000, -1000, -1000">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <FleetController accuracy=10 team=1 >
+        </FleetController>
+      </controller>
+    </SpaceShip>
+    
+    <SpaceShip position="1000, 1000, -1500 ?>" lookat="0,0,0">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=1>
+        </WingmanController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="1000, 1000, -1900 ?>" lookat="0,0,0">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=1>
+        </WingmanController>
+      </controller>
+    </SpaceShip>
+    <!-->
     <?lua
       for i = 0, 5, 1 do
@@ -73,5 +105,5 @@
     </SpaceShip>
     <?lua end ?>
-
+    </!-->
 
   </Scene>
Index: /code/branches/AI_HS15/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/CMakeLists.txt	(revision 10708)
+++ /code/branches/AI_HS15/src/orxonox/controllers/CMakeLists.txt	(revision 10709)
@@ -13,5 +13,4 @@
   FleetController.cc
   DivisionController.cc
-  SectionController.cc
   LeaderController.cc
   WingmanController.cc
Index: /code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	(revision 10708)
+++ /code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	(revision 10709)
@@ -35,5 +35,5 @@
     RegisterClass(DivisionController);
 
-    DivisionController::DivisionController(Context* context) : FleetController(context)
+    DivisionController::DivisionController(Context* context) : LeaderController(context)
     {
         RegisterObject(DivisionController);
@@ -47,5 +47,8 @@
         }
     }
-
+    void DivisionController::setLeader(LeaderController* leader)
+    {
+        this->leader_ = leader;
+    }
     /*void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
Index: /code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h	(revision 10708)
+++ /code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h	(revision 10709)
@@ -30,10 +30,11 @@
 #define _DivisionController_H__
 
-#include "controllers/FleetController.h"
+#include "controllers/LeaderController.h"
+
 
 
 namespace orxonox
 {
-    class _OrxonoxExport DivisionController : public FleetController
+    class _OrxonoxExport DivisionController : public LeaderController
     {
         public:
@@ -48,17 +49,7 @@
      		inline FormationMode getFormationMode() const
            		{ return this->formationMode_; }
+			virtual void setLeader(LeaderController* leader);
+
 			
-			virtual void doFire();
-
-			//WAYPOINT FUNCTIONS`
-            void addWaypoint(WorldEntity* waypoint);
-            WorldEntity* getWaypoint(unsigned int index) const;
-
-            inline void setAccuracy(float accuracy)
-                { this->squaredaccuracy_ = accuracy*accuracy; }
-            inline float getAccuracy() const
-                { return sqrt(this->squaredaccuracy_); }
-            void updatePointsOfInterest(std::string name, float distance);
-            void manageWaypoints();
 
         protected:
@@ -70,5 +61,7 @@
 			bool bHasTargetOrientation_;
 			Quaternion targetOrientation_;
-			void setTargetPosition(const Vector3& target);
+			FormationMode formationMode_;
+			
+			/*void setTargetPosition(const Vector3& target);
 			void searchRandomTargetPosition();
 
@@ -78,5 +71,4 @@
 			virtual void positionReached() {}
 
-			static bool sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype); // hack
 
 
@@ -109,11 +101,9 @@
 		    void spinInit();
 		    void spin();
-      		void turn180();
+      		void turn180();*/
 
-	        //WAYPOINT DATA
-	        std::vector<WeakPtr<WorldEntity> > waypoints_;
-	        size_t currentWaypoint_;
-	        float squaredaccuracy_;
-	        WorldEntity* defaultWaypoint_;
+      		LeaderController* leader_;
+	        
+
 	    
         private:
Index: /code/branches/AI_HS15/src/orxonox/controllers/FleetController.cc
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/FleetController.cc	(revision 10708)
+++ /code/branches/AI_HS15/src/orxonox/controllers/FleetController.cc	(revision 10709)
@@ -35,5 +35,5 @@
     RegisterClass(FleetController);
 
-    FleetController::FleetController(Context* context) : Controller(context)
+    FleetController::FleetController(Context* context) : FormationController(context)
     {
         RegisterObject(FleetController);
@@ -43,4 +43,7 @@
         this->goalTarget_ = NULL;
         this->goalProtect_ = NULL;
+        this->nTicks_ = 0;
+        this->bTicked_ = false;
+        //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&FleetController::action, this)));
     }
 
@@ -52,5 +55,96 @@
         }
     }
-   
+    void FleetController::action()
+    {
+
+
+    }
+    void FleetController::tick(float dt)
+    {
+
+         if (nTicks_ == 30)
+         {
+            std::vector<WeakPtr<WingmanController> > wingmen;
+            std::vector<WeakPtr<LeaderController> > leaders;
+
+            //--------------------------Put all WingmanController's in a vector--------------------------
+            for (ObjectList<WingmanController>::iterator it = ObjectList<WingmanController>::begin(); it; ++it)
+            {
+
+               
+                if ((*it)->getTeam() == this->getTeam())
+                {
+                    orxout(internal_error) << "ANOTHER SUCKER" << endl;
+                    wingmen.push_back(*it);
+                } 
+                
+            }
+            //--------------------------Substitute half of WingmanController's with LeaderController--------------------------
+
+            bool nowLeader = true;
+            LeaderController* leader;
+
+            for (std::vector<WeakPtr<WingmanController> >::iterator it = wingmen.begin() ; it != wingmen.end(); ++it)
+            {
+                if (nowLeader)
+                {
+                    leader = new LeaderController(this->getContext());
+                    leader->setTeam(this->team_);
+
+                    (*it)->getControllableEntity()->setController(leader);
+                    leaders.push_back(leader);
+                    nowLeader = !nowLeader;
+                    orxout(internal_error) << "NEW SUCKER" << endl;
+
+                }
+                else
+                {
+                    if (leader)
+                    {
+                        leader->setWingman(*it);
+                        nowLeader = !nowLeader;
+                        orxout(internal_error) << "I OWN THE SUCKER" << endl;
+
+                    }
+                }
+            }
+
+            //--------------------------Substitute half of LeaderController's with DivisionController--------------------------
+            bool nowDivision = true;
+            DivisionController* division;
+
+            for (std::vector<WeakPtr<LeaderController> >::iterator it = leaders.begin() ; it != leaders.end(); ++it)
+            {
+                if (nowDivision)
+                {
+                    division = new DivisionController(this->getContext());
+                    division->setTeam(this->team_);
+
+                    (*it)->getControllableEntity()->setController(division);
+
+                    divisions_.push_back(division);
+
+                    nowDivision = !nowDivision;
+                }
+                else
+                {
+                    if (division)
+                    {
+                        division->setLeader(*it);
+                        nowDivision = !nowDivision;
+                    }
+                }
+            }
+            bTicked_ = true;
+            nTicks_ += 1;
+         }
+         else if (!bTicked_)
+         {
+            nTicks_ += 1;
+
+         }
+        SUPER(FleetController, tick, dt);
+
+    }
     void FleetController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
Index: /code/branches/AI_HS15/src/orxonox/controllers/FleetController.h
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/FleetController.h	(revision 10708)
+++ /code/branches/AI_HS15/src/orxonox/controllers/FleetController.h	(revision 10709)
@@ -29,13 +29,15 @@
 #ifndef _FleetController_H__
 #define _FleetController_H__
+#include "controllers/FormationController.h"
 
 #include "controllers/Controller.h"
+#include "controllers/DivisionController.h"
+#include "controllers/LeaderController.h"
+#include "controllers/WingmanController.h"
 
 #include "OrxonoxPrereqs.h"
 #include "core/class/Super.h"
 #include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "core/command/ConsoleCommandIncludes.h"
-#include "core/command/Executor.h"
+
 
 #include <vector>
@@ -51,12 +53,4 @@
 #include "worldentities/pawns/TeamBaseMatchBase.h"
 
-#include "gametypes/TeamDeathmatch.h"
-#include "gametypes/Dynamicmatch.h"
-#include "gametypes/Mission.h"
-#include "gametypes/Gametype.h"
-
-#include "controllers/WaypointPatrolController.h"
-#include "controllers/NewHumanController.h"
-#include "controllers/DroneController.h"
 
 
@@ -64,5 +58,5 @@
 {   
 
-    class _OrxonoxExport FleetController : public Controller
+    class _OrxonoxExport FleetController : public FormationController, public Tickable
     {
         public:
@@ -70,4 +64,5 @@
           virtual ~FleetController();
 
+          virtual void tick(float dt); //<! Carrying out the targets set in action().
 
           virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
@@ -80,24 +75,5 @@
           enum GameGoal {DOMINATE, MOVE, DESTROY, PROTECT};
           
-          /*void setGameGoal(GameGoal gameGoal)
-             { this->gameGoal_ = gameGoal; }
-          GameGoal getGameGoal() const
-             { return this->gameGoal_; }
           
-          void setGoalPosition(Vector3* goalPosition)
-             { this->goalPosition_ = goalPosition; }
-          Vector3* getGoalPosition() const
-             { return this->goalPosition_; }
-          
-          void setGoalTarget(Pawn* goalTarget)
-             { this->goalTarget_ = goalTarget; }
-          Pawn* getGoalTarget() const
-             { return this->goalTarget_; }
-          
-          void setGoalProtect(Pawn* goalProtect)
-             { this->goalProtect_ = goalProtect; }
-          Pawn* getGoalProtect() const
-             { return this->goalProtect_; }*/
-
 
 
@@ -110,4 +86,11 @@
             WeakPtr<Pawn> goalProtect_;
 
+            virtual void action();
+        private:
+            int nTicks_;
+            bool bTicked_;
+
+            std::vector<WeakPtr<DivisionController> > divisions_;
+            //Timer actionTimer_; //<! Regularly calls action().
 
     };
Index: /code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc	(revision 10708)
+++ /code/branches/AI_HS15/src/orxonox/controllers/LeaderController.cc	(revision 10709)
@@ -33,13 +33,14 @@
 namespace orxonox
 {
-    const float LeaderController::ACTION_INTERVAL = 1.0f;
 
     RegisterClass(LeaderController);
 
-    LeaderController::LeaderController(Context* context) : SectionController(context)
+    LeaderController::LeaderController(Context* context) : WingmanController(context)
     {
+
         RegisterObject(LeaderController);
-        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&LeaderController::action, this)));
+        //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&LeaderController::action, this)));
     }
+
 
     LeaderController::~LeaderController()
@@ -49,5 +50,5 @@
     void LeaderController::action()
     {
-        
+        //this->target_ = this->sectionTarget_;        
     }
     /*
@@ -66,10 +67,10 @@
     */
     void LeaderController::tick(float dt)
-    {
+    {/*
         if (!this->isActive())
             return;
         
         //--------------------------Stay in division--------------------------
-        this->keepDivisionTick();
+        this->keepDivisionTick();*/
         /*keepDivisionTick(){
             if (this->divisionLeader_ && this->divisionLeader_->getControllableEntity() && desiredRelativePosition_){
@@ -80,23 +81,24 @@
         }
         */
-        //If ordered to attack -> follow target and shoot
+        /*//If ordered to attack -> follow target and shoot
         if (this->bAttackOrder_)
         {
-
+ 
         } 
         //If ordered to move -> move to a target Point
-        else if (this->bMoveOrder_)
-        {
-
-        } 
-        else
+        
         //No orders -> Don't move, but shoot at whatever is close, unless Boss is shooting at it. 
         //(Section shoots same target, Boss's section shoots another target) 
         {
 
-        }
+        }*/
 
-
+        orxout(internal_error) << "my Wingman is " << this->wingman_ << endl;
+        
         SUPER(LeaderController, tick, dt);
+    }
+    void LeaderController::setWingman(WingmanController* wingman)
+    {
+        this->wingman_ = wingman;
     }
 //**********************************************NEW
Index: /code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h	(revision 10708)
+++ /code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h	(revision 10709)
@@ -30,10 +30,12 @@
 #define _LeaderController_H__
 
-#include "SectionController.h"
+#include "controllers/WingmanController.h"
+
+
 
 
 namespace orxonox
 {
-    class _OrxonoxExport LeaderController : public SectionController, public Tickable
+    class _OrxonoxExport LeaderController : public WingmanController
     {
         public:
@@ -41,30 +43,21 @@
             LeaderController(Context* context);
             virtual ~LeaderController();
-
+            virtual void setWingman(WingmanController* wingman);
             virtual void tick(float dt); //<! Carrying out the targets set in action().
 
         protected:
            
-            enum Mode {KEEPFORMATION, ROCKET, KILLENEMY};
-            Mode mode_;
+            
 
             virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
             //void defaultBehaviour(float maxrand); //<! Helper function for code reusage. Some concrete commands for a bot.    
+         
+        private:
             
+            WeakPtr<Pawn> target_;
+            
+            WingmanController* wingman_;
 
-            //WEAPONSYSTEM DATA
-            std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode - managed by setupWeapons()
-            //std::vector<int> projectiles_; //<! Displays amount of projectiles of each weapon. - managed by setupWeapons()
-            float timeout_; //<! Timeout for rocket usage. (If a rocket misses, a bot should stop using it.)
-            void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed.
-            bool bSetupWorked; //<! If false, setupWeapons() is called.
-            int getFiremode(std::string name);
-
-            void boostControl(); //<! Sets and resets the boost parameter of the spaceship. Bots alternate between boosting and saving boost.
-
-        private:
-            static const float ACTION_INTERVAL;
-
-            Timer actionTimer_; //<! Regularly calls action().
+            //Timer actionTimer_; //<! Regularly calls action().
                
     };
Index: /code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc	(revision 10708)
+++ /code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc	(revision 10709)
@@ -32,12 +32,11 @@
 namespace orxonox
 {
-    const float WingmanController::ACTION_INTERVAL = 1.0f;
 
     RegisterClass(WingmanController);
 
-    WingmanController::WingmanController(Context* context) : SectionController(context)
+    WingmanController::WingmanController(Context* context) : Controller(context)
     {
         RegisterObject(WingmanController);
-        this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
+        //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
     }
 
@@ -55,13 +54,9 @@
     void WingmanController::action()
     {
-        //--------------------------Cover Leader's rear--------------------------
-        //check for enemies in Leader's rear that can attack him and if they are visible, meaning there are no other Leader's between Leader and enemies.
-        //if there are enemies, set target_ to the nearest one and set bFollowLeader_ to false, 
-        //otherwise set bFollowLeader_ to true and target_ to sectionTarget_
-        this->coverAllyRear(this->sectionLeader_);
+        //this->target_ = this->sectionTarget_;
     }
 
     void WingmanController::tick(float dt)
-    {
+    {/*
         if (!this->isActive())
             return;
@@ -69,5 +64,5 @@
         if (bFollowLeader_)
         {
-            this->keepSectionTick();
+            this->keepSectionTick();*/
             /*keepSectionTick(){
                 if (this->sectionLeader_ && this->sectionLeader_->getControllableEntity() && desiredRelativePosition_){
@@ -78,7 +73,7 @@
             }
             */
-            
+          /*  
             //--------------------------Attack same target as the Leader--------------------------
-           
+
             if (this->target_)
             {
@@ -86,36 +81,7 @@
                 this->doFire();
             }
-        }
-        //--------------------------Protect Leader by killing target_--------------------------
-
-        else
-        {
-            if (this->target_)
-            {
-                //--------------------------Don't attack if not visible--------------------------                
-                if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */
-                {
-                    this->forgetTarget();
-                    //this->bFollowLeader_ = true;
-                }
-                //--------------------------Otherwise destroy it--------------------------
-                else
-                {
-                    this->aimAtTarget();
-                    this->follow();  //If a bot is shooting a player, it shouldn't let him go away easily.
-                }
-                if (this->bHasTargetPosition_)
-                {
-                    this->moveToTargetPosition();
-                }
-                this->doFire();
-            }
-            //--------------------------no target? do nothing until next action() -> either new target appears or bFollowLeader_ set to true--------------------------
-            else
-            {
-
-            }            
-
-        }
+        }*/
+         //orxout(internal_error) << "I am " << this << endl;
+        
         SUPER(WingmanController, tick, dt);
     }
Index: /code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h	(revision 10708)
+++ /code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h	(revision 10709)
@@ -31,10 +31,36 @@
 
 
-#include "LeaderController.h"
+#include "controllers/Controller.h"
+
+
+#include "OrxonoxPrereqs.h"
+#include "core/class/Super.h"
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/command/ConsoleCommandIncludes.h"
+#include "core/command/Executor.h"
+
+#include <vector>
+#include "util/Math.h"
+#include <climits>
+
+#include "tools/Timer.h"
+#include "tools/interfaces/Tickable.h"
+
+#include "worldentities/ControllableEntity.h"
+#include "worldentities/pawns/SpaceShip.h"
+#include "worldentities/pawns/Pawn.h"
+#include "worldentities/pawns/TeamBaseMatchBase.h"
+
+#include "gametypes/TeamDeathmatch.h"
+#include "gametypes/Dynamicmatch.h"
+#include "gametypes/Mission.h"
+#include "gametypes/Gametype.h"
+
 
 
 namespace orxonox
 {
-    class _OrxonoxExport WingmanController : public LeaderController
+    class _OrxonoxExport WingmanController : public Controller, public Tickable
     {
         public:
@@ -51,7 +77,11 @@
                      
         private:
-            static const float ACTION_INTERVAL;
+            //const float ACTION_INTERVAL;
+            
+            WeakPtr<Pawn> target_;
+            
+            //LeaderController* leader_;
 
-            Timer actionTimer_; //<! Regularly calls action().
+            //Timer actionTimer_; //<! Regularly calls action().
            
     };
