Index: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw	(revision 10885)
+++ code/branches/campaignHS15/data/levels/AITest.oxw	(revision 10886)
@@ -32,5 +32,5 @@
 
     <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"/>
-    <TeamSpawnPoint team=0 position="-5000, 3000, -2000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
+    <TeamSpawnPoint team=0 position="3000, -1500, 1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
     
 <!-- HERE STARTS DEMO FOR THE "WAYPOINTS" -->
@@ -62,5 +62,5 @@
 <!-- HERE STARTS DEMO FOR THE ACTIONPOINTS. 
 P.S. Never set protectMe in the first actionpoint: if human didn't spawn, that actionpoint will be skipped -->
-       <!-- 
+       
     <Model mesh="cube.mesh" scale=8 position="0,0,0" />
 
@@ -123,9 +123,9 @@
       </templates>
     </SpaceShip> 
-  -->
+ 
    
 <!-- HERE ENDS DEMO FOR THE ACTIONPOINTS -->
 <!-- HERE STARTS DEMO FOR FIGHTING -->
-    
+    <!-- 
     <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
       <templates>
@@ -242,5 +242,5 @@
       </controller>
     </SpaceShip>
-
+ -->
     
 <!-- HERE ENDS DEMO FOR FIGHTING -->
@@ -297,16 +297,57 @@
     -->
 <!-- HERE ENDS DEMO FOR FORMATIONS -->
-    <!-- 
-    <SpaceShip position="-2000, 3000, -2000" lookat="0,0,0" team=1 name="ss2">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <DivisionController team=1 formationMode="finger4">
-          
-        </DivisionController>
-      </controller>
-    </SpaceShip>
- -->
+    <!-- 1 division is roughly equal to 6 AIControllers--!>
+<!-- 
+    <SpaceShip position="2000, -1500, 1000" lookat="0,0,0" team=1 >
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <DivisionController team=1 formationMode="WALL">
+
+        </DivisionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="2000, -1900, 1000" lookat="0,0,0" team=1>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <SectionController team=1>
+        </SectionController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="2000, -2100, 1000" lookat="0,0,0" team=1>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=1>
+        </WingmanController>
+      </controller>
+    </SpaceShip>
+    <SpaceShip position="2000, -2400, 1000" lookat="0,0,0" team=1>
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <WingmanController team=1>
+        </WingmanController>
+      </controller>
+    </SpaceShip> 
+
+    <?lua
+      for i = 0, 5, 1 do
+        ?>
+      <SpaceShip position="<?lua print(7000) ?>,<?lua print(i*500) ?>,<?lua print(0) ?>" team=2>
+        <templates>
+          <Template link=spaceshipassff />
+        </templates>
+        <controller>
+          <AIController team=2 />
+        </controller>
+      </SpaceShip>
+    <?lua end ?> -->
+    
 
   </Scene>
Index: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	(revision 10886)
@@ -59,6 +59,13 @@
         XMLPortObject(ActionpointController, WorldEntity, "actionpoints", addActionpoint, getActionpoint,  xmlelement, mode);
     }
