- Timestamp:
- Nov 23, 2015, 11:17:22 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc
r10826 r10832 89 89 this->myDivisionLeader_ = newDivisionLeader; 90 90 91 if (newDivisionLeader)92 {93 //orxout(internal_error) << "new DivisionLeader set" << endl;94 }95 //----If no leader found, attack someone----96 //----TODO: find closest enemy----97 else98 {99 if ( !this->hasTarget() || this->action_ != Action::FIGHT )100 {101 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP)102 {103 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP)) )104 continue;105 106 this->setAction(Action::FIGHT, (*itP));107 break;108 }109 }110 111 }112 113 91 } 114 92 //----If have leader---- 115 93 else 116 94 { 117 this->chooseTarget();118 95 } 119 96 … … 121 98 if (this->action_ == Action::FIGHT) 122 99 { 123 //----choose where to go---- 124 this->maneuver(); 125 //----fire if you can---- 126 this->bShooting_ = this->canFire(); 127 128 if (this->target_) 129 { 130 //----wingmans shall support the fire of their leaders---- 131 if (this->myWingman_) 132 { 133 this->myWingman_->setAction (Action::FIGHT, this->target_); 134 } 100 if (!this->hasTarget()) 101 { 102 if (this->myDivisionLeader_) 103 { 104 this->chooseTarget(); 105 } 106 else 107 { 108 this->setClosestTarget(); 109 } 110 } 111 else 112 { 113 135 114 //----fly in formation if far enough---- 136 115 Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition(); … … 139 118 this->setTargetPositionOfWingman(); 140 119 } 120 else 121 { 122 //----wingmans shall support the fire of their leaders---- 123 if (this->myWingman_) 124 { 125 this->myWingman_->setAction (Action::FIGHT, this->target_); 126 } 127 } 128 } 129 if (this->hasTarget()) 130 { 131 //----choose where to go---- 132 this->maneuver(); 133 //----fire if you can---- 134 this->bShooting_ = this->canFire(); 141 135 } 142 136 } … … 156 150 157 151 } 158 //PRE: myDivisionLeader_ != 0 152 //PRE: myDivisionLeader_ != 0 && myDivisionLeader_->action_ == Action::FIGHT 159 153 //POST: this->target_ is set unless division leader doesn't have one 160 154 void SectionController::chooseTarget() … … 211 205 212 206 //----stay in formation---- 207 //gani-TODO: sum targetAbso... and this->predicted position 213 208 void SectionController::setTargetPositionOfWingman() 214 209 { … … 224 219 case FormationMode::FINGER4: 225 220 { 226 targetRelativePositionOfWingman = new Vector3 (-400, 0, -200);221 targetRelativePositionOfWingman = new Vector3 (-400, 0, 200); 227 222 break; 228 223 }
Note: See TracChangeset
for help on using the changeset viewer.