Index: /code/branches/campaignHS15/data/levels/AITest.oxw
===================================================================
--- /code/branches/campaignHS15/data/levels/AITest.oxw	(revision 10922)
+++ /code/branches/campaignHS15/data/levels/AITest.oxw	(revision 10923)
@@ -92,5 +92,5 @@
 <!-- HERE STARTS DEMO FOR THE ACTIONPOINTS. 
 P.S. Never set protectMe in the first actionpoint: if human didn't spawn, that actionpoint will be skipped -->
-      <!--  
+       
     <Model mesh="cube.mesh" scale=8 position="0,0,0" />
 
@@ -153,9 +153,9 @@
       </templates>
     </SpaceShip> 
-  -->
+ 
    
 <!-- HERE ENDS DEMO FOR THE ACTIONPOINTS -->
 <!-- HERE STARTS DEMO FOR FIGHTING -->
-    
+    <!-- 
 
     <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="d1sd1">
@@ -196,41 +196,4 @@
       </controller>
     </SpaceShip>
-    <SpaceShip position="-5000, 1500, -1000" lookat="0,0,0" team=0 name="d1s1d1">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <DivisionController team=0 formationMode="WALL">
-
-        </DivisionController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="-5000, 1900, -1000" lookat="0,0,0" team=0 name="d1s1s1">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <SectionController team=0>
-        </SectionController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="-5000, 2100, -1000" lookat="0,0,0" team=0 name="d1s1w1">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <WingmanController team=0>
-        </WingmanController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="-5000, 2400, -1000" lookat="0,0,0" team=0 name="d1s1w2">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <WingmanController team=0>
-        </WingmanController>
-      </controller>
-    </SpaceShip>
 
     <SpaceShip position="2000, -1500, 1000" lookat="0,0,0" team=1  name="d2sd1">
@@ -271,42 +234,5 @@
       </controller>
     </SpaceShip> 
-    <SpaceShip position="1000, -1500, 1000" lookat="0,0,0" team=1  name="d2s1d1">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <DivisionController team=1 formationMode="WALL">
-
-        </DivisionController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="1000, -1900, 1000" lookat="0,0,0" team=1 name="d2s1s1">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <SectionController team=1>
-        </SectionController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="1000, -2100, 1000" lookat="0,0,0" team=1 name="d2s1w1">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <WingmanController team=1>
-        </WingmanController>
-      </controller>
-    </SpaceShip>
-    <SpaceShip position="1000, -2400, 1000" lookat="0,0,0" team=1 name="d2s1w2">
-      <templates>
-        <Template link=spaceshipassff />
-      </templates>
-      <controller>
-        <WingmanController team=1>
-        </WingmanController>
-      </controller>
-    </SpaceShip> 
-
+ -->
 <!-- HERE ENDS DEMO FOR FIGHTING -->
 <!-- HERE STARTS DEMO FOR FORMATIONS -->