-   	void ActionpointController::tick(float dt)
-   	{
+    ActionpointController::~ActionpointController()
+    {
+        loopActionpoints_.clear();
+        parsedActionpoints_.clear();
+        actionpoints_.clear();
+    }
+    void ActionpointController::tick(float dt)
+    {
+
         if (this->timeout_ > 0 && this->bFiredRocket_)
         {
@@ -68,5 +75,5 @@
             this->bFiredRocket_ = false;
 
-   		if (this->bHasTargetPosition_)
+        if (this->bHasTargetPosition_)
         {
             this->moveToTargetPosition(dt);
@@ -90,19 +97,127 @@
         }
         if (this->bFirstTick_)
-        {
-            // this->getControllableEntity()->setOrientation(1,0,0,0);
-            // this->getControllableEntity()->rotateRoll(-this->getControllableEntity()->getOrientation().getRoll(true).valueRadians());
-            // this->getControllableEntity()->rotateYaw(-this->getControllableEntity()->getOrientation().getYaw(true).valueRadians());
-            // this->getControllableEntity()->rotatePitch(-this->getControllableEntity()->getOrientation().getPitch(true).valueRadians());            
+        {            
             this->bFirstTick_ = false;
-
-        }
-   		SUPER(ActionpointController, tick, dt);
-   	}
-    ActionpointController::~ActionpointController()
-    {
-        loopActionpoints_.clear();
-        parsedActionpoints_.clear();
-        actionpoints_.clear();
+        }
+
+        SUPER(ActionpointController, tick, dt);
+    }
+    void ActionpointController::action()
+    {
+        if (!this || !this->getControllableEntity())
+            return;
+        if (!this->getControllableEntity() || !orxonox_cast<Pawn*> (this->getControllableEntity()))
+            return;
+        this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
+        this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
+        if (this->actionCounter_ % 2 == 0)
+            this->startAttackingEnemiesThatAreClose();
+        //No action -> pop one from stack
+        if (this->action_ == Action::NONE || this->bTakenOver_)
+        {
+            if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())
+            {
+                Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
+                this->parsedActionpoints_.push_back (p);
+            }
+            this->executeActionpoint();
+            this->bTakenOver_ = false;
+            this->action();
+        }
+        //Action fightall -> fight till nobody alive
+        if (this->action_ == Action::FIGHTALL)
+        {
+            if (!this->hasTarget())
+            {
+                ControllableEntity* newTarget = this->closestTarget();    
+                if (newTarget)
+                {
+                    this->setAction (Action::FIGHTALL, newTarget);
+                    this->action();
+                }
+                else
+                {
+                    this->nextActionpoint();
+                    if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
+                    {
+                        this->action();
+                    }       
+                }
+            }
+        }
+        //Action fight -> fight as long as enemies in range
+        else if (this->action_ == Action::FIGHT)
+        {
+            if (!this->hasTarget())
+            {
+                //----find a target----
+                ControllableEntity* newTarget = this->closestTarget();    
+                if (newTarget && 
+                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
+                {
+                    this->setAction (Action::FIGHT, newTarget);
+                    this->action();
+                }
+                else
+                {
+                    this->nextActionpoint();
+                    this->action();
+                }
+            }
+            else if (this->hasTarget())
+            {
+                //----fly in formation if far enough----
+                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
+                    
+                if (diffVector.length() > this->attackRange_)
+                {
+                    ControllableEntity* newTarget = this->closestTarget();
+                    
+                    if (newTarget && 
+                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
+                    {
+                        this->setAction (Action::FIGHT, newTarget);
+                    }
+                    else
+                    {
+                        this->nextActionpoint();
+                        this->action();
+                    }
+                }
+            }
+        }
+        else if (this->action_ == Action::FLY)
+        {
+            if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
+            {
+                this->nextActionpoint();   
+                this->action();
+            }
+        }
+        else if (this->action_ == Action::PROTECT)
+        {
+            if (!this->getProtect())
+            {
+                this->nextActionpoint();
+                this->action(); 
+            }
+            this->stayNearProtect();
+        }
+        else if (this->action_ == Action::ATTACK)
+        {   
+            if (!this->hasTarget())
+            {
+                this->nextActionpoint();
+                this->action();
+            }
+        }
+        if (this->hasTarget())
+        {
+            //----choose where to go----
+            this->maneuver();
+            //----fire if you can----
+            this->bShooting_ = this->canFire();                
+        }
+        this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
     }
     void ActionpointController::setProtect (ControllableEntity* protect)
@@ -273,6 +388,6 @@
             return;
         }
-        this->action_ = p.action;
-        switch ( this->action_ )
+        this->setAction (p.action);
+        switch (this->action_)
         {
             case Action::FIGHT:
@@ -280,7 +395,5 @@
                 std::string targetName = p.name;
                 if (targetName == "")
-                {
                     break;
-                }
                 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
                 {
@@ -289,5 +402,5 @@
                         this->setTarget (static_cast<ControllableEntity*>(*itP));
                     }
-                }          
+                }
                 break;
             }
