- Timestamp:
- May 31, 2010, 5:31:50 AM (14 years ago)
- Location:
- code/branches/presentation3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3
- Property svn:mergeinfo changed
/code/branches/ai (added) merged: 6592,6601,6640,6683,6695-6696,6782,6795,6832-6833,6847,6850,6854,6888,6891,6918-6919,6958,6978,6986,6991,6997,7029,7033
- Property svn:mergeinfo changed
-
code/branches/presentation3/src/orxonox/controllers/AIController.cc
r7030 r7034 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * Dominik Solenicki 26 26 * 27 27 */ … … 56 56 float maxrand = 100.0f / ACTION_INTERVAL; 57 57 58 // search enemy 59 random = rnd(maxrand); 60 if (random < 15 && (!this->target_)) 61 this->searchNewTarget(); 62 63 // forget enemy 64 random = rnd(maxrand); 65 if (random < 5 && (this->target_)) 66 this->forgetTarget(); 67 68 // next enemy 69 random = rnd(maxrand); 70 if (random < 10 && (this->target_)) 71 this->searchNewTarget(); 72 73 // fly somewhere 74 random = rnd(maxrand); 75 if (random < 50 && (!this->bHasTargetPosition_ && !this->target_)) 76 this->searchRandomTargetPosition(); 77 78 // stop flying 79 random = rnd(maxrand); 80 if (random < 10 && (this->bHasTargetPosition_ && !this->target_)) 81 this->bHasTargetPosition_ = false; 82 83 // fly somewhere else 84 random = rnd(maxrand); 85 if (random < 30 && (this->bHasTargetPosition_ && !this->target_)) 86 this->searchRandomTargetPosition(); 87 88 // shoot 89 random = rnd(maxrand); 90 if (random < 75 && (this->target_ && !this->bShooting_)) 91 this->bShooting_ = true; 92 93 // stop shooting 94 random = rnd(maxrand); 95 if (random < 25 && (this->bShooting_)) 96 this->bShooting_ = false; 58 if (this->state_ == FREE) 59 { 60 61 if (this->formationFlight_) 62 { 63 // return to Master after being forced free 64 if (this->freedomCount_ == 1) 65 { 66 this->state_ = SLAVE; 67 this->freedomCount_ = 0; 68 } 69 70 random = rnd(maxrand); 71 if (random < 90 && (((!this->target_) || (random < 50 && this->target_)) && !this->forcedFree())) 72 this->searchNewMaster(); 73 } 74 75 // search enemy 76 random = rnd(maxrand); 77 if (random < 15 && (!this->target_)) 78 this->searchNewTarget(); 79 80 // forget enemy 81 random = rnd(maxrand); 82 if (random < 5 && (this->target_)) 83 this->forgetTarget(); 84 85 // next enemy 86 random = rnd(maxrand); 87 if (random < 10 && (this->target_)) 88 this->searchNewTarget(); 89 90 // fly somewhere 91 random = rnd(maxrand); 92 if (random < 50 && (!this->bHasTargetPosition_ && !this->target_)) 93 this->searchRandomTargetPosition(); 94 95 // stop flying 96 random = rnd(maxrand); 97 if (random < 10 && (this->bHasTargetPosition_ && !this->target_)) 98 this->bHasTargetPosition_ = false; 99 100 // fly somewhere else 101 random = rnd(maxrand); 102 if (random < 30 && (this->bHasTargetPosition_ && !this->target_)) 103 this->searchRandomTargetPosition(); 104 105 // shoot 106 random = rnd(maxrand); 107 if (!(this->passive_) && random < 75 && (this->target_ && !this->bShooting_)) 108 this->bShooting_ = true; 109 110 // stop shooting 111 random = rnd(maxrand); 112 if (random < 25 && (this->bShooting_)) 113 this->bShooting_ = false; 114 115 } 116 117 if (this->state_ == SLAVE) 118 { 119 120 } 121 122 if (this->state_ == MASTER) 123 { 124 125 126 this->commandSlaves(); 127 128 if (this->specificMasterAction_ != NONE) 129 { 130 this->specificMasterActionHold(); 131 132 // if (this->specificMasterAction_ == TURN180) 133 // this->turn180Init(); 134 135 // if (this->specificMasterAction_ == SPIN) 136 // this->spinInit(); 137 138 // if (this->specificMasterAction_ == FOLLOWHUMAN) 139 // this->followHuman(this->HumanToFollow_, false); 140 } 141 142 else { 143 144 // make 180 degree turn - a specific Master Action 145 random = rnd(1000.0f); 146 if (random < 5) 147 this->turn180Init(); 148 149 // spin around - a specific Master Action 150 random = rnd(1000.0f); 151 if (random < 5) 152 this->spinInit(); 153 154 // lose master status (only if less than 4 slaves in formation) 155 random = rnd(maxrand); 156 if(random < 15/(this->slaves_.size()+1) && this->slaves_.size() < 4 ) 157 this->loseMasterState(); 158 159 // look out for outher masters if formation is small 160 random = rnd(maxrand); 161 if(this->slaves_.size() < 3 && random < 20) 162 this->searchNewMaster(); 163 164 // search enemy 165 random = rnd(maxrand); 166 if (random < 15 && (!this->target_)) 167 this->searchNewTarget(); 168 169 // forget enemy 170 random = rnd(maxrand); 171 if (random < 5 && (this->target_)) 172 this->forgetTarget(); 173 174 // next enemy 175 random = rnd(maxrand); 176 if (random < 10 && (this->target_)) 177 this->searchNewTarget(); 178 179 // fly somewhere 180 random = rnd(maxrand); 181 if (random < 50 && (!this->bHasTargetPosition_ && !this->target_)) 182 this->searchRandomTargetPosition(); 183 184 185 // fly somewhere else 186 random = rnd(maxrand); 187 if (random < 30 && (this->bHasTargetPosition_ && !this->target_)) 188 this->searchRandomTargetPosition(); 189 190 // shoot 191 random = rnd(maxrand); 192 if (!(this->passive_) && random < 9 && (this->target_ && !this->bShooting_)) 193 { 194 this->bShooting_ = true; 195 this->forceFreeSlaves(); 196 } 197 198 // stop shooting 199 random = rnd(maxrand); 200 if (random < 25 && (this->bShooting_)) 201 this->bShooting_ = false; 202 203 } 204 } 205 97 206 } 98 207 … … 102 211 return; 103 212 104 if (this->target_) 105 this->aimAtTarget(); 106 107 if (this->bHasTargetPosition_) 108 this->moveToTargetPosition(); 109 110 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f)) 111 this->getControllableEntity()->fire(0); 213 if (this->state_ == MASTER) 214 { 215 if (this->specificMasterAction_ == NONE) 216 { 217 if (this->target_) 218 this->aimAtTarget(); 219 220 if (this->bHasTargetPosition_) 221 this->moveToTargetPosition(); 222 223 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f)) 224 this->getControllableEntity()->fire(0); 225 } 226 227 if (this->specificMasterAction_ == TURN180) 228 this->turn180(); 229 230 if (this->specificMasterAction_ == SPIN) 231 this->spin(); 232 if (this->specificMasterAction_ == FOLLOWHUMAN) 233 this->follow(); 234 } 235 236 if (this->state_ == SLAVE) 237 { 238 239 if (this->bHasTargetPosition_) 240 this->moveToTargetPosition(); 241 242 } 243 244 if (this->state_ == FREE) 245 { 246 if (this->target_) 247 this->aimAtTarget(); 248 249 if (this->bHasTargetPosition_) 250 this->moveToTargetPosition(); 251 252 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f)) 253 this->getControllableEntity()->fire(0); 254 } 112 255 113 256 SUPER(AIController, tick, dt);
Note: See TracChangeset
for help on using the changeset viewer.