Index: code/branches/AI_HS15/src/libraries/util/Math.cc
===================================================================
--- code/branches/AI_HS15/src/libraries/util/Math.cc	(revision 10669)
+++ code/branches/AI_HS15/src/libraries/util/Math.cc	(revision 10670)
@@ -161,5 +161,5 @@
          - If the other object is exactly above me, the function returns <tt>Vector2(0, 0.5)</tt>.
     */
-    orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
+    orxonox::Vector2 get2DViewCoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition)
     {
         orxonox::Vector3 distance = otherposition - myposition;
Index: code/branches/AI_HS15/src/libraries/util/Math.h
===================================================================
--- code/branches/AI_HS15/src/libraries/util/Math.h	(revision 10669)
+++ code/branches/AI_HS15/src/libraries/util/Math.h	(revision 10670)
@@ -91,5 +91,5 @@
     _UtilExport float getAngle(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& otherposition);
     _UtilExport orxonox::Vector2 get2DViewdirection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
-    _UtilExport orxonox::Vector2 get2DViewcoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
+    _UtilExport orxonox::Vector2 get2DViewCoordinates(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition);
     _UtilExport orxonox::Vector2 get3DProjection(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle, const float detectionlimit);
     _UtilExport bool isObjectHigherThanShipOnMap(const orxonox::Vector3& myposition, const orxonox::Vector3& mydirection, const orxonox::Vector3& myorthonormal, const orxonox::Vector3& otherposition, const float mapangle);
Index: code/branches/AI_HS15/src/modules/docking/DockingController.cc
===================================================================
--- code/branches/AI_HS15/src/modules/docking/DockingController.cc	(revision 10669)
+++ code/branches/AI_HS15/src/modules/docking/DockingController.cc	(revision 10670)
@@ -61,5 +61,5 @@
 
         float distance = (this->dock_->getWorldPosition() - entity->getPosition()).length();
-        Vector2 coord = get2DViewcoordinates(     // I don't understand this too
+        Vector2 coord = get2DViewCoordinates(     // I don't understand this too
             entity->getPosition(),
             entity->getOrientation() * WorldEntity::FRONT,
Index: code/branches/AI_HS15/src/modules/overlays/hud/HUDRadar.cc
===================================================================
--- code/branches/AI_HS15/src/modules/overlays/hud/HUDRadar.cc	(revision 10669)
+++ code/branches/AI_HS15/src/modules/overlays/hud/HUDRadar.cc	(revision 10670)
@@ -240,5 +240,5 @@
             }
             else
-                coord = get2DViewcoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
+                coord = get2DViewCoordinates(this->owner_->getPosition(), this->owner_->getOrientation() * WorldEntity::FRONT, this->owner_->getOrientation() * WorldEntity::UP, wePointer->getWorldPosition());
 
             coord *= math::pi / 3.5f; // small adjustment to make it fit the texture
Index: code/branches/AI_HS15/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/AIController.cc	(revision 10669)
+++ code/branches/AI_HS15/src/orxonox/controllers/AIController.cc	(revision 10670)
@@ -86,4 +86,5 @@
         }
 
+
         if (this->state_ == SLAVE && this->formationMode_ == ATTACK) 
         {
@@ -108,6 +109,9 @@
             //-------------------------------------------------------
             //collect data for AI behaviour
-            Vector3 meanOfEnemies;
-            Vector3 meanOfAllies;
+            Vector3* meanOfEnemiesPtr = new Vector3(0.0,0.0,0.0);
+            Vector3* meanOfAlliesPtr  = new Vector3(0.0,0.0,0.0);
+            Vector3 meanOfAllies = *meanOfAlliesPtr;
+            Vector3 meanOfEnemies = *meanOfEnemiesPtr;
+
 
             for (ObjectList<AIController>::iterator it = ObjectList<AIController>::begin(); it; ++it)
@@ -121,28 +125,33 @@
                 if (!FormationController::sameTeam(this->getControllableEntity(), it->getControllableEntity(),gt))
                 {
-                    enemies.push_back(*it);
+                    enemies_.push_back(*it);
                 } 
                 else {
-                    allies.push_back(*it);
+                    allies_.push_back(*it);
                 } 
             }
-            if (enemies.size() != 0 && allies.size() != 0){
-            for (std::vector<AIController*>::iterator it = enemies.begin() ; it != enemies.end(); ++it)
-                meanOfEnemies += (*it)->getControllableEntity()->getPosition();
-            meanOfEnemies /= enemies.size();
-            for (std::vector<AIController*>::iterator it = allies.begin() ; it != allies.end(); ++it)
-                meanOfAllies += (*it)->getControllableEntity()->getPosition();
-            meanOfAllies /= allies.size();
-            //orxout(internal_error) << "There are " << enemiesCounter << " enemies, mean position is " << meanOfEnemies << endl;
-            orxout(internal_error) << "Distance is " << (meanOfEnemies-meanOfAllies).length() << endl;
-            orxout(internal_error) << "mean of Allies is " << meanOfAllies << ", with a size " << allies.size() << endl;
-            orxout(internal_error) << "mean of Enemies is " << meanOfEnemies << ", with a size " << enemies.size() << endl;
+            if (enemies_.size() != 0 && allies_.size() != 0){
+                for (std::vector<WeakPtr<AIController> >::iterator it = enemies_.begin() ; it != enemies_.end(); ++it)
+                    meanOfEnemies += (*it)->getControllableEntity()->getWorldPosition();
+
+                meanOfEnemies /= enemies_.size();
+
+                for (std::vector<WeakPtr<AIController> >::iterator it = allies_.begin() ; it != allies_.end(); ++it)
+                    meanOfAllies += (*it)->getControllableEntity()->getWorldPosition();
+
+                meanOfAllies /= allies_.size();
+
+                //orxout(internal_error) << "There are " << enemies_Counter << " enemies_, mean position is " << meanOfEnemies << endl;
+                orxout(internal_error) << "Distance is " << (meanOfEnemies-meanOfAllies).length() << endl;
+                orxout(internal_error) << "mean of allies_ is " << meanOfAllies << ", with a size " << allies_.size() << endl;
+                orxout(internal_error) << "mean of enemies_ is " << meanOfEnemies << ", with a size " << enemies_.size() << endl;
             }
             //-------------------------------------------------------
             
-
+            //Decide which formationMode to choose
             this->setFormationMode(ATTACK);
-            
-            this->commandSlaves();
+            this->setDesiredPositionOfSlaves();
+
+            //this->commandSlaves();
 
             if  (this->specificMasterAction_ != NONE)
@@ -184,6 +193,6 @@
             }
         }
