Index: code/branches/ai/data/levels/templates/pickup_representation_templates.oxt
===================================================================
--- code/branches/ai/data/levels/templates/pickup_representation_templates.oxt	(revision 6986)
+++ code/branches/ai/data/levels/templates/pickup_representation_templates.oxt	(revision 6991)
@@ -110,5 +110,5 @@
 
 <Template name=droneTemplate>
-    <Drone name="meineDrohne"  mass= "50" linearDamping = "0.7" angularDamping = "0.9999999" primaryThrust_=250 auxilaryThrust_=250 rotationThrust_=50>
+    <Drone name="meineDrohne"  mass= "50" linearDamping = "0.7" angularDamping = "0.99999" maxDistanceToOwner_=150 minDistanceToOwner_=50 primaryThrust_=250 auxilaryThrust_=250 rotationThrust_=50>
         <attached>
             <Model scale="1" mesh="drone.mesh"/>
Index: code/branches/ai/src/orxonox/controllers/ArtificialController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/ArtificialController.cc	(revision 6986)
+++ code/branches/ai/src/orxonox/controllers/ArtificialController.cc	(revision 6991)
@@ -762,4 +762,8 @@
         if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity1)
             return true;
+        DroneController* droneController1 = orxonox_cast<DroneController*>(entity1->getController());
+        DroneController* droneController2 = orxonox_cast<DroneController*>(entity2->getController());
+        if (droneController1 && droneController2 && droneController1->getOwner() == droneController2->getOwner())
+            return true;
 
         return (team1 == team2 && team1 != -1);
Index: code/branches/ai/src/orxonox/controllers/DroneController.cc
===================================================================
--- code/branches/ai/src/orxonox/controllers/DroneController.cc	(revision 6986)
+++ code/branches/ai/src/orxonox/controllers/DroneController.cc	(revision 6991)
@@ -80,77 +80,22 @@
 
         const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*(ownerPosition-dronePosition); //Vector from Drone To Owner out of drones local coordinate system
-/*
-        int distance_square  = (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x)
-                             + (ownerPosition.y-dronePosition.y)*(ownerPosition.y-dronePosition.y)
-                             + (ownerPosition.z-dronePosition.z)*(ownerPosition.z-dronePosition.z); //distance to Owner squared
-*/
+
         random = rnd(maxrand);
         if ( random < 30 && (!this->target_))
             this->searchNewTarget();
-/*
-        //face target
-        drone_->rotateYaw(-targetPosition_.x);
-        drone_->rotatePitch(targetPosition_.y);
-  */      
-        if (this->target_)
+
+        if (random < 50 && this->target_)
         {
+            this->isShooting_ = true;
             this->aimAtTarget();
+            drone_->rotateYaw(targetPosition_.x);   //face target
+            drone_->rotatePitch(targetPosition_.y);
             drone_->fire(0);
+            this->isShooting_ = false;
         }
-         
 
-
-/*
-        COUT(0) << "Drone: " << dronePosition << endl;
-        COUT(0) << "Distance: " << distance << endl;
-        COUT(0) << "locDrone: " << locOwnerDir << endl;
-        COUT(0) << "target: " << targetPosition_ << endl;
-        COUT(0) << "Owner: " << ownerPosition << endl;
-        COUT(0) << "Rand: " << random << endl;
-*/
-/*
-        // search enemy
-        random = rnd(maxrand);
-        if (random < 15 && (!this->target_))
-            this->searchNewTarget();
-
-        // forget enemy
-        random = rnd(maxrand);
-        if (random < 5 && (this->target_))
-            this->forgetTarget();
-
-        // next enemy
-        random = rnd(maxrand);
-        if (random < 10 && (this->target_))
-            this->searchNewTarget();
-
-        //fly somewhere
-        random = rnd(maxrand);
-        if (random < 50 && (!this->bHasTargetPosition_ && !this->target_))
-            this->searchRandomTargetPosition(); 
- 
-        // stop flying
-        random = rnd(maxrand);
-        if (random < 10 && (this->bHasTargetPosition_ && !this->target_))
-            this->bHasTargetPosition_ = false;
-
-        // fly somewhere else
-        random = rnd(maxrand);
-        if (random < 30 && (this->bHasTargetPosition_ && !this->target_))
-            this->searchRandomTargetPosition();
-
-        // shoot
-        random = rnd(maxrand);
-        if (random < 75 && (this->target_ && !this->bShooting_))
-            this->bShooting_ = true;
-
-        // stop shooting
-        random = rnd(maxrand);
-        if (random < 25 && (this->bShooting_)) 
-            this->bShooting_ = false; */
     }
 
