Index: code/branches/ai/src/orxonox/controllers/AIController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/AIController.cc	(revision 6996)
+++ code/branches/ai/src/orxonox/controllers/AIController.cc	(revision 6997)
@@ -128,12 +128,11 @@
             if  (this->specificMasterAction_ != NONE) 
             {
-                if (this->specificMasterAction_  == HOLD)
                     this->specificMasterActionHold();
 
-                if (this->specificMasterAction_  == TURN180)
-                    this->turn180();
-
-                if (this->specificMasterAction_ == SPIN)
-                    this->spin();
+//                 if (this->specificMasterAction_  == TURN180)
+//                     this->turn180Init();
+
+//                 if (this->specificMasterAction_ == SPIN)
+//                     this->spinInit();
 
 //                 if (this->specificMasterAction_ == FOLLOWHUMAN)
@@ -144,12 +143,12 @@
 
                  // make 180 degree turn - a specific Master Action
-                random = rnd(maxrand);
+                random = rnd(1000.0f);
                 if (random < 5)
-                   this->specificMasterAction_ = TURN180;
+                   this->turn180Init();
 
                 // spin around - a specific Master Action
-                random = rnd(maxrand);
+                random = rnd(1000.0f);
                 if (random < 5)
-                   this->specificMasterAction_ = SPIN;
+                   this->spinInit();
 
                  // lose master status (only if less than 4 slaves in formation)
@@ -191,5 +190,5 @@
                 // shoot
                 random = rnd(maxrand);
-                if (!(this->passive_) && random < 15 && (this->target_ && !this->bShooting_))
+                if (!(this->passive_) && random < 9 && (this->target_ && !this->bShooting_))
                 {
                 this->bShooting_ = true;
@@ -214,4 +213,33 @@
         if (this->state_ == MASTER)
         {
+            if (this->specificMasterAction_ ==  NONE)
+            {
+                if (this->target_)
+                    this->aimAtTarget();
+
+                if (this->bHasTargetPosition_)
+                    this->moveToTargetPosition();
+
+                if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f))
+                    this->getControllableEntity()->fire(0);
+            }
+
+            if (this->specificMasterAction_  == TURN180)
+                    this->turn180();
+
+            if (this->specificMasterAction_ == SPIN)
+                    this->spin();
+        }
+
+        if (this->state_ == SLAVE)
+        {
+
+            if (this->bHasTargetPosition_)
+                this->moveToTargetPosition();
+
+        }
+
+         if (this->state_ == FREE)
+        {
             if (this->target_)
                 this->aimAtTarget();
@@ -219,26 +247,4 @@
             if (this->bHasTargetPosition_)
                 this->moveToTargetPosition();
-            if (this->specificMasterAction_ ==  NONE)
-            {
-                if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f))
-                    this->getControllableEntity()->fire(0);
-            }
-        }
-
-        if (this->state_ == SLAVE)
-        {
-
-            if (this->bHasTargetPosition_)
-                this->moveToTargetPosition();
-
-        }
-
-         if (this->state_ == FREE)
-        {
-            if (this->target_)
-                this->aimAtTarget();
-
-            if (this->bHasTargetPosition_)
-                this->moveToTargetPosition();
 
             if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f))
Index: code/branches/ai/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/ArtificialController.cc	(revision 6996)
+++ code/branches/ai/src/orxonox/controllers/ArtificialController.cc	(revision 6997)
@@ -51,5 +51,5 @@
 
     static const unsigned int STANDARD_MAX_FORMATION_SIZE = 7;
-    static const int FORMATION_LENGTH =  10;
+    static const int FORMATION_LENGTH =  130;
     static const int FORMATION_WIDTH =  110;
     static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy
@@ -112,4 +112,9 @@
             {
                 aiController->formationFlight_ = form;
+                if(!form)
+                {
+                    if(aiController->state_ == MASTER) aiController->freeSlaves();
+                    aiController->state_ = FREE;
+                }
             }
         }
@@ -120,5 +125,5 @@
         @param action which action to perform (integer, so it can be called with a console command (tmp solution))
     */
-    void ArtificialController::masteraction(int action) 
+    void ArtificialController::masteraction(int action)
     {
         for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
@@ -129,10 +134,10 @@
             ArtificialController *aiController = orxonox_cast<ArtificialController*>(it->getController());
 
-            if(aiController || aiController->state_ == MASTER)
+            if(aiController && aiController->state_ == MASTER)
             {
                 if (action == 1)
-                    aiController->specificMasterAction_ = TURN180;
+                    aiController->spinInit();
                 if (action == 2)
-                    aiController->specificMasterAction_ = SPIN;
+                    aiController->turn180Init();
             }
         }
