Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 15, 2015, 4:47:35 PM (9 years ago)
Author:
gania
Message:

Finished groundwork: AI fights enemies like I want it to. TODO implement all the functionality of old AI, like Waypoints, XMLPort

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc

    r10803 r10805  
    5555        this->executingManeuver_ = false;
    5656        this->executingMoveToPoint_ = false;
     57        this->action_ = Action::FLY;
    5758        this->stopLookingAtTarget();
    5859        this->maneuverType_ = ManeuverType::NONE;
     
    6364    CommonController::~CommonController()
    6465    {
     66        orxout(internal_error) << "I died, my Rank is " << rank_ << endl;
    6567    }
    6668
     
    118120        }
    119121    }
     122    Action::Value CommonController::getAction ()
     123    {
     124        return this->action_;
     125    }
     126
     127    void CommonController::setAction (Action::Value action, ControllableEntity* target)
     128    {
     129        this->action_ = action;
     130        if (action == Action::FIGHT)
     131        {   
     132            if (target)
     133                this->setTarget (target);
     134        }
     135        else if (action == Action::PROTECT)
     136        {
     137        }
     138    }
     139    void CommonController::setAction (Action::Value action, const Vector3& target)
     140    {
     141        this->action_ = action;
     142        if (action == Action::FLY)
     143        {
     144            this->setTargetPosition (target);
     145        }
     146        else if (action == Action::PROTECT)
     147        {
     148
     149        }
     150    }
     151    void CommonController::setAction (Action::Value action, const Vector3& target,  const Quaternion& orient )
     152    {
     153        this->action_ = action;
     154        if (action == Action::FLY)
     155        {
     156            this->setTargetPosition (target);
     157            this->setTargetOrientation (orient);
     158        }
     159        else if (action == Action::PROTECT)
     160        {
     161           
     162        }
     163    }
    120164    void CommonController::maneuver()
    121165    {
     
    145189
    146190            //bool bThisIsLookingAtTarget = this->isLooking ( getControllableEntity(), this->target_, math::pi/4 );
    147             bool bTargetIsLookingAtThis = this->isLooking ( this->target_, getControllableEntity(), math::pi/8.0f );
     191            bool bTargetIsLookingAtThis = this->isLooking ( this->target_, getControllableEntity(), math::pi/5.0f );
    148192           
    149193
    150194
    151195            //too far? well, come closer then
    152             if ( diffLength > 5000 )
     196            if ( diffLength > 3000 )
    153197            {
    154198                if (diffLength < 6000)
    155199                {
    156                     this->bEngaging_ = true;
     200
    157201                }
    158202                else
    159203                {
    160                     this->bEngaging_ = false;
    161204                }
    162205                this->setTargetPosition( this->positionOfTarget_ );
    163206            }
    164207            //too close? How do u expect to dodge anything? Just attack!
    165             else if ( diffLength < 600 )
     208            else if ( diffLength < 500 )
    166209            {   
    167210                //at this point, just look and shoot
    168                 if ( diffLength < 300 )
     211                if ( diffLength < 250 )
    169212                {
    170213                    this->stopMoving();
     
    205248        if ( this->getControllableEntity()  && !this->target_ )
    206249        {
    207             this->bEngaging_ = false;
     250
    208251            this->maneuverType_ = ManeuverType::NONE;
    209252        }
    210         orxout ( internal_error ) << "ManeuverType = " << this->maneuverType_ << endl;
     253        //orxout ( internal_error ) << "ManeuverType = " << this->maneuverType_ << endl;
    211254    }
    212255    ControllableEntity* CommonController::getTarget()
     
    305348    {
    306349        this->target_ = target;
    307         orxout ( internal_error ) << " TARGET SET " << endl;
     350        //orxout ( internal_error ) << " TARGET SET " << endl;
    308351       
    309352        if ( this->target_ )
     
    376419    void CommonController::moveToPosition( const Vector3& target, float dt )
    377420    {
    378         float factor = 1;
    379         if ( !this->getControllableEntity() )
    380             return;
    381         if ( this->rank_ == Rank::DIVISIONLEADER )
    382             factor = 0.9;
    383         if ( this->rank_ == Rank::SECTIONLEADER )
    384             factor = 0.95;
     421     
    385422       
    386423        //100 is ( so far )the smallest tolerance ( empirically found )that can be reached,
     
    421458            }
    422459
    423             this->getControllableEntity() ->moveFrontBack( SPEED*factor * dt );
     460            this->getControllableEntity() ->moveFrontBack( SPEED * dt );
    424461        }
    425462        else
     
    560597        float squaredDistance = squaredDistanceToTarget();
    561598
    562         if ( squaredDistance < 25000000.0f && this->isLookingAtTarget( math::pi / 10.0f)) {
     599        if ( squaredDistance < 9000000.0f && this->isLookingAtTarget( math::pi / 10.0f)) {
    563600            return true;
    564601        }
Note: See TracChangeset for help on using the changeset viewer.