Changeset 8730 for code/branches/ai2
- Timestamp:
- Jul 5, 2011, 10:16:47 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai2/src/orxonox/controllers/AIController.cc
r8724 r8730 159 159 // search enemy 160 160 random = rnd(maxrand); 161 if (random < (botlevel_)*25 && (!this->target_))161 if (random < 15 && (!this->target_)) 162 162 this->searchNewTarget(); 163 163 164 164 // forget enemy 165 165 random = rnd(maxrand); 166 if (random < (1-botlevel_)*6&& (this->target_))166 if (random < 5 && (this->target_)) 167 167 this->forgetTarget(); 168 168 … … 185 185 // shoot 186 186 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_)) 188 188 { 189 190 189 this->bShooting_ = true; 190 this->forceFreeSlaves(); 191 191 } 192 192 193 193 // stop shooting 194 194 random = rnd(maxrand); 195 if (random < ( (1- botlevel_)*25 )&& (this->bShooting_))195 if (random < 25 && (this->bShooting_)) 196 196 this->bShooting_ = false; 197 197 … … 203 203 void AIController::tick(float dt) 204 204 { 205 if (!this->isActive()) 206 return; 207 205 208 float random; 206 209 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;213 210 214 211 if (this->state_ == MASTER) … … 226 223 this->moveToTargetPosition(); 227 224 228 this->doFire(); 225 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f)) 226 this->getControllableEntity()->fire(0); 229 227 } 230 228 … … 258 256 this->moveToTargetPosition(); 259 257 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 } 285 261 286 262 SUPER(AIController, tick, dt);
Note: See TracChangeset
for help on using the changeset viewer.