Index: code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- code/branches/campaignHS15/data/levels/AITest.oxw	(revision 10854)
+++ code/branches/campaignHS15/data/levels/AITest.oxw	(revision 10855)
@@ -62,4 +62,18 @@
       </controller>
     </SpaceShip> -->
+    <SpaceShip position="-1500, 1500, -1000" lookat="0,0,0" team=0 name="ss1">
+      <templates>
+        <Template link=spaceshipassff />
+      </templates>
+      <controller>
+        <DivisionController team=0 formationMode="finger4">
+          <actionpoints>
+            <Actionpoint position="-1000,1000,-1000" action="FLY" loopStart=true />
+            <Actionpoint position="-1250,1250,-500" action="FLY" />
+            <Actionpoint position="-1500,1500,-1000" action="FLY" loopEnd=true />
+          </actionpoints>
+        </DivisionController>
+      </controller>
+    </SpaceShip>
     <SpaceShip position="-2000, 1500, -1000" lookat="0,0,0" team=0 name="ss2">
       <templates>
Index: code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10854)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10855)
@@ -69,4 +69,6 @@
         this->stopLookingAtTarget();
         this->attackRange_ = 2500;
+        this->bInLoop_ = false;
+        this->bLoop_ = false;
         RegisterObject( CommonController );
     }
@@ -159,4 +161,5 @@
         Vector3 position;
         std::string targetName;
+        bool inLoop;
         Point p;
         if (static_cast<Actionpoint*> (actionpoint))
@@ -166,4 +169,14 @@
             targetName = ap->getName();
             position = ap->getWorldPosition();
+
+            if (!this->bInLoop_ && ap->getStartLoop())
+            {
+                this->bInLoop_ = true;
+            }
+            if (this->bInLoop_ && ap->getEndLoop())
+            {
+                this->bInLoop_ = false;
+            }
+            inLoop = this->bInLoop_;
 
             Action::Value value;
@@ -183,10 +196,10 @@
             else
                 ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." );
-            p.action = value; p.name = targetName; p.position = position;
+            p.action = value; p.name = targetName; p.position = position; p.inLoop = inLoop;
             parsedActionpoints_.push_back(p);
         }
         else
         {
-            p.action = Action::FLY; p.name = ""; p.position = actionpoint->getWorldPosition();
+            p.action = Action::FLY; p.name = ""; p.position = actionpoint->getWorldPosition(); p.inLoop = inLoop;
         }
             parsedActionpoints_.push_back(p);
