Index: code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10869)
+++ code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc	(revision 10871)
@@ -39,10 +39,4 @@
 #include "controllers/DroneController.h"
 
-//Today, on 25th of November, 2015, I hereby officially declare my code a huge pack of bullshit that I do not understand.
-//#Almost2KLines
-//#SpaghettiCode
-//#ISworeiWouldNever
-//#ItAllStartedSoWell
-
 namespace orxonox
 {
@@ -52,24 +46,9 @@
     const float ROTATEFACTOR = 1.0f/0.02f;
 
-    //Table of content:
-    //Constructor, Destructor & tick
-    //XML methods
-    //World interaction
-    //Helper methods
-    //Flying methods
-    //Fighting methods
-    //Actionpoint methods
-
-
-    //------------------------------------------------------------------------------
-    //------------------------Constructor, Destructor & tick------------------------
-    //------------------------------------------------------------------------------
-    
+  
     CommonController::CommonController( Context* context ): Controller( context )
     {
         this->bFirstTick_ = true;
-        this->tolerance_ = 50;
-        this->stopLookingAtTarget();
-        this->attackRange_ = 2500;
+       
         RegisterObject( CommonController );
 
@@ -85,55 +64,10 @@
     }
 
-    //------------------------------------------------------------------------------
-    //----------------------------------XML methods---------------------------------
-    //------------------------------------------------------------------------------
-    
+      
     void CommonController::XMLPort( Element& xmlelement, XMLPort::Mode mode )
     {
         SUPER( CommonController, XMLPort, xmlelement, mode );
-        XMLPortParam( CommonController, "formationMode", setFormationModeXML, getFormationModeXML,  xmlelement, mode );
-    }
-    void CommonController::setFormationModeXML( std::string val )
-    {
-        const std::string valUpper = getUppercase( val );
-        FormationMode::Value value;
-        
-        if ( valUpper == "WALL" )
-            value = FormationMode::WALL;
-        else if ( valUpper == "FINGER4" )
-            value = FormationMode::FINGER4;
-        else if ( valUpper == "DIAMOND" )
-            value = FormationMode::DIAMOND;
-        else
-            ThrowException( ParseError, std::string( "Attempting to set an unknown FormationMode: '" )+ val + "'." );
-        this->setFormationMode( value );
-    }
-    std::string CommonController::getFormationModeXML() 
-    {
-        switch ( this->formationMode_ )
-        {
-            case FormationMode::WALL:
-            { return "WALL"; break; }
-            case FormationMode::FINGER4:
-            { return "FINGER4"; break; }
-            case FormationMode::DIAMOND:
-            { return "DIAMOND"; break; }
-            default:
-                return "DIAMOND"; break;
-        }
-    }
-    void CommonController::setFormationMode(FormationMode::Value val)
-    { 
-        this->formationMode_ = val; 
-    }
-    FormationMode::Value CommonController::getFormationMode() const
-    { 
-        return this->formationMode_; 
-    }
-    
-    //------------------------------------------------------------------------------
-    //-------------------------------World interaction------------------------------
-    //------------------------------------------------------------------------------
-
+    }
+ 
     //"Virtual" methods
     bool CommonController::setWingman ( CommonController* wingman )
@@ -141,19 +75,4 @@
     bool CommonController::hasWingman() 
     { return true; }
-    bool CommonController::hasTarget() 
-    {
-        if ( this->target_ )
-            return true;
-        return false;
-    }
-    ControllableEntity* CommonController::getTarget()
-    {
-        return this->target_;
-    }
-  
-
-    //------------------------------------------------------------------------------
-    //--------------------------------Helper methods--------------------------------
-    //------------------------------------------------------------------------------
 
     float CommonController::randomInRange( float a, float b )
@@ -300,295 +219,5 @@
         return name;
     }
