Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 16, 2011, 8:36:41 PM (12 years ago)
Author:
jo
Message:

Merged Formation branch. There are still some bugs (just have a look at the tutorial level)

Location:
code/branches/presentation2011
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2011

  • code/branches/presentation2011/src/orxonox/controllers/AIController.cc

    r8980 r8992  
    7575
    7676            this->defaultBehaviour(maxrand);
    77         }
    78 
    79         if (this->state_ == SLAVE)
    80         {
     77
     78        }
     79
     80        if (this->state_ == SLAVE && this->formationMode_ == ATTACK) //TODO: add botlevel parameter
     81        {
     82            // search enemy
     83            random = rnd(maxrand);
     84            if (random < 75 && (!this->target_))
     85                this->searchNewTarget();
     86
     87            // next enemy
     88            random = rnd(maxrand);
     89            if (random < 10 && (this->target_))
     90                this->searchNewTarget();
     91
     92            // shoot
     93            random = rnd(maxrand);
     94            if (!(this->passive_) && random < 75 && (this->target_ && !this->bShooting_))
     95                this->bShooting_ = true;
     96
     97            // stop shooting
     98            random = rnd(maxrand);
     99            if (random < 25 && (this->bShooting_))
     100                this->bShooting_ = false;
    81101
    82102        }
     
    101121                   this->spinInit();
    102122
    103                 // follow a randomly chosen human - a specific Master Action
     123                /*// follow a randomly chosen human - a specific Master Action
    104124                random = rnd(1000.0f);
    105125                if (random < 1)
    106126                   this->followRandomHumanInit();
    107 
     127*/
    108128                 // lose master status (only if less than 4 slaves in formation)
    109129                random = rnd(maxrand);
     
    117137
    118138                this->defaultBehaviour(maxrand);
    119             }
    120         }
     139
     140            }
     141        }
     142
    121143    }
    122144
     
    129151        float maxrand = 100.0f / ACTION_INTERVAL;
    130152        ControllableEntity* controllable = this->getControllableEntity();
    131 
     153        //DOES: Either move to the waypoint or search for a Point of interest
    132154        if (controllable && this->mode_ == DEFAULT)// bot is ready to move to a target
    133155        {
     
    151173            }
    152174        }
    153         if(this->mode_ == DEFAULT)
    154             {
     175
     176        if (this->mode_ == DEFAULT)
     177        {
    155178            if (this->state_ == MASTER)
    156179            {
     
    165188                            this->aimAtTarget();
    166189                            random = rnd(maxrand);
    167                             if(this->botlevel_*100 > random && !this->isCloseAtTarget(20))
     190                            if(this->botlevel_*70 > random && !this->isCloseAtTarget(100))
    168191                                this->follow();  //If a bot is shooting a player, it shouldn't let him go away easily.
    169192                        }
     
    172195                    if (this->bHasTargetPosition_)
    173196                        this->moveToTargetPosition();
    174 
    175197                    this->doFire();
    176198                }
     
    185207            }
    186208
    187             if (this->state_ == SLAVE)
     209            if (this->state_ == SLAVE && this->formationMode_ != ATTACK)
    188210            {
    189211                if (this->bHasTargetPosition_)
     
    191213            }
    192214
    193             if (this->state_ == FREE)
     215            if (this->state_ == FREE || (this->state_==SLAVE && this->formationMode_ == ATTACK) )
    194216            {
    195217                if (this->target_)
     
    197219                    if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */
    198220                        this->forgetTarget();
    199                     else
    200                     {
    201                         this->aimAtTarget();
    202                         random = rnd(maxrand);
    203 
    204                         if(this->botlevel_*100 > random && !this->isCloseAtTarget(20))
    205                             this->follow();//If a bot is shooting a player, it shouldn't let him go away easily.
    206                      }
     221                    else this->aimAtTarget();
    207222                }
    208223
     
    210225                    this->moveToTargetPosition();
    211226
    212                 this->doFire();
    213             }
    214         }//END_OF DEFAULT MODE
     227                    this->doFire();
     228            }
     229        }
    215230        else if (this->mode_ == ROCKET)//Rockets do not belong to a group of bots -> bot states are not relevant.
    216231        {   //Vector-implementation: mode_.back() == ROCKET;
     
    237252        SUPER(AIController, tick, dt);
    238253    }
    239 
     254//**********************************************NEW
    240255    void AIController::defaultBehaviour(float maxrand)
    241256    {       float random;
Note: See TracChangeset for help on using the changeset viewer.