- Timestamp:
- Nov 24, 2015, 10:37:28 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10843 r10851 42 42 this->myLeader_ = 0; 43 43 this->rank_ = Rank::WINGMAN; 44 this->bFirstAction_ = true; 45 44 46 } 45 47 … … 69 71 void WingmanController::action() 70 72 { 73 71 74 //----If no leader, find one---- 72 75 if (!this->myLeader_) … … 79 82 else 80 83 { 81 this->action_ = this->myLeader_->getAction(); 82 } 83 84 85 //----action was set to fight---- 86 if (this->action_ == Action::FIGHT) 87 { 88 //----If no leader found, attack someone---- 89 if (!this->hasTarget() && !this->myLeader_) 90 { 91 this->setClosestTarget(); 84 85 } 86 if (!this->myLeader_) 87 { 88 bool b = this->startAttackingEnemiesThatAreClose(); 89 90 if (this->action_ == Action::NONE) 91 { 92 this->executeActionpoint(); 93 } 94 if (this->action_ == Action::FIGHT || this->action_ == Action::FIGHTALL) 95 { 96 if (!this->hasTarget()) 97 { 98 //----find a target---- 99 ControllableEntity* newTarget = this->closestTarget(); 100 if (this->action_ == Action::FIGHT) 101 { 102 if (newTarget && 103 CommonController::distance (this->getControllableEntity(), newTarget) < this->attackRange_) 104 { 105 this->setAction (Action::FIGHT, newTarget); 106 } 107 else 108 { 109 this->nextActionpoint(); 110 return; 111 } 112 } 113 else if (this->action_ == Action::FIGHTALL) 114 { 115 if (newTarget && newTarget->getController()) 116 { 117 this->setAction (Action::FIGHTALL, newTarget); 118 } 119 else 120 { 121 this->nextActionpoint(); 122 return; 123 } 124 } 125 126 } 127 else if (this->hasTarget()) 128 { 129 //----fly in formation if far enough---- 130 Vector3 diffVector = this->positionOfTarget_ - this->getControllableEntity()->getWorldPosition(); 131 132 if (diffVector.length() > this->attackRange_) 133 { 134 if (this->action_ == Action::FIGHT) 135 { 136 this->nextActionpoint(); 137 return; 138 } 139 } 140 } 141 } 142 else if (this->action_ == Action::FLY) 143 { 144 if (this->squaredDistanceToTarget() <= this->squaredaccuracy_) 145 { 146 this->nextActionpoint(); 147 return; 148 } 149 } 150 else if (this->action_ == Action::PROTECT) 151 { 152 if (!this->getProtect()) 153 { 154 this->nextActionpoint(); 155 return; 156 } 157 158 Vector3* targetRelativePosition; 159 160 targetRelativePosition = new Vector3 (0, 300, 300); 161 162 Vector3 targetAbsolutePosition = ((this->getProtect()->getWorldPosition()) + 163 (this->getProtect()->getWorldOrientation()* (*targetRelativePosition))); 164 this->setTargetPosition(targetAbsolutePosition); 165 166 167 } 168 else if (this->action_ == Action::ATTACK) 169 { 170 if (!this->hasTarget()) 171 { 172 this->nextActionpoint(); 173 return; 174 } 175 92 176 } 93 177 if (this->hasTarget()) … … 99 183 } 100 184 } 101 //----action was set to fly, leader handles the logic---- 102 else if (this->action_ == Action::FLY) 103 { 104 105 } 106 //----gani-TODO: implement protect---- 107 else if (this->action_ == Action::PROTECT) 108 { 109 110 } 111 185 else 186 { 187 //----action was set to fight---- 188 if (this->action_ == Action::FIGHT) 189 { 190 //----If no leader found, attack someone---- 191 if (!this->hasTarget()) 192 { 193 this->setClosestTarget(); 194 } 195 if (this->hasTarget()) 196 { 197 //----choose where to go---- 198 this->maneuver(); 199 //----fire if you can---- 200 this->bShooting_ = this->canFire(); 201 } 202 } 203 //----action was set to fly, leader handles the logic---- 204 else if (this->action_ == Action::FLY) 205 { 206 207 } 208 } 209 if (this->bFirstAction_ && this->myLeader_) 210 { 211 this->parsedActionpoints_ = this->myLeader_->parsedActionpoints_; 212 this->bFirstAction_ = false; 213 } 112 214 } 113 215
Note: See TracChangeset
for help on using the changeset viewer.