- 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/WingmanController.cc
r10826 r10832 85 85 CommonController* newLeader = findNewLeader(); 86 86 this->myLeader_ = newLeader; 87 if (newLeader) 88 { 89 //orxout(internal_error) << "new Leader set" << endl; 90 } 91 //----If no leader found, attack someone---- 92 //----TODO: find closest enemy---- 93 else 94 { 95 if ( !this->hasTarget() || this->action_ != Action::FIGHT ) 96 { 97 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 98 { 99 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP)) ) 100 continue; 101 this->setAction(Action::FIGHT, (*itP)); 102 break; 103 } 104 } 105 } 87 106 88 } 107 89 //----If have leader, he will deal with logic---- 108 90 else 109 91 { 110 92 this->action_ = this->myLeader_->getAction(); 111 93 } 112 94 … … 115 97 if (this->action_ == Action::FIGHT) 116 98 { 117 //----choose where to go---- 118 this->maneuver(); 119 //----fire if you can---- 120 this->bShooting_ = this->canFire(); 99 //----If no leader found, attack someone---- 100 if (!this->hasTarget() && !this->myLeader_) 101 { 102 this->setClosestTarget(); 103 } 104 if (this->hasTarget()) 105 { 106 //----choose where to go---- 107 this->maneuver(); 108 //----fire if you can---- 109 this->bShooting_ = this->canFire(); 110 } 121 111 } 122 112 //----action was set to fly, leader handles the logic---- … … 125 115 126 116 } 127 //---- TODO: implement protect----117 //----gani-TODO: implement protect---- 128 118 else if (this->action_ == Action::PROTECT) 129 119 {
Note: See TracChangeset
for help on using the changeset viewer.