Index: code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	(revision 10737)
+++ code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	(revision 10759)
@@ -27,5 +27,6 @@
  */
 #include "controllers/CommonController.h"
-/*
+#include "core/XMLPort.h"
+
 #include "weaponsystem/WeaponMode.h"
 #include "weaponsystem/WeaponPack.h"
@@ -34,5 +35,5 @@
 #include "weaponsystem/WeaponSlot.h"
 #include "worldentities/pawns/SpaceShip.h"
-*/
+
 
 namespace orxonox
@@ -40,10 +41,10 @@
 
     RegisterClass(CommonController);
-    static const float SPEED = 0.6f;
-    static const float ROTATEFACTOR = 0.2f;
+    float SPEED = 0.7f;
+    float ROTATEFACTOR = 0.3f;
 
     CommonController::CommonController(Context* context) : Controller(context)
     {
-        //this->bSetupWorked = false;
+        this->bSetupWorked = false;
 
         RegisterObject(CommonController);
@@ -55,6 +56,57 @@
     }
 
-
-
+    void CommonController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+    {
+        SUPER(CommonController, XMLPort, xmlelement, mode);
+        XMLPortParam(CommonController, "formationMode", setFormationModeXML, getFormationModeXML,  xmlelement, mode);
+
+    }
+    void CommonController::setFormationModeXML(std::string val)
+    {
+        const std::string valUpper = getUppercase(val);
+        FormationMode::Value value;
+        if (valUpper == "VEE")
+            value = FormationMode::VEE;
+        else if (valUpper == "WALL")
+            value = FormationMode::WALL;
+        else if (valUpper == "FINGER4")
+            value = FormationMode::FINGER4;
+        else if (valUpper == "DIAMOND")
+            value = FormationMode::DIAMOND;
+        else
+            ThrowException(ParseError, std::string("Attempting to set an unknown FormationMode: '") + val + "'.");
+        this->setFormationMode(value);
+       
+    }
+    std::string CommonController::getFormationModeXML()
+    {
+        switch (this->formationMode_)
+        {
+            case FormationMode::VEE:
+            {
+                return "VEE";
+                break;
+            }
+            case FormationMode::WALL:
+            {
+                return "WALL";
+                break;
+            }
+            case FormationMode::FINGER4:
+            {
+                return "FINGER4";
+                break;
+            }
+            case FormationMode::DIAMOND:
+            {
+                return "DIAMOND";
+                break;
+            }
+            default:
+                return "DIAMOND";
+                break;
+
+        }
+    }
 
     bool CommonController::setWingman (CommonController* wingman)
@@ -67,5 +119,11 @@
         return true;
     }
-
+    void CommonController::setTarget(ControllableEntity* target)
+    {
+        this->target_ = target;
+        orxout (internal_error) << " TARGET SET " << endl;
+        if (target)
+            this->targetPosition_ = target->getPosition();
+    }
 
 
@@ -113,5 +171,5 @@
         while(diff>math::twoPi) diff-=math::twoPi;
         while(diff<-math::twoPi) diff+=math::twoPi;
-        this->getControllableEntity()->rotateRoll(-diff);
+        this->getControllableEntity()->rotateRoll(diff*ROTATEFACTOR);
     }
     void CommonController::copyTargetOrientation()
@@ -134,8 +192,12 @@
         if (!this->getControllableEntity())
             return;
+        if (this->rank_ == Rank::DIVISIONLEADER)
+            SPEED *= 0.8;
+        if (this->rank_ == Rank::SECTIONLEADER)
+            SPEED *= 0.9;
         
         //100 is (so far) the smallest tolerance (empirically found) that can be reached, 
         //with smaller distance spaceships can't reach position and go circles around it instead
-        int tolerance = 100;
+        int tolerance = 60;
 
         ControllableEntity* entity = this->getControllableEntity();
@@ -160,5 +222,5 @@
 
             //300 works, maybe less is better
-            if (distance < 300)
+            if (distance < 400)
             {
                 //Change roll when close. When Spaceship faces target, roll doesn't affect it's trajectory
@@ -180,5 +242,5 @@
     }
 
-/*
+
     int CommonController::getFiremode(std::string name)
     {
@@ -227,13 +289,10 @@
     void CommonController::doFire()
     {
-        if(!this->bSetupWorked)//setup: find out which weapons are active ! hard coded: laser is "0", lens flare is "1", ...
+          if(!this->bSetupWorked)//setup: find out which weapons are active ! hard coded: laser is "0", lens flare is "1", ...
         {
             this->setupWeapons();
         }
-        else if(this->getControllableEntity() && 
-            weaponModes_.size()&&
-            this->bShooting_ && 
-            this->isCloseAtTarget((3)*1000) && 
-            this->isLookingAtTarget(math::pi / 20.0f))
+        else if(this->getControllableEntity() && weaponModes_.size()&&this->bShooting_ && 
+            this->isCloseAtTarget((1 + 2)*1000) && this->isLookingAtTarget(math::pi / 20.0f))
         {
             int firemode;
@@ -246,4 +305,5 @@
             else if ((firemode = getFiremode("HsW01")) > -1 ) //LASER: default weapon
                 this->getControllableEntity()->fire(firemode);
+        
         }
     }
@@ -269,5 +329,5 @@
         if (pawn)
             pawn->setAimPosition(aimPosition);
-    }*/
+    }
     
  
