Index: /code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- /code/branches/campaignHS15/data/levels/AITest.oxw	(revision 10848)
+++ /code/branches/campaignHS15/data/levels/AITest.oxw	(revision 10849)
@@ -32,5 +32,5 @@
 
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
-    <TeamSpawnPoint team=1 position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
+    <TeamSpawnPoint team=0 position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
     
 <!-- 
@@ -53,5 +53,5 @@
 <!--                 <ActionPoint position="12,34,56" action="FIGHT" enemy="ss" />
  -->
-    <SpaceShip position="2000, 1500, -1000" lookat="0,0,0" team=0 name="ss1">
+<!--     <SpaceShip position="2000, 1500, -1000" lookat="0,0,0" team=0 name="ss1">
       <templates>
         <Template link=spaceshipassff />
@@ -61,19 +61,35 @@
         </DivisionController>
       </controller>
-    </SpaceShip>
-    <SpaceShip position="0, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
+    </SpaceShip> -->
+    <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=1 name="ss2">
       <templates>
         <Template link=spaceshipassff />
       </templates>
       <controller>
-        <DivisionController team=12>
+        <DivisionController team=1>
           <actionpoints>
-            <Actionpoint position="12,34,56" action="PROTECT" protectMe=true />
-            <Actionpoint position="12,34,56" action="FLY" />
+            <Actionpoint position="-1000,750,-500" action="PROTECt" protect="fuck" />
+            <Actionpoint position="-1000,750,-500" action="ATTACK" enemy="ss3" />
+            <Actionpoint position="-1000,750,-500" action="FLY" />
+            <Actionpoint position="0,0,0" action="FLY" />
           </actionpoints>
         </DivisionController>
       </controller>
     </SpaceShip>
-    
+    <SpaceShip position="0, 0, 0" lookat="0,0,0" team=2 name="ss4">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+    </SpaceShip>
+    <SpaceShip position="1000, 300, 200" lookat="0,0,0" team=2 name="ss3">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+    </SpaceShip>
+    <SpaceShip position="-500, -300, -300" lookat="0,0,0" team=1 name="fuck">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+    </SpaceShip> 
    <!--  <SpaceShip position="4000 ,1500, -1600 " lookat="0,0,0" team=0>
       <templates>
Index: /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10848)
+++ /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10849)
@@ -58,7 +58,8 @@
     CommonController::CommonController( Context* context ): Controller( context )
     {
-        this->action_ = Action::FLY;
+        this->squaredaccuracy_ = 500;
+        this->action_ = Action::NONE;
         this->stopLookingAtTarget();
-        this->attackRange_ = 2500;
+        this->attackRange_ = 800;
         RegisterObject( CommonController );
     }
@@ -69,19 +70,6 @@
         //orxout(internal_error) << "I died, my Rank is " << rank_ << endl;
     }
-    void CommonController::backupAction()
-    {
-        this->actionpoints_.push_back (this->currentActionpoint_);
-    }
-    void CommonController::restoreAction()
-    {
-        this->currentActionpoint_ = this->actionpoints_.back();
-        this->actionpoints_.pop_back();
-    }
-    void CommonController::popAction()
-    {
-        this->currentActionpoint_ = actionpoints_.back();
-        actionpoints_.pop_back();
-    }
-
+    
+  
     void CommonController::XMLPort( Element& xmlelement, XMLPort::Mode mode )
     {
@@ -120,5 +108,5 @@
         if (!this->getProtect())
             return "noProtectWasSet";
-        return CommonController::getName (this->getProtect());
+        return CommonController::getName (orxonox_cast<Pawn*>(this->getProtect()));
     }
     std::string CommonController::getName(Pawn* entity)
@@ -256,5 +244,5 @@
     {
         this->action_ = action;
-        if (action == Action::FIGHT)
+        if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK)
         {   
             if (target)
@@ -334,12 +322,14 @@
             }
             else
