Index: code/branches/AI_HS15/data/levels/AITest.oxw
===================================================================
--- code/branches/AI_HS15/data/levels/AITest.oxw	(revision 10729)
+++ code/branches/AI_HS15/data/levels/AITest.oxw	(revision 10731)
@@ -32,5 +32,5 @@
 
     <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/>
-    <SpawnPoint team=0 position="1000,1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
+    <SpawnPoint team=0 position="-1000,-1000,-1000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff />
     <!-->
 
Index: code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	(revision 10731)
@@ -35,15 +35,23 @@
     static const float ROTATEFACTOR = 0.2f;
 
-    /*static const float SPEED_FREE = 0.8f;
-    static const float ROTATEFACTOR_FREE = 0.8f;*/
-    
+    CommonController::CommonController(Context* context) : Controller(context)
+    {
+
+        RegisterObject(CommonController);
+    }
+
+
+    CommonController::~CommonController()
+    {
+    }
+
+
+
+
     bool CommonController::setWingman (CommonController* wingman)
     {
         return false;
     }
-    bool CommonController::isLeader ()
-    {
-        return false;
-    }
+   
     bool CommonController::hasWingman()
     {
@@ -51,14 +59,42 @@
     }
 
-    CommonController::CommonController(Context* context) : Controller(context)
-    {
-
-        RegisterObject(CommonController);
-    }
-
-
-    CommonController::~CommonController()
-    {
-    }
+
+
+
+    void CommonController::setTargetPosition(const Vector3& target)
+    {
+        this->targetPosition_ = target;
+        this->bHasTargetPosition_ = true;
+    }
+
+    void CommonController::setTargetOrientation(const Quaternion& orient)
+    {
+        this->targetOrientation_=orient;
+        this->bHasTargetOrientation_=true;
+    }
+
+    void CommonController::setTargetOrientation(ControllableEntity* target)
+    {
+        if (target)
+            setTargetOrientation(target->getOrientation());
+    }
+
+    /*void CommonController::spin()
+    {
+        this->moveToTargetPosition();
+        this->getControllableEntity()->rotateRoll(8.0f);
+    }
+    void CommonController::turn180()
+    {
+        Vector2 coord = get2DViewdirection(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->getControllableEntity()->getOrientation() * WorldEntity::UP, this->targetPosition_);
+
+        this->getControllableEntity()->rotateYaw(-2.0f * sgn(coord.x) * coord.x*coord.x);
+        this->getControllableEntity()->rotatePitch(2.0f * sgn(coord.y) * coord.y*coord.y);
+
+        this->getControllableEntity()->moveFrontBack(SPEED);
+    }*/
+
+
+
     //copy the Roll orientation of given Quaternion.
     void CommonController::copyOrientation(const Quaternion& orient)
@@ -69,14 +105,5 @@
         while(diff<-math::twoPi) diff+=math::twoPi;
         this->getControllableEntity()->rotateRoll(-diff);
-
-
-
-    }
-    void CommonController::setTargetPosition(const Vector3& target)
-    {
-        this->targetPosition_ = target;
-        this->bHasTargetPosition_ = true;
-    }
-
+    }
     void CommonController::copyTargetOrientation()
     {
@@ -86,16 +113,12 @@
         }
     }
-    void CommonController::setTargetOrientation(const Quaternion& orient)
-    {
-        this->targetOrientation_=orient;
-        this->bHasTargetOrientation_=true;
-    }
-    void CommonController::setTargetOrientation(ControllableEntity* target)
-    {
-        if (target)
-            setTargetOrientation(target->getOrientation());
-    }
-
-
+
+
+
+
+    void CommonController::moveToTargetPosition()
+    {
+        this->moveToPosition(this->targetPosition_);
+    }
     void CommonController::moveToPosition(const Vector3& target)
     {
@@ -146,11 +169,33 @@
             bHasTargetOrientation_ = false;
         }