Index: /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	(revision 10922)
+++ /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	(revision 10923)
@@ -40,7 +40,7 @@
     ActionpointController::ActionpointController(Context* context) : FightingController(context)
     {
+        this->ticks_ = 0;
         this->bPatrolling_ = false;
-
-        this->actionCounter_ = 0;
+        this->maneuverCounter_ = 0;
         this->bInLoop_ = false;
         this->bLoop_ = false;
@@ -49,7 +49,5 @@
         parsedActionpoints_.clear();
         actionpoints_.clear();
-        healthSpawners_.clear();
-        damageSpawners_.clear();
-        speedSpawners_.clear();
+
         this->bTakenOver_ = false;
         this->action_ = Action::NONE;
@@ -96,30 +94,64 @@
         parsedActionpoints_.clear();
         actionpoints_.clear();
-        healthSpawners_.clear();
-        damageSpawners_.clear();
-        speedSpawners_.clear();
+        ActionpointController::nextActionpointControllerId_--;
+        if (ActionpointController::nextActionpointControllerId_ < 0)
+            ActionpointController::nextActionpointControllerId_ = 0;
     }
     void ActionpointController::tick(float dt)
     {
-        if (!this->getControllableEntity())
-            return;
+        if (!this || !this->getControllableEntity())
+            return;
+        ++this->ticks_;
+        // orxout (internal_error) << "this id = " << this->actionpointControllerId_ << endl;
+        if (ActionpointController::sTicks_ < this->ticks_)
+        {
+            // orxout (internal_error) << "total id's = " << ActionpointController::nextActionpointControllerId_ << endl;
+            ++ActionpointController::sTicks_;
+        }
+
+        if (this->ticks_ == 1)
+        {
+
+            this->actionpointControllerId_ = ActionpointController::nextActionpointControllerId_++;
+            std::reverse(parsedActionpoints_.begin(), parsedActionpoints_.end());
+            std::reverse(actionpoints_.begin(), actionpoints_.end());
+            if (this->parsedActionpoints_.empty())
+            {
+                this->action_ = Action::FIGHTALL;
+            }
+        }
+        if (this->ticks_ == 1)
+        {    
+            this->timeOffset_ = 0.0f;
+            this->bActionCalled_ = false;
+            
+            this->bFirstTick_ = false;
+        }
+/*        if (ActionpointController::sTicks_ % (ActionpointController::nextActionpointControllerId_+1) != this->actionpointControllerId_)
+        {
+            return;
+        }*/
+        if (!this || !this->getControllableEntity())
+            return;
+        
+        if (this->bHasTargetPosition_)
+        {
+            this->moveToTargetPosition(dt);
+        }
+        else if (this->bLookAtTarget_)
+        {
+            this->lookAtTarget(dt);
+        }
+        if (this->bShooting_)
+        {
+            this->doFire();
+        }
+
+        if (!this || !this->getControllableEntity())
+            return;
+        
         if (stop_)
             return;
-        if (this->timeout_ > 0 && this->bFiredRocket_)
-        {
-            this->timeout_ -= dt;
-        }
-        if (this->bStartedDodging_)
-        {
-            this->timeDodged_ += dt;
-            if (this->timeDodged_ > 4.0f)
-            {
-                this->bStartedDodging_ = false;
-                this->timeDodged_ = 0;
-            }
-        }
-        maneuverCounter_ += dt;
-        if (maneuverCounter_ > 6.0f)
-            maneuverCounter_ = 0;
+        
         this->timeOffset_ += dt;
         if (this->timeOffset_ >= 2.4f)
@@ -127,57 +159,50 @@
         if (timeout_ <= 0)
             this->bFiredRocket_ = false;
-
-        if (this->bHasTargetPosition_)
-        {
-            this->moveToTargetPosition(dt);
-        }
-        else if (this->bLookAtTarget_)
-        {
-            this->lookAtTarget(dt);
-        }
-
-        if (!this->getControllableEntity())
-            return;
-        if (this->bShooting_)
-        {
-            this->doFire();
-        }
-        if (this->bFirstTick_)
-        {
-            std::reverse(parsedActionpoints_.begin(), parsedActionpoints_.end());
-            std::reverse(actionpoints_.begin(), actionpoints_.end());
-            if (this->parsedActionpoints_.empty())
-            {
-                this->action_ = Action::FIGHTALL;
-            }
-        }
-        if (this->bFirstTick_)
-        {    
-            this->timeOffset_ = 0.0f;
-            this->bActionCalled_ = false;
-            setSpawners();
-            // orxout(internal_error) << "health spawners size = " << this->healthSpawners_.size() <<
-            // ", damage spawners size = " << this->damageSpawners_.size() <<
-            // ", speed spawners size = " << this->speedSpawners_.size() << endl;        
-            this->bFirstTick_ = false;
-        }
-        if (!this->getControllableEntity())
-            return;
+        if (!this || !this->getControllableEntity())
+            return;
+
+        if (!this || !this->getControllableEntity())
+            return;
+        if (this->timeout_ > 0 && this->bFiredRocket_)
+            {
+                this->timeout_ -= dt;
+            }
+            if (this->bStartedDodging_)
+            {
+                this->timeDodged_ += dt;
+            }
+            maneuverCounter_ += dt;
+
         //maneuver every 0.25 sec -> 
-        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;
+        int step =  5;
+        if (this->hasTarget() && ActionpointController::sTicks_ % 100 == step * (this->actionpointControllerId_) + 3)
+        {
+            if (maneuverCounter_ > 6.0f)
+                maneuverCounter_ = 0;
+            if (this->bStartedDodging_ &&  this->timeDodged_ > 4.0f)
+            {
+                this->bStartedDodging_ = false;
+                this->timeDodged_ = 0;
+            }
             this->maneuver();
+        }
+        if (ActionpointController::sTicks_ % 100 == step * this->actionpointControllerId_ + 1)
+        {
+            this->action();
+        }
+        if (!this || !this->getControllableEntity())
+            return;
+
+        if (!this || !this->getControllableEntity())
+            return;
+        if (this->hasTarget() &&  ActionpointController::sTicks_ % 100 == step * (this->actionpointControllerId_))
+        {
             this->bShooting_ = this->canFire();
-        }
-        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;
+            
+        }
+        if (!this || !this->getControllableEntity())
+            return;
+        
+
         SUPER(ActionpointController, tick, dt);
     }
