Index: /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	(revision 10864)
+++ /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc	(revision 10864)
@@ -0,0 +1,667 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      Dominik Solenicki
+ *
+ */
+
+#include "ActionpointController.h"
+
+#include "core/XMLPort.h"
+
+#include "controllers/NewHumanController.h"
+
+namespace orxonox
+{
+
+    RegisterClass(ActionpointController);
+
+    //CommonController contains all common functionality of AI Controllers
+    ActionpointController::ActionpointController(Context* context) : CommonController(context)
+    {
+              this->bInLoop_ = false;
+        this->bLoop_ = false;
+        this->bEndLoop_ = false;
+        this->parsedActionpoints_.clear();
+        this->bTakenOver_ = false;
+        this->action_ = Action::NONE;
+        this->squaredaccuracy_ = 2500;
+
+
+        RegisterObject(ActionpointController);
+
+    }
+    void ActionpointController::XMLPort( Element& xmlelement, XMLPort::Mode mode )
+    {
+        SUPER( ActionpointController, XMLPort, xmlelement, mode );
+        XMLPortObject(ActionpointController, WorldEntity, "actionpoints", addActionpoint, getActionpoint,  xmlelement, mode);
+    }
+   	void ActionpointController::tick(float dt)
+   	{
+   		if (this->bHasTargetPosition_)
+        {
+            this->moveToTargetPosition(dt);
+        }
+        else if (this->bLookAtTarget_)
+        {
+            this->lookAtTarget(dt);
+        }
+        if (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->bFirstTick_ = false;
+   		SUPER(ActionpointController, tick, dt);
+   	}
+    ActionpointController::~ActionpointController()
+    {
+      parsedActionpoints_.clear();
+        actionpoints_.clear();
+    }
+    void ActionpointController::setProtect (ControllableEntity* protect)
+    {
+        this->protect_ = protect;
+    }
+    ControllableEntity* ActionpointController::getProtect ()
+    {
+        return this->protect_;
+    }
+    void ActionpointController::addActionpoint(WorldEntity* actionpoint)
+    {
+        std::string actionName;
+        Vector3 position;
+        std::string targetName;
+        bool inLoop = false;
+        Point p;
+        if (static_cast<Actionpoint*> (actionpoint))
+        {
+            Actionpoint* ap = static_cast<Actionpoint*> (actionpoint);
+            actionName = ap->getActionXML();
+            targetName = ap->getName();
+            position = ap->getWorldPosition();
+
+            if (this->bEndLoop_)
+            {
+                this->bInLoop_ = false;
+            }
+            if (!this->bInLoop_ && ap->getLoopStart())
+            {
+                this->bInLoop_ = true;
+            }
+            if (this->bInLoop_ && ap->getLoopEnd())
+            {
+                this->bEndLoop_ = true;
+            }
+            inLoop = this->bInLoop_;
+
+            Action::Value value;
+            
+            if ( actionName == "FIGHT" )
+            { value = Action::FIGHT; }
+            else if ( actionName == "FLY" )
+            { value = Action::FLY; }
+            else if ( actionName == "PROTECT" )
+            { value = Action::PROTECT; }
+            else if ( actionName == "NONE" )
+            { value = Action::NONE; }
+            else if ( actionName == "FIGHTALL" )
+            { value = Action::FIGHTALL; }
+            else if ( actionName == "ATTACK" )
+            { value = Action::ATTACK; }
+            else
+                ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." );
+            p.action = value; p.name = targetName; p.position = position; p.inLoop = inLoop;
+        }
+        else
+        {
+            p.action = Action::FLY; p.name = ""; p.position = actionpoint->getWorldPosition(); p.inLoop = inLoop;
+        }
+            parsedActionpoints_.push_back(p);
+            this->actionpoints_.push_back(actionpoint);
+    }
+    WorldEntity* ActionpointController::getActionpoint(unsigned int index) const
+    {
+        if (index < this->actionpoints_.size())
+            return this->actionpoints_[index];
+        else
+            return 0;
+    }
+
+      Action::Value ActionpointController::getAction ()
+    {
+        return this->action_;
+    }
+    std::string ActionpointController::getActionName()
+    {
+        switch ( this->action_ )
+        {
+            case Action::FIGHT:
+            { return "FIGHT"; break; }
+            case Action::FLY:
+            { return "FLY"; break; }
+            case Action::PROTECT:
+            { return "PROTECT"; break; }
+            case Action::NONE:
+            { return "NONE"; break; }
+            case Action::FIGHTALL:
+            { return "FIGHTALL"; break; }
+            case Action::ATTACK:
+            { return "ATTACK"; break; }
+            default:
+                return "NONE";
+                break;
+        }
+    }
+    void ActionpointController::setAction (Action::Value action)
+    {
+        this->action_ = action;
+    }
+    void ActionpointController::setAction (Action::Value action, ControllableEntity* target)
+    {
+        this->action_ = action;
+        if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK)
+        {   
+            if (target)
+                this->setTarget (target);
+        }
+        else if (action == Action::PROTECT)
+        {
+            if (target)
+                this->setProtect (target);
+        }
+    }
+    void ActionpointController::setAction (Action::Value action, const Vector3& target)
+    {
+        this->action_ = action;
+        if (action == Action::FLY)
+        {
+            this->setTargetPosition (target);
+        }
+    }
+    void ActionpointController::setAction (Action::Value action, const Vector3& target,  const Quaternion& orient )
+    {
+        this->action_ = action;
+        if (action == Action::FLY)
+        {
+            this->setTargetPosition (target);
+            this->setTargetOrientation (orient);
+        }  
+    }
+    
+    //------------------------------------------------------------------------------
+    //------------------------------Actionpoint methods-----------------------------
+    //------------------------------------------------------------------------------
+
+    //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 ActionpointController::executeActionpoint()
+    {
+        if (this->bLoop_)
+        {
+            if (!this->loopActionpoints_.empty())
+            {
+                this->action_ = this->loopActionpoints_.back().action;
+                switch ( this->action_ )
+                {
+                    case Action::FIGHT:
+                    {
+                        std::string targetName = this->loopActionpoints_.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));
+                            }
+                        }          
+                        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;
+                        if (protectName == "reservedKeyword:human")
+                        {
+                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                            {
+                                if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
+                                {
+                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
+                                }
+                            }
+                        }
+                        else
+                        {
+                            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;
+                    }
+                      
+                }
+            }
+            else
+            {
+                this->bLoop_ = false;
+            }
+        }
+        else
+        {
+            if (!this->parsedActionpoints_.empty())
+            {
+                if (this->parsedActionpoints_.back().inLoop)
+                {
+                    //MOVES all points that are in loop to a loop vector
+                    this->fillLoop();
+                    this->bLoop_ = true;
+                    executeActionpoint();
+                    return;
+                }
+                this->action_ = this->parsedActionpoints_.back().action;
+                switch ( this->action_ )
+                {
+                    case Action::FIGHT:
+                    {
+                        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));
+                            }
+                        }          
+                        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;
+                        if (protectName == "reservedKeyword:human")
+                        {
+                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+                            {
+                                if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
+                                {
+                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
+                                }
+                            }
+                        }
+                        else
+                        {
+                            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;
+                }
+            }
+
+            else
+            {
+                this->setTarget(0);
+                this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
+                this->action_ = Action::NONE;
+            }
+        }
+      }
+
+    
+    void ActionpointController::stayNearProtect()
+    {
+        Vector3* targetRelativePosition;
+        targetRelativePosition = new Vector3 (0, 300, 300);  
+        Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) + 
+            (this->getProtect()->getWorldOrientation()* (*targetRelativePosition)));
+        this->setTargetPosition(targetAbsolutePosition);
+    }
+    void ActionpointController::nextActionpoint()
+    {
+        if (!this || !this->getControllableEntity())
+            return;
+        if (this->bLoop_)
+        {
+            if (!this->loopActionpoints_.empty())
+            {
+                this->moveBackToTop();
+            }
+        }
+        else
+        {
+            if (!this->parsedActionpoints_.empty())
+            {
+                this->parsedActionpoints_.pop_back();
+            }            
+        }
+        this->setAction(Action::NONE);
+    }
+    void ActionpointController::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 ActionpointController::fillLoop()
+    {
+        loopActionpoints_.clear();
+        fillLoopReversed();
+        std::reverse (loopActionpoints_.begin(), loopActionpoints_.end());
+    }
+    void ActionpointController::fillLoopReversed()
+    {
+        if (parsedActionpoints_.back().inLoop)
+        {
+            loopActionpoints_.push_back(parsedActionpoints_.back());
+            parsedActionpoints_.pop_back();
+        }
+        if (parsedActionpoints_.back().inLoop)
+        {
+            fillLoopReversed();
+        }
+    }
+    void ActionpointController::action()
+    {
+        if (!this || !this->getControllableEntity())
+            return;
+        // orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
+        this->startAttackingEnemiesThatAreClose();
+        //No action -> pop one from stack
+        if (this->action_ == Action::NONE || this->bTakenOver_)
+        {
+            if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())
+            {
+                Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
+                this->parsedActionpoints_.push_back (p);
+            }
+            this->executeActionpoint();
+            this->bTakenOver_ = false;
+        }
+        //Action fightall -> fight till nobody alive
+        if (this->action_ == Action::FIGHTALL)
+        {
+            if (!this->hasTarget())
+            {
+                //----find a target----
+                ControllableEntity* newTarget = this->closestTarget();    
+                if (newTarget)
+                {
+                    this->setAction (Action::FIGHTALL, newTarget);
+                }
+                else
+                {
+                    this->nextActionpoint();
+                    return;
+                }
+            }
+            else if (this->hasTarget())
+            {
+
+            }
+        }
+        //Action fight -> fight as long as enemies in range
+        else if (this->action_ == Action::FIGHT)
+        {
+            if (!this->hasTarget())
+            {
+                //----find a target----
+                ControllableEntity* newTarget = this->closestTarget();    
+                if (newTarget && 
+                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
+                {
+                    this->setAction (Action::FIGHT, newTarget);
+                }
+                else
+                {
+                    this->nextActionpoint();
+                    return;
+                }
+            }
+            else if (this->hasTarget())
+            {
+                //----fly in formation if far enough----
+                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
+                    
+                if (diffVector.length() > this->attackRange_)
+                {
+                    ControllableEntity* newTarget = this->closestTarget();
+                    
+                    if (newTarget && 
+                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
+                    {
+                        this->setAction (Action::FIGHT, newTarget);
+                    }
+                    else
+                    {
+                        this->nextActionpoint();
+                        return;
+                    }
+                }
+            }
+        }
+        else if (this->action_ == Action::FLY)
+        {
+            if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
+            {
+                this->nextActionpoint();   
+                return;
+            }
+        }
+        else if (this->action_ == Action::PROTECT)
+        {
+            if (!this->getProtect())
+            {
+                this->nextActionpoint(); 
+                return;
+            }
+            this->stayNearProtect();
+        }
+        else if (this->action_ == Action::ATTACK)
+        {   
+            if (!this->hasTarget())
+            {
+                this->nextActionpoint();
+                return;
+            }
+        }
+        if (this->hasTarget())
+        {
+            //----choose where to go----
+            this->maneuver();
+            //----fire if you can----
+            this->bShooting_ = this->canFire();                
+        }
+    }
+    void ActionpointController::takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b)
+    {
+      this->parsedActionpoints_ = vector;
+      this->loopActionpoints_ = loop;
+      this->bLoop_ = this->bLoop_;
+      this->bTakenOver_ = true;
+      // orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
+    }
+    void ActionpointController::setClosestTarget()
+    {
+        this->setTarget (static_cast<ControllableEntity*>( closestTarget() ) ); 
+    }
+    Pawn* ActionpointController::closestTarget()
+    {
+        if (!this->getControllableEntity())
+            return 0;
+
+        Pawn* closestTarget = 0;
+        float minDistance =  std::numeric_limits<float>::infinity();
+        Gametype* gt = this->getGametype();
+        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
+        {
+            if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) )
+                continue;
+
+            float distance = CommonController::distance (*itP, this->getControllableEntity());
+            if (distance < minDistance)
+            {
+                closestTarget = *itP;
+                minDistance = distance;
+            }
+        }
+        if (closestTarget)
+        {
+           return closestTarget;
+        } 
+        return 0;  
+    }
+    void ActionpointController::startAttackingEnemiesThatAreClose()
+    {
+        if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
+        {
+            if ( (this->target_ && this->distance (this->getControllableEntity(), this->target_) > this->attackRange_) 
+                || !this->target_ )
+            {
+                Pawn* newTarget = this->closestTarget();
+                if ( newTarget && 
+                    this->distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
+                        <= this->attackRange_ )
+                {
+                    Point p = { Action::FIGHT, this->getName(newTarget), Vector3::ZERO, false };
+                    this->parsedActionpoints_.push_back(p);
+                    this->executeActionpoint();
+                }
+            }
+        }
+    }
+}
Index: /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h	(revision 10864)
+++ /code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h	(revision 10864)
@@ -0,0 +1,112 @@
+/*
+ *   ORXONOX - the hottest 3D action shooter ever to exist
+ *                    > www.orxonox.net <
+ *
+ *
+ *   License notice:
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation; either version 2
+ *   of the License, or (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ *
+ *   Author:
+ *      Fabian 'x3n' Landau
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _ActionpointController_H__
+#define _ActionpointController_H__
+
+#include "controllers/CommonController.h"
+
+
+namespace orxonox
+{
+    namespace Action
+    {  
+        enum Value
+        {
+            NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK
+        };
+        
+    }
+    
+    struct Point {
+        Action::Value action;
+        std::string name;
+        Vector3 position;
+        bool inLoop;
+    } ;
+
+    class _OrxonoxExport ActionpointController : public CommonController
+    {
+        public:
+            //----[language demanded functions]----            
+                ActionpointController(Context* context);
+                virtual ~ActionpointController();
+            //----[language demanded functions]----            
+                virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);          
+               
+            virtual void tick(float dt); 
+            void addActionpoint(WorldEntity* waypoint);
+            WorldEntity* getActionpoint(unsigned int index) const;           
+            virtual void stayNearProtect();
+            virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
+            virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b);
+            Action::Value getAction ();
+            std::string getActionName();
+
+            void setAction (Action::Value action);
+            void setAction (Action::Value action, ControllableEntity* target);
+            void setAction (Action::Value action, const Vector3& target);
+            void setAction (Action::Value action, const Vector3& target,  const Quaternion& orient );
+
+           
+
+
+        protected:
+            void startAttackingEnemiesThatAreClose();
+
+            //----[Actionpoint information]----
+                Action::Value action_;
+                std::string protectName_;
+                std::string targetName_;
+                std::vector<WeakPtr<WorldEntity> > actionpoints_;
+                float squaredaccuracy_;
+                std::vector<Point > parsedActionpoints_;
+                std::vector<Point > loopActionpoints_;
+                bool bInLoop_;
+                bool bLoop_;   
+                bool bEndLoop_;  
+                bool bTakenOver_;  
+            //----[/Actionpoint information]----
+                void setProtect (ControllableEntity* protect);
+                ControllableEntity* getProtect (); 
+                void setClosestTarget();
+                Pawn* closestTarget();
+            //----[Actionpoint methods]----
+                void executeActionpoint();
+                void nextActionpoint();
+                void fillLoop();
+                void fillLoopReversed();
+                void moveBackToTop();
+            //----[Actionpoint methods]----          
+            
+        private:
+            
+    };
+}
+
+#endif /* _ActionpointController_H__ */
Index: /code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt	(revision 10863)
+++ /code/branches/campaignHS15/src/orxonox/controllers/CMakeLists.txt	(revision 10864)
@@ -16,3 +16,4 @@
   SectionController.cc
   CommonController.cc
