Index: /code/branches/AI_HS15/data/levels/AITest.oxw
===================================================================
--- /code/branches/AI_HS15/data/levels/AITest.oxw	(revision 10802)
+++ /code/branches/AI_HS15/data/levels/AITest.oxw	(revision 10803)
@@ -76,5 +76,5 @@
 
     
-    <SpaceShip position="<?1000 ?>,<?lua print(1500+i*1000) ?>, -1000 ?>" lookat="0,0,0">
+    <SpaceShip position="<?4000 ?>,<?lua print(1500+i*1000) ?>, -1000 ?>" lookat="0,0,0">
       <templates>
         <Template link=spaceshipassff />
Index: /code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	(revision 10802)
+++ /code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc	(revision 10803)
@@ -47,5 +47,5 @@
     RegisterClass( CommonController );
     float SPEED = 0.9f/0.02f;
-    float ROTATEFACTOR = 0.5f/0.02f;
+    float ROTATEFACTOR = 1.0f/0.02f;
 
     CommonController::CommonController( Context* context ): Controller( context )
@@ -55,5 +55,5 @@
         this->executingManeuver_ = false;
         this->executingMoveToPoint_ = false;
-
+        this->stopLookingAtTarget();
         this->maneuverType_ = ManeuverType::NONE;
         RegisterObject( CommonController );
@@ -120,17 +120,19 @@
     void CommonController::maneuver() 
     {
-
-        if ( this->target_ && this->bHasPositionOfTarget_ && this->getControllableEntity() )
-        {
-            Vector3 thisPosition = this->getControllableEntity() ->getWorldPosition();
-            Quaternion thisOrientation = this->getControllableEntity() ->getOrientation();
-
-            /*this->setPositionOfTarget( getPredictedPosition( 
+        counter++;
+
+        if (counter > 5)
+            counter = 0;
+        if ( this->target_ && this->getControllableEntity())
+        {
+            Vector3 thisPosition = this->getControllableEntity()->getWorldPosition();
+            //Quaternion thisOrientation = this->getControllableEntity()->getOrientation();
+
+            this->setPositionOfTarget( getPredictedPosition( 
                 thisPosition, 
                 hardcoded_projectile_speed, 
                 this->target_->getWorldPosition() , 
                 this->target_->getVelocity()  
-                ) );*/
-            this->setPositionOfTarget( this->target_->getWorldPosition()  );
+                )  );
             this->setOrientationOfTarget( this->target_->getOrientation() );
 
@@ -140,206 +142,155 @@
             Vector3 diffUnit = diffVector/diffLength;
 
-            Vector3 thisForwardVector = thisOrientation * WorldEntity::FRONT;
-            float thisDotProduct = diffVector.dotProduct( thisForwardVector );
-
-            Vector3 targetForwardVector = this->orientationOfTarget_ * WorldEntity::FRONT;
-            float targetDotProduct = diffVector.dotProduct( targetForwardVector );            
-
-            float thisAngle = getAngle( thisPosition, thisForwardVector, this->positionOfTarget_ ); 
-            float targetAngle = getAngle( this->positionOfTarget_, targetForwardVector, thisPosition ); 
-
-
-            bool bThisIsLookingAtTarget = ( thisAngle/( diffLength*diffLength ) < math::pi/8000000.0f );
-            bool bTargetIsLookingAtThis = ( targetAngle/( diffLength*diffLength ) < math::pi/8000000.0f );
+
+
+            //bool bThisIsLookingAtTarget = this->isLooking ( getControllableEntity(), this->target_, math::pi/4 );
+            bool bTargetIsLookingAtThis = this->isLooking ( this->target_, getControllableEntity(), math::pi/8.0f );
             
