Index: code/branches/turretFS14/src/modules/objects/Turret.cc
===================================================================
--- code/branches/turretFS14/src/modules/objects/Turret.cc	(revision 10044)
+++ code/branches/turretFS14/src/modules/objects/Turret.cc	(revision 10049)
@@ -38,5 +38,9 @@
 
     /**
-     * @brief Constructor
+        @brief 
+        Sets default values for all variables. Also hides the turret from the radar.
+
+        @param context
+        The context
      */
     Turret::Turret(Context* context) : Pawn(context)
@@ -48,5 +52,6 @@
         this->localY_ = Vector3::UNIT_Y;
         this->localX_ = Vector3::UNIT_X;
-        this->attackRadius_ = 200;
+        this->maxAttackRadius_ = 200;
+        this->minAttackRadius_ = 0;
         this->maxPitch_ = 90;
         this->maxYaw_ = 90;
@@ -58,5 +63,6 @@
 
     /**
-     * @brief Destructor
+        @brief 
+        Destructor. Nothing to see here.
      */
     Turret::~Turret()
@@ -65,10 +71,20 @@
     }
 
-
+    /**
+        @brief
+        Checks, if a (world)position is inside the turret's range.
+
+        This function is safe to use on turrets that are attached, rotated, etc.
+        The turret's range is determined with the maxPitch, maxYaw, and the two attackRadius'.
+
+        @param position
+        The position to check
+    */
     bool Turret::isInRange(const Vector3 &position)
     {
         //Check distance
         Vector3 distance = position - this->getWorldPosition();
-        if(distance.squaredLength() > (this->attackRadius_ * this->attackRadius_))
+        float distanceVal = distance.squaredLength();
+        if(distanceVal > (this->maxAttackRadius_ * this->maxAttackRadius_) || distanceVal < (this->minAttackRadius_ * this->minAttackRadius_))
         {
             return false;
@@ -100,4 +116,15 @@
     }
 
+    /**
+        @brief
+        Rotates the turret to make it aim at a certain position.
+
+        @note
+        There are no checks, if the position is valid (i.e. if the turret is allowed to aim there).
+        This function must be called again for every tick, or the turret will stop rotating.
+
+        @param position
+        The position to aim at
+    */
     void Turret::aimAtPosition(const Vector3& position)
     {
@@ -106,7 +133,12 @@
 
         this->rotation_ = currDir.getRotationTo(targetDir);
-
-    }
-
+    }
+
+    /**
+        @brief
+        Does currently nothing.
+
+        Should rotate the turret with the specified pitch. Contains a failed attempt at limiting said rotation.
+    */
     void Turret::rotatePitch(const Vector2& value)
     {    
@@ -127,4 +159,10 @@
     }
 
+    /**
+        @brief
+        Does currently nothing.
+
+        Should rotate the turret with the specified yaw. Contains a failed attempt at limiting said rotation.
+    */
     void Turret::rotateYaw(const Vector2& value)
     {
@@ -145,8 +183,20 @@
     }
 
+    /**
+        @brief
+        Does currently nothing.
+
+        May be used to limit turret's rotation in the future.
+    */
     void Turret::rotateRoll(const Vector2& value)
     {
     }
 
+    /**
+        @brief
+        Loads parameters from xml
+
+        Parameters loaded are: rotationThrust, maxAttackRadius, minAttackRadius, maxYaw, maxPitch
+    */
     void Turret::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
@@ -154,9 +204,16 @@
         
         XMLPortParamVariable(Turret, "rotationThrust", rotationThrust_, xmlelement, mode);
-        XMLPortParam(Turret, "attackRadius", setAttackRadius, getAttackRadius, xmlelement, mode);
+        XMLPortParam(Turret, "maxAttackRadius", setMaxAttackRadius, getMaxAttackRadius, xmlelement, mode);
+        XMLPortParam(Turret, "minAttackRadius", setMinAttackRadius, getMinAttackRadius, xmlelement, mode);
         XMLPortParam(Turret, "maxYaw", setMaxYaw, getMaxYaw, xmlelement, mode);
         XMLPortParam(Turret, "maxPitch", setMaxPitch, getMaxPitch, xmlelement, mode);
     }
 