@@ -361,6 +474,5 @@
             default:
                 break;
-        }
-        
+        }   
     }
 
@@ -368,8 +480,18 @@
     void ActionpointController::stayNearProtect()
     {
-        Vector3 targetRelativePosition(0, 300, 300);  
+        Vector3 targetRelativePosition(0, 300, 300);
+        if (!this->getProtect())
+        {
+            this->nextActionpoint();
+            return;
+        }  
         Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) + 
             (this->getProtect()->getWorldOrientation()* (targetRelativePosition)));
         this->setTargetPosition(targetAbsolutePosition);
+        if (!this->getProtect())
+        {
+            this->nextActionpoint();
+            return;
+        }  
         if (this->actionCounter_ % 3 == 0)
             this->setTargetOrientation(this->getProtect()->getWorldOrientation());
@@ -422,126 +544,5 @@
         }
     }
-    void ActionpointController::action()
-    {
-        if (!this || !this->getControllableEntity())
-            return;
-        // orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
-        if (this->actionCounter_ % 2 == 0)
-            this->startAttackingEnemiesThatAreClose();
-        //No action -> pop one from stack
-        if (this->action_ == Action::NONE || this->bTakenOver_)
-        {
-            if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())
-            {
-                Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
-                this->parsedActionpoints_.push_back (p);
-
-            }
-            this->executeActionpoint();
-            this->bTakenOver_ = false;
-            this->action();
-        }
-        //Action fightall -> fight till nobody alive
-        if (this->action_ == Action::FIGHTALL)
-        {
-            if (!this->hasTarget())
-            {
-                //----find a target----
-                ControllableEntity* newTarget = this->closestTarget();    
-                if (newTarget)
-                {
-                    this->setAction (Action::FIGHTALL, newTarget);
-                }
-                else
-                {
-                    this->nextActionpoint();
-
-                    if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
-                    {
-                        this->action();
-                    }
-                    
-                }
-            }
-            else if (this->hasTarget())
-            {
-
-            }
-        }
-        //Action fight -> fight as long as enemies in range
-        else if (this->action_ == Action::FIGHT)
-        {
-            if (!this->hasTarget())
-            {
-                //----find a target----
-                ControllableEntity* newTarget = this->closestTarget();    
-                if (newTarget && 
-                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
-                {
-                    this->setAction (Action::FIGHT, newTarget);
-                }
-                else
-                {
-                    this->nextActionpoint();
-                    this->action();
-                }
-            }
-            else if (this->hasTarget())
-            {
-                //----fly in formation if far enough----
-                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
-                    
-                if (diffVector.length() > this->attackRange_)
-                {
-                    ControllableEntity* newTarget = this->closestTarget();
-                    
-                    if (newTarget && 
-                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
-                    {
-                        this->setAction (Action::FIGHT, newTarget);
-                    }
-                    else
-                    {
-                        this->nextActionpoint();
-                        this->action();
-                    }
-                }
-            }
-        }
-        else if (this->action_ == Action::FLY)
-        {
-            if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
-            {
-                this->nextActionpoint();   
-                this->action();
-            }
-        }
-        else if (this->action_ == Action::PROTECT)
-        {
-            if (!this->getProtect())
-            {
-                this->nextActionpoint();
-                this->action(); 
-            }
-            this->stayNearProtect();
-        }
-        else if (this->action_ == Action::ATTACK)
-        {   
-            if (!this->hasTarget())
-            {
-                this->nextActionpoint();
-                this->action();
-            }
-        }
-        if (this->hasTarget())
-        {
-            //----choose where to go----
-            this->maneuver();
-            //----fire if you can----
-            this->bShooting_ = this->canFire();                
-        }
-        this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
-
-    }
+    
     void ActionpointController::takeActionpoints (const std::vector<Point>& vector, const std::vector<Point>& loop, bool b)
     {
@@ -550,5 +551,4 @@
       this->bLoop_ = b;
       this->bTakenOver_ = true;
-      // orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
     }
     void ActionpointController::setClosestTarget()
Index: code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt	(revision 10886)
@@ -12,5 +12,4 @@
   ControllerDirector.cc
   DivisionController.cc
-  LeaderController.cc
   WingmanController.cc
   SectionController.cc
Index: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10886)
@@ -36,5 +36,5 @@
 
     //Leaders share the fact that they have Wingmans