-            float angleDiff = targetAngle - thisAngle;
-
-            //if his angle is bigger than mine
-            if ( angleDiff > 0 )
-            {
-                //if diff is insignificant
-                if ( bThisIsLookingAtTarget && bTargetIsLookingAtThis )
-                {
-                    //no way to dodge
-                    if ( diffLength < 400 )
-                    {
-                        Vector3* target = new Vector3 ( 0, -200, -200 );
-                        this->setTargetPosition( this->positionOfTarget_ );
-
-
-                    }
-                    //do scissors
-                    else
-                    {
-                        Vector3 target = ( diffUnit )* 150.0f;
-                        Vector3* randVector = new Vector3( 
-                            randomInRange( -300, 300 ), 
-                            randomInRange( -300, 300 ), 
-                            randomInRange( -300, 300 ) 
-                        );
-                        Vector3 projection = randVector->dotProduct( diffUnit )* diffUnit;
-                        *randVector -= projection;
-                        target += *randVector;
-                        this->setTargetPosition( this->getControllableEntity() ->getWorldPosition() + target );
-
-                    }
-                }
-                //this has advantage
+
+
+            //too far? well, come closer then
+            if ( diffLength > 5000 )
+            {
+                if (diffLength < 6000)
+                {
+                    this->bEngaging_ = true;
+                }
                 else
                 {
-                    //if too close
-                    if ( diffLength < 300 )
-                    {
-                        this->setTargetPosition( this->getControllableEntity() ->getWorldPosition()  );
-                    }
-                    //move closer
-                    else
-                    {
-                        this->setTargetPosition( this->positionOfTarget_ - 0.6f*diffVector );
-                    }
-                }
-            }
-            else
-            {
-                //if diff is insignificant
-                if ( bThisIsLookingAtTarget && bTargetIsLookingAtThis )
-                {
-                    //no way to dodge
-                    if ( diffLength < 400 )
-                    {
-                        Vector3* target = new Vector3 ( 0, -200, -200 );
-                        this->setTargetPosition( this->positionOfTarget_ );
-
-                    }
-                    //do scissors
-                    else
-                    {
-                        Vector3 target = ( diffUnit )* 150.0f;
-                        Vector3* randVector = new Vector3( 
-                            randomInRange( -300, 300 ), 
-                            randomInRange( -300, 300 ), 
-                            randomInRange( -300, 300 ) 
-                        );
-                        Vector3 projection = randVector->dotProduct( diffUnit )* diffUnit;
-                        *randVector -= projection;
-                        target += *randVector;
-                        this->setTargetPosition( this->getControllableEntity() ->getWorldPosition() + target );
-
-                    }
-                }
-                //target has advantage
+                    this->bEngaging_ = false;
+                }
+                this->setTargetPosition( this->positionOfTarget_ );
+            }
+            //too close? How do u expect to dodge anything? Just attack!
+            else if ( diffLength < 600 )
+            {   
+                //at this point, just look and shoot
+                if ( diffLength < 300 )
+                {
+                    this->stopMoving();
+                    this->startLookingAtTarget();
+                }
                 else
                 {
-                    //if too close
-                    if ( diffLength < 300 )
-                    {
-                        this->setTargetPosition( this->getControllableEntity() ->getWorldPosition()  );
-                    }
-                    //move closer
-                    else
-                    {
-                        this->setTargetPosition( this->positionOfTarget_ - 0.6f*diffVector );
-                    }
-                }
-            }
-            this->bShooting_ = true;
+                    this->setTargetPosition( this->positionOfTarget_ );
+                }
+            }
+            //Good distance? Check if target looks at us. It doesn't? Go hunt!
+            else if ( !bTargetIsLookingAtThis )
+            {
+                this->setTargetPosition( this->positionOfTarget_ );
+              /*  if (counter == 0)
+                {
+                    this->setTargetPosition( this->positionOfTarget_ );   
+                    return;
+                }
+                else
+                {
+                    dodge( thisPosition, diffUnit );
+                }*/
+            }
+            //That's unfortunate, he is looking and probably shooting... try to dodge what we can...  
+            else 
+            {   
+            
+                if (counter == 0)
+                {
+                    this->setTargetPosition( this->positionOfTarget_ );   
+                    return;
+                }
+                dodge( thisPosition, diffUnit );
+                
+            }
+        }
+        if ( this->getControllableEntity()  && !this->target_ )
+        {
+            this->bEngaging_ = false;
+            this->maneuverType_ = ManeuverType::NONE;
+        }
+        orxout ( internal_error ) << "ManeuverType = " << this->maneuverType_ << endl;
+    }
+    ControllableEntity* CommonController::getTarget()
+    {
+        return this->target_;
+    }
+    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 );
+    }
+    void CommonController::stopMoving()
+    {
+        this->bHasTargetPosition_ = false;
+    }
+    void CommonController::startLookingAtTarget()
+    {
+        this->bLookAtTarget_ = true;
+    }
+    void CommonController::stopLookingAtTarget()
+    {
+        this->bLookAtTarget_ = false;
+    }
+    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 );
+        
            
