- Timestamp:
- Nov 15, 2015, 4:47:35 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/SectionController.cc
r10789 r10805 55 55 void SectionController::tick(float dt) 56 56 { 57 if (!this->isActive())57 if (!this->isActive()) 58 58 return; 59 60 61 59 if (this->bHasTargetPosition_) 62 60 { 63 61 this->moveToTargetPosition(dt); 64 62 } 65 if (this->bShooting_) 66 doFire(); 63 else if (this->bLookAtTarget_) 64 { 65 this->lookAtTarget(dt); 66 } 67 if (bShooting_) 68 { 69 this->doFire(); 70 } 67 71 68 72 SUPER(SectionController, tick, dt); … … 80 84 else 81 85 { 82 83 } 84 85 } 86 setTargetPositionOfWingman(); 87 if (this->target_ && this->myWingman_) 88 this->myWingman_->setTarget(this->target_); 89 if (canFire()) 90 this->bShooting_ = true; 86 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 87 { 88 if (this->getControllableEntity()->getTeam() == static_cast<ControllableEntity*>(*itP)->getTeam()) 89 continue; 90 91 if (!this->myDivisionLeader_) 92 { 93 this->setAction(Action::FIGHT, (*itP)); 94 break; 95 } 96 97 } 98 } 99 100 } 91 101 else 92 this->bShooting_ = false; 102 { 103 if (this->myDivisionLeader_->getAction() == Action::FIGHT) 104 { 105 if (this->myDivisionLeader_->hasTarget()) 106 { 107 if (this->myDivisionLeader_->hasWingman() && (!this->hasTarget() || this->getTarget() == this->myDivisionLeader_->getTarget())) 108 { 109 bool foundTarget = false; 110 Vector3 divisionTargetPosition = this->myDivisionLeader_->getTarget()->getWorldPosition(); 111 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 112 { 113 if (this->getControllableEntity()->getTeam() == static_cast<ControllableEntity*>(*itP)->getTeam()) 114 continue; 115 116 if (((*itP)->getWorldPosition() - divisionTargetPosition).length() < 3000 && 117 ((*itP)->getWorldPosition() - divisionTargetPosition).length() > 1000 && 118 (*itP) != this->myDivisionLeader_->getTarget()) 119 { 120 foundTarget = true; 121 this->setAction(Action::FIGHT, (*itP)); 122 orxout(internal_error) << "Found target" << endl; 123 break; 124 } 125 } 126 if (!foundTarget) 127 { 128 this->setAction(Action::FIGHT, this->myDivisionLeader_->getTarget()); 129 } 130 131 } 132 } 133 } 134 } 135 136 if (this->action_ == Action::FIGHT) 137 { 138 this->maneuver(); 139 this->bShooting_ = this->canFire(); 140 if (this->target_) 141 { 142 if (this->myWingman_) 143 { 144 this->myWingman_->setAction (Action::FIGHT, this->target_); 145 } 146 Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition(); 147 if (diffVector.length() > 3000) 148 { 149 this->setTargetPositionOfWingman(); 150 } 151 } 152 } 153 else if (this->action_ == Action::FLY) 154 { 155 this->setTargetPositionOfWingman(); 156 } 157 else if (this->action_ == Action::PROTECT) 158 { 159 160 } 93 161 94 162 … … 126 194 (this->getControllableEntity()->getWorldOrientation()* (*targetRelativePositionOfWingman))); 127 195 128 myWingman_->setTargetOrientation(orient); 129 myWingman_->setTargetPosition(targetAbsolutePositionOfWingman); 196 myWingman_->setAction (Action::FLY, targetAbsolutePositionOfWingman, orient); 130 197 131 198 }
Note: See TracChangeset
for help on using the changeset viewer.