Changeset 7843 for code/branches/ai
- Timestamp:
- Feb 3, 2011, 5:46:31 PM (14 years ago)
- Location:
- code/branches/ai/src/orxonox/controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/src/orxonox/controllers/AIController.cc
r7842 r7843 26 26 * 27 27 */ 28 //TODO: intended behaviour: when a bot has a target_ it shouldn't move away. 28 29 29 #include "AIController.h" 30 30 … … 35 35 #include "worldentities/pawns/Pawn.h" 36 36 37 //Todo: Bot soll pickupspawner besuchen können, falls Pickup vorhanden 37 38 namespace orxonox 38 39 { … … 86 87 // next enemy 87 88 random = rnd(maxrand); 88 if (random < ((1 +botlevel_)*10) && (this->target_))89 if (random < ((1-botlevel_)*10) && (this->target_)) 89 90 this->searchNewTarget(); 90 91 … … 159 160 // search enemy 160 161 random = rnd(maxrand); 161 if (random < 15 && (!this->target_))162 if (random < (botlevel_)*25 && (!this->target_)) 162 163 this->searchNewTarget(); 163 164 164 165 // forget enemy 165 166 random = rnd(maxrand); 166 if (random < 5&& (this->target_))167 if (random < (1-botlevel_)*6 && (this->target_)) 167 168 this->forgetTarget(); 168 169 … … 184 185 // shoot 185 186 random = rnd(maxrand); 186 if (!(this->passive_) && random < 9&& (this->target_ && !this->bShooting_))187 if (!(this->passive_) && random < 25*(botlevel_)+1 && (this->target_ && !this->bShooting_)) 187 188 { 188 this->bShooting_ = true;189 this->forceFreeSlaves();189 this->bShooting_ = true; 190 this->forceFreeSlaves(); 190 191 } 191 192 … … 202 203 void AIController::tick(float dt) 203 204 { 205 float random; 206 float maxrand = 100.0f / ACTION_INTERVAL; 207 204 208 if (!this->isActive()) 205 209 return; … … 213 217 if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */ 214 218 this->forgetTarget(); 215 else this->aimAtTarget(); 219 else 220 { 221 this->aimAtTarget(); 222 random = rnd(maxrand); 223 if(this->botlevel_*100 > random) 224 this->follow();//If a bot is shooting a player, it shouldn't let him go away easily. 225 } 216 226 } 217 227 … … 233 243 if (this->state_ == SLAVE) 234 244 { 235 236 245 if (this->bHasTargetPosition_) 237 246 this->moveToTargetPosition(); 238 239 247 } 240 248 … … 245 253 if (!this->target_->getRadarVisibility()) /* So AI won't shoot invisible Spaceships */ 246 254 this->forgetTarget(); 247 else this->aimAtTarget(); 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. 261 } 248 262 } 249 263 -
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
r7842 r7843 53 53 SetConsoleCommand("ArtificialController", "formationsize", &ArtificialController::formationsize); 54 54 SetConsoleCommand("ArtificialController", "setbotlevel", &ArtificialController::setAllBotLevel); 55 56 55 57 56 static const unsigned int STANDARD_MAX_FORMATION_SIZE = 7; … … 131 130 XMLPortParam(ArtificialController, "formationSize", setFormationSize, getFormationSize, xmlelement, mode).defaultValues(STANDARD_MAX_FORMATION_SIZE); 132 131 XMLPortParam(ArtificialController, "passive", setPassive, getPassive, xmlelement, mode).defaultValues(false); 133 XMLPortParam(ArtificialController, "level", setBotLevel, getBotLevel, xmlelement, mode).defaultValues(1.0f);132 //XMLPortParam(ArtificialController, "level", setBotLevel, getBotLevel, xmlelement, mode).defaultValues(0.0f); 134 133 } 135 134 … … 1033 1032 bSetupWorked=true; 1034 1033 } 1035 else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget( 1000 + botlevel_*200) && this->isLookingAtTarget(math::pi / 20.0f))1034 else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget((1 + 2*botlevel_)*1000) && this->isLookingAtTarget(math::pi / 20.0f)) 1036 1035 { 1037 1036 if (this->isCloseAtTarget(130) && this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[1]==1) )
Note: See TracChangeset
for help on using the changeset viewer.