-
-      
-    }
-    void CommonController::moveToTargetPosition()
-    {
-        this->moveToPosition(this->targetPosition_);
-    }
+    }
+    void CommonController::doFire()
+    {
+         if (this->isLookingAtTarget(math::pi / 20.0f))
+            this->getControllableEntity()->fire(0); //ai uses lens flare if they're close enough to the target
+    }
+    bool CommonController::isLookingAtTarget(float angle) const
+    {
+        if (!this->getControllableEntity())
+            return false;
+
+        return (getAngle(this->getControllableEntity()->getPosition(), this->getControllableEntity()->getOrientation() * WorldEntity::FRONT, this->targetPosition_) < angle);
+    }
+
+    void CommonController::aimAtTarget()
+    {
+        if (!this->target_ || !this->getControllableEntity())
+            return;
+
+        static const float hardcoded_projectile_speed = 750;
+
+        Vector3 aimPosition = getPredictedPosition(this->getControllableEntity()->getWorldPosition(), 
+            hardcoded_projectile_speed, this->target_->getWorldPosition(), this->target_->getVelocity());
+
+        Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
+        if (pawn)
+            pawn->setAimPosition(aimPosition);
+    }
+    
  
 
Index: code/branches/AI_HS15/src/orxonox/controllers/CommonController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/CommonController.h	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/controllers/CommonController.h	(revision 10731)
@@ -33,4 +33,6 @@
 #include "controllers/Controller.h"
 #include "worldentities/ControllableEntity.h"
+#include "worldentities/pawns/Pawn.h"
+
 
 namespace orxonox
@@ -39,7 +41,14 @@
     {
         public:
+
             static const float ACTION_INTERVAL = 1.0f;
 
-            enum FormationMode {VEE,FINGER4,DIAMOND, WALL};
+
+            CommonController(Context* context);
+            virtual ~CommonController();
+
+
+
+            enum FormationMode { VEE, FINGER4, DIAMOND, WALL };
             virtual void setFormationMode(FormationMode val)
                 { this->formationMode_ = val; }
@@ -47,7 +56,13 @@
                 { return this->formationMode_; }
 
-            CommonController(Context* context);
-            virtual ~CommonController();
-            virtual bool isLeader();
+            enum Rank { NONE, SECTIONLEADER, DIVISIONLEADER, WINGMAN };
+            virtual void setRank(Rank val)
+                { this->rank_ = val; }
+            inline Rank getRank() const
+                { return this->rank_; }
+
+
+
+
             virtual bool setWingman(CommonController* wingman);
             virtual bool hasWingman();
@@ -58,13 +73,20 @@
             void setTargetPosition(const Vector3& target);
 
+            /*void spin();
+            void turn180();*/
+
+
         protected:
+
             void moveToPosition(const Vector3& target);
-            virtual void positionReached() {}
+            void moveToTargetPosition();
 
-       
-            void moveToTargetPosition();
+
             void copyOrientation(const Quaternion& orient);
             void copyTargetOrientation();
 
+            void doFire();
+            void aimAtTarget();
+            bool isLookingAtTarget(float angle) const;
 
             bool bHasTargetPosition_;
@@ -73,9 +95,11 @@
             Quaternion targetOrientation_;
 
+
             WeakPtr<ControllableEntity> target_;
             bool bShooting_;
 
+
             FormationMode formationMode_;
-
+            Rank rank_;
 
 
Index: code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	(revision 10731)
@@ -40,11 +40,11 @@
         this->setFormationMode(WALL);
 
-        bIsDivisionLeader_ = true;
         this->myFollower_ = 0;
         this->myWingman_ = 0;
         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));
-       
-        /*Vector3* pos = new Vector3(500,500,-500);
-        this->setTargetPosition(*pos);*/
+        this->rank_ = DIVISIONLEADER;
+
+        Vector3* pos = new Vector3(500,500,-500);
+        this->setTargetPosition(*pos);
 
     }
@@ -54,6 +54,14 @@
       
     } 
+
+    
     void DivisionController::tick(float dt)
     {
+        if (this->target_)
+        {
+            this->aimAtTarget();
+            this->doFire();
+        }
+     
         if (this->bHasTargetPosition_)
         {
@@ -68,18 +76,19 @@
         setTargetPositionOfFollower();
         setTargetPositionOfWingman();
-    }
-
-    bool DivisionController::setFollower(LeaderController* myFollower)
-    {
-         if (!this->myFollower_)
-        {
-            this->myFollower_ = myFollower;
-            return true;
-        }
-        else
-        {
-            return false;
-        }
-    }
+
+        for (ObjectList<Controller>::iterator it = ObjectList<Controller>::begin(); it; ++it)
+        {
+            if (this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam())
+            {
+                this->target_=it->getControllableEntity();
+                this->setTargetPosition(this->target_->getWorldPosition());
+                break;
+            } 
+        }
+           
+      
+    }
+
+    
 
     void DivisionController::setTargetPositionOfWingman()