+  ActionpointController.cc
 )
Index: /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10863)
+++ /code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10864)
@@ -68,47 +68,18 @@
     CommonController::CommonController( Context* context ): Controller( context )
     {
-        this->squaredaccuracy_ = 2500;
         this->bFirstTick_ = true;
         this->tolerance_ = 50;
-        this->action_ = Action::NONE;
         this->stopLookingAtTarget();
         this->attackRange_ = 2500;
-        this->bInLoop_ = false;
-        this->bLoop_ = false;
-        this->bEndLoop_ = false;
-        this->parsedActionpoints_.clear();
         RegisterObject( CommonController );
-        this->bTakenOver_ = false;
+
     }
     CommonController::~CommonController() 
     {
-        parsedActionpoints_.clear();
-        actionpoints_.clear();
+        
     }
     void CommonController::tick(float dt)
     {
-        if (this->bHasTargetPosition_)
-        {
-            this->moveToTargetPosition(dt);
-        }
-        else if (this->bLookAtTarget_)
-        {
-            this->lookAtTarget(dt);
-        }
-        if (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->bFirstTick_ = false;
+        
         SUPER(CommonController, tick, dt);
     }
@@ -122,5 +93,4 @@
         SUPER( CommonController, XMLPort, xmlelement, mode );
         XMLPortParam( CommonController, "formationMode", setFormationModeXML, getFormationModeXML,  xmlelement, mode );
-        XMLPortObject(CommonController, WorldEntity, "actionpoints", addActionpoint, getActionpoint,  xmlelement, mode);
     }
     void CommonController::setFormationModeXML( std::string val )