-        }
-        if ( this->getControllableEntity()  && !this->target_ )
-        {
-            this->maneuverType_ = ManeuverType::NONE;
-        }
-        orxout ( internal_error ) << "ManeuverType = " << this->maneuverType_ << endl;
-    }
-    void CommonController::chooseManeuverType() 
-    {
-
-        if ( this->target_ && this->bHasPositionOfTarget_ && this->getControllableEntity() )
-        {
-            Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity() ->getWorldPosition();
-            Vector3 thisForwardVector = this->getControllableEntity() ->getOrientation()  * WorldEntity::FRONT;
-            float thisDotProduct = diffVector.dotProduct( thisForwardVector );
-
-            Vector3 targetForwardVector = this->target_->getOrientation()  * WorldEntity::FRONT;
-            float targetDotProduct = diffVector.dotProduct( targetForwardVector );            
-
-
-            switch ( ( thisDotProduct > 0 )- ( thisDotProduct < 0 ))
-            {
-                case 1:
-                {
-                    switch ( ( targetDotProduct > 0 )- ( targetDotProduct < 0 ))
-                    {
-                        case 1:
-                        {
-                            this->maneuverType_ = ManeuverType::OFFENSIVE;
-                            break;
-                        }
-                        case 0:
-                        {
-                            this->maneuverType_ = ManeuverType::OFFENSIVE;
-                            break;
-                        }
-                        case -1:
-                        {
-                            this->maneuverType_ = ManeuverType::NEUTRAL;
-                            break;
-                        }
-                    }
-                    break;
-                }
-                case 0:
-                {
-                    switch ( ( targetDotProduct > 0 )- ( targetDotProduct < 0 ))
-                    {
-                        case 1:
-                        {
-                            this->maneuverType_ = ManeuverType::OFFENSIVE;
-                            break;
-                        }
-                        case 0:
-                        {
-                            this->maneuverType_ = ManeuverType::NEUTRAL;
-                            break;
-                        }
-                        case -1:
-                        {
-                            this->maneuverType_ = ManeuverType::DEFENCIVE;
-                            break;
-                        }
-                    }
-
-                    break;
-                }
-                case -1:
-                {
-                    switch ( ( targetDotProduct > 0 )- ( targetDotProduct < 0 ))
-                    {
-                        case 1:
-                        {
-                            this->maneuverType_ = ManeuverType::NEUTRAL;
-                            break;
-                        }
-                        case 0:
-                        {
-                            this->maneuverType_ = ManeuverType::DEFENCIVE;
-                            break;
-                        }
-                        case -1:
-                        {
-                            this->maneuverType_ = ManeuverType::DEFENCIVE;
-                            break;
-                        }
-                    }
-                    break;
-                }
-            }
-        }
-        if ( this->getControllableEntity()  && !this->target_ )
-        {
-            this->maneuverType_ = ManeuverType::NONE;
-        }
-        orxout ( internal_error ) << "ManeuverType = " << this->maneuverType_ << endl;
-    }
+    }
+   
     bool CommonController::setWingman ( CommonController* wingman )
     {
@@ -396,19 +347,4 @@
             setTargetOrientation( target->getOrientation() );
     }
-
-    /*void CommonController::spin() 
-    {
-        this->moveToTargetPosition();
-        this->getControllableEntity() ->rotateRoll( 8.0f );
-    }
-    void CommonController::turn180() 
-    {
-        Vector2 coord = get2DViewdirection( this->getControllableEntity() ->getPosition() , this->getControllableEntity() ->getOrientation()  * WorldEntity::FRONT, this->getControllableEntity() ->getOrientation()  * WorldEntity::UP, this->targetPosition_ );
-
-        this->getControllableEntity() ->rotateYaw( -2.0f * sgn( coord.x )* coord.x*coord.x );
-        this->getControllableEntity() ->rotatePitch( 2.0f * sgn( coord.y )* coord.y*coord.y );
-
-        this->getControllableEntity() ->moveFrontBack( SPEED );
-    }*/
 
 
@@ -444,11 +380,11 @@
             return;
         if ( this->rank_ == Rank::DIVISIONLEADER )
