Index: /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10847)
+++ /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10848)
@@ -122,5 +122,5 @@
         return CommonController::getName (this->getProtect());
     }
-    std::string CommonController::getName(ControllableEntity* entity)
+    std::string CommonController::getName(Pawn* entity)
     {
         std::string name = entity->getName();
@@ -291,50 +291,58 @@
         Vector3 position;
         std::string targetName;
-        this->actionpoints_.push_back(actionpoint);
+
         if (static_cast<Actionpoint*> (actionpoint))
         {
             Actionpoint* ap = static_cast<Actionpoint*> (actionpoint);
+            
             actionName = ap->getActionXML();
-            targetName = ap->get
+            targetName = ap->getName();
+            position = ap->getWorldPosition();
+
             Action::Value value;
             
-            if ( valUpper == "FIGHT" )
+            if ( actionName == "FIGHT" )
             {
                 value = Action::FIGHT;
 
             }
-            else if ( valUpper == "FLY" )
+            else if ( actionName == "FLY" )
             {
                 value = Action::FLY;
 
             }
-            else if ( valUpper == "PROTECT" )
+            else if ( actionName == "PROTECT" )
             {
                 value = Action::PROTECT;
 
             }
-            else if ( valUpper == "NONE" )
+            else if ( actionName == "NONE" )
             {
                 value = Action::NONE;
 
             }
-            else if ( valUpper == "FIGHTALL" )
+            else if ( actionName == "FIGHTALL" )
             {
                 value = Action::FIGHTALL;
 
             }
-            else if ( valUpper == "ATTACK" )
+            else if ( actionName == "ATTACK" )
             {
                 value = Action::ATTACK;
+
 
             }
             else
                 ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ val + "'." );
-            this->setAction( value );
-        }
-        else
-        {
-            actionName = "FLY";
-        }
+            //this->setAction( value );
+            parsedActionpoints_.push_back( std::make_tuple (value, targetName, position) );
+        }
+        else
+        {
+            parsedActionpoints_.push_back( 
+                std::make_tuple (Action::FLY, "", actionpoint->getWorldPosition()) );
+        }
+            this->actionpoints_.push_back(actionpoint);
+
         
     }
@@ -377,4 +385,94 @@
         return 0;  
     }
+    //POST: this starts doing what was asked by the last element of parsedActionpoints_,
+    //if last element was failed to be parsed, next element will be executed.
+    void CommonController::executeActionpoint()
+    {
+        if (!this->parsedActionpoints_.empty())
+        {
+            this->action_ = std::get<0>( this->parsedActionpoints_.back() );
+
+            switch ( this->action_ )
+            {
+                case Action::FIGHT:
+                {                
+                    break;
+                }
+                case Action::FLY:
+                {
+                    this->setTargetPosition(std::get<2>( this->parsedActionpoints_.back() ));
+                    if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
+                    {
+                        this->nextActionpoint();
+                        this->executeActionpoint();
+                    }
+                    break;
+                }
+                case Action::PROTECT:
+                {
+                    std::string protectName = std::get<1>( this->parsedActionpoints_.back() );
+
+                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                    {
+                        if (CommonController::getName(*itP) == protectName)
+                        {
+                            this->setProtect (static_cast<ControllableEntity*>(*itP));
+                        }
+                    }
+                    if (!this->getProtect())
+                    {
+                        this->nextActionpoint();
+                        this->executeActionpoint();
+                    }
+                    break;
+                }
+                case Action::NONE:
+                {
+                    break;
+                }
+                case Action::FIGHTALL:
+                {
+                    break;
+                }
+                case Action::ATTACK:
+                {
+                    std::string targetName = std::get<1>( this->parsedActionpoints_.back() );
+
+                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                    {
+                        if (CommonController::getName(*itP) == targetName)
+                        {
+                            this->setTarget (static_cast<ControllableEntity*>(*itP));
+                        }
+                    }
+                    if (!this->getTarget())
+                    {
+                        this->nextActionpoint();
+                        this->executeActionpoint();
+                    }
+                    break;
+                }
+                default:
+                    break;
+            }
+            
+
+        }
+        else
+        {
+            this->setTarget(0);
+            this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
+            this->action_ = Action::NONE;
+        }
+    }
+    void CommonController::nextActionpoint()
+    {
+        if (!this->parsedActionpoints_.empty())
+        {
+            this->parsedActionpoints_.pop_back();
+        }
+        this->setAction(Action::NONE);
+    }
+
     void CommonController::maneuver() 
     {
Index: /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	(revision 10847)
+++ /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	(revision 10848)
@@ -138,5 +138,5 @@
                 static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gt);
                 static bool isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle ) ;
-                static std::string getName( ControllableEntity* entity ) ;
+                static std::string getName( Pawn* entity ) ;
 
                 float squaredDistanceToTarget() const;
@@ -207,4 +207,5 @@
                 Rank::Value rank_;
                 std::string protectName_;
+                std::string targetName_;
                 Action::Value action_;
                 int attackRange_;