@@ -149,4 +158,49 @@
        
     }
+
+
+    bool DivisionController::setWingman(CommonController* cwingman)
+    {
+
+        WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
+        if (!this->myWingman_)
+        {
+            this->myWingman_ = wingman;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    
+    }
+    bool DivisionController::setFollower(LeaderController* myFollower)
+    {
+         if (!this->myFollower_)
+        {
+            this->myFollower_ = myFollower;
+            return true;
+        }
+        else
+        {
+            return false;
+        }
+    }
+    bool DivisionController::hasWingman()
+    {
+        if (this->myWingman_)
+            return true;
+        else
+            return false;
+    }
+    bool DivisionController::hasFollower()
+    {
+        if (this->myFollower_)
+            return true;
+        else
+            return false;
+    }
+
+
     void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
Index: code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/controllers/DivisionController.h	(revision 10731)
@@ -42,51 +42,27 @@
       {
         public:
+
         	DivisionController(Context* context);
         	virtual ~DivisionController();
 
-        	virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+            virtual void tick(float dt); //<! Carrying out the targets set in action().
 
-        	//Using british military aircraft formations
-        	
      		
 			virtual bool setFollower(LeaderController* myFollower);
-			virtual bool setWingman(CommonController* cwingman)
-            {
-                WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
-                if (!this->myWingman_)
-                {
-                    this->myWingman_ = wingman;
-                    return true;
-                }
-                else
-                {
-                    return false;
-                }
-            };
-            virtual bool hasWingman()
-            {
-                if (this->myWingman_)
-                    return true;
-                else
-                    return false;
-            }
-            virtual bool hasFollower()
-            {
-                if (this->myFollower_)
-                    return true;
-                else
-                    return false;
-            };
-            
+			virtual bool setWingman(CommonController* cwingman);
+            virtual bool hasWingman();
+            virtual bool hasFollower();
 
-            virtual void tick(float dt); //<! Carrying out the targets set in action().
-
+            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);          
 
         protected:
+            
             void setTargetPositionOfWingman();
             void setTargetPositionOfFollower();
+
             virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
 	    
         private:
+
             Timer actionTimer_; //<! Regularly calls action().
 
Index: code/branches/AI_HS15/src/orxonox/controllers/FleetController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/FleetController.cc	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/controllers/FleetController.cc	(revision 10731)
@@ -43,6 +43,5 @@
       /*  this->goalTarget_ = NULL;
         this->goalProtect_ = NULL;*/
-        this->nTicks_ = 0;
-        this->bTicked_ = false;
+        
         //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&FleetController::action, this)));
     }
