- Timestamp:
- Nov 22, 2015, 5:06:38 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/DivisionController.cc
r10805 r10826 35 35 RegisterClass(DivisionController); 36 36 37 //Leaders share the fact that they have Wingmans 37 38 DivisionController::DivisionController(Context* context) : LeaderController(context) 38 39 { … … 53 54 } 54 55 56 void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode) 57 { 58 SUPER(DivisionController, XMLPort, xmlelement, mode); 59 60 //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f); 61 } 62 55 63 56 64 void DivisionController::tick(float dt) … … 76 84 void DivisionController::action() 77 85 { 78 if (!this->target_) 86 //----find a target---- 87 if ( !this->hasTarget() ) 79 88 { 80 89 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 81 90 { 82 if ( this->getControllableEntity()->getTeam() == static_cast<ControllableEntity*>(*itP)->getTeam())91 if ( CommonController::sameTeam (this->getControllableEntity(), static_cast<ControllableEntity*>(*itP)) ) 83 92 continue; 84 93 85 94 86 if (static_cast<ControllableEntity*>(*itP) != (this)->getControllableEntity() && !(this)->hasTarget()87 && ((*itP)->getWorldPosition() - (this)->getControllableEntity()->getWorldPosition()).length()< 10000)95 if (static_cast<ControllableEntity*>(*itP) != (this)->getControllableEntity() 96 && CommonController::distance (*itP, this->getControllableEntity()) < 10000) 88 97 { 89 98 (this)->setAction(Action::FIGHT, *itP); … … 94 103 if (this->action_ == Action::FIGHT) 95 104 { 105 //----choose where to go---- 96 106 this->maneuver(); 107 //----fire if you can---- 97 108 this->bShooting_ = this->canFire(); 109 98 110 if (this->target_) 99 111 { 100 112 if (this->myWingman_) 101 113 { 114 //----wingmans shall support the fire of their leaders---- 102 115 this->myWingman_->setAction (Action::FIGHT, this->target_); 103 116 } 104 117 118 //----fly in formation if far enough---- 105 119 Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition(); 106 120 if (diffVector.length() > 3000) … … 141 155 break; 142 156 } 143 case FormationMode::VEE: 144 { 145 break; 146 } 157 147 158 case FormationMode::DIAMOND: 148 159 { … … 177 188 break; 178 189 } 179 case FormationMode::VEE: 180 { 181 break; 182 } 190 183 191 case FormationMode::DIAMOND: 184 192 { … … 239 247 240 248 241 void DivisionController::XMLPort(Element& xmlelement, XMLPort::Mode mode)242 {243 SUPER(DivisionController, XMLPort, xmlelement, mode);244 245 //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);246 }247 248 249 249 250
Note: See TracChangeset
for help on using the changeset viewer.