-            factor = 0.8;
+            factor = 0.9;
         if ( this->rank_ == Rank::SECTIONLEADER )
-            factor = 0.9;
+            factor = 0.95;
         
         //100 is ( so far )the smallest tolerance ( empirically found )that can be reached, 
         //with smaller distance spaceships can't reach position and go circles around it instead
-        int tolerance = 60;
+        int tolerance = 65;
 
         ControllableEntity* entity = this->getControllableEntity();
@@ -462,5 +398,5 @@
 
         //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 rotateX = -clamp( coord.x * 10, -1.0f, 1.0f );
         float rotateY = clamp( coord.y * 10, -1.0f, 1.0f );
 
@@ -469,6 +405,6 @@
         {
             //Yaw and Pitch are enough to start facing the target
-            this->getControllableEntity() ->rotateYaw( -2.0f * ROTATEFACTOR * rotateX * dt );
-            this->getControllableEntity() ->rotatePitch( 2.0f * ROTATEFACTOR * rotateY * dt );
+            this->getControllableEntity() ->rotateYaw( ROTATEFACTOR * rotateX * dt );
+            this->getControllableEntity() ->rotatePitch( ROTATEFACTOR * rotateY * dt );
 
             //300 works, maybe less is better
@@ -485,5 +421,5 @@
             }
 
-            this->getControllableEntity() ->moveFrontBack( 1.2f*SPEED*factor * dt );
+            this->getControllableEntity() ->moveFrontBack( SPEED*factor * dt );
         }
         else
@@ -500,190 +436,6 @@
         return a + r;
     }