@@ -169,65 +139,5 @@
         return this->rank_; 
     }
-    void CommonController::addActionpoint(WorldEntity* actionpoint)
-    {
-        std::string actionName;
-        Vector3 position;
-        std::string targetName;
-        bool inLoop = false;
-        Point p;
-        if (static_cast<Actionpoint*> (actionpoint))
-        {
-            Actionpoint* ap = static_cast<Actionpoint*> (actionpoint);
-            actionName = ap->getActionXML();
-            targetName = ap->getName();
-            position = ap->getWorldPosition();
-
-            if (this->bEndLoop_)
-            {
-                this->bInLoop_ = false;
-            }
-            if (!this->bInLoop_ && ap->getLoopStart())
-            {
-                this->bInLoop_ = true;
-            }
-            if (this->bInLoop_ && ap->getLoopEnd())
-            {
-                this->bEndLoop_ = true;
-            }
-            inLoop = this->bInLoop_;
-
-            Action::Value value;
-            
-            if ( actionName == "FIGHT" )
-            { value = Action::FIGHT; }
-            else if ( actionName == "FLY" )
-            { value = Action::FLY; }
-            else if ( actionName == "PROTECT" )
-            { value = Action::PROTECT; }
-            else if ( actionName == "NONE" )
-            { value = Action::NONE; }
-            else if ( actionName == "FIGHTALL" )
-            { value = Action::FIGHTALL; }
-            else if ( actionName == "ATTACK" )
-            { value = Action::ATTACK; }
-            else
-                ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." );
-            p.action = value; p.name = targetName; p.position = position; p.inLoop = inLoop;
-        }
-        else
-        {
-            p.action = Action::FLY; p.name = ""; p.position = actionpoint->getWorldPosition(); p.inLoop = inLoop;
-        }
-            parsedActionpoints_.push_back(p);
-            this->actionpoints_.push_back(actionpoint);
-    }
-    WorldEntity* CommonController::getActionpoint(unsigned int index) const
-    {
-        if (index < this->actionpoints_.size())
-            return this->actionpoints_[index];
-        else
-            return 0;
-    }
-
+    
     //------------------------------------------------------------------------------
     //-------------------------------World interaction------------------------------
