Index: code/branches/formation/data/defaultConfig/keybindings.ini
===================================================================
--- code/branches/formation/data/defaultConfig/keybindings.ini	(revision 8948)
+++ code/branches/formation/data/defaultConfig/keybindings.ini	(revision 8953)
@@ -72,5 +72,5 @@
 KeyNumRow0=
 KeyNumRow1="toggleFormationFlight"
-KeyNumRow2=
+KeyNumRow2="FFChangeMode"
 KeyNumRow3=
 KeyNumRow4=
Index: code/branches/formation/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/formation/src/orxonox/controllers/AIController.cc	(revision 8948)
+++ code/branches/formation/src/orxonox/controllers/AIController.cc	(revision 8953)
@@ -116,6 +116,20 @@
         }
 
-        if (this->state_ == SLAVE)
-        {
+        if (this->state_ == SLAVE && this->mode_==ATTACK)
+        {
+            if (!this->target_)
+            {
+               this->searchNewTarget();
+            }
+
+            // shoot
+            random = rnd(maxrand);
+            if (!(this->passive_) && random < 75 && (this->target_ && !this->bShooting_))
+                this->bShooting_ = true;
+
+            // stop shooting
+            random = rnd(maxrand);
+            if (random < 25 && (this->bShooting_))
+                this->bShooting_ = false;
 
         }
@@ -142,9 +156,9 @@
                    this->spinInit();
 
-                // follow a randomly chosen human - a specific Master Action
+                /*// follow a randomly chosen human - a specific Master Action
                 random = rnd(1000.0f);
                 if (random < 1)
                    this->followRandomHumanInit();
-
+*/
                  // lose master status (only if less than 4 slaves in formation)
                 random = rnd(maxrand);
@@ -233,5 +247,5 @@
         }
 
-        if (this->state_ == SLAVE)
+        if (this->state_ == SLAVE && this->mode_!=ATTACK)
         {
 
@@ -241,5 +255,5 @@
         }
 
-         if (this->state_ == FREE)
+         if (this->state_ == FREE || (this->state_==SLAVE && this->mode_==ATTACK) )
         {
             if (this->target_)
Index: code/branches/formation/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/formation/src/orxonox/controllers/ArtificialController.cc	(revision 8948)
+++ code/branches/formation/src/orxonox/controllers/ArtificialController.cc	(revision 8953)
@@ -28,17 +28,6 @@
 
 #include "ArtificialController.h"
-
-#include <vector>
-
-
-#include "util/Math.h"
 #include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
-#include "core/command/ConsoleCommand.h"
-#include "worldentities/ControllableEntity.h"
 #include "worldentities/pawns/Pawn.h"
-#include "worldentities/pawns/TeamBaseMatchBase.h"
-#include "gametypes/TeamDeathmatch.h"
-#include "gametypes/Dynamicmatch.h"
 
 
Index: code/branches/formation/src/orxonox/controllers/ArtificialController.h
===================================================================
--- code/branches/formation/src/orxonox/controllers/ArtificialController.h	(revision 8948)
+++ code/branches/formation/src/orxonox/controllers/ArtificialController.h	(revision 8953)
@@ -31,10 +31,4 @@
 
 #include "OrxonoxPrereqs.h"
-
-#include <vector>
-
-#include "util/Math.h"
-#include "Controller.h"
-#include "controllers/NewHumanController.h"
 #include "controllers/Masterable.h"
 
Index: code/branches/formation/src/orxonox/controllers/HumanController.cc
===================================================================
--- code/branches/formation/src/orxonox/controllers/HumanController.cc	(revision 8948)
+++ code/branches/formation/src/orxonox/controllers/HumanController.cc	(revision 8953)
@@ -51,4 +51,5 @@
     SetConsoleCommand("HumanController", "rotateRoll",             &HumanController::rotateRoll    ).addShortcut().setAsInputCommand();
     SetConsoleCommand("HumanController", "toggleFormationFlight",  &HumanController::toggleFormationFlight).addShortcut().keybindMode(KeybindMode::OnPress);
+    SetConsoleCommand("HumanController", "FFChangeMode",  &HumanController::FFChangeMode).addShortcut().keybindMode(KeybindMode::OnPress);
     SetConsoleCommand("HumanController", __CC_fire_name,           &HumanController::fire          ).addShortcut().keybindMode(KeybindMode::OnHold);
     SetConsoleCommand("HumanController", "reload",                 &HumanController::reload        ).addShortcut();
@@ -105,5 +106,6 @@
         if (HumanController::localController_s && HumanController::localController_s->state_==MASTER)
         {
-            HumanController::localController_s->commandSlaves();
+            if (HumanController::localController_s->mode_!=ATTACK)
+                HumanController::localController_s->commandSlaves();
         }
     }
