Changeset 8724 for code/branches/ai2
- Timestamp:
- Jul 1, 2011, 12:59:23 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai2/src/orxonox/controllers/AIController.cc
r7284 r8724 76 76 // search enemy 77 77 random = rnd(maxrand); 78 if (random < 15&& (!this->target_))78 if (random < (15 + botlevel_* 20) && (!this->target_)) 79 79 this->searchNewTarget(); 80 80 81 81 // forget enemy 82 82 random = rnd(maxrand); 83 if (random < 5&& (this->target_))83 if (random < ((1-botlevel_)*6) && (this->target_)) 84 84 this->forgetTarget(); 85 85 86 86 // next enemy 87 87 random = rnd(maxrand); 88 if (random < 10&& (this->target_))88 if (random < (botlevel_*20) && (this->target_)) 89 89 this->searchNewTarget(); 90 90 … … 106 106 // shoot 107 107 random = rnd(maxrand); 108 if (!(this->passive_) && random < 75&& (this->target_ && !this->bShooting_))108 if (!(this->passive_) && random < (75 + botlevel_*25) && (this->target_ && !this->bShooting_)) 109 109 this->bShooting_ = true; 110 110 111 111 // stop shooting 112 112 random = rnd(maxrand); 113 if (random < 25&& (this->bShooting_))113 if (random < ((1 - botlevel_)*25) && (this->bShooting_)) 114 114 this->bShooting_ = false; 115 115 … … 159 159 // search enemy 160 160 random = rnd(maxrand); 161 if (random < 15 && (!this->target_))161 if (random < (botlevel_)*25 && (!this->target_)) 162 162 this->searchNewTarget(); 163 163 164 164 // forget enemy 165 165 random = rnd(maxrand); 166 if (random < 5&& (this->target_))166 if (random < (1-botlevel_)*6 && (this->target_)) 167 167 this->forgetTarget(); 168 168 … … 185 185 // shoot 186 186 random = rnd(maxrand); 187 if (!(this->passive_) && random < 9&& (this->target_ && !this->bShooting_))188 { 189 this->bShooting_ = true;190 this->forceFreeSlaves();187 if (!(this->passive_) && random < 25*(botlevel_)+1 && (this->target_ && !this->bShooting_)) 188 { 189 this->bShooting_ = true; 190 this->forceFreeSlaves(); 191 191 } 192 192 193 193 // stop shooting 194 194 random = rnd(maxrand); 195 if (random < 25&& (this->bShooting_))195 if (random < ( (1- botlevel_)*25 ) && (this->bShooting_)) 196 196 this->bShooting_ = false; 197 197 … … 203 203 void AIController::tick(float dt) 204 204 { 205 float random; 206 float maxrand = 100.0f / ACTION_INTERVAL; 207 205 208 if (!this->isActive()) 206 209 return; 210 //Vector-implementation: if(target_.size() == 0) target[0] = DEFAULT; 211 if(this->mode_ == DEFAULT) 212 {//Vector-implementation: mode_.back() == DEFAULT; 207 213 208 214 if (this->state_ == MASTER) … … 220 226 this->moveToTargetPosition(); 221 227 222 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f)) 223 this->getControllableEntity()->fire(0); 228 this->doFire(); 224 229 } 225 230 … … 253 258 this->moveToTargetPosition(); 254 259 255 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f)) 256 this->getControllableEntity()->fire(0); 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 285 259 286 SUPER(AIController, tick, dt);
Note: See TracChangeset
for help on using the changeset viewer.