@@ -249,64 +159,5 @@
         return this->target_;
     }
-    Action::Value CommonController::getAction ()
-    {
-        return this->action_;
-    }
-    std::string CommonController::getActionName()
-    {
-        switch ( this->action_ )
-        {
-            case Action::FIGHT:
-            { return "FIGHT"; break; }
-            case Action::FLY:
-            { return "FLY"; break; }
-            case Action::PROTECT:
-            { return "PROTECT"; break; }
-            case Action::NONE:
-            { return "NONE"; break; }
-            case Action::FIGHTALL:
-            { return "FIGHTALL"; break; }
-            case Action::ATTACK:
-            { return "ATTACK"; break; }
-            default:
-                return "NONE";
-                break;
-        }
-    }
-    void CommonController::setAction (Action::Value action)
-    {
-        this->action_ = action;
-    }
-    void CommonController::setAction (Action::Value action, ControllableEntity* target)
-    {
-        this->action_ = action;
-        if (action == Action::FIGHT || action == Action::FIGHTALL || action == Action::ATTACK)
-        {   
-            if (target)
-                this->setTarget (target);
-        }
-        else if (action == Action::PROTECT)
-        {
-            if (target)
-                this->setProtect (target);
-        }
-    }
-    void CommonController::setAction (Action::Value action, const Vector3& target)
-    {
-        this->action_ = action;
-        if (action == Action::FLY)
-        {
-            this->setTargetPosition (target);
-        }
-    }
-    void CommonController::setAction (Action::Value action, const Vector3& target,  const Quaternion& orient )
-    {
-        this->action_ = action;
-        if (action == Action::FLY)
-        {
-            this->setTargetPosition (target);
-            this->setTargetOrientation (orient);
-        }  
-    }
+  
 
     //------------------------------------------------------------------------------