@@ -63,85 +62,4 @@
     {
 
-         /*if (nTicks_ == 30)
-         {
-            std::vector<WeakPtr<WingmanController> > wingmen;
-            std::vector<WeakPtr<LeaderController> > leaders;
-
-            //--------------------------Put all WingmanController's in a vector--------------------------
-            for (ObjectList<WingmanController>::iterator it = ObjectList<WingmanController>::begin(); it; ++it)
-            {
-
-               
-                if ((*it)->getTeam() == this->getTeam())
-                {
-                    orxout(internal_error) << "ANOTHER SUCKER" << endl;
-                    wingmen.push_back(*it);
-                } 
-                
-            }
-            //--------------------------Substitute half of WingmanController's with LeaderController--------------------------
-
-            bool nowLeader = true;
-            LeaderController* leader;
-
-            for (std::vector<WeakPtr<WingmanController> >::iterator it = wingmen.begin() ; it != wingmen.end(); ++it)
-            {
-                if (nowLeader)
-                {
-                    leader = new LeaderController(this->getContext());
-                    leader->setTeam(this->team_);
-
-                    (*it)->getControllableEntity()->setController(leader);
-                    leaders.push_back(leader);
-                    nowLeader = !nowLeader;
-                    orxout(internal_error) << "NEW SUCKER" << endl;
-
-                }
-                else
-                {
-                    if (leader)
-                    {
-                        leader->setWingman(*it);
-                        nowLeader = !nowLeader;
-                        orxout(internal_error) << "I OWN THE SUCKER" << endl;
-
-                    }
-                }
-            }
-
-            //--------------------------Substitute half of LeaderController's with DivisionController--------------------------
-            bool nowDivision = true;
-            DivisionController* division;
-
-            for (std::vector<WeakPtr<LeaderController> >::iterator it = leaders.begin() ; it != leaders.end(); ++it)
-            {
-                if (nowDivision)
-                {
-                    division = new DivisionController(this->getContext());
-                    division->setTeam(this->team_);
-
-                    (*it)->getControllableEntity()->setController(division);
-
-                    divisions_.push_back(division);
-
-                    nowDivision = !nowDivision;
-                }
-                else
-                {
-                    if (division)
-                    {
-                        division->setLeader(*it);
-                        nowDivision = !nowDivision;
-                    }
-                }
-            }
-            bTicked_ = true;
-            nTicks_ += 1;
-         }
-         else if (!bTicked_)
-         {
-            nTicks_ += 1;
-
-         }*/
         SUPER(FleetController, tick, dt);
 
Index: code/branches/AI_HS15/src/orxonox/controllers/FleetController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/FleetController.h	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/controllers/FleetController.h	(revision 10731)
@@ -83,7 +83,5 @@
             virtual void action();
         private:
-            int nTicks_;
-            bool bTicked_;
-
+        
             std::vector<WeakPtr<DivisionController> > divisions_;
             //Timer actionTimer_; //<! Regularly calls action().
Index: code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/controllers/LeaderController.h	(revision 10731)
@@ -45,21 +45,16 @@
             LeaderController(Context* context);
             virtual ~LeaderController();
-            virtual bool isLeader()
-            {
-                return true;
-            };
-            bool bIsDivisionLeader_;
+           
             virtual bool setFollower(LeaderController* myFollower)
-            {
-                return false;
-            };
-            virtual bool bIsDivisionLeader()
-            {
-                return bIsDivisionLeader_;
-            };
+                { return false; }
+           
             virtual bool hasFollower()
-            {
-                return true;
-            };
+                { return true; }
+            
+
+
+
+        protected:
+         
             WeakPtr<WingmanController> myWingman_;
 
@@ -67,7 +62,5 @@
             WeakPtr<LeaderController> myDivisionLeader_;
 
-
-        protected:
-         
+            
         private:
             
Index: code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc	(revision 10731)
@@ -39,8 +39,8 @@
         this->setFormationMode(WALL);
 
-        bIsDivisionLeader_ = false;
         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&SectionController::action, this)));
         this->myWingman_ = 0;
         this->myDivisionLeader_ = 0;
+        this->rank_ = SECTIONLEADER;
 
         orxout(internal_error) << this << "Was created" << endl;
@@ -52,4 +52,34 @@
        
     }
+
+    void SectionController::tick(float dt)
+    {
+        if (!this->isActive())
+            return;
+        
+        if (this->bHasTargetPosition_)
+        {
+            this->moveToTargetPosition();
+        }
+
+        
+        SUPER(SectionController, tick, dt);
+    }
+
+    void SectionController::action()
+    {
+        //this->target_ = this->sectionTarget_;        
+        if (!myDivisionLeader_)
+        {
+            LeaderController* newDivisionLeader = findNewDivisionLeader();
+            this->myDivisionLeader_ = newDivisionLeader;
+            if (newDivisionLeader)
+                orxout(internal_error) << "new DivisionLeader set" << endl;
+
+        }
+        setTargetPositionOfWingman();
+
+    }
+    
     void SectionController::setTargetPositionOfWingman()
     {
@@ -85,5 +115,4 @@
        
     }
