Changeset 7833 for code/branches/ai
- Timestamp:
- Jan 27, 2011, 7:50:16 PM (14 years ago)
- Location:
- code/branches/ai/src/orxonox/controllers
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/src/orxonox/controllers/AIController.cc
r7832 r7833 76 76 // search enemy 77 77 random = rnd(maxrand); 78 if (random < 15&& (!this->target_))78 if (random < (15 + botlevel_* 2) && (!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 < (5/botlevel_) && (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 < (10 + botlevel_) && (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_*3) && (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 < (25 - botlevel_*2 ) && (this->bShooting_)) 114 114 this->bShooting_ = false; 115 115 … … 176 176 if (random < 50 && (!this->bHasTargetPosition_ && !this->target_)) 177 177 this->searchRandomTargetPosition(); 178 179 178 180 179 // fly somewhere else … … 193 192 // stop shooting 194 193 random = rnd(maxrand); 195 if (random < 25&& (this->bShooting_))194 if (random < (25 - botlevel_*2 ) && (this->bShooting_)) 196 195 this->bShooting_ = false; 197 196 -
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
r7832 r7833 86 86 this->bSetupWorked = false; 87 87 this->numberOfWeapons = 0; 88 this->botlevel_ = 10.0f; 88 89 } 89 90 … … 128 129 XMLPortParam(ArtificialController, "formationSize", setFormationSize, getFormationSize, xmlelement, mode).defaultValues(STANDARD_MAX_FORMATION_SIZE); 129 130 XMLPortParam(ArtificialController, "passive", setPassive, getPassive, xmlelement, mode).defaultValues(false); 131 XMLPortParam(ArtificialController, "level", setBotLevel, getBotLevel, xmlelement, mode).defaultValues(1.0f); 130 132 } 131 133 … … 1018 1020 return (team1 == team2 && team1 != -1); 1019 1021 } 1020 1022 /** 1023 @brief DoFire is called when a bot should shoot and decides which weapon is used and whether the bot shoots at all. 1024 */ 1021 1025 void ArtificialController::doFire() 1022 1026 { … … 1027 1031 bSetupWorked=true; 1028 1032 } 1029 else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget(1000 ) && this->isLookingAtTarget(math::pi / 20.0f))1030 { 1031 if (this->isCloseAtTarget(1 40) && this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[1]==1) )1033 else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget(1000 + botlevel_*200) && this->isLookingAtTarget(math::pi / 20.0f)) 1034 { 1035 if (this->isCloseAtTarget(130) && this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[1]==1) ) 1032 1036 this->getControllableEntity()->fire(1); //ai uses lens flare if they're close enough to the target 1033 1037 … … 1037 1041 } 1038 1042 } 1043 /** 1044 @brief Information gathering: Which weapons are ready to use? 1045 */ 1039 1046 void ArtificialController::setupWeapons() 1040 1047 { … … 1057 1064 } 1058 1065 } 1066 1067 void ArtificialController::setBotLevel(float level) 1068 { 1069 if (level < 1) 1070 this->botlevel_ = 1 ; 1071 else if (level > 10) 1072 this->botlevel_ = 10; 1073 else 1074 this->botlevel_ = level; 1075 } 1059 1076 } -
code/branches/ai/src/orxonox/controllers/ArtificialController.h
r7832 r7833 80 80 81 81 virtual void doFire(); 82 void setBotLevel(float level=1.0f); 83 inline float getBotLevel() const 84 { return this->botlevel_; } 82 85 83 86 protected: … … 144 147 int numberOfWeapons; 145 148 int weapons[WeaponSystem::MAX_WEAPON_MODES]; 149 float botlevel_; //< Makes the level of a bot configurable. 146 150 147 151 private:
Note: See TracChangeset
for help on using the changeset viewer.