@@ -603,12 +454,5 @@
         this->bHasOrientationOfTarget_=true;
     }
-    void CommonController::setProtect (ControllableEntity* protect)
-    {
-        this->protect_ = protect;
-    }
-    ControllableEntity* CommonController::getProtect ()
-    {
-        return this->protect_;
-    }
+    
     void CommonController::maneuver() 
     {
@@ -739,445 +583,7 @@
         this->getControllableEntity() ->fire( 0 );
     }
-    void CommonController::setClosestTarget()
-    {
-        this->setTarget (static_cast<ControllableEntity*>( closestTarget() ) ); 
-    }
-    Pawn* CommonController::closestTarget()
-    {
-        if (!this->getControllableEntity())
-            return 0;
-
-        Pawn* closestTarget = 0;
-        float minDistance =  std::numeric_limits<float>::infinity();
-        Gametype* gt = this->getGametype();
-        for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
-        {
-            if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP), gt) )
-                continue;
-
-            float distance = CommonController::distance (*itP, this->getControllableEntity());
-            if (distance < minDistance)
-            {
-                closestTarget = *itP;
-                minDistance = distance;
-            }
-        }
-        if (closestTarget)
-        {
-           return closestTarget;
-        } 
-        return 0;  
-    }
-    void CommonController::startAttackingEnemiesThatAreClose()
-    {
-        if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL)
-        {
-            if ( (this->target_ && this->distance (this->getControllableEntity(), this->target_) > this->attackRange_) 
-                || !this->target_ )
-            {
-                Pawn* newTarget = this->closestTarget();
-                if ( newTarget && 
-                    this->distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget))
-                        <= this->attackRange_ )
-                {
-                    Point p = { Action::FIGHT, this->getName(newTarget), Vector3::ZERO, false };
-                    this->parsedActionpoints_.push_back(p);
-                    this->executeActionpoint();
-                }
-            }
-        }
-    }
-
-    //------------------------------------------------------------------------------
-    //------------------------------Actionpoint methods-----------------------------
-    //------------------------------------------------------------------------------
-
-    //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->bLoop_)
-        {
-            if (!this->loopActionpoints_.empty())
-            {
-                this->action_ = this->loopActionpoints_.back().action;
-                switch ( this->action_ )
-                {
-                    case Action::FIGHT:
-                    {
-                        std::string targetName = this->loopActionpoints_.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));
-                            }
-                        }          
-                        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;
-                        if (protectName == "reservedKeyword:human")
-                        {
-                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
-                            {
-                                if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
-                                {
-                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
-                                }
-                            }
-                        }
-                        else
-                        {
-                            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;
-                }
-            }
-            else
-            {
-                this->bLoop_ = false;
-            }
-        }
-        else
-        {
-            if (!this->parsedActionpoints_.empty())
-            {
-                if (this->parsedActionpoints_.back().inLoop)
-                {
-                    //MOVES all points that are in loop to a loop vector
-                    this->fillLoop();
-                    this->bLoop_ = true;
-                    executeActionpoint();
-                    return;
-                }
-                this->action_ = this->parsedActionpoints_.back().action;
-                switch ( this->action_ )
-                {
-                    case Action::FIGHT:
-                    {
-                        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));
-                            }
-                        }          
-                        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;
-                        if (protectName == "reservedKeyword:human")
-                        {
-                            for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)
-                            {
-                                if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController()))
-                                {
-                                    this->setProtect (static_cast<ControllableEntity*>(*itP));
-                                }
-                            }
-                        }
-                        else
-                        {
-                            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;
-                }
-            }
-            else
-            {
-                this->setTarget(0);
-                this->setTargetPosition(this->getControllableEntity()->getWorldPosition());
-                this->action_ = Action::NONE;
-            }
-        }
-
-    }
-    void CommonController::stayNearProtect()
-    {
-        Vector3* targetRelativePosition;
-        targetRelativePosition = new Vector3 (0, 300, 300);  
-        Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) + 
-            (this->getProtect()->getWorldOrientation()* (*targetRelativePosition)));
-        this->setTargetPosition(targetAbsolutePosition);
-    }
-    void CommonController::nextActionpoint()
-    {
-        if (!this || !this->getControllableEntity())
-            return;
-        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()
-    {
-        if (!this || !this->getControllableEntity())
-            return;
-        // orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;
-        this->startAttackingEnemiesThatAreClose();
-        //No action -> pop one from stack
-        if (this->action_ == Action::NONE || this->bTakenOver_)
-        {
-            if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())
-            {
-                Point p = { Action::FIGHTALL, "", Vector3::ZERO, false };
-                this->parsedActionpoints_.push_back (p);
-            }
-            this->executeActionpoint();
-            this->bTakenOver_ = false;
-        }
-        //Action fightall -> fight till nobody alive
-        if (this->action_ == Action::FIGHTALL)
-        {
-            if (!this->hasTarget())
-            {
-                //----find a target----
-                ControllableEntity* newTarget = this->closestTarget();    
-                if (newTarget)
-                {
-                    this->setAction (Action::FIGHTALL, newTarget);
-                }
-                else
-                {
-                    this->nextActionpoint();
-                    return;
-                }
-            }
-            else if (this->hasTarget())
-            {
-
-            }
-        }
-        //Action fight -> fight as long as enemies in range
-        else if (this->action_ == Action::FIGHT)
-        {
-            if (!this->hasTarget())
-            {
-                //----find a target----
-                ControllableEntity* newTarget = this->closestTarget();    
-                if (newTarget && 
-                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
-                {
-                    this->setAction (Action::FIGHT, newTarget);
-                }
-                else
-                {
-                    this->nextActionpoint();
-                    return;
-                }
-            }
-            else if (this->hasTarget())
-            {
-                //----fly in formation if far enough----
-                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();         
-                    
-                if (diffVector.length() > this->attackRange_)
-                {
-                    ControllableEntity* newTarget = this->closestTarget();
-                    
-                    if (newTarget && 
-                        CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_)
-                    {
-                        this->setAction (Action::FIGHT, newTarget);
-                    }
-                    else
-                    {
-                        this->nextActionpoint();
-                        return;
-                    }
-                }
-            }
-        }
-        else if (this->action_ == Action::FLY)
-        {
-            if (this->squaredDistanceToTarget() <= this->squaredaccuracy_)
-            {
-                this->nextActionpoint();   
-                return;
-            }
-        }
-        else if (this->action_ == Action::PROTECT)
-        {
-            if (!this->getProtect())
-            {
-                this->nextActionpoint(); 
-                return;
-            }
-            this->stayNearProtect();
-        }
-        else if (this->action_ == Action::ATTACK)
-        {   
-            if (!this->hasTarget())
-            {
-                this->nextActionpoint();
-                return;
-            }
-        }
-        if (this->hasTarget())
-        {
-            //----choose where to go----
-            this->maneuver();
-            //----fire if you can----
-            this->bShooting_ = this->canFire();                
-        }
-    }
-    void CommonController::takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b)
-    {
-      this->parsedActionpoints_ = vector;
-      this->loopActionpoints_ = loop;
-      this->bLoop_ = this->bLoop_;
-      this->bTakenOver_ = true;
-      // orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl;
-    }
+
+
+    
     void CommonController::boostControl()
     {
Index: /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	(revision 10863)
+++ /code/branches/campaignHS15/src/orxonox/controllers/CommonController.h	(revision 10864)
@@ -61,20 +61,5 @@
 
     }