-    DivisionController::DivisionController(Context* context) : LeaderController(context)
+    DivisionController::DivisionController(Context* context) : ActionpointController(context)
     {
         RegisterObject(DivisionController);
Index: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h	(revision 10886)
@@ -30,5 +30,5 @@
 #define _DivisionController_H__
 
-#include "controllers/LeaderController.h"
+#include "controllers/ActionpointController.h"
 
 
@@ -36,5 +36,5 @@
 namespace orxonox
 {
-    class _OrxonoxExport DivisionController : public LeaderController
+    class _OrxonoxExport DivisionController : public ActionpointController
     {
         public:
Index: code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	(revision 10886)
@@ -45,5 +45,5 @@
     FightingController::FightingController( Context* context ): FlyingController( context )
     {
-    	this->attackRange_ = 3000;
+    	this->attackRange_ = 2500;
         this->stopLookingAtTarget();
         this->bSetupWorked = false;
@@ -126,22 +126,23 @@
         float diffLength = diffVector.length();
         Vector3 diffUnit = diffVector/diffLength;
-        bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/20.0f);
-        
+        bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/15.0f)
+            || this->deltaHp < 0;
+
         //too far? well, come closer then
         if (diffLength > this->attackRange_)
         {
-            this->spread_ = 300;
-            this->formationMode_ = FormationMode::WALL;
+            this->spread_ = 400;
+            this->formationMode_ = FormationMode::DIAMOND;
             this->bKeepFormation_ = true;
             
-            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);
+            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
         }
         //too close? How do u expect to dodge anything? Just attack!
-        else if (diffLength < 500)
+        else if (diffLength < 400)
         {   
             this->bKeepFormation_ = false;
 
             //at this point, just look and shoot
-            if (diffLength < 250)
+            if (diffLength < 200)
             {
                 this->stopMoving();
@@ -150,5 +151,5 @@
             else
             {
-                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);
+                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
             }
         }
@@ -157,5 +158,5 @@
         {
             this->bKeepFormation_ = false;
-            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);
+            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
         }
         //That's unfortunate, he is looking and probably shooting... try to dodge what we can...  
@@ -165,5 +166,5 @@
             if (maneuverCounter_ == 0)
             {
-                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);   
+                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 50.0f);   
                 return;
             }
@@ -176,8 +177,8 @@
         //d.x*x + d.y*y + d.z*z == 0
         //z = 1/d.z * (-d.y*y - d.x * x)
-        float x = CommonController::randomInRange (1000, 10000) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
-        float y = CommonController::randomInRange (1000, 10000) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
+        float x = CommonController::randomInRange (100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
+        float y = CommonController::randomInRange (100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
         float z = (1/diffUnit.z) * (-x * diffUnit.x - y * diffUnit.y);
-        this->setTargetPosition(thisPosition + Vector3(x,y,z) + diffUnit * 1000.0f);
+        this->setTargetPosition(thisPosition + Vector3(x,y,z) + (this->deltaHp < 0 ? -diffUnit * 450.0f : diffUnit * 100.0f));
         this->boostControl();
 
@@ -195,4 +196,5 @@
             this->setPositionOfTarget(newPositionOfTarget);
         }
+
         return squaredDistanceToTarget() < this->attackRange_*this->attackRange_ && this->isLookingAtTarget(math::pi / 20.0f);
     }
