Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 9, 2011, 11:40:54 PM (13 years ago)
Author:
jo
Message:

First successful attempt, to make bots shoot rockets. Unfortunately they're shooting the wrong ones.

File:
1 edited

Legend:

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

    r8238 r8701  
    3535#include "worldentities/pawns/Pawn.h"
    3636
    37 //Todo: Bot soll pickupspawner besuchen können, falls Pickup vorhanden
     37//Todo: Bot soll pickupspawner besuchen können, falls Pickup vorhanden --modules/weapons/
    3838namespace orxonox
    3939{
     
    205205        float random;
    206206        float maxrand = 100.0f / ACTION_INTERVAL;
    207        
     207       
    208208        if (!this->isActive())
    209209            return;
    210210
    211         if (this->state_ == MASTER)
    212         {
    213             if (this->specificMasterAction_ ==  NONE)
     211        if(this->mode_ == DEFAULT)
     212        {
     213            if (this->state_ == MASTER)
     214            {
     215                if (this->specificMasterAction_ ==  NONE)
     216                {
     217                    if (this->target_)
     218                    {
     219                        if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */
     220                            this->forgetTarget();
     221                        else
     222                        {
     223                            this->aimAtTarget();
     224                            random = rnd(maxrand);
     225                            if(this->botlevel_*100 > random)
     226                                this->follow();//If a bot is shooting a player, it shouldn't let him go away easily.
     227                        }
     228                    }
     229
     230                    if (this->bHasTargetPosition_)
     231                        this->moveToTargetPosition();
     232
     233                    this->doFire();
     234                }
     235
     236                if (this->specificMasterAction_  == TURN180)
     237                    this->turn180();
     238
     239                if (this->specificMasterAction_ == SPIN)
     240                    this->spin();
     241                if (this->specificMasterAction_ == FOLLOW)
     242                    this->follow();
     243            }
     244
     245            if (this->state_ == SLAVE)
     246            {
     247                if (this->bHasTargetPosition_)
     248                    this->moveToTargetPosition();
     249            }
     250
     251            if (this->state_ == FREE)
    214252            {
    215253                if (this->target_)
     
    223261                        if(this->botlevel_*100 > random)
    224262                            this->follow();//If a bot is shooting a player, it shouldn't let him go away easily.
    225                     }
     263                     }
    226264                }
    227265
     
    231269                this->doFire();
    232270            }
    233 
    234             if (this->specificMasterAction_  == TURN180)
    235                     this->turn180();
    236 
    237             if (this->specificMasterAction_ == SPIN)
    238                     this->spin();
    239             if (this->specificMasterAction_ == FOLLOW)
    240                     this->follow();
    241         }
    242 
    243         if (this->state_ == SLAVE)
    244         {
    245             if (this->bHasTargetPosition_)
    246                 this->moveToTargetPosition();
    247         }
    248 
    249         if (this->state_ == FREE)
    250         {
    251             if (this->target_)
    252             {
    253                 if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */
    254                     this->forgetTarget();
    255                 else
    256                 {
    257                     this->aimAtTarget();
    258                     random = rnd(maxrand);
    259                     if(this->botlevel_*100 > random)
    260                         this->follow();//If a bot is shooting a player, it shouldn't let him go away easily.
     271        }//END_OF DEFAULT MODE
     272        else if (this->mode_ == ROCKET)
     273        {   
     274            ControllableEntity *controllable = this->getControllableEntity();
     275            if(controllable)
     276            {
     277                 if(controllable->getRocket())//Check wether the bot is controlling the rocket.
     278                 {
     279                     this->follow(); //TODO: CHECK: does follow make the bot crash into the target_ ?
    261280                 }
    262             }
    263 
    264             if (this->bHasTargetPosition_)
    265                 this->moveToTargetPosition();
    266 
    267             this->doFire();
    268         }
    269 
     281                 else
     282                     this->mode_ = DEFAULT;//no rocket -> get out of rocket mode
     283            }
     284            else
     285                this->mode_ = DEFAULT;//If bot dies -> getControllableEntity == NULL -> get out of ROCKET mode
     286        }//END_OF ROCKET MODE
    270287        SUPER(AIController, tick, dt);
    271288    }
    272289
    273290}
     291
Note: See TracChangeset for help on using the changeset viewer.