Index: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10848)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10849)
@@ -28,5 +28,5 @@
 
 #include "DivisionController.h"
-
+#include "infos/PlayerInfo.h"
 
 namespace orxonox
@@ -93,15 +93,17 @@
         if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
         {
-            if ((this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_) ||
-             !this->target_)
-            {
-                ControllableEntity* newTarget = this->closestTarget();
+            if ( (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_) 
+                || !this->target_ )
+            {
+                Pawn* newTarget = this->closestTarget();
                 if ( newTarget && 
-                    CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_ )
+                    CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
+                        <= this->attackRange_ )
                 {
                     // this->backupAction();
                     // this->setAction (Action::FIGHT, newTarget);
-                    this->parsedActionpoints_.push_back(
-                        std::make_tuple (Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO) );
+                    Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO };
+                    this->parsedActionpoints_.push_back(p);
+                    this->executeActionpoint();
                 }
             }
@@ -113,8 +115,7 @@
         if (this->action_ == Action::NONE)
         {
-
-        }
-
-        this->executeActionpoint();
+            this->executeActionpoint();
+        }
+
 
         //this->action_ is what I am actually executing, this->target_ is what I am 
@@ -142,5 +143,5 @@
                 else if (this->action_ == Action::FIGHTALL)
                 {
-                    if (newTarget)
+                    if (newTarget && newTarget->getController())
                     {
                         this->setAction (Action::FIGHTALL, newTarget);
@@ -158,4 +159,6 @@
                 //----fly in formation if far enough----
                 Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
+                
+                    
                 if (diffVector.length() > this->attackRange_)
                 {
@@ -198,4 +201,11 @@
         else if (this->action_ == Action::FLY)
         {
+
+            if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
+            {
+                orxout(internal_error) << "arrived";
+                this->nextActionpoint();
+                return;
+            }
             this->setTargetPositionOfWingman();
             this->setTargetPositionOfFollower();
@@ -203,4 +213,9 @@
         else if (this->action_ == Action::PROTECT)
         {
+            if (!this->getProtect())
+            {
+                this->nextActionpoint();
+                return;
+            }
            /* if (this->myWingman_)
                 this->myWingman_->setAction (Action::PROTECT, this->getProtect());
@@ -218,38 +233,38 @@
             this->setTargetPositionOfWingman();
             this->setTargetPositionOfFollower();
+
         }
         else if (this->action_ == Action::ATTACK)
         {   
-            if (this->hasTarget())
-            {
-                //----fly in formation if far enough----
-                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
-                if (diffVector.length() > this->attackRange_)
-                {
-                    this->setTargetPositionOfWingman();
-                    this->setTargetPositionOfFollower();                    
-                }
-                else
-                {
-                    //----wingmans shall support the fire of their leaders----
-                    if (this->myWingman_)
-                    {
-                        this->myWingman_->setAction (this->action_, this->target_);     
-                    }
-                    if (this->myFollower_)
-                    {
-                        this->myFollower_->setAction (this->action_);                                    
-                    }
-
-                }
-                
-            }
-            if (this->hasTarget())
-            {
-                //----choose where to go----
-                this->maneuver();
-                //----fire if you can----
-                this->bShooting_ = this->canFire();                
-            }
+            if (!this->hasTarget())
+            {
+                this->nextActionpoint();
+                return;
+            }
+            //----fly in formation if far enough----
+            Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
+            if (diffVector.length() > this->attackRange_)
+            {
+                this->setTargetPositionOfWingman();
+                this->setTargetPositionOfFollower();                    
+            }
+            else
+            {
+                //----wingmans shall support the fire of their leaders----
+                if (this->myWingman_)
+                {
+                    this->myWingman_->setAction (this->action_, this->target_);     
+                }
+                if (this->myFollower_)
+                {
+                    this->myFollower_->setAction (this->action_);                                    
+                }
+
+            }
+            
+            //----choose where to go----
+            this->maneuver();
+            //----fire if you can----
+            this->bShooting_ = this->canFire();                
         }
 