-        allies.clear();
-        enemies.clear();
+        allies_.clear();
+        enemies_.clear();
     }
 
@@ -196,4 +205,13 @@
         float maxrand = 100.0f / ACTION_INTERVAL;
         ControllableEntity* controllable = this->getControllableEntity();
+        if (this->state_ == SLAVE)
+        {
+            Vector3 desiredAbsolutePosition = this->myMaster_->getControllableEntity()->getWorldPosition() + this->myMaster_->getControllableEntity()->getWorldOrientation()*desiredRelativePosition_;
+            
+            orxonox::WeakPtr<MovableEntity> waypoint = new MovableEntity(this->center_->getContext());
+            waypoint->setPosition(desiredAbsolutePosition);
+            
+            this->addWaypoint(waypoint);
+        }
         //DOES: Either move to the waypoint or search for a Point of interest
         if (controllable && this->mode_ == DEFAULT)// bot is ready to move to a target
Index: code/branches/AI_HS15/src/orxonox/controllers/AIController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/AIController.h	(revision 10669)
+++ code/branches/AI_HS15/src/orxonox/controllers/AIController.h	(revision 10670)
@@ -54,5 +54,7 @@
 
             Timer actionTimer_; //<! Regularly calls action().
-            std::vector<AIController*> enemies, allies;
+            std::vector<WeakPtr<AIController> > enemies_, allies_;
+            Vector3* desiredRelativePosition_;
+            Vector3* currentRelativePosition_;
     };
 }
Index: code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc	(revision 10669)
+++ code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc	(revision 10670)
@@ -278,5 +278,5 @@
         }
 
-        Vector2 coord = get2DViewcoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
+        Vector2 coord = get2DViewCoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
         float distance = (target - this->getControllableEntity()->getPosition()).length();
         float rotateX = clamp(coord.x * 10, -1.0f, 1.0f);
@@ -703,4 +703,28 @@
         }
     }
+     /**
+      @brief If master, set the desired relative position of slaves (Vector3) in respect to a master for all the slaves.
+    */
+    void FormationController::setDesiredPositionOfSlaves()
+    {
+        if (this->state_ != MASTER)
+            return;
+        switch (this->formationMode_){
+            case ATTACK:
+            for(std::vector<FormationController*>::iterator it = slaves_.begin(), float i = 0; it != slaves_.end(); it++, ++i)
+            {
+                (*it)->desiredPosition_ = new Vector3 ((i-slaves_.size()/2)*200, 0, 0);
+                
+            }
+            break;
+            case NORMAL:
+
+            break;
+            case DEFEND:
+
+            break;
+        }
+       
+    }
 
     /**
@@ -1070,5 +1094,5 @@
             return;
 
-        Vector2 coord = get2DViewcoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
+        Vector2 coord = get2DViewCoordinates(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, target);
         float distance = (target - this->getControllableEntity()->getPosition()).length();
 
Index: code/branches/AI_HS15/src/orxonox/controllers/FormationController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/FormationController.h	(revision 10669)
+++ code/branches/AI_HS15/src/orxonox/controllers/FormationController.h	(revision 10670)
@@ -70,5 +70,9 @@
            { return this->maxFormationSize_; }
 
-
+      /**
+      @brief If master, set the desired position of slaves (Vector2) for all the slaves.
+      */
+      inline void setDesiredPositionOfSlaves();
+      
       inline void setPassive(bool passive)
            { this->passive_ = passive; }
@@ -92,5 +96,5 @@
       inline FormationMode getFormationMode() const
            { return this->formationMode_; }
-
+      
       virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage);
 
Index: code/branches/AI_HS15/test/util/MathTest.cc
===================================================================
--- code/branches/AI_HS15/test/util/MathTest.cc	(revision 10669)
+++ code/branches/AI_HS15/test/util/MathTest.cc	(revision 10670)
@@ -337,5 +337,5 @@
     getAngle
     get2DViewdirection
-    get2DViewcoordinates
+    get2DViewCoordinates
     getPredictedPosition
 */
