Index: code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	(revision 10885)
+++ code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc	(revision 10886)
@@ -45,5 +45,5 @@
     FightingController::FightingController( Context* context ): FlyingController( context )
     {
-    	this->attackRange_ = 3000;
+    	this->attackRange_ = 2500;
         this->stopLookingAtTarget();
         this->bSetupWorked = false;
@@ -126,22 +126,23 @@
         float diffLength = diffVector.length();
         Vector3 diffUnit = diffVector/diffLength;
-        bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/20.0f);
-        
+        bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/15.0f)
+            || this->deltaHp < 0;
+
         //too far? well, come closer then
         if (diffLength > this->attackRange_)
         {
-            this->spread_ = 300;
-            this->formationMode_ = FormationMode::WALL;
+            this->spread_ = 400;
+            this->formationMode_ = FormationMode::DIAMOND;
             this->bKeepFormation_ = true;
             
-            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);
+            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
         }
         //too close? How do u expect to dodge anything? Just attack!
-        else if (diffLength < 500)
+        else if (diffLength < 400)
         {   
             this->bKeepFormation_ = false;
 
             //at this point, just look and shoot
-            if (diffLength < 250)
+            if (diffLength < 200)
             {
                 this->stopMoving();
@@ -150,5 +151,5 @@
             else
             {
-                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);
+                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
             }
         }
@@ -157,5 +158,5 @@
         {
             this->bKeepFormation_ = false;
-            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);
+            this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f);
         }
         //That's unfortunate, he is looking and probably shooting... try to dodge what we can...  
@@ -165,5 +166,5 @@
             if (maneuverCounter_ == 0)
             {
-                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);   
+                this->setTargetPosition(this->positionOfTarget_ - diffUnit * 50.0f);   
                 return;
             }
@@ -176,8 +177,8 @@
         //d.x*x + d.y*y + d.z*z == 0
         //z = 1/d.z * (-d.y*y - d.x * x)
-        float x = CommonController::randomInRange (1000, 10000) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
-        float y = CommonController::randomInRange (1000, 10000) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
+        float x = CommonController::randomInRange (100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
+        float y = CommonController::randomInRange (100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);
         float z = (1/diffUnit.z) * (-x * diffUnit.x - y * diffUnit.y);
-        this->setTargetPosition(thisPosition + Vector3(x,y,z) + diffUnit * 1000.0f);
+        this->setTargetPosition(thisPosition + Vector3(x,y,z) + (this->deltaHp < 0 ? -diffUnit * 450.0f : diffUnit * 100.0f));
         this->boostControl();
 
@@ -195,4 +196,5 @@
             this->setPositionOfTarget(newPositionOfTarget);
         }
+
         return squaredDistanceToTarget() < this->attackRange_*this->attackRange_ && this->isLookingAtTarget(math::pi / 20.0f);
     }
@@ -270,8 +272,10 @@
             return;
         }
+
         Pawn* pawn = orxonox_cast<Pawn*> (this->getControllableEntity());
         if (pawn)
             pawn->setAimPosition (this->positionOfTarget_);
-
+        // if (pawn->getHealth() < 100)
+        //     orxout(internal_error) << "not full, hp = " << pawn->getHealth() << endl;
         int firemode;
         float distance = CommonController::distance (this->getControllableEntity(), this->target_);
@@ -281,45 +285,46 @@
         //                                                      : getFiremode("HsW01")) : 
         //                                                      (distance < 2500 ? getFiremode("LightningGun") : getFiremode("HsW01"));
-        if (distance < 800)
-        {
-            if (this->rocketsLeft_ > 0)
-            {
-                firemode = getFiremode ("SimpleRocketFire");
+        if (distance < 1500)
+        {
+            if (this->rocketsLeft_ > 0 && !this->bFiredRocket_)
+            {
+                firemode = getFiremode ("RocketFire");
             }
             else
             {
-                if (distance > 450)
+                if (distance > 800)
+                    firemode = getFiremode ("HsW01");
+                else
                     firemode = getFiremode ("LightningGun");
-                else
-                    firemode = getFiremode ("HsW01");
             }
 
         } 
-        else if (distance < 1200)
-        {
-            if (this->rocketsLeft_ > 0 && !this->bFiredRocket_)
-            {
-                firemode = getFiremode ("RocketFire");
-            }
-            else
-            {
-                firemode = getFiremode ("HsW01");
-            }
-        }
-        else if (distance < 1500)
+        // else if (distance < 1000)
+        // {
+        //     if (this->rocketsLeft_ > 0 && !this->bFiredRocket_)
+        //     {
+        //         firemode = getFiremode ("RocketFire");
+        //     }
+        //     else
+        //     {
+        //         firemode = getFiremode ("HsW01");
+        //     }
+        // }
+        else if (distance < 2000)
+        {
+            firemode = getFiremode ("HsW01");
+        }
+        else
         {
             firemode = getFiremode ("LightningGun");
         }
-        else
-        {
-            firemode = getFiremode ("HsW01");
-        }
         if (firemode < 0)
         {
-            firemode = getFiremode ("HsW01");
+            //assuming there is always some weapon with index 0
+            firemode = 0;
         }
         if (firemode == getFiremode("RocketFire"))
         {
-            this->timeout_ = 1.0f;
+            this->timeout_ = 0.5f;
             this->rocketsLeft_--;
             this->bFiredRocket_ = true;