@@ -270,8 +272,10 @@
             return;
         }
+
         Pawn* pawn = orxonox_cast<Pawn*> (this->getControllableEntity());
         if (pawn)
             pawn->setAimPosition (this->positionOfTarget_);
-
+        // if (pawn->getHealth() < 100)
+        //     orxout(internal_error) << "not full, hp = " << pawn->getHealth() << endl;
         int firemode;
         float distance = CommonController::distance (this->getControllableEntity(), this->target_);
@@ -281,45 +285,46 @@
         //                                                      : getFiremode("HsW01")) : 
         //                                                      (distance < 2500 ? getFiremode("LightningGun") : getFiremode("HsW01"));
-        if (distance < 800)
-        {
-            if (this->rocketsLeft_ > 0)
-            {
-                firemode = getFiremode ("SimpleRocketFire");
+        if (distance < 1500)
+        {
+            if (this->rocketsLeft_ > 0 && !this->bFiredRocket_)
+            {
+                firemode = getFiremode ("RocketFire");
             }
             else
             {
-                if (distance > 450)
+                if (distance > 800)
+                    firemode = getFiremode ("HsW01");
+                else
                     firemode = getFiremode ("LightningGun");
-                else
-                    firemode = getFiremode ("HsW01");
             }
 
         } 
-        else if (distance < 1200)
-        {
-            if (this->rocketsLeft_ > 0 && !this->bFiredRocket_)
-            {
-                firemode = getFiremode ("RocketFire");
-            }
-            else
-            {
-                firemode = getFiremode ("HsW01");
-            }
-        }
-        else if (distance < 1500)
+        // else if (distance < 1000)
+        // {
+        //     if (this->rocketsLeft_ > 0 && !this->bFiredRocket_)
+        //     {
+        //         firemode = getFiremode ("RocketFire");
+        //     }
+        //     else
+        //     {
+        //         firemode = getFiremode ("HsW01");
+        //     }
+        // }
+        else if (distance < 2000)
+        {
+            firemode = getFiremode ("HsW01");
+        }
+        else
         {
             firemode = getFiremode ("LightningGun");
         }
-        else
-        {
-            firemode = getFiremode ("HsW01");
-        }
         if (firemode < 0)
         {
-            firemode = getFiremode ("HsW01");
+            //assuming there is always some weapon with index 0
+            firemode = 0;
         }
         if (firemode == getFiremode("RocketFire"))
         {
-            this->timeout_ = 1.0f;
+            this->timeout_ = 0.5f;
             this->rocketsLeft_--;
             this->bFiredRocket_ = true;
Index: code/branches/campaignHS15/src/orxonox/controllers/FightingController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.h	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.h	(revision 10886)
@@ -77,5 +77,6 @@
             int maneuverCounter_;   
             bool bLookAtTarget_; 
-
+            float deltaHp;
+            float previousHp;
             //WEAPONSYSTEM DATA
             int rocketsLeft_;
Index: code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc	(revision 10886)
@@ -201,3 +201,35 @@
         }
     }
+    void FlyingController::keepFormation(const ControllableEntity* leaderEntity, Vector3& targetRelativePosition)
+    {
+        ControllableEntity* myEntity = this->getControllableEntity();
+        Vector3 myPosition = myEntity->getWorldPosition();
+
+        if (!leaderEntity)
+        {
+            return;
+        }
+        Quaternion orient = leaderEntity->getWorldOrientation();
+        Vector3 leaderPosition = leaderEntity->getWorldPosition();
+
+        if (!leaderEntity)
+        {
+            return;
+        }
+        Vector3 targetAbsolutePosition = 
+            (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
+             + (orient* (targetRelativePosition)));
+        //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
+        if (this->actionCounter_ % 6 == 0 && !this->bHasTargetOrientation_)
+            this->setTargetOrientation (orient);
+        this->setTargetPosition (targetAbsolutePosition);
+        if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
+        {
+            this->boostControl();
+        }
+        else
+        {
+           this->getControllableEntity()->boost(false);
+        }
+    }
 }