-
     LeaderController* SectionController::findNewDivisionLeader()
     {
@@ -98,5 +127,5 @@
         {
             //0ptr or not DivisionController?
-            if (!(it) || !(it)->bIsDivisionLeader_ || !(it->getControllableEntity()))
+            if (!(it) || !((it)->getRank() == DIVISIONLEADER) || !(it->getControllableEntity()))
                 continue;
             //same team?
@@ -126,48 +155,26 @@
 
     }
+    bool SectionController::setWingman(CommonController* cwingman)
+    {
+        WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
 
-    void SectionController::action()
-    {
-        //this->target_ = this->sectionTarget_;        
-        if (!myDivisionLeader_)
+        if (!this->myWingman_)
         {
-            LeaderController* newDivisionLeader = findNewDivisionLeader();
-            this->myDivisionLeader_ = newDivisionLeader;
-            if (newDivisionLeader)
-                orxout(internal_error) << "new DivisionLeader set" << endl;
-
+            this->myWingman_ = wingman;
+            return true;
         }
-        setTargetPositionOfWingman();
-
-    }
-    /*
-    Wingmen and Leaders attack target_, which is a member variable of their classes.
-    Wingmen's target_ is set to sectionTarget_, which is a member variable of SectionController class, unless
-    Wingman covers Leader's rear.
-    Leader's target_ must always equal sectionTarget_.
-    if section has a target, its Leader shoots at it, but doesn't follow.
-    Every section is a part of division. Division consisting of one Section is still a division.
-    Division's leader's target_ must always equal divisionTarget_, which is a member variable of DivisionController.
-    Division leader ONLY can follow target_ while in formation flight.
-    If Division doesn't have a target, Division Leader stays in place, unless it has a waypoint.
-    Division Leader's sectionTarget_ must equal divisionTarget_,
-    but the other section, that is not a leading section, can attack any target that is near divisonTarget_
-
-    */
-    
-    void SectionController::tick(float dt)
-    {
-        if (!this->isActive())
-            return;
-        
-        if (this->bHasTargetPosition_)
+        else
         {
-            this->moveToTargetPosition();
+            return false;
         }
-
-        
-        SUPER(SectionController, tick, dt);
     }
     
+    bool SectionController::hasWingman()
+    {
+        if (this->myWingman_)
+            return true;
+        else
+            return false;
+    }
 
     void SectionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
Index: code/branches/AI_HS15/src/orxonox/controllers/SectionController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/SectionController.h	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/controllers/SectionController.h	(revision 10731)
@@ -40,49 +40,25 @@
     {
         public:
+
             SectionController(Context* context);
             virtual ~SectionController();
-            virtual bool setWingman(CommonController* cwingman)
-            {
-                WeakPtr<WingmanController> wingman = orxonox_cast<WingmanController*>(cwingman);
+            
+            virtual void tick(float dt); //<! Carrying out the targets set in action().
+            
 
-                if (!this->myWingman_)
-                {
-                    this->myWingman_ = wingman;
-                    return true;
-                }
-                else
-                {
-                    return false;
-                }
-            }
-
-
-            virtual bool hasWingman()
-            {
-                if (this->myWingman_)
-                    return true;
-                else
-                    return false;
-            }
-
-            virtual void tick(float dt); //<! Carrying out the targets set in action().
-
+            LeaderController* findNewDivisionLeader();
+            virtual bool setWingman(CommonController* cwingman);
+            virtual bool hasWingman();
+            
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
-            LeaderController* findNewDivisionLeader();
 
         protected:
+
             void setTargetPositionOfWingman();
-            //A division is the biggest block of spaceships.
-            //In division one section is leading, the other one always stays on the same position
-            //relative to the Leader of the leading section.
-            //In section a Wingman always stays on same position relative to the Leader.
-            //That position is desiredRelativePosition_
+            
             virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour ~ setting targets.
 
+        private:
 
-           
-
-        
-        private:
             Timer actionTimer_; //<! Regularly calls action().
             
Index: code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/controllers/WingmanController.cc	(revision 10731)
@@ -41,4 +41,6 @@
         this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));
         this->myLeader_ = 0;
+        this->rank_ = WINGMAN;
+
     }
 
@@ -48,100 +50,4 @@
     }
 