-    void CommonController::attack() 
-    {
-        if ( !this->getControllableEntity()  )
-            return;
-        if ( this->target_ )
-        {
-            this->positionOfTarget_ = getPredictedPosition( 
-                this->getControllableEntity() ->getWorldPosition() , 
-                hardcoded_projectile_speed, 
-                this->target_->getWorldPosition() , 
-                this->target_->getVelocity()  
-                );
-            Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity() ->getWorldPosition();
-            float diffLength = diffVector.length();
-            if ( diffLength < 100 )
-            {
-                Vector3* targetPosition;
-                targetPosition = new Vector3 ( 
-                    //randomInRange( 200, 300 ), 
-                    0,
-                    //randomInRange( -300, -200 ), 
-                    0,
-                    randomInRange( -300, -400 )
-                    );
-                Quaternion rotationToTarget = ( this->getControllableEntity() ->getOrientation()  * WorldEntity::FRONT ).getRotationTo( diffVector );
-                Vector3 target = rotationToTarget * ( *targetPosition );
-                moveToPoint( 
-                    target, 
-                    randomInRange( 45, 180 )
-                    );
-                executingMoveToPoint_ = true; 
-                return;
-            }
-            this->bShooting_ = true;
-            this->positionOfTarget_ = getPredictedPosition( 
-                this->getControllableEntity() ->getWorldPosition() , 
-                hardcoded_projectile_speed, 
-                this->target_->getWorldPosition() , 
-                this->target_->getVelocity()  
-                );
-            this->targetPosition_ = positionOfTarget_;
-
-        }    
-        else
-        {
-            this->chooseManeuverType();
-        }
-    }
-    void CommonController::scissors() 
-    {
-        if ( !this->getControllableEntity()  )
-            return;
-        if ( this->target_ )
-        {
-            this->positionOfTarget_ = getPredictedPosition( 
-                this->getControllableEntity() ->getWorldPosition() , 
-                hardcoded_projectile_speed, 
-                this->target_->getWorldPosition() , 
-                this->target_->getVelocity()  
-                );
-            Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity() ->getWorldPosition();
-            float diffLength = diffVector.length();
-            Vector3 targetForwardVector = this->target_->getOrientation()  * WorldEntity::FRONT;
-            float targetDotProduct = diffVector.dotProduct( targetForwardVector );            
-            
-            int f = ( int )rnd( 100.0f );
-            f = ( f % 2 == 0 ? 1 : -1 );
-
-            if( !this->executingMoveToPoint_ )
-            {
-                Vector3* targetPosition;
-                if ( diffLength < 100 )
-                {
-                    targetPosition = new Vector3 ( 
-                        //f * randomInRange( 200, 300 ), 
-                        0,
-                        //f * randomInRange( -300, -200 ), 
-                        0,
-                        //randomInRange( -300, -400 )
-                        0
-                        );
-                }
-                else
-                {
-                    if ( targetDotProduct < 0 )
-                    {
-                        targetPosition = new Vector3 ( 
-                        //f * randomInRange( 200, 300 ), 
-                        0,
-                        //f * randomInRange( -300, -200 ), 
-                        0,
-                        //randomInRange( -300, -400 )
-                        -300
-                        );
-                    }
-                    else
-                    {
-                        targetPosition = new Vector3 ( 
-                        //f * randomInRange( 200, 300 ), 
-                        0,
-                        //f * randomInRange( -300, -200 ), 
-                        0,
-                        //randomInRange( -300, -400 )
-                        300
-                        );
-                    }
-                }
-                Quaternion rotationToTarget = ( this->getControllableEntity() ->getOrientation()  * WorldEntity::FRONT ).getRotationTo( diffVector );
-                Vector3 target = rotationToTarget * ( *targetPosition );
-                moveToPoint( 
-                    target, 
-                    randomInRange( 45, 180 )
-                    );
-                executingMoveToPoint_ = true;  
-            }
-        }
-        
-        else
-        {
-            this->chooseManeuverType();
-        }
-    }
-    void CommonController::gunsD() 
-    {
-        if ( !this->getControllableEntity()  )
-            return;
-        if ( this->target_ )
-        {
-            this->positionOfTarget_ = getPredictedPosition( 
-                this->getControllableEntity() ->getWorldPosition() , 
-                hardcoded_projectile_speed, 
-                this->target_->getWorldPosition() , 
-                this->target_->getVelocity()  
-                );
-            Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity() ->getWorldPosition();
-            float diffLength = diffVector.length();
-            if( !this->executingMoveToPoint_ )
-            {
-                Vector3* targetPosition;
-                if ( diffLength < 200 )
-                {
-                    targetPosition = new Vector3 ( 
-                        //f * randomInRange( 200, 300 ), 
-                        0,
-                        //f * randomInRange( -300, -200 ), 
-                        0,
-                        //randomInRange( -300, -400 )
-                        0
-                        );
-                }
-                else if ( diffLength < 500 )
-                {
-                    targetPosition = new Vector3 ( 
-                        //randomInRange( 100, 200 ), 
-                        0,
-                        //randomInRange( -200, -100 ), 
-                        0,
-                        //randomInRange( -400, -600 )
-                        500
-                        );
-                }
-                else
-                {
-                    targetPosition = new Vector3 ( 
-                        //randomInRange( 200, 300 ), 
-                        0,
-                        //randomInRange( -300, -200 ), 
-                        0,
-                        //randomInRange( -400, -600 )
-                        500
-                        );
-                }
-                Quaternion rotationToTarget = ( this->getControllableEntity() ->getOrientation()  * WorldEntity::FRONT ).getRotationTo( diffVector );
-                Vector3 target = rotationToTarget * ( *targetPosition );
-                moveToPoint( 
-                    target, 
-                    randomInRange( 45, 180 )
-                    );
-                executingMoveToPoint_ = true;  
-            }
-        }
-        else
-        {
-            this->chooseManeuverType();
-        }
-    }
+    
+
     //to be called in action
     //PRE: relativeTargetPosition is desired position relative to the spaceship,
@@ -769,5 +521,5 @@
         if ( !this->getControllableEntity()  )
             return 0;
-        if ( !this->target_ )
+        if ( !this->target_ || !this->getControllableEntity() )
             return ( this->getControllableEntity() ->getPosition() .squaredDistance( this->targetPosition_ ) );
         else