@@ -195,6 +220,11 @@
             this->startAttackingEnemiesThatAreClose();
         }
+        if (!this || !this->getControllableEntity())
+            return;
+
         this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
         this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
+        if (!this || !this->getControllableEntity())
+            return;
 
         // if (this->actionCounter_ % 2 == 0)
@@ -202,11 +232,4 @@
         if (this->action_ == Action::NONE || this->bTakenOver_)
         {
-            // Point point = closestPickup(PickupType::HEALTH);
-            // if (point.action != Action::NONE)
-            // {
-            //     orxout(internal_error) << "found health" << endl;
-            //     this->parsedActionpoints_.push_back(point);
-            // }
-
             if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty() && this->bDefaultFightAll_)
             {
@@ -218,4 +241,7 @@
             // this->action();
         }
+        if (!this || !this->getControllableEntity())
+            return;
+
         //Action fightall -> fight till nobody alive
         if (this->action_ == Action::FIGHTALL)
@@ -307,18 +333,4 @@
         }
 
-            // Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length());
-            // if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_)
-            // {
-            //     //----choose where to go----
-            //     this->maneuver();
-            // }
-            // else
-            // {
-            //     this->dodgeTowards(healthPosition);
-            // }
-            // //----fire if you can----
-            // this->bShooting_ = this->canFire();  
-         
-        this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
 
     }