Index: /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10847)
+++ /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10848)
@@ -97,11 +97,15 @@
             {
                 ControllableEntity* newTarget = this->closestTarget();
-                if (newTarget && CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
-                {
-                    this->backupAction();
-                    this->setAction (Action::FIGHT, newTarget);
-                }
-            }
-        }
+                if ( newTarget && 
+                    CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_ )
+                {
+                    // this->backupAction();
+                    // this->setAction (Action::FIGHT, newTarget);
+                    this->parsedActionpoints_.push_back(
+                        std::make_tuple (Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO) );
+                }
+            }
+        }
+
         //action is NONE whenever ships finishes current action, 
         //if it was fighting before because enemies were close, resume what it was doing
@@ -109,12 +113,13 @@
         if (this->action_ == Action::NONE)
         {
-            if (this->bBackuped_)
-            {
-                this->restoreAction();
-            } else if (!this->actionpoints_.empty())
-            {
-                this->popAction();
-            }
-        }
+
+        }
+
+        this->executeActionpoint();
+
+        //this->action_ is what I am actually executing, this->target_ is what I am 
+        //actually attacking, etc.
+
+        //after action is finished, .pop_back() is to be called.
         if (this->action_ == Action::FIGHT || this->action_ == Action::FIGHTALL)
         {
@@ -122,7 +127,7 @@
             {
                 //----find a target----
+                ControllableEntity* newTarget = this->closestTarget();
                 if (this->action_ == Action::FIGHT)
                 {
-                    ControllableEntity* newTarget = this->closestTarget();
                     if (newTarget && CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
                     {
@@ -131,10 +136,19 @@
                     else
                     {
-                        this->setAction (Action::NONE);
+                        this->nextActionpoint();
+                        return;
                     }
                 }
                 else if (this->action_ == Action::FIGHTALL)
                 {
-                    this->setClosestTarget();                     
+                    if (newTarget)
+                    {
+                        this->setAction (Action::FIGHTALL, newTarget);
+                    }
+                    else
+                    {
+                        this->nextActionpoint();
+                        return;
+                    }
                 }
 
@@ -146,6 +160,15 @@
                 if (diffVector.length() > this->attackRange_)
                 {
-                    this->setTargetPositionOfWingman();
-                    this->setTargetPositionOfFollower();                    
+                    if (this->action_ == Action::FIGHT)
+                    {
+                        this->nextActionpoint();
+                        return;
+                    }
+                    else
+                    {
+                        this->setTargetPositionOfWingman();
+                        this->setTargetPositionOfFollower();                    
+                    }
+
                 }
                 else
@@ -154,9 +177,9 @@
                     if (this->myWingman_)
                     {
-                        this->myWingman_->setAction (Action::FIGHT, this->target_);     
+                        this->myWingman_->setAction (this->action_, this->target_);     
                     }
                     if (this->myFollower_)
                     {
-                        this->myFollower_->setAction (Action::FIGHT);                                    
+                        this->myFollower_->setAction (this->action_);                                    
                     }
 
@@ -180,37 +203,53 @@
         else if (this->action_ == Action::PROTECT)
         {
-            if (!this->getProtect())
-            {
-                for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
-                {
-                    if ((*itP)->getName() == this->protectName_)
-                    {
-                        this->setProtect (static_cast<ControllableEntity*>(*itP));
-                    }
-                }
-                if (!this->getProtect())
-                {
-                    this->setAction (Action::NONE);
-                }
-            }
-            else
-            {
-               /* if (this->myWingman_)
-                    this->myWingman_->setAction (Action::PROTECT, this->getProtect());
-                if (this->myFollower_)
-                    this->myFollower_->setAction (Action::PROTECT, this->getProtect());
-                */
-                Vector3* targetRelativePosition;
-                    
-                targetRelativePosition = new Vector3 (0, 0, 500);  
-     
-                Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) + 
-                    (this->getProtect()->getWorldOrientation()* (*targetRelativePosition)));
-                this->setTargetPosition(targetAbsolutePosition);
+           /* if (this->myWingman_)
+                this->myWingman_->setAction (Action::PROTECT, this->getProtect());
+            if (this->myFollower_)
+                this->myFollower_->setAction (Action::PROTECT, this->getProtect());
+            */
+            Vector3* targetRelativePosition;
                 
-                this->setTargetPositionOfWingman();
-                this->setTargetPositionOfFollower();
-            }            
-
+            targetRelativePosition = new Vector3 (0, 0, 500);  
+ 
+            Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) + 
+                (this->getProtect()->getWorldOrientation()* (*targetRelativePosition)));
+            this->setTargetPosition(targetAbsolutePosition);
+            
+            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();                
+            }
         }
 
Index: /code/branches/campaignHS15/src/orxonox/worldentities/ActionPoint.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/worldentities/ActionPoint.h	(revision 10847)
+++ /code/branches/campaignHS15/src/orxonox/worldentities/ActionPoint.h	(revision 10848)
@@ -91,4 +91,15 @@
                 void setEnemy( ControllableEntity* enemy);
                 ControllableEntity* getEnemy();
+                std::string getName()
+                {
+                    if (actionName_ != "")
+                        return actionName_;
+                    else if (protectName_ != "")
+                        return protectName_;
+                    else if (enemyName_ != "")
+                        return enemyName_;
+                    else
+                        return "";
+                }
             //----["Waypoints" data]----
                 void setTargetPosition(const Vector3& target);
