Changeset 8731 for code/branches/ai2
- Timestamp:
- Jul 5, 2011, 10:39:50 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai2/src/orxonox/controllers/AIController.cc
r8730 r8731 208 208 float random; 209 209 float maxrand = 100.0f / ACTION_INTERVAL; 210 211 if (this->state_ == MASTER) 212 { 213 if (this->specificMasterAction_ == NONE) 210 if(this->mode_ == DEFAULT) 211 { 212 if (this->state_ == MASTER) 213 { 214 if (this->specificMasterAction_ == NONE) 215 { 216 if (this->target_) 217 { 218 if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */ 219 this->forgetTarget(); 220 else this->aimAtTarget(); 221 } 222 223 if (this->bHasTargetPosition_) 224 this->moveToTargetPosition(); 225 226 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f)) 227 this->getControllableEntity()->fire(0); 228 } 229 230 if (this->specificMasterAction_ == TURN180) 231 this->turn180(); 232 233 if (this->specificMasterAction_ == SPIN) 234 this->spin(); 235 if (this->specificMasterAction_ == FOLLOW) 236 this->follow(); 237 } 238 239 if (this->state_ == SLAVE) 240 { 241 if (this->bHasTargetPosition_) 242 this->moveToTargetPosition(); 243 } 244 245 if (this->state_ == FREE) 214 246 { 215 247 if (this->target_) … … 226 258 this->getControllableEntity()->fire(0); 227 259 } 228 229 if (this->specificMasterAction_ == TURN180) 230 this->turn180(); 231 232 if (this->specificMasterAction_ == SPIN) 233 this->spin(); 234 if (this->specificMasterAction_ == FOLLOW) 235 this->follow(); 236 } 237 238 if (this->state_ == SLAVE) 239 { 240 241 if (this->bHasTargetPosition_) 242 this->moveToTargetPosition(); 243 244 } 245 246 if (this->state_ == FREE) 247 { 248 if (this->target_) 249 { 250 if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */ 251 this->forgetTarget(); 252 else this->aimAtTarget(); 253 } 254 255 if (this->bHasTargetPosition_) 256 this->moveToTargetPosition(); 257 258 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f)) 259 this->getControllableEntity()->fire(0); 260 } 260 }//END_OF DEFAULT MODE 261 else if (this->mode_ == ROCKET)//Rockets do not belong to a group of bots -> bot states are not relevant. 262 { //Vector-implementation: mode_.back() == ROCKET; 263 ControllableEntity *controllable = this->getControllableEntity(); 264 if(controllable) 265 { 266 if(controllable->getRocket())//Check wether the bot is controlling the rocket and if the timeout is over. 267 { 268 this->follow(); //TODO: CHECK: does follow make the bot crash into the target_ ? 269 this->timeout_ -= dt; 270 if((timeout_< 0)||(!target_))//Check if the timeout is over or target died. 271 { 272 controllable->fire(0);//kill the rocket 273 this->setPreviousMode();//get out of rocket mode 274 } 275 } 276 else 277 this->setPreviousMode();//no rocket entity -> get out of rocket mode 278 } 279 else 280 this->setPreviousMode();//If bot dies -> getControllableEntity == NULL -> get out of ROCKET mode 281 }//END_OF ROCKET MODE 261 282 262 283 SUPER(AIController, tick, dt);
Note: See TracChangeset
for help on using the changeset viewer.