@@ -752,5 +765,5 @@
                         <= this->attackRange_ )
                 {
-                    Point p = { Action::FIGHT, this->getName(newTarget), Vector3::ZERO };
+                    Point p = { Action::FIGHT, this->getName(newTarget), Vector3::ZERO, false };
                     this->parsedActionpoints_.push_back(p);
                     this->executeActionpoint();
@@ -768,90 +781,187 @@
     void CommonController::executeActionpoint()
     {
-        if (!this->parsedActionpoints_.empty())
-        {
-            this->action_ = this->parsedActionpoints_.back().action;
-
-            switch ( this->action_ )
-            {
-                case Action::FIGHT:
+        if (this->bLoop_)
+        {
+            if (!this->loopActionpoints_.empty())
+            {
+                this->action_ = this->loopActionpoints_.back().action;
+                switch ( this->action_ )
                 {
-                    std::string targetName = this->parsedActionpoints_.back().name;
-                    if (targetName == "")
-                    {
-                        break;
-                    }
-                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
-                    {
-                        if (CommonController::getName(*itP) == targetName)
-                        {
-                            this->setTarget (static_cast<ControllableEntity*>(*itP));
+                    case Action::FIGHT:
+                    {
+                        std::string targetName = this->loopActionpoints_.back().name;
+                        if (targetName == "")
+                        {
+                            break;
                         }
-                    }          
-                    break;
+                        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                        {
+                            if (CommonController::getName(*itP) == targetName)
+                            {
+                                this->setTarget (static_cast<ControllableEntity*>(*itP));
+                            }
+                        }          
+                        break;
+                    }
+                    case Action::FLY:
+                    {
+                        this->setTargetPosition( this->loopActionpoints_.back().position );
+                        if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
+                        {
+                            this->nextActionpoint();
+                            this->executeActionpoint();
+                        }
+                        break;
+                    }
+                    case Action::PROTECT:
+                    {
+                        std::string protectName = this->loopActionpoints_.back().name;
+
+                        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 = this->loopActionpoints_.back().name;
+
+                        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                        {
+                            if (CommonController::getName(*itP) == targetName)
+                            {
+                                this->setTarget (static_cast<ControllableEntity*>(*itP));
+                            }
+                        }
+                        if (!this->hasTarget())
+                        {
+                            this->nextActionpoint();
+                            this->executeActionpoint();
+                        }
+                        break;
+                    }
+                    default:
+                        break;
                 }
-                case Action::FLY:
+            }
+            else
+            {
+                this->bLoop_ = false;
+            }
+        }
+        else
+        {
+            if (!this->parsedActionpoints_.empty())
+            {
+                if (this->parsedActionpoints_.back().inLoop)
                 {
-                    this->setTargetPosition( this->parsedActionpoints_.back().position );
-                    if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
-                    {
-                        this->nextActionpoint();
-                        this->executeActionpoint();
-                    }
-                    break;
+                    //MOVES all points that are in loop to a loop vector
+                    this->fillLoop();
+                    this->bLoop_ = true;
+                    executeActionpoint();
+                    return;
                 }
-                case Action::PROTECT:
+                this->action_ = this->parsedActionpoints_.back().action;
+                switch ( this->action_ )
                 {
-                    std::string protectName = this->parsedActionpoints_.back().name;
-
-                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
-                    {
-                        if (CommonController::getName(*itP) == protectName)
-                        {
-                            this->setProtect (static_cast<ControllableEntity*>(*itP));
+                    case Action::FIGHT:
+                    {
+                        std::string targetName = this->parsedActionpoints_.back().name;
+                        if (targetName == "")
+                        {
+                            break;
                         }
-                    }
-                    if (!this->getProtect())
-                    {
-                        this->nextActionpoint();
-                        this->executeActionpoint();
-                    }
-                    break;
+                        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                        {
+                            if (CommonController::getName(*itP) == targetName)
+                            {
+                                this->setTarget (static_cast<ControllableEntity*>(*itP));
+                            }
+                        }          
+                        break;
+                    }
+                    case Action::FLY:
+                    {
+                        this->setTargetPosition( this->parsedActionpoints_.back().position );
+                        if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
+                        {
+                            this->nextActionpoint();
+                            this->executeActionpoint();
+                        }
+                        break;
+                    }
+                    case Action::PROTECT:
+                    {
+                        std::string protectName = this->parsedActionpoints_.back().name;
+
+                        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 = this->parsedActionpoints_.back().name;
+
+                        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                        {
+                            if (CommonController::getName(*itP) == targetName)
+                            {
+                                this->setTarget (static_cast<ControllableEntity*>(*itP));
+                            }
+                        }
+                        if (!this->hasTarget())
+                        {
+                            this->nextActionpoint();
+                            this->executeActionpoint();
+                        }
+                        break;
+                    }
+                    default:
+                        break;
                 }
-                case Action::NONE:
-                {
-                    break;
-                }
-                case Action::FIGHTALL:
-                {
-                    break;
-                }
-                case Action::ATTACK:
-                {
-                    std::string targetName = this->parsedActionpoints_.back().name;
-
-                    for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
-                    {
-                        if (CommonController::getName(*itP) == targetName)
-                        {
-                            this->setTarget (static_cast<ControllableEntity*>(*itP));
-                        }
-                    }
-                    if (!this->hasTarget())
-                    {
-                        this->nextActionpoint();
-                        this->executeActionpoint();
-                    }
-                    break;
-                }
-                default:
-                    break;
-            }
-        }
-        else
-        {
-            this->setTarget(0);
-            this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
-            this->action_ = Action::NONE;
-        }
+            }
+            else
+            {
+                this->setTarget(0);
+                this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
+                this->action_ = Action::NONE;
+            }
+        }
+
     }
     void CommonController::stayNearProtect()
@@ -865,9 +975,45 @@
     void CommonController::nextActionpoint()
     {
-        if (!this->parsedActionpoints_.empty())
-        {
-            this->parsedActionpoints_.pop_back();
+        if (this->bLoop_)
+        {
+            if (!this->loopActionpoints_.empty())
+            {
+                this->moveBackToTop();
+            }
+        }
+        else
+        {
+            if (!this->parsedActionpoints_.empty())
+            {
+                this->parsedActionpoints_.pop_back();
+            }            
         }
         this->setAction(Action::NONE);
+    }
+    void CommonController::moveBackToTop()
+    {
+        Point temp = loopActionpoints_.back();
+        loopActionpoints_.pop_back();
+        std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
+        loopActionpoints_.push_back(temp);
+        std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
+    }
+    void CommonController::fillLoop()
+    {
+        loopActionpoints_.clear();
+        fillLoopReversed();
+        std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
+    }
+    void CommonController::fillLoopReversed()
+    {
+        if (parsedActionpoints_.back().inLoop)
+        {
+            loopActionpoints_.push_back(parsedActionpoints_.back());
+            parsedActionpoints_.pop_back();
+        }
+        if (parsedActionpoints_.back().inLoop)
+        {
+            fillLoopReversed();
+        }
     }
     void CommonController::action()
Index: code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	(revision 10854)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	(revision 10855)
@@ -74,4 +74,5 @@
         std::string name;
         Vector3 position;
+        bool inLoop;
     } ;
 
@@ -202,4 +203,5 @@
                 float squaredaccuracy_;
                 std::vector<Point > parsedActionpoints_;
+                std::vector<Point > loopActionpoints_;
 
             //----[/Actionpoint information]----
@@ -207,4 +209,7 @@
                 void executeActionpoint();
                 void nextActionpoint();
+                void fillLoop();
+                void fillLoopReversed();
+                void moveBackToTop();
             //----[Actionpoint methods]----
             //----["Private" variables]----
@@ -219,5 +224,7 @@
                 int maneuverCounter_;
                 int tolerance_; 
-                bool bFirstTick_;                        
+                bool bFirstTick_; 
+                bool bInLoop_;
+                bool bLoop_;                   
             //----[/"Private" variables]----               
     };
Index: code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10854)
+++ code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10855)
@@ -78,5 +78,4 @@
     {   
         CommonController::action();
-        
     }
     void DivisionController::stayNearProtect()