@@ -402,15 +414,15 @@
         {
             case Action::FIGHT:
-            { return "FIGHT"; break; }
+            { return "FIGHT"; }
             case Action::FLY:
-            { return "FLY"; break; }
+            { return "FLY"; }
             case Action::PROTECT:
-            { return "PROTECT"; break; }
+            { return "PROTECT"; }
             case Action::NONE:
-            { return "NONE"; break; }
+            { return "NONE"; }
             case Action::FIGHTALL:
-            { return "FIGHTALL"; break; }
+            { return "FIGHTALL"; }
             case Action::ATTACK:
-            { return "ATTACK"; break; }
+            { return "ATTACK"; }
             default:
                 return "NONE";
@@ -462,4 +474,7 @@
     void ActionpointController::executeActionpoint()
     {
+        if (!this || !this->getControllableEntity())
+            return;
+
         Point p;
         if (this->bLoop_ && !loopActionpoints_.empty())
@@ -478,4 +493,7 @@
         else
         {
+            if (!this || !this->getControllableEntity())
+                return;
+
             this->setTarget(0);
             this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
@@ -520,5 +538,7 @@
             case Action::PROTECT:
             {
-                
+                if (!this || !this->getControllableEntity())
+                    return;
+
                 std::string protectName = p.name;
                 if (protectName == "reservedKeyword:human")
@@ -583,4 +603,7 @@
     void ActionpointController::stayNearProtect()
     {
+        if (!this || !this->getControllableEntity())
+            return;
+
         Vector3 targetRelativePosition(0, 300, 300);
         if (!this->getProtect())
@@ -665,5 +688,5 @@
     Pawn* ActionpointController::closestTarget()
     {
-        if (!this->getControllableEntity())
+        if (!this || !this->getControllableEntity())
             return 0;
 
@@ -691,4 +714,7 @@
     void ActionpointController::startAttackingEnemiesThatAreClose()
     {
+        if (!this || !this->getControllableEntity())
+            return;
+
         //if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
         {
@@ -700,4 +726,6 @@
                         <= this->attackRange_ )
                 {
+                    if (!this || !this->getControllableEntity())
+                        return;
                     this->setTarget(newTarget);
                     if (this->bLoop_ && !this->bPatrolling_)
@@ -718,124 +746,5 @@
         }
     }
-    Vector3 ActionpointController::bestHealthPickup(float searchRadius)
-    {
-
-        //1000000/distance^2 * 1/index+1
-        float maxUse = 0;
-        float tempUse = -1;
-        int index = 0;
-        float distance = 0;
-        Vector3 bestPosition = this->getControllableEntity()->getWorldPosition();
-
-        for (std::multimap<int, std::pair<PickupSpawner*, bool> >::iterator it=healthSpawners_.begin(); it!=healthSpawners_.end(); ++it)
-        {
-            distance = (this->getControllableEntity()->getWorldPosition() - (*it).second.first->getWorldPosition()).length();
-            if (distance < this->tolerance_ || !(*it).second.second)
-            {
-                (*it).second.second = false;
-                continue;
-            }
-            if (distance > searchRadius)
-                continue;
-            index = (*it).first;
-            tempUse = 1000000*1/(1+distance*distance) * 1/((index/2.0f)+1);
-            if (tempUse > maxUse)
-            {
-                bestPosition = (*it).second.first->getWorldPosition();
-                maxUse = tempUse;
-            }
-        }
-        //std::multimap<int, std::pair<PickupSpawner*, bool> >::iterator it = this->healthSpawners_.find(index);
-        //P.S. check if it == ... .end()
-        //orxout (internal_error) << "best position = " << bestPosition << endl;
-        return  bestPosition;
-    }
-    void ActionpointController::setSpawners()
-    {
-        std::vector<std::string> damagePickups;
-        std::vector<std::string> healthPickups;
-        std::vector<std::string> speedPickups;       
-        int index = 0;
-
-
-        damagePickups.push_back("largedamageboostpickup");
-        damagePickups.push_back("dronepickup");            
-        damagePickups.push_back("mediumdamageboostpickup");
-        damagePickups.push_back("smalldamageboostpickup");
-
-        healthPickups.push_back("triplehealthspeedinvisibilitypickup");            
-        healthPickups.push_back("crazyhealthpickup");
-        healthPickups.push_back("hugehealthpickup");
-        healthPickups.push_back("hugeshieldpickup");
-        healthPickups.push_back("hugeinvisiblepickup");
-        healthPickups.push_back("hugeshrinkpickup");
-        healthPickups.push_back("mediumhealthpickup");
-        healthPickups.push_back("mediumshieldpickup");
-        healthPickups.push_back("mediuminvisiblepickup");
-        healthPickups.push_back("mediumshrinkpickup");  
-        healthPickups.push_back("smallhealthpickup");                   
-        healthPickups.push_back("smallshieldpickup");
-        healthPickups.push_back("smallinvisiblepickup");
-        healthPickups.push_back("smallshrinkpickup");
-
-        speedPickups.push_back("triplehealthspeedinvisibilitypickup");
-        speedPickups.push_back("hugespeedpickup");
-        speedPickups.push_back("smalljumppickup");
-        speedPickups.push_back("mediumspeedpickup");
-        speedPickups.push_back("smallspeedpickup");
-        
-
-
-        for (ObjectList<WorldEntity>::iterator it = ObjectList<WorldEntity>::begin(); it; ++it)
-        {
-            if ((*it)->getIdentifier()->getName() != "PickupSpawner")
-                continue;
-            PickupSpawner* spawner = static_cast<PickupSpawner*>(*it);
-            std::string name = spawner->getPickupTemplateName();
-            //float distance = ((*it)->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length(); 
-            // if (distance < 50.0f)
-            //     continue;           
-            for (unsigned int i = 0; i < healthPickups.size(); ++i)
-            {
-                if (name == healthPickups.at(i))
-                {
-                    index = i;
-                    this->healthSpawners_.insert(std::make_pair(index, std::make_pair(spawner, true)));
-                    break;
-                }
-            }
-            for (unsigned int i = 0; i < damagePickups.size(); ++i)
-            {
-                if (name == damagePickups.at(i))
-                {
-                    //tempUse = 1000000*1/(1+distance*distance) * 1/((i/2.0f)+1);
-                    index = i;
-                    this->damageSpawners_.insert(std::make_pair(index, std::make_pair(spawner, true)));
-                    break;
-                }
-            }
-            for (unsigned int i = 0; i < speedPickups.size(); ++i)
-            {
-                if (name == speedPickups.at(i))
-                {
-                    //tempUse = 1000000*1/(1+distance*distance) * 1/((i/2.0f)+1);
-                    index = i;
-                    this->speedSpawners_.insert(std::make_pair(index, std::make_pair(spawner, true)));
-                    break;
-                }
-            }
-            // if (tempUse > maxUse)
-            // {
-            //     Point p = { Action::FLY, "", (*it)->getWorldPosition(), false };
-            //     maxUse = tempUse;
-            //     maxPoint = p;
-            // }
-            // else
-            // {
-            //     tempUse = -1;
-            //     continue;
-            // }
-            // orxout(internal_error) << "resp time  = " << static_cast<PickupSpawner*>(*it)->getRespawnTime() << endl;
-        }  
-    }
-}
+    int ActionpointController::nextActionpointControllerId_ = 0;
+    int ActionpointController::sTicks_ = 0;
+}   
Index: /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h	(revision 10922)
+++ /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h	(revision 10923)
@@ -35,5 +35,4 @@
 #include "../modules/pickup/PickupSpawner.h"
 #include <map>
-
 
 
@@ -246,5 +245,5 @@
                 bool bFirstTick_; 
 
-                void setSpawners();
+              /*  void setSpawners();
                 Vector3 bestHealthPickup (float searchRadius);
                 // Point closestPickup(PickupType::Value pickupType);
@@ -252,5 +251,5 @@
                 std::multimap <int, std::pair<PickupSpawner*, bool> > damageSpawners_; 
                 std::multimap <int, std::pair<PickupSpawner*, bool> > speedSpawners_; 
-
+*/
                 float timeOffset_;
                 bool bActionCalled_;
@@ -262,4 +261,9 @@
                 bool bDefaultPatrol_;
                 bool stop_;
+                static int sTicks_;
+                static int nextActionpointControllerId_;
+                int actionpointControllerId_;
+                int ticks_;
+
 
         private:
Index: /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10922)
+++ /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10923)
@@ -68,5 +68,5 @@
             return;   
         SUPER(DivisionController, tick, dt);
-        if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_)
+        /*if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_)
         {
             this->action();
@@ -76,5 +76,5 @@
         {
             this->bActionCalled_ = false;
-        }
+        }*/
 
         
Index: /code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	(revision 10922)
+++ /code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	(revision 10923)
@@ -63,4 +63,6 @@
     void FightingController::lookAtTarget(float dt)
     {
+        if (!this || !this->getControllableEntity())
+            return;
         ControllableEntity* entity = this->getControllableEntity();
         if ( !entity )
@@ -126,6 +128,7 @@
         float diffLength = diffVector.length();
         Vector3 diffUnit = diffVector/diffLength;
-        bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/10.0f)
-            || this->deltaHp < 0;
+
+        if (!this || !this->getControllableEntity())
+            return;
 
         //too far? well, come closer then
@@ -139,6 +142,11 @@
         }
         else