@@ -271,14 +276,6 @@
             if (this->target_ || distance > 10)
             {
-                if (this->specificMasterAction_ == NONE)
-                {
                 this->getControllableEntity()->rotateYaw(-1.0f * ROTATEFACTOR_MASTER * sgn(coord.x) * coord.x*coord.x);
                 this->getControllableEntity()->rotatePitch(ROTATEFACTOR_MASTER * sgn(coord.y) * coord.y*coord.y);
-                } else if (this->specificMasterAction_ == TURN180)
-                {
-                this->getControllableEntity()->rotateYaw(-1.0f * sgn(coord.x) * coord.x*coord.x);
-                this->getControllableEntity()->rotatePitch(sgn(coord.y) * coord.y*coord.y);
-                }
-
             }
 
@@ -416,12 +413,12 @@
             {
                 pos = Vector3::ZERO;
-                if (i <= 1) pos += dest  + FORMATION_WIDTH*WorldEntity::LEFT;
-                if (i == 2) pos += dest  + FORMATION_WIDTH*WorldEntity::RIGHT;
-                if (i == 3) pos += dest  + FORMATION_WIDTH*WorldEntity::UP;
+                if (i <= 1) pos += dest  + FORMATION_WIDTH*(orient*WorldEntity::LEFT);
+                if (i == 2) pos += dest  + FORMATION_WIDTH*(orient*WorldEntity::RIGHT);
+                if (i == 3) pos += dest  + FORMATION_WIDTH*(orient*WorldEntity::UP);
                 if (i >= 4)
                 {
-                    pos += dest  + FORMATION_WIDTH*WorldEntity::DOWN;
+                    pos += dest  + FORMATION_WIDTH*(orient*WorldEntity::DOWN);
                     i = 1;
-                    dest += FORMATION_LENGTH*orient*WorldEntity::BACK;
+                    dest += FORMATION_LENGTH*(orient*WorldEntity::BACK);
                     (*it)->setTargetPosition(pos);
                     continue;
@@ -518,5 +515,5 @@
 
     /**
-        @brief Used to continue a "specific master action" for a certain time.
+        @brief Used to continue a "specific master action" for a certain time and resuming normal behaviour after.
     */
     void ArtificialController::specificMasterActionHold()
@@ -533,27 +530,51 @@
 
     /**
-        @brief Master engages a 180 degree turn. Is a "specific master action".
+        @brief Master initializes a 180 degree turn. Leads to a "specific master action".
+    */
+    void ArtificialController::turn180Init()
+    {
+        COUT(0) << "~turnInit" << std::endl;
+        if(this->state_ != MASTER) return;
+
+        Quaternion orient = this->getControllableEntity()->getOrientation();
+
+        this->setTargetPosition(this->getControllableEntity()->getPosition() + 1000.0f*orient*WorldEntity::BACK);
+
+        this->specificMasterActionHoldCount_ = 4;
+
+        this->specificMasterAction_ = TURN180;
+    }
+
+    /**
+        @brief Execute the 180 degree turn. Called within tick.
     */
     void ArtificialController::turn180()
     {
+            Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_);
+
+            this->getControllableEntity()->rotateYaw(-2.0f * sgn(coord.x) * coord.x*coord.x);
+            this->getControllableEntity()->rotatePitch(2.0f * sgn(coord.y) * coord.y*coord.y);
+
+            this->getControllableEntity()->moveFrontBack(SPEED_MASTER);
+    }
+
+    /**
+        @brief Master initializes a spin around its looking direction axis. Leads to a "specific master action". Not yet implemented.
+    */
+    void ArtificialController::spinInit()
+    {
+         COUT(0) << "~spinInit" << std::endl;
         if(this->state_ != MASTER) return;
-
-        COUT(0) << "~turn" << std::endl;
-
-        Quaternion orient = this->getControllableEntity()->getOrientation();
-
-        this->setTargetPosition(this->getControllableEntity()->getPosition() + 500.0f*orient*WorldEntity::BACK);
-        this->specificMasterActionHoldCount_ = 2;
-        this->specificMasterAction_  =  HOLD;
-    }
-
-    /**
-        @brief Master spins around its looking direction axis. Is a "specific master action". Not yet implemented.
+        this->specificMasterAction_ = SPIN;
+        this->specificMasterActionHoldCount_ = 10;
+    }
+
+    /**
+        @brief Execute the spin. Called within tick.
     */
     void ArtificialController::spin()
     {
-        if(this->state_ != MASTER) return;
-
-        this->specificMasterAction_  =  NONE;
+            this->moveToTargetPosition();
+            this->getControllableEntity()->rotateRoll(0.8f);
     }
 
Index: code/branches/ai/src/orxonox/controllers/ArtificialController.h
===================================================================
--- code/branches/ai/src/orxonox/controllers/ArtificialController.h	(revision 6996)
+++ code/branches/ai/src/orxonox/controllers/ArtificialController.h	(revision 6997)
@@ -71,5 +71,5 @@
             bool formationFlight_;
             bool passive_;
-            int maxFormationSize_;
+            unsigned int maxFormationSize_;
             int freedomCount_;
             enum State {SLAVE, MASTER, FREE};
@@ -101,5 +101,7 @@
 
             void specificMasterActionHold();
+            void turn180Init();
             void turn180();
+            void spinInit();
             void spin();
             void followHuman(Pawn* humanController, bool always);
