Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8730 for code/branches/ai2


Ignore:
Timestamp:
Jul 5, 2011, 10:16:47 PM (13 years ago)
Author:
jo
Message:

Going back one step (version without hud bug). Bots have better combat strength but do not use all weapons available.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/ai2/src/orxonox/controllers/AIController.cc

    r8724 r8730  
    159159                // search enemy
    160160                random = rnd(maxrand);
    161                 if (random < (botlevel_)*25 && (!this->target_))
     161                if (random < 15 && (!this->target_))
    162162                    this->searchNewTarget();
    163163
    164164                // forget enemy
    165165                random = rnd(maxrand);
    166                 if (random < (1-botlevel_)*6 && (this->target_))
     166                if (random < 5 && (this->target_))
    167167                    this->forgetTarget();
    168168
     
    185185                // shoot
    186186                random = rnd(maxrand);
    187                 if (!(this->passive_) && random < 25*(botlevel_)+1 && (this->target_ && !this->bShooting_))
     187                if (!(this->passive_) && random < 9 && (this->target_ && !this->bShooting_))
    188188                {
    189                     this->bShooting_ = true;
    190                     this->forceFreeSlaves();
     189                this->bShooting_ = true;
     190                this->forceFreeSlaves();
    191191                }
    192192
    193193                // stop shooting
    194194                random = rnd(maxrand);
    195                 if (random < ( (1- botlevel_)*25 ) && (this->bShooting_))
     195                if (random < 25 && (this->bShooting_))
    196196                    this->bShooting_ = false;
    197197
     
    203203    void AIController::tick(float dt)
    204204    {
     205        if (!this->isActive())
     206            return;
     207
    205208        float random;
    206209        float maxrand = 100.0f / ACTION_INTERVAL;
    207 
    208         if (!this->isActive())
    209             return;
    210         //Vector-implementation: if(target_.size() == 0) target[0] = DEFAULT;
    211         if(this->mode_ == DEFAULT)
    212         {//Vector-implementation: mode_.back() == DEFAULT;
    213210
    214211        if (this->state_ == MASTER)
     
    226223                    this->moveToTargetPosition();
    227224
    228                 this->doFire();
     225                if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
     226                    this->getControllableEntity()->fire(0);
    229227            }
    230228
     
    258256                this->moveToTargetPosition();
    259257
    260             this->doFire();
    261         }
    262 
    263         }//END_OF DEFAULT MODE
    264         else if (this->mode_ == ROCKET)//Rockets do not belong to a group of bots -> bot states are not relevant.
    265         {   //Vector-implementation: mode_.back() == ROCKET;
    266             ControllableEntity *controllable = this->getControllableEntity();
    267             if(controllable)
    268             {
    269                 if(controllable->getRocket())//Check wether the bot is controlling the rocket and if the timeout is over.
    270                 {
    271                     this->follow(); //TODO: CHECK: does follow make the bot crash into the target_ ?
    272                     this->timeout_ -= dt;
    273                     if((timeout_< 0)||(!target_))//Check if the timeout is over or target died.
    274                     {
    275                        controllable->fire(0);//kill the rocket
    276                        this->setPreviousMode();//get out of rocket mode
    277                     }
    278                 }
    279                 else
    280                     this->setPreviousMode();//no rocket entity -> get out of rocket mode
    281             }
    282             else
    283                 this->setPreviousMode();//If bot dies -> getControllableEntity == NULL -> get out of ROCKET mode
    284         }//END_OF ROCKET MODE
     258            if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f))
     259                this->getControllableEntity()->fire(0);
     260        }
    285261
    286262        SUPER(AIController, tick, dt);
Note: See TracChangeset for help on using the changeset viewer.