Index: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	(revision 10912)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	(revision 10915)
@@ -40,4 +40,6 @@
     ActionpointController::ActionpointController(Context* context) : FightingController(context)
     {
+        this->bPatrolling_ = false;
+
         this->actionCounter_ = 0;
         this->bInLoop_ = false;
@@ -100,4 +102,6 @@
     void ActionpointController::tick(float dt)
     {
+        if (!this->getControllableEntity())
+            return;
         if (stop_)
             return;
@@ -109,5 +113,5 @@
         {
             this->timeDodged_ += dt;
-            if (this->timeDodged_ > 2.0f)
+            if (this->timeDodged_ > 4.0f)
             {
                 this->bStartedDodging_ = false;
@@ -119,5 +123,5 @@
             maneuverCounter_ = 0;
         this->timeOffset_ += dt;
-        if (this->timeOffset_ >= 2.0f)
+        if (this->timeOffset_ >= 2.4f)
             this->timeOffset_ = 0.0f;
         if (timeout_ <= 0)
@@ -133,5 +137,6 @@
         }
 
-
+        if (!this->getControllableEntity())
+            return;
         if (this->bShooting_)
         {
@@ -157,8 +162,12 @@
             this->bFirstTick_ = false;
         }
-
+        if (!this->getControllableEntity())
+            return;
         //maneuver every 0.25 sec -> 
-        float currentPeriodTime = this->timeOffset_ - static_cast<int>(this->timeOffset_);
-        if (this->hasTarget() && ((currentPeriodTime >= 0.25f && currentPeriodTime <= 0.5f) || (currentPeriodTime >= 0.75 && currentPeriodTime <= 0.999f)) && !this->bManeuverCalled_)
+        if (this->hasTarget() && 
+            ((this->timeOffset_ >= 0.4f && this->timeOffset_ < 0.8f) || 
+             (this->timeOffset_ >= 1.2f && this->timeOffset_ < 1.6f) ||
+             (this->timeOffset_ >= 1.8f && this->timeOffset_ < 2.0f) ||
+             (this->timeOffset_ >= 2.2f && this->timeOffset_ < 2.4f)) && !this->bManeuverCalled_)
         {
             this->bManeuverCalled_ = true;
@@ -166,5 +175,8 @@
             this->bShooting_ = this->canFire();
         }
-        if ((currentPeriodTime >= 0.0f && currentPeriodTime <= 0.25f) || (currentPeriodTime >= 0.5f && currentPeriodTime <= 0.75f))
+        if ((this->timeOffset_ >= 0.0f && this->timeOffset_ < 0.4f) || 
+             (this->timeOffset_ >= 0.8f && this->timeOffset_ < 1.2f) ||
+             (this->timeOffset_ >= 1.6f && this->timeOffset_ < 1.8f) ||
+             (this->timeOffset_ >= 2.0f && this->timeOffset_ < 2.2f))
             this->bManeuverCalled_ = false;
         SUPER(ActionpointController, tick, dt);
@@ -183,5 +195,4 @@
             this->startAttackingEnemiesThatAreClose();
         }
-
         this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
         this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
@@ -217,16 +228,11 @@
                 {
                     this->setAction (Action::FIGHTALL, newTarget);
-                    this->action();
+                    //this->action();
                 }
                 else
                 {
                     this->nextActionpoint();
-                    if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()))
-                    {
-                        this->action();
-                    }
-                    else
-                    {
-                    }      
+                    this->executeActionpoint();
+    
                 }
             }
@@ -244,10 +250,10 @@
                 {
                     this->setAction (Action::FIGHT, newTarget);
-                    this->action();
+                    //this->action();
                 }
                 else
                 {
                     this->nextActionpoint();
-                    this->action();
+                    this->executeActionpoint();
                 }
             }
@@ -269,5 +275,5 @@
                     {
                         this->nextActionpoint();
-                        this->action();
+                        this->executeActionpoint();
                     }
                 }
@@ -279,5 +285,5 @@
             {
                 this->nextActionpoint();   
-                this->action();
+                this->executeActionpoint();
             }
         }
@@ -287,5 +293,5 @@
             {
                 this->nextActionpoint();
-                this->action(); 
+                this->executeActionpoint(); 
             }
             this->stayNearProtect();
@@ -297,5 +303,5 @@
             {
                 this->nextActionpoint();
-                this->action();
+                this->executeActionpoint();
             }
         }
@@ -599,5 +605,10 @@
         if (this->bLoop_)
         {
-            if (!this->loopActionpoints_.empty())
+            if (this->bPatrolling_)
+            {
+                this->loopActionpoints_.pop_back();
+                this->bPatrolling_ = false;
+            }
+            else if (!this->loopActionpoints_.empty())
             {
                 this->moveBackToTop();
@@ -689,15 +700,17 @@
                         <= this->attackRange_ )
                 {
-                    if (this->bLoop_)
+                    this->setTarget(newTarget);
+                    if (this->bLoop_ && !this->bPatrolling_)
                     {
-                        Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, true };
+                        Point p = { Action::FIGHT, "", Vector3::ZERO, true };
                         this->loopActionpoints_.push_back(p);
                     }
-                    else
+                    else if (!this->bPatrolling_)
                     {
                         //orxout (internal_error) << "found new target " << CommonController::getName(newTarget) <<endl;
-                        Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, false };
+                        Point p = { Action::FIGHT, "", Vector3::ZERO, false };
                         this->parsedActionpoints_.push_back(p);
                     }
+                    this->bPatrolling_ = true;
                     this->executeActionpoint();
                 }