-    namespace Action
-    {  
-        enum Value
-        {
-            NONE, FLY, FIGHT, PROTECT, FIGHTALL, ATTACK
-        };
-        
-    }
-    
-    struct Point {
-        Action::Value action;
-        std::string name;
-        Vector3 position;
-        bool inLoop;
-    } ;
-
+   
 
     
@@ -96,14 +81,13 @@
                 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
                 
-                    void setFormationModeXML(std::string val);
-                    std::string getFormationModeXML();
-                    void setFormationMode(FormationMode::Value val);
-                    FormationMode::Value getFormationMode() const;
+                void setFormationModeXML(std::string val);
+                std::string getFormationModeXML();
+                void setFormationMode(FormationMode::Value val);
+                FormationMode::Value getFormationMode() const;
 
-                    void setRank(Rank::Value val);
-                    Rank::Value getRank() const;
-               
-                    void addActionpoint(WorldEntity* waypoint);
-                    WorldEntity* getActionpoint(unsigned int index) const;
+                void setRank(Rank::Value val);
+                Rank::Value getRank() const;
+           
+
             //----[/XML methods]----
 
@@ -115,12 +99,5 @@
                 ControllableEntity* getTarget();
                       
-                Action::Value getAction ();
-                std::string getActionName();
-
-                void setAction (Action::Value action);
-                void setAction (Action::Value action, ControllableEntity* target);
-                void setAction (Action::Value action, const Vector3& target);
-                void setAction (Action::Value action, const Vector3& target,  const Quaternion& orient );
-            //----[/Interaction with other Controllers]----
+             //----[/Interaction with other Controllers]----
 
             //----[Helper methods]----