-        {
+        {   
+            bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/10.0f)
+                || this->deltaHp < 0;
             this->bKeepFormation_ = false;
+
+            if (!this || !this->getControllableEntity())
+                return;
             // if (this->actionCounter_ % 3 == 0)
             if (maneuverCounter_ <= 1.2)
@@ -173,65 +181,6 @@
             }
         }
-        /*//too close? How do u expect to dodge anything? Just attack!
-        else if (diffLength < 1000)
-        {   
-            this->bKeepFormation_ = false;
-
-            //at this point, just look and shoot
-            if (diffLength < 1000)
-            {
-                this->stopMoving();
-                this->startLookingAtTarget();
-
-            }
-            else
-            {
-                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 300.0f);
-            }
-        }
-        //Good distance? Check if target looks at us. It doesn't? Go hunt!
-        else if (!bTargetIsLookingAtThis)
-        {
-            this->bKeepFormation_ = false;
-            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 900.0f);
-        }
-        //That's unfortunate, he is looking and probably shooting... try to dodge what we can...  
-        else 
-        {   
-            this->bKeepFormation_ = false;
-            if (maneuverCounter_ == 0)
-            {
-                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 900.0f);   
-                return;
-            }
-            if (this->actionCounter_ % 3 == 0)
-                dodge(thisPosition, diffLength, diffUnit);
-        }*/
-    }
-    void FightingController::dodgeTowards (Vector3& position)
-    {
-        Vector3 thisPosition = this->getControllableEntity()->getPosition();
-        Vector3 diff = (position - thisPosition);
-        float diffLength = diff.length();
-        Vector3 diffUnit = diff/diffLength;
-        float factor = 300.0f;
-        if (diffLength < 300)
-        {
-            this->setTargetPosition(position);
-            return;    
-        }
-        else if (diffLength < 600)
-            factor = 400.0f;
-        else if (diffLength < 1000)
-            factor = 700.0f;
-        else
-            factor = 1000.0f;
-        float x = CommonController::randomInRange (400, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
-        float y = CommonController::randomInRange (400, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
-        float z = diffUnit.z == 0 ? 0 : (1/diffUnit.z) * (-x * diffUnit.x - y * diffUnit.y);
-        this->setTargetPosition(thisPosition + Vector3(x,y,z) + diffUnit * factor);
-        // orxout(internal_error) << "Dodging towards " << Vector3(x,y,z)  << endl;
-        this->boostControl();
-    }
+    }
+    
     void FightingController::dodge(const Vector3& thisPosition, float diffLength, Vector3& diffUnit)
     {
@@ -257,5 +206,5 @@
     {
         //no target? why fire?
-        if (!this->target_)
+        if (!this->target_ || !this->getControllableEntity())
             return false;
         Vector3 newPositionOfTarget = getPredictedPosition(this->getControllableEntity()->getWorldPosition(), 
@@ -274,5 +223,5 @@
     float FightingController::squaredDistanceToTarget()  const
     {
-        if (!this->getControllableEntity())
+        if (!this || !this->getControllableEntity())
             return 0;
         if (!this->target_ || !this->getControllableEntity())
@@ -294,5 +243,5 @@
     Pawn* FightingController::closestTarget() const
     {
-        if (!this->getControllableEntity())
+        if (!this || !this->getControllableEntity())
             return 0;
 
Index: /code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc	(revision 10922)
+++ /code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc	(revision 10923)
@@ -24,5 +24,5 @@
 
  *   Co-authors:
- *      Dominik Solenicki
+ *   ...
  *
  */
@@ -46,5 +46,4 @@
     FlyingController::~FlyingController() 
     {
-
     }
 
@@ -76,11 +75,11 @@
         {
             case FormationMode::WALL:
-            { return "WALL"; break; }
+            { return "WALL"; }
             case FormationMode::FINGER4:
-            { return "FINGER4"; break; }
+            { return "FINGER4"; }
             case FormationMode::DIAMOND:
-            { return "DIAMOND"; break; }
+            { return "DIAMOND"; }
             default:
-                return "DIAMOND"; break;
+                return "DIAMOND";
         }
     }
@@ -89,9 +88,11 @@
         this->bHasTargetPosition_ = false;
     }
-    void FlyingController::moveToPosition(const Vector3& target, float dt)
-    {
+    void FlyingController::moveToPosition(const Vector3& targetPosition, float dt)
+    {
+        if (!this->getControllableEntity())
+            return;
         ControllableEntity* entity = this->getControllableEntity();
 
-        float distance = ( target - entity->getPosition() ).length();
+        float distance = ( targetPosition - entity->getPosition() ).length();
 
         if ( distance >= this->tolerance_ )
@@ -101,5 +102,5 @@
                 entity->getOrientation()  * WorldEntity::FRONT, 
                 entity->getOrientation()  * WorldEntity::UP, 
-                target );
+                targetPosition );
             float rotateX = -clamp( coord.x * 10, -1.0f, 1.0f );
             float rotateY = clamp( coord.y * 10, -1.0f, 1.0f );
@@ -107,5 +108,5 @@
             entity->rotatePitch( ROTATEFACTOR * rotateY * dt );
           
-            if (distance > this->tolerance_*1.5f || (rotateX > -0.01 && rotateX < 0.01 && rotateY > -0.01 && rotateY < 0.01))
+            if (distance > this->tolerance_*1.5f || (rotateX > -0.03 && rotateX < 0.03 && rotateY > -0.03 && rotateY < 0.03))
                 entity->moveFrontBack( SPEED * dt );
                 copyTargetOrientation(dt);
@@ -123,8 +124,9 @@
     void FlyingController::copyOrientation(const Quaternion& orient, float dt)
     {
-        //inspired by
+        //copied from
         //http://www.ogre3d.org/tikiwiki/tiki-index.php?page=Quaternion+and+Rotation+Primer&structure=Tutorials#Q._How_can_I_make_my_objects_rotate_smoothly_You_mentioned_slerp_etc_
         //how can I make my objects rotate smoothly?
-       
+        if (!this->getControllableEntity())
+            return;
         Quaternion myOrient = this->getControllableEntity()->getOrientation();
         this->rotationProgress_ += dt;
@@ -137,35 +139,26 @@
         else
         {
-
-            Quaternion delta = Quaternion::Slerp(rotationProgress_, myOrient, orient, true);
+            Quaternion deltaOrientation = Quaternion::Slerp(rotationProgress_, myOrient, orient, true);
             
-            //rotate roll builds a Quaternion in roll method of WorldEntity, then it sets orientation.
-            //it is faster just to set orientation, plus that way there is no need in calculating the roll angle.
-            //On the downside, however, ship might also yaw and pitch, but this effect is neglectable, as we only call 
-            //copyOrientation after we move our ship, thus it doesn't affect ships's flying direction too much.
-            //If you don't like the code style, you are welcomed to uncomment the code below
-            //and comment out setOrientation part, it will work just fine, but it will also be a tiny bit slower.
-            //P.S. apperantly it did affect ship's direction and did so way too much.
-            Matrix3 orientMatrix, myMatrix;
-
-            delta.ToRotationMatrix(orientMatrix);
+            Matrix3 deltaMatrix, myMatrix;
+
+            deltaOrientation.ToRotationMatrix(deltaMatrix);
             myOrient.ToRotationMatrix (myMatrix);
 
-            Radian yRad, pRad, rRad, yMy, pMy, rMy;
-            orientMatrix.ToEulerAnglesYXZ(yRad, pRad, rRad);
-            myMatrix.ToEulerAnglesYXZ (yMy, pMy, rMy);
-
-            this->getControllableEntity()->rotateRoll ((rRad.valueRadians() - rMy.valueRadians())*ROTATEFACTOR*dt);
-            // this->getControllableEntity()->setOrientation(delta);
-        }
-        
-        
-    }
-    //change log: increased precision, increased rotation speed
+            Radian yawDelta, pitchDelta, rollDelta, yawMy, pitchMy, rollMy;
+            deltaMatrix.ToEulerAnglesYXZ(yawDelta, pitchDelta, rollDelta);
+            myMatrix.ToEulerAnglesYXZ (yawMy, pitchMy, rollMy);
+
+            if (!this->getControllableEntity())
+                return;
+            this->getControllableEntity()->rotateRoll ((rollDelta.valueRadians() - rollMy.valueRadians())*ROTATEFACTOR*dt);
+        }
+    }
+
     void FlyingController::copyTargetOrientation(float dt)
     {
         if (bHasTargetOrientation_)
         {   
-            copyOrientation(targetOrientation_, dt);
+            this->copyOrientation(targetOrientation_, dt);
         }
     }
@@ -186,8 +179,10 @@
     {
         if (target)
-            setTargetOrientation(target->getOrientation());
+            this->setTargetOrientation(target->getOrientation());
     }
     void FlyingController::boostControl()
     {
+        if (!this->getControllableEntity())
+            return;
         SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity());
         if(ship == NULL) return;
@@ -221,5 +216,5 @@
              + (orient* (targetRelativePosition)));
         //let ship finish rotating. also don't call copyOrientation to often as it is a slow function.
-        if (this->actionCounter_ % 6 == 0 && !this->bHasTargetOrientation_)
+        if (static_cast<int>(rnd(1.0f) * 100) % 3 == 0)
             this->setTargetOrientation (orient);
         this->setTargetPosition (targetAbsolutePosition);
Index: /code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h	(revision 10922)
+++ /code/branches/campaignHS15/src/orxonox/controllers/FlyingController.h	(revision 10923)
@@ -85,8 +85,8 @@
             virtual void boostControl();  
             void keepFormation (const ControllableEntity* leaderEntity, Vector3& targetRelativePosition);      
+            
             FormationMode::Value formationMode_;
           
-            float rotationProgress_;
-            int actionCounter_;
+            float rotationProgress_;    //<! for slerp
             bool bHasTargetPosition_;
             Vector3 targetPosition_;
Index: /code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	(revision 10922)
+++ /code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	(revision 10923)
@@ -74,5 +74,5 @@
    
         SUPER(SectionController, tick, dt);
-        if (this->timeOffset_ > 0.8f && this->timeOffset_ <= 1.6f && !this->bActionCalled_)
+        /*if (this->timeOffset_ > 0.8f && this->timeOffset_ <= 1.6f && !this->bActionCalled_)
         {
             this->action();
@@ -82,5 +82,5 @@
         {
             this->bActionCalled_ = false;
-        }
+        }*/
 
     }