Index: code/branches/campaignHS15/src/orxonox/worldentities/ActionPoint.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/worldentities/ActionPoint.cc	(revision 10854)
+++ code/branches/campaignHS15/src/orxonox/worldentities/ActionPoint.cc	(revision 10855)
@@ -72,4 +72,6 @@
         XMLPortParam( Actionpoint, "protectMe", setProtectMeXML, getProtectMeXML,  xmlelement, mode ).defaultValues(false);
         XMLPortParam( Actionpoint, "fightAll", setFightAllXML, getFightAllXML,  xmlelement, mode ).defaultValues(false);
+        XMLPortParam( Actionpoint, "loopStart", setLoopStart, getLoopStart,  xmlelement, mode ).defaultValues(false);
+        XMLPortParam( Actionpoint, "loopEnd", setLoopEnd, getLoopEnd,  xmlelement, mode ).defaultValues(false);
 
     }
Index: code/branches/campaignHS15/src/orxonox/worldentities/ActionPoint.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/worldentities/ActionPoint.h	(revision 10854)
+++ code/branches/campaignHS15/src/orxonox/worldentities/ActionPoint.h	(revision 10855)
@@ -68,9 +68,9 @@
                     inline void setProtectMeXML(bool c)
                     {
-                        this->protectMe_ = c;
+                        this->bProtectMe_ = c;
                     }
                     inline bool getProtectMeXML ()
                     {
-                        return this->protectMe_;
+                        return this->bProtectMe_;
                     }
 
@@ -79,9 +79,9 @@
                     inline void setFightAllXML(bool c)
                     {
-                        this->fightAll_ = c;
+                        this->bFightAll_ = c;
                     }
                     inline bool getFightAllXML ()
                     {
-                        return this->fightAll_;
+                        return this->bFightAll_;
                     }
                 //----[/FightAll data]----
@@ -102,4 +102,12 @@
                         return "";
                 }
+                void setLoopStart(bool value)
+                {
+                    this->bLoopStart_ = value;
+                }
+                void setLoopEnd (bool value)
+                {
+                    this->bLoopEnd_ = value;
+                }
             //----["Waypoints" data]----
                 void setTargetPosition(const Vector3& target);
@@ -107,4 +115,12 @@
             //----[/"Waypoints" data]----
 
+            bool getLoopStart()
+            {
+                return this->bLoopStart_;
+            }
+            bool getLoopEnd();
+            {
+                return this->bLoopEnd_;
+            }
         private:
             
@@ -115,6 +131,8 @@
             WeakPtr<ControllableEntity> enemy_;
 
-            bool protectMe_;
-            bool fightAll_;
+            bool bLoopStart_;
+            bool bLoopEnd_;
+            bool bProtectMe_;
+            bool bFightAll_;
             Vector3 targetPosition_;
     };