Index: code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h	(revision 10886)
@@ -21,7 +21,7 @@
  *
  *   Author:
- *      Fabian 'x3n' Landau
+ *      Gani Aliguzhinov
  *   Co-authors:
- *      ...
+ *      Dominik Solenicki
  *
  */
@@ -79,5 +79,6 @@
             void setTargetOrientation(const Quaternion& orient);
             void setTargetOrientation(ControllableEntity* target);
-            virtual void boostControl();        
+            virtual void boostControl();  
+            void keepFormation (const ControllableEntity* leaderEntity, Vector3& targetRelativePosition);      
             FormationMode::Value formationMode_;
           
Index: code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc	(revision 10885)
+++ 	(revision )
@@ -1,56 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Gani Aliguzhinov
- *   Co-authors:
- *      ...
- *
- */
-
-#include "LeaderController.h"
-
-
-namespace orxonox
-{
-
-    RegisterClass(LeaderController);
-
-    //CommonController contains all common functionality of AI Controllers
-    LeaderController::LeaderController(Context* context) : ActionpointController(context)
-    {
-
-        RegisterObject(LeaderController);
-
-    }
-
-   	void LeaderController::tick(float dt)
-   	{
-   		
-   		SUPER(LeaderController, tick, dt);
-   	}
-    LeaderController::~LeaderController()
-    {
-    }
-    
-    
-
-}
Index: code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h	(revision 10885)
+++ 	(revision )
@@ -1,60 +1,0 @@
-/*
- *   ORXONOX - the hottest 3D action shooter ever to exist
- *                    > www.orxonox.net <
- *
- *
- *   License notice:
- *
- *   This program is free software; you can redistribute it and/or
- *   modify it under the terms of the GNU General Public License
- *   as published by the Free Software Foundation; either version 2
- *   of the License, or (at your option) any later version.
- *
- *   This program is distributed in the hope that it will be useful,
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *   GNU General Public License for more details.
- *
- *   You should have received a copy of the GNU General Public License
- *   along with this program; if not, write to the Free Software
- *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- *
- *   Author:
- *      Gani Aliguzhinov
- *   Co-authors:
- *      ...
- *
- */
-
-#ifndef _LeaderController_H__
-#define _LeaderController_H__
-
-#include "controllers/ActionpointController.h"
-
-
-
-
-namespace orxonox
-{
-    class _OrxonoxExport LeaderController : public ActionpointController
-    {
-        public:
-            //----[language demanded functions]----            
-                LeaderController(Context* context);
-                virtual ~LeaderController();
-            //----[language demanded functions]----            
-                virtual void tick(float dt); 
-
-
-
-        protected:
-            //----private variables-----
-
-
-            
-        private:
-            
-    };
-}
-
-#endif /* _LeaderController_H__ */
Index: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	(revision 10886)
@@ -39,5 +39,5 @@
 
     //Leaders share the fact that they have Wingmans