-    CommonController* WingmanController::findNewLeader()
-    {
-
-        if (!this->getControllableEntity())
-            return 0;
-
-        CommonController* closestLeader = 0;
-        float minDistance =  std::numeric_limits<float>::infinity();
-
-        for (ObjectList<CommonController>::iterator it = ObjectList<CommonController>::begin(); it; ++it)
-        {
-            //0ptr?
-            if (!it || !it->isLeader() || !(it->getControllableEntity()))
-                continue;
-            //same team?
-            if (this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam())
-                continue;
-            //is equal to this?
-            if (it->getControllableEntity() == this->getControllableEntity())
-                continue;
-
-            float distance = (it->getControllableEntity()->getPosition() - this->getControllableEntity()->getPosition()).length();
-            if (distance < minDistance && !(it->hasWingman()))
-            {
-                closestLeader = *it;
-                minDistance = distance;
-            }
-           
-        }
-        if (closestLeader)
-        {
-            if (closestLeader->setWingman(this))
-                return closestLeader;
-        }
-        return 0;
-    }
-    
-    void WingmanController::action()
-    {
-        if (!this->myLeader_)
-        {
-            CommonController* newLeader = findNewLeader();
-            this->myLeader_ = newLeader;
-            if (newLeader)
-                orxout(internal_error) << "new Leader set" << endl;
-            else
-                orxout(internal_error) << "0 leader" << endl;
-
-        }
-        else
-        {
-
-        }
-    }
- /*//collect data for AI behaviour
-            Vector3* meanOfEnemiesPtr = new Vector3(0.0,0.0,0.0);
-            Vector3* meanOfAlliesPtr  = new Vector3(0.0,0.0,0.0);
-            Vector3 meanOfAllies = *meanOfAlliesPtr;
-            Vector3 meanOfEnemies = *meanOfEnemiesPtr;
-
-
-            for (ObjectList<AIController>::iterator it = ObjectList<AIController>::begin(); it; ++it)
-            {
-
-                Gametype* gt=this->getGametype();
-                if (!gt)
-                {
-                    gt=it->getGametype();
-                }
-                if (!FormationController::sameTeam(this->getControllableEntity(), it->getControllableEntity(),gt))
-                {
-                    enemies_.push_back(*it);
-                } 
-                else {
-                    allies_.push_back(*it);
-                } 
-            }
-            if (enemies_.size() != 0 && allies_.size() != 0){
-                for (std::vector<WeakPtr<AIController> >::iterator it = enemies_.begin() ; it != enemies_.end(); ++it)
-                    meanOfEnemies += (*it)->getControllableEntity()->getWorldPosition();
-
-                meanOfEnemies /= enemies_.size();
-
-                for (std::vector<WeakPtr<AIController> >::iterator it = allies_.begin() ; it != allies_.end(); ++it)
-                    meanOfAllies += (*it)->getControllableEntity()->getWorldPosition();
-
-                meanOfAllies /= allies_.size();
-
-                //orxout(internal_error) << "There are " << enemies_Counter << " enemies_, mean position is " << meanOfEnemies << endl;
-                orxout(internal_error) << "Distance is " << (meanOfEnemies-meanOfAllies).length() << endl;
-                orxout(internal_error) << "mean of allies_ is " << meanOfAllies << ", with a size " << allies_.size() << endl;
-                orxout(internal_error) << "mean of enemies_ is " << meanOfEnemies << ", with a size " << enemies_.size() << endl;
-            }*/
-
-     
-   
     void WingmanController::tick(float dt)
     {   
@@ -172,4 +78,64 @@
         SUPER(WingmanController, tick, dt);
     }
+    
+    void WingmanController::action()
+    {
+        if (!this->myLeader_)
+        {
+            CommonController* newLeader = findNewLeader();
+            this->myLeader_ = newLeader;
+            if (newLeader)
+                orxout(internal_error) << "new Leader set" << endl;
+            else
+                orxout(internal_error) << "0 leader" << endl;
+
+        }
+        else
+        {
+
+        }
+    }
+     
+   
+    
+
+    CommonController* WingmanController::findNewLeader()
+    {
+
+        if (!this->getControllableEntity())
+            return 0;
+
+        CommonController* closestLeader = 0;
+        float minDistance =  std::numeric_limits<float>::infinity();
+
+        for (ObjectList<CommonController>::iterator it = ObjectList<CommonController>::begin(); it; ++it)
+        {
+            //0ptr?
+            if (!it || 
+                (it->getRank() != SECTIONLEADER && it->getRank() != DIVISIONLEADER) || 
+                !(it->getControllableEntity()))
+                continue;
+            //same team?
+            if (this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam())
+                continue;
+            //is equal to this?
+            if (it->getControllableEntity() == this->getControllableEntity())
+                continue;
+
+            float distance = (it->getControllableEntity()->getPosition() - this->getControllableEntity()->getPosition()).length();
+            if (distance < minDistance && !(it->hasWingman()))
+            {
+                closestLeader = *it;
+                minDistance = distance;
+            }
+           
+        }
+        if (closestLeader)
+        {
+            if (closestLeader->setWingman(this))
+                return closestLeader;
+        }
+        return 0;
+    }
 
     void WingmanController::XMLPort(Element& xmlelement, XMLPort::Mode mode)
