- Timestamp:
- Nov 24, 2015, 5:21:03 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
r10848 r10849 28 28 29 29 #include "DivisionController.h" 30 30 #include "infos/PlayerInfo.h" 31 31 32 32 namespace orxonox … … 93 93 if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL) 94 94 { 95 if ( (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_) ||96 !this->target_)97 { 98 ControllableEntity* newTarget = this->closestTarget();95 if ( (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_) 96 || !this->target_ ) 97 { 98 Pawn* newTarget = this->closestTarget(); 99 99 if ( newTarget && 100 CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_ ) 100 CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget)) 101 <= this->attackRange_ ) 101 102 { 102 103 // this->backupAction(); 103 104 // this->setAction (Action::FIGHT, newTarget); 104 this->parsedActionpoints_.push_back( 105 std::make_tuple (Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO) ); 105 Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO }; 106 this->parsedActionpoints_.push_back(p); 107 this->executeActionpoint(); 106 108 } 107 109 } … … 113 115 if (this->action_ == Action::NONE) 114 116 { 115 116 } 117 118 this->executeActionpoint(); 117 this->executeActionpoint(); 118 } 119 119 120 120 121 //this->action_ is what I am actually executing, this->target_ is what I am … … 142 143 else if (this->action_ == Action::FIGHTALL) 143 144 { 144 if (newTarget )145 if (newTarget && newTarget->getController()) 145 146 { 146 147 this->setAction (Action::FIGHTALL, newTarget); … … 158 159 //----fly in formation if far enough---- 159 160 Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition(); 161 162 160 163 if (diffVector.length() > this->attackRange_) 161 164 { … … 198 201 else if (this->action_ == Action::FLY) 199 202 { 203 204 if (this->squaredDistanceToTarget() <= this->squaredaccuracy_) 205 { 206 orxout(internal_error) << "arrived"; 207 this->nextActionpoint(); 208 return; 209 } 200 210 this->setTargetPositionOfWingman(); 201 211 this->setTargetPositionOfFollower(); … … 203 213 else if (this->action_ == Action::PROTECT) 204 214 { 215 if (!this->getProtect()) 216 { 217 this->nextActionpoint(); 218 return; 219 } 205 220 /* if (this->myWingman_) 206 221 this->myWingman_->setAction (Action::PROTECT, this->getProtect()); … … 218 233 this->setTargetPositionOfWingman(); 219 234 this->setTargetPositionOfFollower(); 235 220 236 } 221 237 else if (this->action_ == Action::ATTACK) 222 238 { 223 if (this->hasTarget()) 224 { 225 //----fly in formation if far enough---- 226 Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition(); 227 if (diffVector.length() > this->attackRange_) 228 { 229 this->setTargetPositionOfWingman(); 230 this->setTargetPositionOfFollower(); 231 } 232 else 233 { 234 //----wingmans shall support the fire of their leaders---- 235 if (this->myWingman_) 236 { 237 this->myWingman_->setAction (this->action_, this->target_); 238 } 239 if (this->myFollower_) 240 { 241 this->myFollower_->setAction (this->action_); 242 } 243 244 } 245 246 } 247 if (this->hasTarget()) 248 { 249 //----choose where to go---- 250 this->maneuver(); 251 //----fire if you can---- 252 this->bShooting_ = this->canFire(); 253 } 239 if (!this->hasTarget()) 240 { 241 this->nextActionpoint(); 242 return; 243 } 244 //----fly in formation if far enough---- 245 Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition(); 246 if (diffVector.length() > this->attackRange_) 247 { 248 this->setTargetPositionOfWingman(); 249 this->setTargetPositionOfFollower(); 250 } 251 else 252 { 253 //----wingmans shall support the fire of their leaders---- 254 if (this->myWingman_) 255 { 256 this->myWingman_->setAction (this->action_, this->target_); 257 } 258 if (this->myFollower_) 259 { 260 this->myFollower_->setAction (this->action_); 261 } 262 263 } 264 265 //----choose where to go---- 266 this->maneuver(); 267 //----fire if you can---- 268 this->bShooting_ = this->canFire(); 254 269 } 255 270
Note: See TracChangeset
for help on using the changeset viewer.