-    SectionController::SectionController(Context* context) : LeaderController(context)
+    SectionController::SectionController(Context* context) : ActionpointController(context)
     {
         RegisterObject(SectionController);
@@ -54,8 +54,4 @@
     SectionController::~SectionController()
     {
-        // if (this->myWingman_)
-        // {
-        //     this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);
-        // }
        for (size_t i = 0; i < this->actionpoints_.size(); ++i)
         {
@@ -69,6 +65,4 @@
     {
         SUPER(SectionController, XMLPort, xmlelement, mode);
-
-        //XMLPortParam(SectionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
     }
 
@@ -78,11 +72,5 @@
         if (!this->isActive())
             return;
-
-    //this doesn't fight in formation flight, thus we can afford executing following code in tick: when nobody fights, tick is anyway stable.
-        if (this->myDivisionLeader_ && this->myDivisionLeader_->getAction() != Action::FIGHT && this->myDivisionLeader_->getAction() !=
-            Action::FIGHTALL && this->myDivisionLeader_->getAction() != Action::ATTACK)
-        {
-            
-        }    
+   
         SUPER(SectionController, tick, dt);
     }
@@ -110,5 +98,4 @@
         if (!myDivisionLeader_)
         {
-            
             ActionpointController::action();
             if (!this || !this->getControllableEntity())
@@ -128,83 +115,20 @@
                 || this->myDivisionLeader_->getAction() == Action::ATTACK))
             {
-                ControllableEntity* myEntity = this->getControllableEntity();
-                Vector3 myPosition = myEntity->getWorldPosition();
-                if (!this->myDivisionLeader_)
-                {
-                    return;
-                }
-                ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity();
-                Quaternion orient = leaderEntity->getWorldOrientation();
-                Vector3 leaderPosition = leaderEntity->getWorldPosition();
-
-                Vector3 targetRelativePosition = getFormationPosition();
-                if (!this->myDivisionLeader_)
-                {
-                    return;
-                }
-                Vector3 targetAbsolutePosition = 
-                    (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
-                     + (orient* (targetRelativePosition)));
-                //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
-                if (this->actionCounter_ % 6 == 0 && !this->bHasTargetOrientation_)
-                    this->setAction (Action::FLY, targetAbsolutePosition, orient);
-                else
-                    this->setAction (Action::FLY, targetAbsolutePosition);
-
-                if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
-                {
-                    this->boostControl();
-                }
-                else
-                {
-                   this->getControllableEntity()->boost(false);
-                }
-            }
-            else
-            {
-                switch (myDivisionLeader_->getAction())
-                {
-                    case Action::FIGHT:
-                    {
-                        if (!this->hasTarget())
-                        {
-                            this->chooseTarget();
-                        }
-                        break;
-                    }
-                    case Action::FIGHTALL:
-                    {
-                        if (!this->hasTarget())
-                        {
-                            this->chooseTarget();
-                        }
-                        break;
-                    }
-                    case Action::ATTACK:
-                    {
-                        if (!this->hasTarget())
-                        {
-                            this->chooseTarget();
-                        }
-                        break;
-                    }
-                    default:
-                    {
-                        //formation flight is executed in tick 
-                    }
+                this->keepFormation();
+            }
+            else if (!this->myDivisionLeader_->bKeepFormation_)
+            {
+                if (!this->hasTarget())
+                {
+                    this->chooseTarget(); 
                 }
                 if (this->hasTarget())
                 {
-                    //----choose where to go----
                     this->maneuver();
-                    //----fire if you can----
                     this->bShooting_ = this->canFire();                
                 }
             }
-            
-            
         }
         this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
-
     }
 
@@ -298,5 +222,13 @@
     }
 
-    
+    void SectionController::keepFormation()
+    {
+        this->bKeepFormation_ = true;
+        ControllableEntity* leaderEntity = this->myDivisionLeader_->getControllableEntity();
+        Vector3 targetRelativePosition = this->getFormationPosition();
+        if (!leaderEntity)
+            return;
+        FlyingController::keepFormation(leaderEntity, targetRelativePosition);
+    }
 
     ActionpointController* SectionController::findNewDivisionLeader()
Index: code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.h	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.h	(revision 10886)
@@ -30,10 +30,10 @@
 #define _SectionController_H__
 