-
-    /**
+    /*
     @brief
         The controlling happens here. This method defines what the controller has to do each tick.
@@ -163,10 +108,22 @@
 
 	Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());
-
-        if ((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength()  > 150*150) { //TODO: variable implementation of maxdistance
+        float maxDistanceSquared = this->getDrone()->getMaxDistanceToOwner()*this->getDrone()->getMaxDistanceToOwner();
+        float minDistanceSquared = this->getDrone()->getMinDistanceToOwner()*this->getDrone()->getMinDistanceToOwner();
+        if ((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength()  > maxDistanceSquared) { 
             this->moveToPosition(this->getOwner()->getWorldPosition());
-
         }
-
+        else if((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength() < minDistanceSquared) {
+            this->moveToPosition(-this->getOwner()->getWorldPosition());
+        }
+        else if(!isShooting_) {
+            float random = rnd(2.0f);
+            float randomSelection = rnd(6.0f);
+            if((int)randomSelection==0) drone_->moveUpDown(random);
+            else if((int)randomSelection==1) drone_->moveRightLeft(random);
+            else if((int)randomSelection==2) drone_->moveFrontBack(random);
+            else if((int)randomSelection==3) drone_->rotateYaw(random);
+            else if((int)randomSelection==4) drone_->rotatePitch(random);
+            else if((int)randomSelection==5) drone_->rotateRoll(random);
+        }
         SUPER(AIController, tick, dt);
 
Index: code/branches/ai/src/orxonox/controllers/DroneController.h
===================================================================
--- code/branches/ai/src/orxonox/controllers/DroneController.h	(revision 6986)
+++ code/branches/ai/src/orxonox/controllers/DroneController.h	(revision 6991)
@@ -66,4 +66,5 @@
             virtual void action();
             void ownerDied();
+            bool isShooting_;
 
         private:
Index: code/branches/ai/src/orxonox/worldentities/Drone.cc
===================================================================
--- code/branches/ai/src/orxonox/worldentities/Drone.cc	(revision 6986)
+++ code/branches/ai/src/orxonox/worldentities/Drone.cc	(revision 6991)
@@ -40,6 +40,4 @@
 namespace orxonox
 {
-    // put your code in here:
-    // create the factory for the drone
     CreateFactory(Drone);
     /**
@@ -49,6 +47,4 @@
     Drone::Drone(BaseObject* creator) : Pawn(creator)
     {
-        // put your code in here:
-        // - register the drone class to the core
 	RegisterObject(Drone);
 
@@ -57,8 +53,5 @@
         this->localLinearAcceleration_.setValue(0, 0, 0);
         this->localAngularAcceleration_.setValue(0, 0, 0);
-        this->primaryThrust_  = 100;
-        this->auxilaryThrust_ = 100;
-        this->rotationThrust_ = 10;
-        
+        this->setRadarVisibility(false);
         this->setCollisionType(WorldEntity::Dynamic);
         
@@ -85,17 +78,11 @@
     void Drone::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
-        // this calls the XMLPort function of the parent class
         SUPER(Drone, XMLPort, xmlelement, mode);
 
-        // put your code in here:
-        // make sure you add the variables primaryThrust_, auxilaryThrust_ and rotationThrust_ to xmlport 
-        // make sure that the set- and get-functions exist.
-        // variables can be added by the following command 
-        // XMLPortParam(Classname, "xml-attribute-name (i.e. variablename)", setFunction, getFunction, xmlelement, mode)
 	XMLPortParam(Drone, "primaryThrust_", setPrimaryThrust, getPrimaryThrust, xmlelement, mode);
 	XMLPortParam(Drone, "auxilaryThrust_", setAuxilaryThrust, getAuxilaryThrust, xmlelement, mode);
 	XMLPortParam(Drone, "rotationThrust_", setRotationThrust, getRotationThrust, xmlelement, mode);
-
-
+        XMLPortParam(Drone, "maxDistanceToOwner_", setMaxDistanceToOwner, getMaxDistanceToOwner, xmlelement, mode);
+        XMLPortParam(Drone, "minDistanceToOwner_", setMinDistanceToOwner, getMinDistanceToOwner, xmlelement, mode);
     }
 
Index: code/branches/ai/src/orxonox/worldentities/Drone.h
===================================================================
--- code/branches/ai/src/orxonox/worldentities/Drone.h	(revision 6986)
+++ code/branches/ai/src/orxonox/worldentities/Drone.h	(revision 6991)
@@ -110,4 +110,8 @@
             inline void setRotationThrust( float thrust )
                 { this->rotationThrust_=thrust; }      
+            inline void setMaxDistanceToOwner( float distance)
+                { this->maxDistanceToOwner_=distance; }
+            inline void setMinDistanceToOwner( float distance)
+                { this->minDistanceToOwner_=distance; }
                 	
             
@@ -118,9 +122,12 @@
             inline float getPrimaryThrust()
                 { return this->primaryThrust_; }
-
-	   inline float getAuxilaryThrust()
+	    inline float getAuxilaryThrust()
                 { return this->auxilaryThrust_; }
-	   inline float getRotationThrust()
+	    inline float getRotationThrust()
                 { return this->rotationThrust_; }
+	    inline float getMaxDistanceToOwner()
+                { return this->maxDistanceToOwner_; }
+            inline float getMinDistanceToOwner()
+                { return this->minDistanceToOwner_; }
             
         private:
@@ -132,4 +139,6 @@
             float auxilaryThrust_; //!< The amount of auxilary thrust. Used for all other movements (except for rotations).
             float rotationThrust_; //!< The amount of rotation thrust. Used for rotations only.
+            float maxDistanceToOwner_; //Maximum Distance to owner
+            float minDistanceToOwner_; //Minimum Distance to owner
     };
 