@@ -777,17 +529,36 @@
     bool CommonController::isLookingAtTarget( float angle )const
     {
-        if ( !this->getControllableEntity() )
+        if ( !this->getControllableEntity()  || !this->target_ )
             return false;
 
-        return ( getAngle( this->getControllableEntity() ->getPosition() , this->getControllableEntity() ->getOrientation()  * WorldEntity::FRONT, this->positionOfTarget_ ) < angle );
+        return ( getAngle( this->getControllableEntity() ->getPosition() , 
+            this->getControllableEntity() ->getOrientation()  * WorldEntity::FRONT, this->positionOfTarget_ ) < angle );
+    }
+    bool CommonController::isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle )const
+    {
+        if ( !entityThatLooks || !entityBeingLookedAt )
+            return false;
+        return ( getAngle( entityThatLooks ->getPosition() , 
+            entityThatLooks->getOrientation()  * WorldEntity::FRONT, 
+            entityBeingLookedAt->getWorldPosition() ) < angle );
     }
 
     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();
-        this->setPositionOfTarget( this->target_->getPosition() );
-
-        if ( this->bShooting_ && squaredDistance < 9000000 && squaredDistance > 10000 && this->isLookingAtTarget( math::pi /( 0.0002f*squaredDistance )) )
-        {
+
+        if ( squaredDistance < 25000000.0f && this->isLookingAtTarget( math::pi / 10.0f)) {
             return true;
         }
@@ -801,10 +572,10 @@
     {
         if ( !this->target_ || !this->getControllableEntity() )
+        {
             return;
-        static const float hardcoded_projectile_speed = 750;
-
-        this->positionOfTarget_ = getPredictedPosition( this->getControllableEntity() ->getWorldPosition() , hardcoded_projectile_speed, this->target_->getWorldPosition() , this->target_->getVelocity() );
-        this->bHasPositionOfTarget_ = ( this->positionOfTarget_ != Vector3::ZERO );
-
+        }
+      
+
+        
         Pawn* pawn = orxonox_cast<Pawn*>( this->getControllableEntity() );
 
Index: /code/branches/AI_HS15/src/orxonox/controllers/CommonController.h
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/CommonController.h	(revision 10802)
+++ /code/branches/AI_HS15/src/orxonox/controllers/CommonController.h	(revision 10803)
@@ -81,7 +81,7 @@
 
         public:
-        static const float hardcoded_projectile_speed = 750;
+            static const float hardcoded_projectile_speed = 750;
 
-            static const float ACTION_INTERVAL = 2.0f;
+            static const float ACTION_INTERVAL = 1.0f;
 
 
@@ -114,4 +114,5 @@
             void setTarget(ControllableEntity* target);
             bool hasTarget();
+            ControllableEntity* getTarget();
             void setTargetOrientation(const Quaternion& orient);
             void setTargetOrientation(ControllableEntity* target);
@@ -123,5 +124,6 @@
 
         protected:
-
+            void dodge(Vector3& thisPosition, Vector3& diffUnit);
+            int counter;
             void moveToPoint(const Vector3& relativeTargetPosition, float angleRoll);
             bool moveAndRoll(float dt);
@@ -139,4 +141,5 @@
             void aimAtTarget();
             bool isLookingAtTarget(float angle) const;
+            bool isLooking( ControllableEntity* entityThatLooks, ControllableEntity* entityBeingLookedAt, float angle )const;
 
             //checks if spaceship points at enemy and if there are allies inbetween
@@ -155,4 +158,5 @@
             Quaternion targetOrientation_;
 
+            void stopMoving();
             void setPositionOfTarget(const Vector3& target);
             void setOrientationOfTarget(const Quaternion& orient);
@@ -164,7 +168,14 @@
 
             WeakPtr<ControllableEntity> target_;
+            //WeakPtr<ControllableEntity> thisEntity_;
+
+            bool bEngaging_;
             bool bShooting_;
             WeakPtr<ControllableEntity> objectiveTarget_;
 
+            void lookAtTarget(float dt);
+            void stopLookingAtTarget();
+            void startLookingAtTarget();
+            bool bLookAtTarget_;
             void maneuver();
             void chooseManeuverType();
Index: /code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
===================================================================
--- /code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	(revision 10802)
+++ /code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc	(revision 10803)
@@ -56,57 +56,20 @@
     
     void DivisionController::tick(float dt)
-    {
-        if (this->target_ )
-        {
-            this->setPositionOfTarget(target_->getWorldPosition());
-
-        }
-        /*if (this->target_)
-        {
-            this->aimAtTarget();
+    {   
+        if (!this->isActive())
+            return;
+        if (this->bHasTargetPosition_)
+        {
+            this->moveToTargetPosition(dt);
+        }
+        else if (this->bLookAtTarget_)
+        {
+            this->lookAtTarget(dt);
+        }
+        if (bShooting_)
+        {
             this->doFire();
-            this->bShooting_ = true;
-        }*/
-        
-        if (this->bHasTargetPosition_)
-        {
-            this->moveToTargetPosition(dt);
-        }
-       /* if (executingMoveToPoint_)
-        {
-            executingMoveToPoint_ = !this->moveAndRoll(dt);
-        }
-        else
-        {
-            if (this->target_)
-            {
-                this->positionOfTarget_ = getPredictedPosition( 
-                    this->getControllableEntity()->getWorldPosition(), 
-                    hardcoded_projectile_speed, 
-                    this->target_->getWorldPosition(), 
-                    this->target_->getVelocity() 
-                    );
-                Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition();
-                float diffLength = diffVector.length();
-                Quaternion rotationToTarget = (this->getControllableEntity()->getOrientation() * WorldEntity::FRONT).getRotationTo(diffVector);
-                Vector3* targetPosition = new Vector3 ( 0, 0, -200 );
-                Vector3 target = rotationToTarget * (*targetPosition);
-                if (diffLength > 200)
-                    this->setTargetPosition( this->positionOfTarget_ - 0.6f*diffVector);
-                
-                else
-                    this->setTargetPosition( this->getControllableEntity()->getWorldPosition() );
-                executingMoveToPoint_ = true;  
-            }
-            
-            
-            if (this->maneuverType_ == ManeuverType::OFFENSIVE)
-            {
-                this->attack();
-                this->moveAndRoll(dt);
-            }
-        }*/
-        if (this->bShooting_ && this->canFire())
-            doFire();
+        }
+        
         SUPER(DivisionController, tick, dt);
 
@@ -114,82 +77,8 @@
     void DivisionController::action()
     {
-/*
-        Vector3* pos = new Vector3(4000,1000,2000);
-        this->setTargetPosition(*pos);*/
-       
-/*        if (!this->target_)
-        {
-
-            for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it)
-            {
-                if (this->getControllableEntity()->getTeam() == static_cast<ControllableEntity*>(*it)->getTeam())
-                    continue;
-
-               
-
-                if (static_cast<ControllableEntity*>(*it) != this->getControllableEntity())
-                {
-                    this->setTarget(*it);
-                }
-            }
-        }*/
-        //this->chooseManeuverType();
-                    this->maneuver();
-
-        switch (this->maneuverType_)
-        {
-            case ManeuverType::NONE:
-            {
-                setTargetPositionOfFollower();
-                setTargetPositionOfWingman();
-                break;
-            }
-            case ManeuverType::DEFENCIVE:
-            {
-                this->gunsD();
-                break;
-            }
-            case ManeuverType::OFFENSIVE:
-            {
-                this->attack();
-                break;
-            }
-            case ManeuverType::NEUTRAL:
-            {
-                this->scissors();
-            }
-            default:
-            {
-                this->gunsD();
-                break;
-            }
-        }
-       
-        /*if (!executingMoveToPoint_)
-        {
-            Vector3* targetPosition = new Vector3 (0, 0, -2000);
-            moveToPoint(*targetPosition, 180);
-            executingMoveToPoint_ = true;
-        }
-        */
-        // if (this->myFollower_ && this->target_)
-        //     this->myFollower_->setTarget(this->target_);
-        // if (this->target_ && this->myWingman_)
-        //     this->myWingman_->setTarget(this->target_);
-    /*            
-        for (ObjectList<Controller>::iterator it = ObjectList<Controller>::begin(); it; ++it)
-        {
-            if ((this->getControllableEntity()->getTeam() != (it)->getControllableEntity()->getTeam()) && (it)->getControllableEntity()->getTeam() != 0)
-            {
-                this->setTargetPosition(it->getControllableEntity()->getWorldPosition());
-                             
-                break;
-            } 
-        }
-           */
-        if (canFire())
-           this->bShooting_ = true;
-        else
-            this->bShooting_ = false;
+        this->maneuver();
+        this->bShooting_ = this->canFire();
+        
+
     }
 
