Index: code/branches/AI_HS15/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/ArtificialController.cc	(revision 10731)
+++ code/branches/AI_HS15/src/orxonox/controllers/ArtificialController.cc	(revision 10737)
@@ -82,4 +82,6 @@
     void ArtificialController::changedControllableEntity()
     {
+        FormationController::changedControllableEntity(); // super
+
         if (!this->getControllableEntity())
             this->removeFromFormation();
Index: code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	(revision 10731)
+++ code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	(revision 10737)
@@ -27,4 +27,12 @@
  */
 #include "controllers/CommonController.h"
+/*
+#include "weaponsystem/WeaponMode.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponSlot.h"
+#include "weaponsystem/WeaponSlot.h"
+#include "worldentities/pawns/SpaceShip.h"
+*/
 
 namespace orxonox
@@ -37,4 +45,5 @@
     CommonController::CommonController(Context* context) : Controller(context)
     {
+        //this->bSetupWorked = false;
 
         RegisterObject(CommonController);
@@ -170,8 +179,72 @@
         }
     }
+
+/*
+    int CommonController::getFiremode(std::string name)
+    {
+        for (std::map< std::string, int >::iterator it = this->weaponModes_.begin(); it != this->weaponModes_.end(); ++it)
+        {
+            if (it->first == name)
+                return it->second;
+        }
+        return -1;
+    }
+    bool CommonController::isCloseAtTarget(float distance) const
+    {
+        if (!this->getControllableEntity())
+            return false;
+
+        if (!this->target_)
+            return (this->getControllableEntity()->getPosition().squaredDistance(this->targetPosition_) < distance*distance);
+        else
+            return (this->getControllableEntity()->getPosition().squaredDistance(this->target_->getPosition()) < distance*distance);
+    }
+    void CommonController::setupWeapons() //TODO: Make this function generic!! (at the moment is is based on conventions)
+    {
+        this->bSetupWorked = false;
+        if(this->getControllableEntity())
+        {
+            Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity());
+            if(pawn && pawn->isA(Class(SpaceShip))) //fix for First Person Mode: check for SpaceShip
+            {
+                this->weaponModes_.clear(); // reset previous weapon information
+                WeaponSlot* wSlot = 0;
+                for(int l=0; (wSlot = pawn->getWeaponSlot(l)) ; l++)
+                {
+                    WeaponMode* wMode = 0;
+                    for(int i=0; (wMode = wSlot->getWeapon()->getWeaponmode(i)) ; i++)
+                    {
+                        std::string wName = wMode->getIdentifier()->getName();
+                        if(this->getFiremode(wName) == -1) //only add a weapon, if it is "new"
+                            weaponModes_[wName] = wMode->getMode();
+                    }
+                }
+                if(weaponModes_.size())//at least one weapon detected
+                    this->bSetupWorked = true;
+            }//pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user);
+        }
+    }
     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
+        if(!this->bSetupWorked)//setup: find out which weapons are active ! hard coded: laser is "0", lens flare is "1", ...
+        {
+            this->setupWeapons();
+        }
+        else if(this->getControllableEntity() && 
+            weaponModes_.size()&&
+            this->bShooting_ && 
+            this->isCloseAtTarget((3)*1000) && 
+            this->isLookingAtTarget(math::pi / 20.0f))
+        {
+            int firemode;
+            float random = rnd(1);//
+            if (this->isCloseAtTarget(130) && (firemode = getFiremode("LightningGun")) > -1 )
+            {//LENSFLARE: short range weapon
+                this->getControllableEntity()->fire(firemode); //ai uses lens flare if they're close enough to the target
+            }
+           
+            else if ((firemode = getFiremode("HsW01")) > -1 ) //LASER: default weapon
+                this->getControllableEntity()->fire(firemode);
+        }
     }
     bool CommonController::isLookingAtTarget(float angle) const
@@ -196,5 +269,5 @@
         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 10731)
+++ code/branches/AI_HS15/src/orxonox/controllers/CommonController.h	(revision 10737)
@@ -33,6 +33,6 @@
 #include "controllers/Controller.h"
 #include "worldentities/ControllableEntity.h"
-#include "worldentities/pawns/Pawn.h"
-
+/*#include "worldentities/pawns/Pawn.h"
+*/
 
 namespace orxonox
@@ -81,12 +81,23 @@
             void moveToPosition(const Vector3& target);
             void moveToTargetPosition();
+            //enum Mode {ROCKET, ATTACK, MOVE, HOLD};//TODO; implement DEFENCE, MOVING modes
 
-
+            //Mode mode_;
             void copyOrientation(const Quaternion& orient);
             void copyTargetOrientation();
 
+          /*  bool isCloseAtTarget(float distance) const;
             void doFire();
             void aimAtTarget();
             bool isLookingAtTarget(float angle) const;
+
+
+            std::map<std::string, int> weaponModes_; //<! Links each "weapon" to it's weaponmode - managed by setupWeapons()
+            //std::vector<int> projectiles_; //<! Displays amount of projectiles of each weapon. - managed by setupWeapons()
+            float timeout_; //<! Timeout for rocket usage. (If a rocket misses, a bot should stop using it.)
+            void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed.
+            bool bSetupWorked; //<! If false, setupWeapons() is called.
+            int getFiremode(std::string name);
+*/
 
             bool bHasTargetPosition_;
Index: code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	(revision 10731)
+++ code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	(revision 10737)
@@ -60,6 +60,7 @@
         if (this->target_)
         {
-            this->aimAtTarget();
-            this->doFire();
+            //this->aimAtTarget();
+            //this->doFire();
+            //this->bShooting_ = true;
         }
      
@@ -76,5 +77,5 @@
         setTargetPositionOfFollower();
         setTargetPositionOfWingman();
-
+/*
         for (ObjectList<Controller>::iterator it = ObjectList<Controller>::begin(); it; ++it)
         {
@@ -85,5 +86,5 @@
                 break;
             } 
-        }
+        }*/
            
       
Index: code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc	(revision 10731)
+++ code/branches/AI_HS15/src/orxonox/controllers/FormationController.cc	(revision 10737)
@@ -1087,3 +1087,11 @@
     }
 
+    void FormationController::changedControllableEntity()
+    {
+        Controller::changedControllableEntity(); // super
+
+        // when changing the controllable entity, ensure that the controller does not use the new entity as target
+        if (this->target_ && this->getControllableEntity() == static_cast<ControllableEntity*>(this->target_))
+            this->forgetTarget();
+    }
 }
Index: code/branches/AI_HS15/src/orxonox/controllers/FormationController.h
===================================================================
--- code/branches/AI_HS15/src/orxonox/controllers/FormationController.h	(revision 10731)
+++ code/branches/AI_HS15/src/orxonox/controllers/FormationController.h	(revision 10737)
@@ -99,4 +99,6 @@
       FormationController* getSlave( void ) { return this->slaves_.back(); }
 
+      virtual void changedControllableEntity();
+
   protected:
       bool formationFlight_;