@@ -135,9 +112,5 @@
             //----[/Helper methods]----
 
-             
-                virtual void stayNearProtect();
-                virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.
-                 virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b);
-   
+  
         protected:
             //----[Flying methods]----
@@ -168,6 +141,4 @@
                 void setOrientationOfTarget(const Quaternion& orient);
 
-                void setProtect (ControllableEntity* protect);
-                ControllableEntity* getProtect (); 
 
                 void maneuver();
@@ -175,7 +146,5 @@
                 bool canFire();
                 void doFire();
-                void setClosestTarget();
-                Pawn* closestTarget();
-                void startAttackingEnemiesThatAreClose();
+
             //----[/Fighting methods]----            
             
@@ -200,25 +169,9 @@
             //----[/who-to-kill information]----
 
-            //----[Actionpoint information]----
 
-                std::vector<WeakPtr<WorldEntity> > actionpoints_;
-                float squaredaccuracy_;
-                std::vector<Point > parsedActionpoints_;
-                std::vector<Point > loopActionpoints_;
-
-            //----[/Actionpoint information]----
-            //----[Actionpoint methods]----
-                void executeActionpoint();
-                void nextActionpoint();
-                void fillLoop();
-                void fillLoopReversed();
-                void moveBackToTop();
-            //----[Actionpoint methods]----
             //----["Private" variables]----
                 FormationMode::Value formationMode_;
                 Rank::Value rank_;
-                std::string protectName_;
-                std::string targetName_;
-                Action::Value action_;
+
                 int attackRange_;
                 bool bLookAtTarget_;        
@@ -227,8 +180,5 @@
                 int tolerance_; 
                 bool bFirstTick_; 
-                bool bInLoop_;
-                bool bLoop_;   
-                bool bEndLoop_;  
-                bool bTakenOver_;              
+            
             //----[/"Private" variables]----    
            
Index: /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10863)
+++ /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc	(revision 10864)
@@ -91,5 +91,5 @@
             return;
         
-        CommonController::action();
+        ActionpointController::action();
         if (!this || !this->getControllableEntity())
             return;
@@ -109,8 +109,8 @@
     void DivisionController::stayNearProtect()
     {
-        CommonController::stayNearProtect();
+        ActionpointController::stayNearProtect();
     }
     