-#include "controllers/LeaderController.h"
+#include "controllers/ActionpointController.h"
 
 
 namespace orxonox
 {
-    class _OrxonoxExport SectionController : public LeaderController
+    class _OrxonoxExport SectionController : public ActionpointController
     {
         public:
@@ -64,4 +64,5 @@
                 virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
                 Vector3 getFormationPosition ();
+                void keepFormation();
         private:
             //----private variables-----
Index: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	(revision 10886)
@@ -59,6 +59,4 @@
     {
         SUPER(WingmanController, XMLPort, xmlelement, mode);
-
-        //XMLPortParam(SectionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);
     }
     
@@ -67,9 +65,5 @@
     {   
         if (!this->isActive())
-            return;
-        if (this->myLeader_ && this->myLeader_->getAction() != Action::FIGHT && this->myLeader_->getAction() !=
-            Action::FIGHTALL && this->myLeader_->getAction() != Action::ATTACK)
-        {
-        }   
+            return; 
         
         SUPER(WingmanController, tick, dt);
@@ -108,67 +102,11 @@
                 || this->myLeader_->getAction() == Action::ATTACK))
             {
-                ControllableEntity* myEntity = this->getControllableEntity();
-                Vector3 myPosition = myEntity->getWorldPosition();
-                if (!this->myLeader_)
-                {
-                    return;
-                }
-                ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity();
-                Quaternion orient = leaderEntity->getWorldOrientation();
-                Vector3 leaderPosition = leaderEntity->getWorldPosition();
-                Vector3 targetRelativePosition = getFormationPosition();
-                if (!this->myLeader_)
-                {
-                    return;
-                }
-                Vector3 targetAbsolutePosition = 
-                    (leaderPosition + (orient*WorldEntity::FRONT) * (leaderEntity->getVelocity().length()/5)
-                     + (orient* (targetRelativePosition)));
-                //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
-                if (this->actionCounter_ % 6 == 0 && !this->bHasTargetOrientation_)
-                    this->setAction (Action::FLY, targetAbsolutePosition, orient);
-                else
-                    this->setAction (Action::FLY, targetAbsolutePosition);
-                if ((targetAbsolutePosition - myPosition).length() > this->tolerance_ * 1.5f)
-                {
-                    this->boostControl();
-                }
-                else
-                {
-                   this->getControllableEntity()->boost(false);
-                }
-            }
-            else
-            {
-                switch (this->myLeader_->getAction())
-                {
-                    case Action::FIGHT:
-                    {
-                        if (!this->hasTarget())
-                        {
-                            this->setTarget(this->myLeader_->getTarget());
-                        }
-                        break;
-                    }
-                    case Action::FIGHTALL:
-                    {
-                        if (!this->hasTarget())
-                        {
-                            this->setTarget(this->myLeader_->getTarget());
-                        }
-                        break;
-                    }
-                    case Action::ATTACK:
-                    {
-                        if (!this->hasTarget())
-                        {
-                            this->setTarget(this->myLeader_->getTarget());
-                        }
-                        break;
-                    }
-                    default:
-                    {
-                    
-                    }
+                this->keepFormation();
+            }
+            else if (!this->myLeader_->bKeepFormation_)
+            {
+                if (!this->hasTarget())
+                {
+                    this->setTarget(this->myLeader_->getTarget());
                 }
                 if (this->hasTarget())
@@ -180,6 +118,4 @@
                 }
             }
-            
-            
         }
         this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
@@ -236,4 +172,13 @@
         delete targetRelativePosition;
         return result;
+    }
+    void WingmanController::keepFormation()
+    {
+        this->bKeepFormation_ = true;
+        ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity();
+        Vector3 targetRelativePosition = this->getFormationPosition();
+        if (!leaderEntity)
+            return;
+        FlyingController::keepFormation (leaderEntity, targetRelativePosition);
     }
     //----POST: closest leader that is ready to take a new wingman is returned----
@@ -268,5 +213,4 @@
                 minDistance = distance;
             }
-           
         }
         if (closestLeader)
@@ -277,12 +221,7 @@
                 return closestLeader;
             }
-
-        }
-
+        }
         return 0;
     }
 
-
-
-
 }
Index: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h	(revision 10886)
@@ -63,5 +63,6 @@
                 virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
                 Vector3 getFormationPosition ();
-
+                void keepFormation();
+                
         private:
             //----private variables-----