@@ -97,8 +97,5 @@
             this->myDivisionLeader_ = newDivisionLeader;
             //spread copyOrientation called equally among the division
-            if (this->myDivisionLeader_)
-            {
-                this->actionCounter_ = 5;
-            }
+
         }
         //----If have leader----
@@ -156,5 +153,4 @@
         }
 
-        this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
     }
 
@@ -166,8 +162,8 @@
         //----If division leader fights, cover him by fighting emenies close to his target----
         Action::Value action = this->myDivisionLeader_->getAction();
-        
-        Pawn* target;
+
         if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK)
         {
+            Pawn* target;
             //----if he has a target----
             if (this->myDivisionLeader_->hasTarget())
@@ -177,5 +173,4 @@
                     !( this->hasTarget() && this->getTarget() != this->myDivisionLeader_->getTarget() ) )
                 {
-
                     bool foundTarget = false;
                     //----new target should be close to division's target----
Index: /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	(revision 10922)
+++ /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	(revision 10923)
@@ -70,5 +70,5 @@
         if (!this->myLeader_)
         {
-            if (this->actionTime_ == 2.0f)
+            /*if (this->actionTime_ == 2.0f)
             {
                 if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_)
@@ -93,9 +93,9 @@
                     this->bActionCalled_ = false;
                 }
-            }
+            }*/
         }
         else
         {
-            if (this->timeOffset_ >= this->actionTime_ && this->timeOffset_ <= this->actionTime_ + 0.4f && !this->bActionCalled_)
+           /* if (this->timeOffset_ >= this->actionTime_ && this->timeOffset_ <= this->actionTime_ + 0.4f && !this->bActionCalled_)
             {
                 this->action();
@@ -105,5 +105,5 @@
             {
                 this->bActionCalled_ = false;
-            }
+            }*/
         }
        
@@ -114,5 +114,6 @@
     void WingmanController::action()
     {
-
+        if (!this || !this->getControllableEntity())
+            return;
         //----If no leader, find one----
         if (!this->myLeader_)
@@ -122,9 +123,5 @@
             if (this->myLeader_)
             {
-                //spread copyOrientation called equally among the division
-                if (this->myLeader_->getIdentifier()->getName() == "SectionController")
-                    this->actionCounter_ = 1;
-                else
-                    this->actionCounter_ = 4;
+               
             }
         }
@@ -137,4 +134,7 @@
         {
            ActionpointController::action();
+            if (!this || !this->getControllableEntity())
+                return;
+
         }
         else if (this->myLeader_)
@@ -170,5 +170,4 @@
             }
         }
-        this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ;
     }
      