-                ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ val + "'." );
+                ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." );
             //this->setAction( value );
-            parsedActionpoints_.push_back( std::make_tuple (value, targetName, position) );
-        }
-        else
-        {
-            parsedActionpoints_.push_back( 
-                std::make_tuple (Action::FLY, "", actionpoint->getWorldPosition()) );
+            Point p = { value, targetName, position };
+            parsedActionpoints_.push_back(p);
+            orxout(internal_error) << "Pushed " << p.action << endl;
+        }
+        else
+        {
+            Point p = { Action::FLY, "", actionpoint->getWorldPosition() };
+            parsedActionpoints_.push_back(p);
         }
             this->actionpoints_.push_back(actionpoint);
@@ -357,7 +347,7 @@
     void CommonController::setClosestTarget()
     {
-        this->setTarget (closestTarget()); 
-    }
-    ControllableEntity* CommonController::closestTarget()
+        this->setTarget (static_cast<ControllableEntity*>( closestTarget() ) ); 
+    }
+    Pawn* CommonController::closestTarget()
     {
         if (!this->getControllableEntity())
@@ -381,5 +371,5 @@
         if (closestTarget)
         {
-           return static_cast<ControllableEntity*>(closestTarget);
+           return closestTarget;
         } 
         return 0;  
@@ -391,5 +381,5 @@
         if (!this->parsedActionpoints_.empty())
         {
-            this->action_ = std::get<0>( this->parsedActionpoints_.back() );
+            this->action_ = this->parsedActionpoints_.back().action;
 
             switch ( this->action_ )
@@ -401,5 +391,5 @@
                 case Action::FLY:
                 {
-                    this->setTargetPosition(std::get<2>( this->parsedActionpoints_.back() ));
+                    this->setTargetPosition( this->parsedActionpoints_.back().position );
                     if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
                     {
@@ -411,5 +401,5 @@
                 case Action::PROTECT:
                 {
-                    std::string protectName = std::get<1>( this->parsedActionpoints_.back() );
+                    std::string protectName = this->parsedActionpoints_.back().name;
 
                     for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
@@ -437,5 +427,5 @@
                 case Action::ATTACK:
                 {
-                    std::string targetName = std::get<1>( this->parsedActionpoints_.back() );
+                    std::string targetName = this->parsedActionpoints_.back().name;
 
                     for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
@@ -443,4 +433,5 @@
                         if (CommonController::getName(*itP) == targetName)
                         {
+                            orxout(internal_error) << "Attacking" << endl;
                             this->setTarget (static_cast<ControllableEntity*>(*itP));
                         }
@@ -465,4 +456,5 @@
             this->action_ = Action::NONE;
         }
+        orxout(internal_error) << "Executing action " << this->getActionXML() << endl;
     }
     void CommonController::nextActionpoint()
Index: /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	(revision 10848)
+++ /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	(revision 10849)
@@ -65,5 +65,15 @@
             NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK
         };
+        
     }
+    
+    struct Point {
+        Action::Value action;
+        std::string name;
+        Vector3 position;
+    } ;
+
+
+    
  
 
@@ -171,5 +181,5 @@
                 void doFire();
                 void setClosestTarget();
-                ControllableEntity* closestTarget();
+                Pawn* closestTarget();
 
                 bool bShooting_;
@@ -200,6 +210,8 @@
                 std::vector<WeakPtr<WorldEntity> > actionpoints_;
                 float squaredaccuracy_;
-                <tuple<Action::Value ,std::string ,Vector3 > > currentActionpoint_;
-                std::vector<tuple<Action::Value ,std::string ,Vector3 > > parsedActionpoints_;
+                Point  currentActionpoint_;
+                std::vector<Point > parsedActionpoints_;
+                void executeActionpoint();
+                void nextActionpoint();
             //----[/Actionpoint information]----
             //----["Private" variables]----
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();                
         }
 