+    /**
+        @brief
+        The turret's actions are done here.
+
+        Every tick, the turret gets rotated if it should, and the local axes get updated with the parent's rotation.
+    */
     void Turret::tick(float dt)
     {
@@ -166,5 +223,5 @@
         if(!this->once_)
         {
-
+            //Account for rotations done in xml
             Quaternion startOrient = this->getOrientation();
             this->localXStart_ = startOrient * this->localX_;
@@ -198,6 +255,6 @@
         if(this->rotation_ != Quaternion::IDENTITY)
         {
-            //Don't make the rotation instantaneous
-            Quaternion drot = Quaternion::Slerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_);
+            //Don't make the rotation instantaneous. Use an arbitrary interpolation, not that great...
+            Quaternion drot = Quaternion::nlerp(dt*this->rotationThrust_/20.f, Quaternion::IDENTITY, this->rotation_);
             this->rotate(drot, WorldEntity::World);
             this->rotation_ = Quaternion::IDENTITY;
Index: code/branches/turretFS14/src/modules/objects/Turret.h
===================================================================
--- code/branches/turretFS14/src/modules/objects/Turret.h	(revision 10044)
+++ code/branches/turretFS14/src/modules/objects/Turret.h	(revision 10049)
@@ -21,5 +21,5 @@
  *
  *   Author:
- *      Marian Runo
+ *      Marian Runo, Martin Mueller
  *   Co-authors:
  *      ...
@@ -28,5 +28,4 @@
 
 /**
-    @file Turret.h
     @brief Definition of the Turret class.
     @ingroup Objects
@@ -41,4 +40,13 @@
 namespace orxonox
 {
+    /**
+    @brief
+        Creates a turret with limited rotation. The point of this class is to be able to attach
+        a turret to a spaceship or a spacestation which is more or less completely autonomous in
+        it's behaviour.
+
+    @note
+        The rotation isn't limited "physically". You have to call isInRange to find out if the turret is allowed to shoot at a target.
+    */
     class _ObjectsExport Turret : public Pawn
     {
@@ -56,40 +64,55 @@
             virtual void tick(float dt);
 
-            inline void setAttackRadius(float radius)
-                { this->attackRadius_ = radius; }
+            /** @brief Sets the maximum distance the turret is allowed to shoot. @param radius The distance*/
+            inline void setMaxAttackRadius(float radius)
+                { this->maxAttackRadius_ = radius; }
 
+            /** @brief Sets the minimum distance the turret is allowed to shoot. @param radius The distance*/
+            inline void setMinAttackRadius(float radius)
+                { this->minAttackRadius_ = radius; }
+
+            /** @brief Sets the maximum pitch the turret can have (in both directions). @param pitch The pitch (in one direction)*/
             inline void setMaxPitch(float pitch)
                 { this->maxPitch_ = pitch; }
 
+            /** @brief Sets the maximum yaw the turret can have (in both directions). @param yaw The yaw (in one direction)*/
             inline void setMaxYaw(float yaw)
                 { this->maxYaw_ = yaw; }
 
-            inline float getAttackRadius() const
-                { return this->attackRadius_; }                
+            /** @brief Returns the maximum distance the turret is allowed to shoot. @return The distance */
+            inline float getMaxAttackRadius() const
+                { return this->maxAttackRadius_; }                
 
+            /** @brief Returns the minimum distance the turret is allowed to shoot. @return The distance */
+            inline float getMinAttackRadius() const
+                { return this->minAttackRadius_; }   
+
+            /** @brief Returns the maximum pitch the turret can have. @return The pitch */
             inline float getMaxPitch() const
                 { return this->maxPitch_; }
 
+            /** @brief Returns the maximum yaw the turret can have. @return The yaw */
             inline float getMaxYaw() const
                 { return this->maxYaw_; }
 
         protected:
-            Vector3 startDir_;
-            Vector3 localZ_;
-            Vector3 localZStart_;
-            Vector3 localY_;
-            Vector3 localYStart_;
-            Vector3 localX_;
-            Vector3 localXStart_;           
+            Vector3 startDir_; //!< The initial facing direction, in local coordinates.
+            Vector3 localZ_; //!< The local z-axis, includes for the parent's rotation and rotations done in xml.
+            Vector3 localY_; //!< The local y-axis, includes for the parent's rotation and rotations done in xml.
+            Vector3 localX_; //!< The local x-axis, includes for the parent's rotation and rotations done in xml.      
+            Quaternion rotation_; //!< The rotation to be done by the turret.
 
         private:
-            bool once_;
+            bool once_; //!< Flag for executing code in the tick function only once.
 
-            float attackRadius_;
-            Ogre::Real maxPitch_;
-            Ogre::Real maxYaw_;
-            float rotationThrust_;
+            Vector3 localZStart_; //!< The local z-axis, without the parent's rotation.
+            Vector3 localYStart_; //!< The local y-axis, without the parent's rotation.
+            Vector3 localXStart_; //!< The local x-axis, without the parent's rotation.
+            float maxAttackRadius_; //!< The maximum distance the turret is allowed to shoot.
+            float minAttackRadius_; //!< The minimum distance the turret is allowed to shoot.
+            Ogre::Real maxPitch_; //!< The maxmium pitch the turret can have (on one side).
+            Ogre::Real maxYaw_; //!< The maxmium yaw the turret can have (on one side).
+            float rotationThrust_;  //!< The velocity the turret rotates with.
 
-            Quaternion rotation_;
     };
 }
Index: code/branches/turretFS14/src/modules/objects/controllers/CMakeLists.txt
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/CMakeLists.txt	(revision 10044)
+++ code/branches/turretFS14/src/modules/objects/controllers/CMakeLists.txt	(revision 10049)
@@ -1,3 +1,4 @@
 ADD_SOURCE_FILES(OBJECTS_SRC_FILES
   TurretController.cc
+  TeamTargetProxy.cc
 )
Index: code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.cc
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.cc	(revision 10049)
+++ code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.cc	(revision 10049)
@@ -0,0 +1,87 @@
+/*
+ *   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:
+ *      Martin Mueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#include "TeamTargetProxy.h"
+#include "worldentities/pawns/Pawn.h"
+
+ namespace orxonox
+ {
+ 	RegisterClass(TeamTargetProxy);
+
+ 	TeamTargetProxy::TeamTargetProxy(Context* context) : FormationController(context)
+ 	{
+ 		RegisterObject(TeamTargetProxy);
+
+ 		this->once_ = false;
+ 	}
+
+ 	TeamTargetProxy::~TeamTargetProxy()
+ 	{
+ 	}
+
+ 	void TeamTargetProxy::tick(float dt)
+ 	{
+	    if (!this->isActive() || !this->getControllableEntity())
+	        return;
+
+        ControllableEntity* parent = orxonox_cast<ControllableEntity*> (this->getControllableEntity()->getParent());
+ 		
+
+
+        if(parent)
+        {
+
+            if(!this->once_)
+            {
+                //Set the same team
+                if(parent)
+                {
+                    Controller* parentcontroller = parent->getController();
+                    if(parentcontroller)
+                    {
+                        this->setTeam(parentcontroller->getTeam());
+                    }
+                    else
+                    {
+                        this->setTeam(parent->getTeam());
+                    }
+                    this->getControllableEntity()->setTeam(parent->getTeam());
+                }
+                this->once_ = true;
+            }
+
+            Pawn* parenttarget = orxonox_cast<Pawn*>(parent->getTarget());
+            if(parenttarget)
+            {
+                this->setTarget(parenttarget);
+                this->getControllableEntity()->setTarget(parenttarget);
+            }
+        }
+
+ 	}
+ }
Index: code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.h
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.h	(revision 10049)
+++ code/branches/turretFS14/src/modules/objects/controllers/TeamTargetProxy.h	(revision 10049)
@@ -0,0 +1,50 @@
+/*
+ *   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:
+ *      Martin Mueller
+ *   Co-authors:
+ *      ...
+ *
+ */
+
+#ifndef _TeamTargetProxy_H__
+#define _TeamTargetProxy_H__
+
+#include "OrxonoxPrereqs.h"
+#include "controllers/FormationController.h"
+
+ namespace orxonox
+ {
+ 	class _OrxonoxExport TeamTargetProxy : public FormationController, public Tickable
+ 	{
+ 		public:
+ 			TeamTargetProxy(Context* context);
+ 			virtual ~TeamTargetProxy();
+
+ 			virtual void tick(float dt);
+
+ 		private:
+ 			bool once_;
+ 	};
+ }
+
+ #endif
Index: code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc	(revision 10044)
+++ code/branches/turretFS14/src/modules/objects/controllers/TurretController.cc	(revision 10049)
@@ -136,5 +136,4 @@
  			{
  				this->getControllableEntity()->fire(0);
- 				orxout() << 42 << endl;
  			}
  		}
Index: code/branches/turretFS14/src/modules/objects/controllers/TurretController.h
===================================================================
--- code/branches/turretFS14/src/modules/objects/controllers/TurretController.h	(revision 10044)
+++ code/branches/turretFS14/src/modules/objects/controllers/TurretController.h	(revision 10049)
@@ -27,6 +27,10 @@
  */
 
- #ifndef _TurretController_H__
- #define _TurretController_H__
+/**
+    @brief Definition for the controller for turrets.
+*/
+
+#ifndef _TurretController_H__
+#define _TurretController_H__
 
 #include "OrxonoxPrereqs.h"
@@ -35,4 +39,10 @@
  namespace orxonox
  {
+ 	/**
+ 		@brief
+ 		Controller for turrets. Chooses a target, and makes the turret aim/shoot at it.
+
+ 		The controllableEntity gets casted to Turret, so this controller won't work for anything else.
+ 	*/
  	class _OrxonoxExport TurretController : public ArtificialController, public Tickable
  	{