-    bool DivisionController::setWingman(CommonController* cwingman)
+    bool DivisionController::setWingman(ActionpointController* cwingman)
     {
 
Index: /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h	(revision 10863)
+++ /code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h	(revision 10864)
@@ -53,5 +53,5 @@
             //----[own functions]----
                 virtual bool setFollower(LeaderController* myFollower);
-                virtual bool setWingman(CommonController* cwingman);
+                virtual bool setWingman(ActionpointController* cwingman);
                 virtual bool hasWingman();
                 virtual bool hasFollower();
Index: /code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc	(revision 10863)
+++ /code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc	(revision 10864)
@@ -36,5 +36,5 @@
 
     //CommonController contains all common functionality of AI Controllers
-    LeaderController::LeaderController(Context* context) : CommonController(context)
+    LeaderController::LeaderController(Context* context) : ActionpointController(context)
     {
 
Index: /code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h	(revision 10863)
+++ /code/branches/campaignHS15/src/orxonox/controllers/LeaderController.h	(revision 10864)
@@ -30,5 +30,5 @@
 #define _LeaderController_H__
 
-#include "controllers/CommonController.h"
+#include "controllers/ActionpointController.h"
 #include "controllers/WingmanController.h"
 
@@ -38,5 +38,5 @@
 namespace orxonox
 {
-    class _OrxonoxExport LeaderController : public CommonController
+    class _OrxonoxExport LeaderController : public ActionpointController
     {
         public:
Index: /code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	(revision 10863)
+++ /code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc	(revision 10864)
@@ -99,5 +99,5 @@
         {
             
-            CommonController::action();
+            ActionpointController::action();
             if (!this || !this->getControllableEntity())
                 return;
@@ -307,5 +307,5 @@
         return 0;
     }
-    bool SectionController::setWingman(CommonController* cwingman)
+    bool SectionController::setWingman(ActionpointController* cwingman)
     {
         WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
Index: /code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/SectionController.h	(revision 10863)
+++ /code/branches/campaignHS15/src/orxonox/controllers/SectionController.h	(revision 10864)
@@ -53,5 +53,5 @@
                 LeaderController* findNewDivisionLeader();
 
-                virtual bool setWingman(CommonController* cwingman);
+                virtual bool setWingman(ActionpointController* cwingman);
                 virtual bool hasWingman();
 
Index: /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	(revision 10863)
+++ /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc	(revision 10864)
@@ -35,6 +35,6 @@
     RegisterClass(WingmanController);
     
-    //CommonController contains all common functionality of AI Controllers
-    WingmanController::WingmanController(Context* context) : CommonController(context)
+    //ActionpointController contains all common functionality of AI Controllers
+    WingmanController::WingmanController(Context* context) : ActionpointController(context)
     {
         RegisterObject(WingmanController);
@@ -81,5 +81,5 @@
         if (!this->myLeader_)
         {
-            CommonController* newLeader = findNewLeader();
+            ActionpointController* newLeader = findNewLeader();
             this->myLeader_ = newLeader;
            
@@ -92,5 +92,5 @@
         if (!this->myLeader_)
         {
-           CommonController::action();
+           ActionpointController::action();
         }
         else if (this->myLeader_)
@@ -217,5 +217,5 @@
     }
     //----POST: closest leader that is ready to take a new wingman is returned----
-    CommonController* WingmanController::findNewLeader()
+    ActionpointController* WingmanController::findNewLeader()
     {
 
@@ -224,8 +224,8 @@
 
         //----vars for finding the closest leader----
-        CommonController* closestLeader = 0;
+        ActionpointController* closestLeader = 0;
         float minDistance =  std::numeric_limits<float>::infinity();
         Gametype* gt = this->getGametype();
-        for (ObjectList<CommonController>::iterator it = ObjectList<CommonController>::begin(); it; ++it)
+        for (ObjectList<ActionpointController>::iterator it = ObjectList<ActionpointController>::begin(); it; ++it)
         {
             //----0ptr or not a leader or dead?----
Index: /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
===================================================================
--- /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h	(revision 10863)
+++ /code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h	(revision 10864)
@@ -31,10 +31,10 @@
 
 
-#include "controllers/CommonController.h"
+#include "controllers/ActionpointController.h"
 
 
 namespace orxonox
 {
-    class _OrxonoxExport WingmanController : public CommonController
+    class _OrxonoxExport WingmanController : public ActionpointController
     {
         public:
@@ -52,5 +52,5 @@
 
             //----[own functions]----
-               CommonController* findNewLeader();
+               ActionpointController* findNewLeader();
             //----[/own functions]----
 
@@ -62,5 +62,5 @@
         private:
             //----private variables-----
-                WeakPtr<CommonController> myLeader_;
+                WeakPtr<ActionpointController> myLeader_;
                 Timer actionTimer_; //<! Regularly calls action().
                 bool bFirstAction_;