@@ -274,13 +276,19 @@
     }
 
+    /**
+    @brief
+       toggle the formation. Not usable, if formationflight is disabled generally (formationFlight_)
+    */
     void HumanController::toggleFormationFlight()
     {
-        
-        if (HumanController::localController_s)
-        {
+        if (HumanController::localController_s)
+        {
+            if (!HumanController::localController_s->formationFlight_)
+            {
+                return; //dont use when formationFlight is disabled
+            }
             if (HumanController::localController_s->state_==MASTER)
             {
-                HumanController::localController_s->freeSlaves();
-                HumanController::localController_s->state_=FREE;
+                HumanController::localController_s->loseMasterState();
                 orxout(message) <<"FormationFlight disabled "<< endl;
             } else //SLAVE or FREE
@@ -294,4 +302,35 @@
     }
 
+    /**
+    @brief
+       Switch through the different Modes of formationflight. You must be a master of a formation to use.
+    */
+    void HumanController::FFChangeMode()
+    {
+        if (HumanController::localController_s && HumanController::localController_s->state_==MASTER)
+        {
+            switch (HumanController::localController_s->getMode()) {
+              case NORMAL:
+                HumanController::localController_s->setMode(DEFEND);
+                orxout(message) <<"Mode: DEFEND "<< endl;
+                break;
+              case DEFEND:
+                HumanController::localController_s->setMode(ATTACK);
+                orxout(message) <<"Mode: ATTACK "<< endl;
+                break;
+              case ATTACK:
+                HumanController::localController_s->setMode(NORMAL);
+                orxout(message) <<"Mode: NORMAL "<< endl;
+                break;
+            }
+            changedMode();
+        }
+    }
+
+    void HumanController::changedMode()
+    {
+
+    }
+    
     void HumanController::addBots(unsigned int amount)
     {
Index: code/branches/formation/src/orxonox/controllers/HumanController.h
===================================================================
--- code/branches/formation/src/orxonox/controllers/HumanController.h	(revision 8948)
+++ code/branches/formation/src/orxonox/controllers/HumanController.h	(revision 8953)
@@ -74,5 +74,6 @@
             void keepBoosting(void);
             void terminateBoosting(void);
-            
+                  
+
             static void greet();
             static void switchCamera();
@@ -86,4 +87,6 @@
 
             static void toggleFormationFlight();
+            static void FFChangeMode();
+            static void changedMode();
 
             static void addBots(unsigned int amount);
Index: code/branches/formation/src/orxonox/controllers/Masterable.cc
===================================================================
--- code/branches/formation/src/orxonox/controllers/Masterable.cc	(revision 8948)
+++ code/branches/formation/src/orxonox/controllers/Masterable.cc	(revision 8953)
@@ -57,6 +57,6 @@
 
 
-  static const unsigned int STANDARD_MAX_FORMATION_SIZE = 7;
-  static const int RADIUS_TO_SEARCH_FOR_MASTERS = 20000;
+  static const unsigned int STANDARD_MAX_FORMATION_SIZE = 9;
+  static const int RADIUS_TO_SEARCH_FOR_MASTERS = 5000;
   static const int FORMATION_LENGTH =  110;
   static const int FORMATION_WIDTH =  110;
@@ -79,4 +79,5 @@
 
         this->state_ = FREE;
+        this->mode_ = NORMAL;
         this->specificMasterAction_ = NONE;
         this->specificMasterActionHoldCount_  = 0;
@@ -444,6 +445,7 @@
             this->state_ = MASTER;
             this->myMaster_ = 0;
-            orxout(debug_output) << "search new master: no master found, but teammates"<< endl;
-        }
+            orxout(debug_output) << "search new master: no master found, but "<<teamSize<<" teammates"<< endl;
+        } else if (this->state_ != SLAVE)
+            orxout(debug_output) << "search new master: no master found, no teammates..."<< endl;
     }
  /**
@@ -589,60 +591,4 @@
         if (this->state_==FREE)
         {
-          /*
-            float minDistance=(float)RADIUS_TO_SEARCH_FOR_MASTERS;
-            Masterable* bestMaster=NULL;
-
-            //search nearest Master, store in bestMaster
-            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
-            {
-           
-                //same team?  (doesnt work with a HumanPlayer??!?) TODO
-                if (!Masterable::sameTeam(this->getControllableEntity(), static_cast<ControllableEntity*>(*it), this->getGametype()))
-                    continue;
-
-                //get Controller
-                Controller* controller = 0;
-
-                if (it->getController())
-                    controller = it->getController();
-                else if (it->getXMLController())
-                    controller = it->getXMLController();
-
-                if (!controller)
-                    continue;
-
-                //myself?
-                if (orxonox_cast<ControllableEntity*>(*it) == this->getControllableEntity())
-                    continue;
-
-                Masterable *newMaster = orxonox_cast<Masterable*>(controller);
-                if (!newMaster || newMaster->state_!=MASTER) continue;
-                
-                float distance= (it->getPosition() - this->getControllableEntity()->getPosition()).length();
-                
-                if (distance<minDistance)
-                {
-                    minDistance=distance;
-                    bestMaster=newMaster;
-                }
-            }
-
-            if (bestMaster!=NULL)
-            {
-                //becom slave of formation
-                bestMaster->slaves_.push_back(this);
-                this->state_=SLAVE;
-                this->myMaster_=bestMaster;
-            }
-            else
-            {
-              //no formation found to lead, become master of empty formation
-              this->state_=MASTER;
-              this->slaves_.clear();
-              this->myMaster_=0;
-              orxout(debug_output) << this << "no formation found!, empty formation"<< endl;
-              return;
-            }
-         */
           searchNewMaster();
         }
