Changeset 8701 for code/branches
- Timestamp:
- Jun 9, 2011, 11:40:54 PM (13 years ago)
- Location:
- code/branches/ai/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/src/modules/weapons/projectiles/Rocket.cc
r7163 r8701 59 59 this->bDestroy_ = false; 60 60 this->lifetime_ = 100; 61 this->bIsRocket=true; 61 62 62 63 if (GameMode::isMaster()) … … 115 116 Rocket::~Rocket() 116 117 { 118 this->bIsRocket=false; 117 119 if(this->isInitialized()) 118 120 { -
code/branches/ai/src/orxonox/controllers/AIController.cc
r8238 r8701 35 35 #include "worldentities/pawns/Pawn.h" 36 36 37 //Todo: Bot soll pickupspawner besuchen können, falls Pickup vorhanden 37 //Todo: Bot soll pickupspawner besuchen können, falls Pickup vorhanden --modules/weapons/ 38 38 namespace orxonox 39 39 { … … 205 205 float random; 206 206 float maxrand = 100.0f / ACTION_INTERVAL; 207 207 208 208 if (!this->isActive()) 209 209 return; 210 210 211 if (this->state_ == MASTER) 212 { 213 if (this->specificMasterAction_ == NONE) 211 if(this->mode_ == DEFAULT) 212 { 213 if (this->state_ == MASTER) 214 { 215 if (this->specificMasterAction_ == NONE) 216 { 217 if (this->target_) 218 { 219 if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */ 220 this->forgetTarget(); 221 else 222 { 223 this->aimAtTarget(); 224 random = rnd(maxrand); 225 if(this->botlevel_*100 > random) 226 this->follow();//If a bot is shooting a player, it shouldn't let him go away easily. 227 } 228 } 229 230 if (this->bHasTargetPosition_) 231 this->moveToTargetPosition(); 232 233 this->doFire(); 234 } 235 236 if (this->specificMasterAction_ == TURN180) 237 this->turn180(); 238 239 if (this->specificMasterAction_ == SPIN) 240 this->spin(); 241 if (this->specificMasterAction_ == FOLLOW) 242 this->follow(); 243 } 244 245 if (this->state_ == SLAVE) 246 { 247 if (this->bHasTargetPosition_) 248 this->moveToTargetPosition(); 249 } 250 251 if (this->state_ == FREE) 214 252 { 215 253 if (this->target_) … … 223 261 if(this->botlevel_*100 > random) 224 262 this->follow();//If a bot is shooting a player, it shouldn't let him go away easily. 225 }263 } 226 264 } 227 265 … … 231 269 this->doFire(); 232 270 } 233 234 if (this->specificMasterAction_ == TURN180) 235 this->turn180(); 236 237 if (this->specificMasterAction_ == SPIN) 238 this->spin(); 239 if (this->specificMasterAction_ == FOLLOW) 240 this->follow(); 241 } 242 243 if (this->state_ == SLAVE) 244 { 245 if (this->bHasTargetPosition_) 246 this->moveToTargetPosition(); 247 } 248 249 if (this->state_ == FREE) 250 { 251 if (this->target_) 252 { 253 if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */ 254 this->forgetTarget(); 255 else 256 { 257 this->aimAtTarget(); 258 random = rnd(maxrand); 259 if(this->botlevel_*100 > random) 260 this->follow();//If a bot is shooting a player, it shouldn't let him go away easily. 271 }//END_OF DEFAULT MODE 272 else if (this->mode_ == ROCKET) 273 { 274 ControllableEntity *controllable = this->getControllableEntity(); 275 if(controllable) 276 { 277 if(controllable->getRocket())//Check wether the bot is controlling the rocket. 278 { 279 this->follow(); //TODO: CHECK: does follow make the bot crash into the target_ ? 261 280 } 262 } 263 264 if (this->bHasTargetPosition_) 265 this->moveToTargetPosition(); 266 267 this->doFire(); 268 } 269 281 else 282 this->mode_ = DEFAULT;//no rocket -> get out of rocket mode 283 } 284 else 285 this->mode_ = DEFAULT;//If bot dies -> getControllableEntity == NULL -> get out of ROCKET mode 286 }//END_OF ROCKET MODE 270 287 SUPER(AIController, tick, dt); 271 288 } 272 289 273 290 } 291 -
code/branches/ai/src/orxonox/controllers/AIController.h
r5929 r8701 55 55 56 56 #endif /* _AIController_H__ */ 57 -
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
r8239 r8701 88 88 this->numberOfWeapons = 0; 89 89 this->botlevel_ = 1.0f; 90 this->mode_ = DEFAULT; 90 91 } 91 92 … … 1034 1035 else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget((1 + 2*botlevel_)*1000) && this->isLookingAtTarget(math::pi / 20.0f)) 1035 1036 { 1036 if (this->isCloseAtTarget(130) && this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[1]==1) ) 1037 /*if (this->isCloseAtTarget(130) && this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[1]==1) ) 1038 {//LENSFLARE: short range weapon 1037 1039 this->getControllableEntity()->fire(1); //ai uses lens flare if they're close enough to the target 1038 1039 //default fire (laser) 1040 else if ((weapons[0]==0)) 1041 this->getControllableEntity()->fire(0); 1040 } 1041 else if(this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[3]==3)&& this->isCloseAtTarget(260) &&projectiles[3] )*/ 1042 {//ROCKET: mid range weapon 1043 //TODO: Which weapon is the rocket? How many rockets are available? 1044 this->mode_ = ROCKET; 1045 //TODO: this->rockettimer->start() 1046 this->getControllableEntity()->fire(3);//launch rocket 1047 this->projectiles[3]-=1;//decrease ammo !! 1048 } 1049 1050 /*else if ((weapons[0]==0))//LASER: default weapon 1051 this->getControllableEntity()->fire(0);*/ 1042 1052 } 1043 1053 } … … 1045 1055 @brief Information gathering: Which weapons are ready to use? 1046 1056 */ 1047 void ArtificialController::setupWeapons() 1057 void ArtificialController::setupWeapons() //TODO: Make this function generic!! (at the moment is is based on conventions) 1048 1058 { 1049 1059 if(this->getControllableEntity()) … … 1057 1067 { 1058 1068 weapons[i]=i; 1069 projectiles[i]=1;//TODO: how to express infinite ammo? how to get data?? 1059 1070 numberOfWeapons++; 1060 1071 } … … 1062 1073 weapons[i]=-1; 1063 1074 } 1075 //pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user); 1064 1076 } 1065 1077 } … … 1070 1082 { 1071 1083 if (level < 0.0f) 1072 1073 1074 1075 1084 this->botlevel_ = 0.0f; 1085 else if (level > 1.0f) 1086 this->botlevel_ = 1.0f; 1087 else 1076 1088 this->botlevel_ = level; 1077 1089 } … … 1084 1096 1085 1097 } 1098 -
code/branches/ai/src/orxonox/controllers/ArtificialController.h
r7842 r8701 146 146 bool bShooting_; 147 147 148 int numberOfWeapons; 148 int numberOfWeapons;//< Used for weapon init function. Displayes number of weapons available for a bot. 149 149 int weapons[WeaponSystem::MAX_WEAPON_MODES]; 150 int projectiles[WeaponSystem::MAX_WEAPON_MODES]; 150 151 float botlevel_; //< Makes the level of a bot configurable. 152 153 enum Mode {DEFAULT, ROCKET, DEFENCE, MOVING};//TODO; implement DEFENCE, MOVING modes 154 Mode mode_; 151 155 152 156 private: … … 157 161 158 162 #endif /* _ArtificialController_H__ */ 163 -
code/branches/ai/src/orxonox/worldentities/ControllableEntity.cc
r7534 r8701 88 88 this->setPriority( Priority::VeryHigh ); 89 89 this->registerVariables(); 90 this->bIsRocket=false; 90 91 } 91 92 -
code/branches/ai/src/orxonox/worldentities/ControllableEntity.h
r7533 r8701 155 155 { return this->target_.get(); } 156 156 void setTargetInternal( uint32_t targetID ); 157 inline bool getRocket() const 158 {return this-> bIsRocket;} 157 159 158 160 protected: … … 168 170 169 171 Ogre::SceneNode* cameraPositionRootNode_; 172 bool bIsRocket; //Workaround to see, if the controllable entity is a Rocket. 170 173 171 174 private:
Note: See TracChangeset
for help on using the changeset viewer.