Index: code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/controllers/WingmanController.h	(revision 10731)
@@ -47,9 +47,5 @@
             WingmanController(Context* context);
             virtual ~WingmanController();
-            virtual bool isLeader()
-            {
-                return false;
-            };
-
+           
             virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
             virtual void tick(float dt); //<! Carrying out the targets set in action().
Index: code/branches/AI_HS15/src/orxonox/worldentities/pawns/Pawn.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/worldentities/pawns/Pawn.cc	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/worldentities/pawns/Pawn.cc	(revision 10731)
@@ -320,4 +320,5 @@
     }
 
+
     void Pawn::death()
     {
@@ -325,7 +326,6 @@
         if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_))
         {
-            // Set bAlive_ to false and wait for destroyLater() to do the destruction
+            // Set bAlive_ to false and wait for PawnManager to do the destruction
             this->bAlive_ = false;
-            this->destroyLater();
 
             this->setDestroyWhenPlayerLeft(false);
@@ -367,5 +367,5 @@
             if (GameMode::isMaster())
             {
-                this->deatheffect();
+//                this->deathEffect();
                 this->goWithStyle();
             }
@@ -387,5 +387,5 @@
     {
         // play death effect
-        /*{
+        {
             ParticleSpawner* effect = new ParticleSpawner(this->getContext());
             effect->setPosition(this->getPosition());
@@ -410,58 +410,5 @@
             effect->setSource("Orxonox/sparks");
             effect->setLifetime(4.0f);
-        }*/
-        
-        
-        {
-            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
-            effect->setPosition(this->getPosition());
-            effect->setOrientation(this->getOrientation());
-            effect->setDestroyAfterLife(true);
-            effect->setSource("orxonox/explosion_flash2");
-            effect->setLifetime(5.0f);
-        }
-        {
-            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
-            effect->setPosition(this->getPosition());
-            effect->setOrientation(this->getOrientation());
-            effect->setDestroyAfterLife(true);
-            effect->setSource("orxonox/explosion_flame2");
-            effect->setLifetime(5.0f);
-        }
-        {
-            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
-            effect->setPosition(this->getPosition());
-            effect->setOrientation(this->getOrientation());
-            effect->setDestroyAfterLife(true);
-            effect->setSource("orxonox/explosion_shockwave2");
-            effect->scale(20);
-            effect->setLifetime(5.0f);
-        }{
-            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
-            effect->setPosition(this->getPosition());
-            effect->setOrientation(this->getOrientation());
-            effect->setDestroyAfterLife(true);
-            effect->setSource("orxonox/explosion_sparks2");
-            effect->setLifetime(5.0f);
-        }
-        {
-            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
-            effect->setPosition(this->getPosition());
-            effect->setOrientation(this->getOrientation());
-            effect->setDestroyAfterLife(true);
-            effect->setSource("orxonox/explosion_streak2");
-            effect->setLifetime(5.0f);
-        }
-        {
-            ParticleSpawner* effect = new ParticleSpawner(this->getContext());
-            effect->setPosition(this->getPosition());
-            effect->setOrientation(this->getOrientation());
-            effect->setDestroyAfterLife(true);
-            effect->setSource("orxonox/explosion_afterglow");
-            effect->scale(20);
-            effect->setLifetime(5.0f);
-        }
-        
-        
+        }
         for (unsigned int i = 0; i < this->numexplosionchunks_; ++i)
         {
Index: code/branches/AI_HS15/src/orxonox/worldentities/pawns/Pawn.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/worldentities/pawns/Pawn.h	(revision 10729)
+++ code/branches/AI_HS15/src/orxonox/worldentities/pawns/Pawn.h	(revision 10731)
@@ -39,17 +39,5 @@
 
 namespace orxonox // tolua_export
-{
-    /**
-    @brief
-        Everything in Orxonoy that has a health attribute is a Pawn. After a Pawn is spawned its health is set to
-        its initial health. In every call of the Pawns tick function the game checks whether the pawns health is at
-        or below zero. If it is, the pawn gets killed.
-
-        Pawns can carry pickups and fire weapons. The can also have shields.
-
-        Notice that every Pawn is a ControllableEntity.
-    */
-
-    // tolua_export
+{ // tolua_export
     class _OrxonoxExport Pawn // tolua_export
         : public ControllableEntity, public RadarViewable, public PickupCarrier