@@ -681,4 +627,21 @@
 
     /**
+      @brief Sets the new mode. If master, set it for all slaves.
+    */
+    void Masterable::setMode(Mode val)
+    {
+        this->mode_=val;
+        if (this->state_==MASTER)
+        {
+            for(std::vector<Masterable*>::iterator it = slaves_.begin(); it != slaves_.end(); it++)
+            {
+                 (*it)->mode_=val;
+                 if (val==ATTACK)
+                     (*it)->forgetTarget();
+            }
+        }
+    }
+
+    /**
         @brief Used to continue a "specific master action" for a certain time and resuming normal behaviour after.
     */
@@ -935,22 +898,4 @@
     }
 
-
-
-
-
-  void Masterable::setMode(Mode mode)
-  {
-     for (std::vector<Masterable*>::iterator it=slaves_.begin(); it != slaves_.end(); it++)
-     {
-	//(*it)->myMode_=mode;
-     }
-  }
-
-  Masterable::Mode Masterable::getMode()
-  {
-    return Masterable::NORMAL;
-  }
-
-
   bool Masterable::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)
     {
@@ -992,4 +937,5 @@
             if (entity2->getPlayer())
                 team2 = tdm->getTeam(entity2->getPlayer());
+            return (team1 == team2 && team1 != -1); //temp solution
         }
 
Index: code/branches/formation/src/orxonox/controllers/Masterable.h
===================================================================
--- code/branches/formation/src/orxonox/controllers/Masterable.h	(revision 8948)
+++ code/branches/formation/src/orxonox/controllers/Masterable.h	(revision 8953)
@@ -88,13 +88,12 @@
       */ 
       enum Mode {NORMAL,DEFEND,ATTACK};
+      
       /**
-        @brief set a mode in formation
-      */ 
-      void setMode(Mode mode);
-       /**
-        @brief get the current mode
+        @brief Sets the new mode. If master, set it for all slaves.
       */
-      Mode getMode();
-      
+      void setMode(Mode val);
+      inline Mode getMode() const
+           { return this->mode_; }
+
     protected:
       bool formationFlight_;
@@ -104,7 +103,10 @@
       int freedomCount_;
       enum State {SLAVE, MASTER, FREE};
+      
       State state_;
       std::vector<Masterable*> slaves_;
       Masterable* myMaster_;
+
+      Mode mode_;
 
       enum SpecificMasterAction {NONE, HOLD, SPIN, TURN180, FOLLOW};
