Index: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	(revision 10886)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	(revision 10888)
@@ -32,6 +32,4 @@
 #include <algorithm>
 #include "worldentities/Actionpoint.h"
-
-
 namespace orxonox
 {
@@ -45,5 +43,10 @@
         this->bLoop_ = false;
         this->bEndLoop_ = false;
-        this->parsedActionpoints_.clear();
+        loopActionpoints_.clear();
+        parsedActionpoints_.clear();
+        actionpoints_.clear();
+        healthSpawners_.clear();
+        damageSpawners_.clear();
+        speedSpawners_.clear();
         this->bTakenOver_ = false;
         this->action_ = Action::NONE;
@@ -64,4 +67,7 @@
         parsedActionpoints_.clear();
         actionpoints_.clear();
+        healthSpawners_.clear();
+        damageSpawners_.clear();
+        speedSpawners_.clear();
     }
     void ActionpointController::tick(float dt)
@@ -97,5 +103,9 @@
         }
         if (this->bFirstTick_)
-        {            
+        {    
+            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;
         }
@@ -109,4 +119,5 @@
         if (!this->getControllableEntity() || !orxonox_cast<Pawn*> (this->getControllableEntity()))
             return;
+
         this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp;
         this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth();
@@ -116,4 +127,10 @@
         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())
             {
@@ -142,5 +159,8 @@
                     {
                         this->action();
-                    }       
+                    }
+                    else
+                    {
+                    }      
                 }
             }
@@ -214,10 +234,21 @@
         if (this->hasTarget())
         {
-            //----choose where to go----
             this->maneuver();
-            //----fire if you can----
-            this->bShooting_ = this->canFire();                
+            this->bShooting_ = this->canFire();
+            // 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_ ;
+
     }
     void ActionpointController::setProtect (ControllableEntity* protect)
@@ -236,7 +267,7 @@
         bool inLoop = false;
         Point p;
-        if (static_cast<Actionpoint*> (actionpoint))
-        {
-            Actionpoint* ap = static_cast<Actionpoint*> (actionpoint);
+        if (actionpoint->getIdentifier()->getName() == "Actionpoint")
+        {
+            Actionpoint* ap = orxonox_cast<Actionpoint*> (actionpoint);
             actionName = ap->getActionXML();
             targetName = ap->getName();
@@ -277,4 +308,5 @@
         else
         {
+            inLoop = true;
             p.action = Action::FLY; p.name = ""; p.position = actionpoint->getWorldPosition(); p.inLoop = inLoop;
         }
@@ -290,5 +322,5 @@
     }
 
-      Action::Value ActionpointController::getAction ()
+    Action::Value ActionpointController::getAction ()
     {
         return this->action_;
@@ -593,6 +625,14 @@
                         <= this->attackRange_ )
                 {
-                    Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, false };
-                    this->parsedActionpoints_.push_back(p);
+                    if (this->bLoop_)
+                    {
+                        Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, true };
+                        this->loopActionpoints_.push_back(p);
+                    }
+                    else
+                    {
+                        Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, false };
+                        this->parsedActionpoints_.push_back(p);
+                    }
                     this->executeActionpoint();
                 }
@@ -600,3 +640,124 @@
         }
     }
+    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;
+        }  
+    }
 }
Index: code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h	(revision 10886)
+++ code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h	(revision 10888)
@@ -33,4 +33,6 @@
 #include "tools/Timer.h"
 #include "tools/interfaces/Tickable.h"
+#include "../modules/pickup/PickupSpawner.h"
+#include <map>
 
 namespace orxonox
@@ -51,4 +53,11 @@
         bool inLoop;
     } ;
+    namespace PickupType
+    {
+        enum Value
+        {  
+            NONE, DAMAGE, HEALTH, SPEED, PORTAL
+        };
+    }
 
     class _OrxonoxExport ActionpointController : public FightingController, public Tickable
@@ -118,4 +127,11 @@
                 bool bFirstTick_; 
 
+                void setSpawners();
+                Vector3 bestHealthPickup (float searchRadius);
+                // Point closestPickup(PickupType::Value pickupType);
+                std::multimap <int, std::pair<PickupSpawner*, bool> > healthSpawners_; 
+                std::multimap <int, std::pair<PickupSpawner*, bool> > damageSpawners_; 
+                std::multimap <int, std::pair<PickupSpawner*, bool> > speedSpawners_; 
+
         private:
             
Index: code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	(revision 10886)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	(revision 10888)
@@ -172,5 +172,29 @@
         }
     }
-    
+    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, Vector3& diffUnit)
     {
@@ -179,5 +203,5 @@
         float x = CommonController::randomInRange (100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
         float y = CommonController::randomInRange (100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
-        float z = (1/diffUnit.z) * (-x * diffUnit.x - y * diffUnit.y);
+        float z = diffUnit.z == 0 ? 0 : (1/diffUnit.z) * (-x * diffUnit.x - y * diffUnit.y);
         this->setTargetPosition(thisPosition + Vector3(x,y,z) + (this->deltaHp < 0 ? -diffUnit * 450.0f : diffUnit * 100.0f));
         this->boostControl();
Index: code/branches/campaignHS15/src/orxonox/controllers/FightingController.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.h	(revision 10886)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.h	(revision 10888)
@@ -62,4 +62,5 @@
             void maneuver();
             void dodge(const Vector3& thisPosition, Vector3& diffUnit);
+            void dodgeTowards (Vector3& position);
             bool canFire();
             void doFire();
Index: code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc	(revision 10886)
+++ code/branches/campaignHS15/src/orxonox/controllers/FlyingController.cc	(revision 10888)
@@ -42,5 +42,5 @@
         this->rotationProgress_ = 0;
         this->spread_ = 200;
-        this->tolerance_ = 100;
+        this->tolerance_ = 80;
     }
     FlyingController::~FlyingController() 
Index: code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	(revision 10886)
+++ code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	(revision 10888)
@@ -126,5 +126,17 @@
                 {
                     this->maneuver();
-                    this->bShooting_ = this->canFire();                
+                    this->bShooting_ = this->canFire();
+                    // 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();               
                 }
             }
Index: code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	(revision 10886)
+++ code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	(revision 10888)
@@ -112,8 +112,18 @@
                 if (this->hasTarget())
                 {
-                    //----choose where to go----
                     this->maneuver();
-                    //----fire if you can----
-                    this->bShooting_ = this->canFire();                
+                    this->bShooting_ = this->canFire();
+                    // 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();               
                 }
             }
Index: code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.h
===================================================================
--- code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.h	(revision 10886)
+++ code/branches/campaignHS15/src/orxonox/worldentities/Actionpoint.h	(revision 10888)
@@ -90,4 +90,6 @@
         </SpaceShip>
         
+        One can also use other Worldentities instead of Actionpoints just like Waypoints, but those points
+        will be included in loop.
         For more information read descriptions of the methods.
     */
