- Timestamp:
- Nov 29, 2015, 12:14:43 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
r10885 r10886 45 45 FightingController::FightingController( Context* context ): FlyingController( context ) 46 46 { 47 this->attackRange_ = 3000;47 this->attackRange_ = 2500; 48 48 this->stopLookingAtTarget(); 49 49 this->bSetupWorked = false; … … 126 126 float diffLength = diffVector.length(); 127 127 Vector3 diffUnit = diffVector/diffLength; 128 bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/20.0f); 129 128 bool bTargetIsLookingAtThis = CommonController::isLooking (this->target_, this->getControllableEntity(), math::pi/15.0f) 129 || this->deltaHp < 0; 130 130 131 //too far? well, come closer then 131 132 if (diffLength > this->attackRange_) 132 133 { 133 this->spread_ = 300;134 this->formationMode_ = FormationMode:: WALL;134 this->spread_ = 400; 135 this->formationMode_ = FormationMode::DIAMOND; 135 136 this->bKeepFormation_ = true; 136 137 137 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);138 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f); 138 139 } 139 140 //too close? How do u expect to dodge anything? Just attack! 140 else if (diffLength < 500)141 else if (diffLength < 400) 141 142 { 142 143 this->bKeepFormation_ = false; 143 144 144 145 //at this point, just look and shoot 145 if (diffLength < 2 50)146 if (diffLength < 200) 146 147 { 147 148 this->stopMoving(); … … 150 151 else 151 152 { 152 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);153 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f); 153 154 } 154 155 } … … 157 158 { 158 159 this->bKeepFormation_ = false; 159 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);160 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 100.0f); 160 161 } 161 162 //That's unfortunate, he is looking and probably shooting... try to dodge what we can... … … 165 166 if (maneuverCounter_ == 0) 166 167 { 167 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 200.0f);168 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 50.0f); 168 169 return; 169 170 } … … 176 177 //d.x*x + d.y*y + d.z*z == 0 177 178 //z = 1/d.z * (-d.y*y - d.x * x) 178 float x = CommonController::randomInRange (100 0, 10000) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);179 float y = CommonController::randomInRange (100 0, 10000) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1);179 float x = CommonController::randomInRange (100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1); 180 float y = CommonController::randomInRange (100, 800) * (CommonController::randomInRange(0,1) <= 0.5 ? 1 : -1); 180 181 float z = (1/diffUnit.z) * (-x * diffUnit.x - y * diffUnit.y); 181 this->setTargetPosition(thisPosition + Vector3(x,y,z) + diffUnit * 1000.0f);182 this->setTargetPosition(thisPosition + Vector3(x,y,z) + (this->deltaHp < 0 ? -diffUnit * 450.0f : diffUnit * 100.0f)); 182 183 this->boostControl(); 183 184 … … 195 196 this->setPositionOfTarget(newPositionOfTarget); 196 197 } 198 197 199 return squaredDistanceToTarget() < this->attackRange_*this->attackRange_ && this->isLookingAtTarget(math::pi / 20.0f); 198 200 } … … 270 272 return; 271 273 } 274 272 275 Pawn* pawn = orxonox_cast<Pawn*> (this->getControllableEntity()); 273 276 if (pawn) 274 277 pawn->setAimPosition (this->positionOfTarget_); 275 278 // if (pawn->getHealth() < 100) 279 // orxout(internal_error) << "not full, hp = " << pawn->getHealth() << endl; 276 280 int firemode; 277 281 float distance = CommonController::distance (this->getControllableEntity(), this->target_); … … 281 285 // : getFiremode("HsW01")) : 282 286 // (distance < 2500 ? getFiremode("LightningGun") : getFiremode("HsW01")); 283 if (distance < 800)284 { 285 if (this->rocketsLeft_ > 0 )286 { 287 firemode = getFiremode (" SimpleRocketFire");287 if (distance < 1500) 288 { 289 if (this->rocketsLeft_ > 0 && !this->bFiredRocket_) 290 { 291 firemode = getFiremode ("RocketFire"); 288 292 } 289 293 else 290 294 { 291 if (distance > 450) 295 if (distance > 800) 296 firemode = getFiremode ("HsW01"); 297 else 292 298 firemode = getFiremode ("LightningGun"); 293 else294 firemode = getFiremode ("HsW01");295 299 } 296 300 297 301 } 298 else if (distance < 1200) 299 { 300 if (this->rocketsLeft_ > 0 && !this->bFiredRocket_) 301 { 302 firemode = getFiremode ("RocketFire"); 303 } 304 else 305 { 306 firemode = getFiremode ("HsW01"); 307 } 308 } 309 else if (distance < 1500) 302 // else if (distance < 1000) 303 // { 304 // if (this->rocketsLeft_ > 0 && !this->bFiredRocket_) 305 // { 306 // firemode = getFiremode ("RocketFire"); 307 // } 308 // else 309 // { 310 // firemode = getFiremode ("HsW01"); 311 // } 312 // } 313 else if (distance < 2000) 314 { 315 firemode = getFiremode ("HsW01"); 316 } 317 else 310 318 { 311 319 firemode = getFiremode ("LightningGun"); 312 320 } 313 else314 {315 firemode = getFiremode ("HsW01");316 }317 321 if (firemode < 0) 318 322 { 319 firemode = getFiremode ("HsW01"); 323 //assuming there is always some weapon with index 0 324 firemode = 0; 320 325 } 321 326 if (firemode == getFiremode("RocketFire")) 322 327 { 323 this->timeout_ = 1.0f;328 this->timeout_ = 0.5f; 324 329 this->rocketsLeft_--; 325 330 this->bFiredRocket_ = true;
Note: See TracChangeset
for help on using the changeset viewer.