- Timestamp:
- Jun 22, 2011, 6:57:16 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
r8701 r8711 89 89 this->botlevel_ = 1.0f; 90 90 this->mode_ = DEFAULT; 91 this->timeout_=0; 91 92 } 92 93 … … 1035 1036 else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget((1 + 2*botlevel_)*1000) && this->isLookingAtTarget(math::pi / 20.0f)) 1036 1037 { 1037 /*if (this->isCloseAtTarget(130) && this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[1]==1) )1038 if (this->isCloseAtTarget(130) &&(weapons[1]==1) ) 1038 1039 {//LENSFLARE: short range weapon 1039 1040 this->getControllableEntity()->fire(1); //ai uses lens flare if they're close enough to the target 1040 1041 } 1041 else if( this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[3]==3)&& this->isCloseAtTarget(260) &&projectiles[3] )*/1042 else if((weapons[3]==3)&& this->isCloseAtTarget(400) /*&&projectiles[3]*/ ) 1042 1043 {//ROCKET: mid range weapon 1043 1044 //TODO: Which weapon is the rocket? How many rockets are available? 1044 1045 this->mode_ = ROCKET; 1045 //TODO: this->rockettimer->start()1046 1046 this->getControllableEntity()->fire(3);//launch rocket 1047 if(this->getControllableEntity()&&this->target_)//after fire(3) getControllableEntity() refers to the rocket! 1048 { 1049 float speed = this->getControllableEntity()->getVelocity().length() - target_->getVelocity().length(); 1050 if(!speed) speed = 0.1f; 1051 float distance = target_->getPosition().length() - this->getControllableEntity()->getPosition().length(); 1052 this->timeout_= distance/speed*sgn(speed*distance) + 1.8f;//predicted time of target hit (+ tolerance) 1053 } 1054 else 1055 this->timeout_ = 4.0f;//TODO: find better default value 1056 1047 1057 this->projectiles[3]-=1;//decrease ammo !! 1048 1058 } 1049 1050 /*else if ((weapons[0]==0))//LASER: default weapon 1051 this->getControllableEntity()->fire(0);*/ 1059 else if ((weapons[0]==0))//LASER: default weapon 1060 this->getControllableEntity()->fire(0); 1052 1061 } 1053 1062 } … … 1094 1103 it->setBotLevel(level); 1095 1104 } 1105 1106 void ArtificialController::setPreviousMode() 1107 { 1108 this->mode_ = DEFAULT; 1109 } 1096 1110 1097 1111 }
Note: See TracChangeset
for help on using the changeset viewer.