-    float CommonController::squaredDistanceToTarget()  const
-    {
-        if ( !this->getControllableEntity()  )
-            return 0;
-        if ( !this->target_ || !this->getControllableEntity() )
-            return ( this->getControllableEntity() ->getPosition() .squaredDistance( this->targetPosition_ ) );
-        else
-            return ( this->getControllableEntity() ->getPosition() .squaredDistance( this->positionOfTarget_ ) );
-    }
-    bool CommonController::isLookingAtTarget( float angle )
-    {
-        if ( !this->getControllableEntity()  || !this->target_ )
-            return false;
-        return this->isLooking(this->getControllableEntity(), this->getTarget(), angle);
-    }
-
-
-    //------------------------------------------------------------------------------
-    //--------------------------------Flying methods--------------------------------
-    //------------------------------------------------------------------------------
-
-    void CommonController::stopMoving()
-    {
-        this->bHasTargetPosition_ = false;
-    }
-    void CommonController::stopLookingAtTarget()
-    {
-        this->bLookAtTarget_ = false;
-    }
-    void CommonController::startLookingAtTarget()
-    {
-        this->bLookAtTarget_ = true;
-    }
-    void CommonController::moveToPosition( const Vector3& target, float dt )
-    {
-        ControllableEntity* entity = this->getControllableEntity();
-        Vector2 coord = get2DViewCoordinates
-            ( entity->getPosition() , 
-            entity->getOrientation()  * WorldEntity::FRONT, 
-            entity->getOrientation()  * WorldEntity::UP, 
-            target );
-
-        float distance = ( target - this->getControllableEntity() ->getPosition() ).length();
-        float rotateX = -clamp( coord.x * 10, -1.0f, 1.0f );
-        float rotateY = clamp( coord.y * 10, -1.0f, 1.0f );
-
-        if ( distance > this->tolerance_ )
-        {
-            this->getControllableEntity() ->rotateYaw( ROTATEFACTOR * rotateX * dt );
-            this->getControllableEntity() ->rotatePitch( ROTATEFACTOR * rotateY * dt );
-
-            if ( distance < 300 )
-            {
-                if ( bHasTargetOrientation_ )
-                {
-                    copyTargetOrientation( dt );
-                }
-            }
-            if (distance > this->tolerance_*1.5f || (rotateX > -0.01 && rotateX < 0.01 && rotateY > -0.01 && rotateY < 0.01))
-                this->getControllableEntity() ->moveFrontBack( SPEED * dt );
-        }
-        else
-        {      
-            bHasTargetPosition_ = false;
-            bHasTargetOrientation_ = false;
-        }
-    }
-    void CommonController::moveToTargetPosition(float dt)
-    {
-        this->moveToPosition (this->targetPosition_, dt);
-    }
-    void CommonController::copyOrientation( const Quaternion& orient, float dt )
-    {
-        //roll angle difference in radian
-        float diff=orient.getRoll(false).valueRadians() -
-                        ( this->getControllableEntity() ->getOrientation() .getRoll( false ).valueRadians() );
-        while( diff>math::twoPi )diff-=math::twoPi;
-        while( diff<-math::twoPi )diff+=math::twoPi;
-        this->getControllableEntity() ->rotateRoll( diff*0.2f*ROTATEFACTOR * dt );
-    }
-    void CommonController::copyTargetOrientation( float dt )
-    {
-        if ( bHasTargetOrientation_ )
-        {   
-            copyOrientation( targetOrientation_, dt );
-        }
-    }
-    void CommonController::lookAtTarget(float dt)
-    {
-        ControllableEntity* entity = this->getControllableEntity();
-        if ( !entity )
-            return;
-        Vector2 coord = get2DViewCoordinates
-            ( entity->getPosition() , 
-            entity->getOrientation()  * WorldEntity::FRONT, 
-            entity->getOrientation()  * WorldEntity::UP, 
-            positionOfTarget_ );
-
-        //rotates should be in range [-1,+1], clamp cuts off all that is not
-        float rotateX = -clamp( coord.x * 10, -1.0f, 1.0f );
-        float rotateY = clamp( coord.y * 10, -1.0f, 1.0f ); 
-   
-        //Yaw and Pitch are enough to start facing the target
-        this->getControllableEntity() ->rotateYaw( ROTATEFACTOR * rotateX * dt );
-        this->getControllableEntity() ->rotatePitch( ROTATEFACTOR * rotateY * dt );
-    }
-    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() );
-    }
-
-    //------------------------------------------------------------------------------
-    //-------------------------------Fighting methods-------------------------------
-    //------------------------------------------------------------------------------
-
-    void CommonController::setTarget( ControllableEntity* target )
-    {
-        this->target_ = target;        
-        if ( this->target_ )
-        {
-            this->setPositionOfTarget( target_->getWorldPosition() );
-        }
-    }
-    void CommonController::setPositionOfTarget( const Vector3& target )
-    {
-        this->positionOfTarget_ = target;
-        this->bHasPositionOfTarget_ = true;
-    }
-    void CommonController::setOrientationOfTarget( const Quaternion& orient )
-    {
-        this->orientationOfTarget_=orient;
-        this->bHasOrientationOfTarget_=true;
-    }
-    
-    void CommonController::maneuver() 
-    {
-        maneuverCounter_++;
-        if (maneuverCounter_ > 5)
-            maneuverCounter_ = 0;
-
-        if ( !this->target_ || !this->getControllableEntity())
-            return;
-        
-        Vector3 thisPosition = this->getControllableEntity()->getWorldPosition();
-        this->setPositionOfTarget( getPredictedPosition( 
-            thisPosition, 
-            hardcoded_projectile_speed, 
-            this->target_->getWorldPosition() , 
-            this->target_->getVelocity()  
-            )  );
-        this->setOrientationOfTarget( this->target_->getOrientation() );
-
-        Vector3 diffVector = this->positionOfTarget_ - thisPosition;
-        float diffLength = diffVector.length();
-        Vector3 diffUnit = diffVector/diffLength;
-
-        bool bTargetIsLookingAtThis = this->isLooking ( this->target_, getControllableEntity(), math::pi/10.0f );
-        
-        //too far? well, come closer then
-        if ( diffLength > this->attackRange_ )
-        {
-            this->setTargetPosition( this->positionOfTarget_ );
-        }
-        //too close? How do u expect to dodge anything? Just attack!
-        else if ( diffLength < 500 )
-        {   
-            //at this point, just look and shoot
-            if ( diffLength < 250 )
-            {
-                this->stopMoving();
-                this->startLookingAtTarget();
-            }
-            else
-            {
-                this->setTargetPosition( this->positionOfTarget_ );
-            }
-        }
-        //Good distance? Check if target looks at us. It doesn't? Go hunt!
-        else if ( !bTargetIsLookingAtThis )
-        {
-            this->setTargetPosition( this->positionOfTarget_ );
-        }
-        //That's unfortunate, he is looking and probably shooting... try to dodge what we can...  
-        else 
-        {   
-            if (maneuverCounter_ == 0)
-            {
-                this->setTargetPosition( this->positionOfTarget_ );   
-                return;
-            }
-            dodge( thisPosition, diffUnit );
-        }
-    }
-    
-    void CommonController::dodge(Vector3& thisPosition, Vector3& diffUnit)
-    {
-        float factorX = 0, factorY = 0, factorZ = 0;
-        float rand = randomInRange (0, 1);
-    
-        if (rand <= 0.5)
-        { factorX = 1; }
-        else
-        { factorX = -1; }
-        rand = randomInRange (0, 1);
-        if (rand <= 0.5)
-        { factorY = 1; }
-        else
-        { factorY = -1; }
-        rand = randomInRange (0, 1);
-        if (rand <= 0.5)
-        { factorZ = 1; }
-        else
-        { factorZ = -1; }
-
-        Vector3 target = ( diffUnit )* 8000.0f;
-        Vector3* randVector = new Vector3( 
-            factorX * randomInRange( 10000, 40000 ), 
-            factorY * randomInRange( 10000, 40000 ), 
-            factorZ * randomInRange( 10000, 40000 ) 
-        );
-        Vector3 projection = randVector->dotProduct( diffUnit )* diffUnit;
-        *randVector -= projection;
-        target += *randVector;
-        this->setTargetPosition( thisPosition + target );
-    }
-    bool CommonController::canFire() 
-    {
-        //no target? why fire?
-        if ( !this->target_ )
-            return false;
-
-        Vector3 newPositionOfTarget = getPredictedPosition( this->getControllableEntity() ->getWorldPosition() , 
-            hardcoded_projectile_speed, this->target_->getWorldPosition() , this->target_->getVelocity() );
-        if ( newPositionOfTarget != Vector3::ZERO )
-        {
-            this->setPositionOfTarget( newPositionOfTarget );
-        }
-
-        float squaredDistance = squaredDistanceToTarget();
-
-        if ( squaredDistance < this->attackRange_*this->attackRange_ && this->isLookingAtTarget( math::pi / 20.0f)) 
-        {
-            return true;
-        }
-        else
-        {
-            return false;
-        }
-    }
-    void CommonController::doFire() 
-    {
-        if ( !this->target_ || !this->getControllableEntity() )
-        {
-            return;
-        }
-      
-        Pawn* pawn = orxonox_cast<Pawn*>( this->getControllableEntity() );
-
-        if ( pawn )
-            pawn->setAimPosition( this->positionOfTarget_ );
-        this->getControllableEntity() ->fire( 0 );
-    }
-
-
-    
-    void CommonController::boostControl()
-    {
-        SpaceShip* ship = orxonox_cast<SpaceShip*>(this->getControllableEntity());
-        if(ship == NULL) return;
-        if(ship->getBoostPower()*1.5f > ship->getInitialBoostPower() ) //upper limit ->boost
-        {
-
-            this->getControllableEntity()->boost(true);
-        }
-        else if(ship->getBoostPower()*4.0f < ship->getInitialBoostPower()) //lower limit ->do not boost
-        {
-           this->getControllableEntity()->boost(false);
-        }
-    }
+  
+
 }
