- Timestamp:
- Dec 2, 2015, 10:31:23 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
r10912 r10915 40 40 ActionpointController::ActionpointController(Context* context) : FightingController(context) 41 41 { 42 this->bPatrolling_ = false; 43 42 44 this->actionCounter_ = 0; 43 45 this->bInLoop_ = false; … … 100 102 void ActionpointController::tick(float dt) 101 103 { 104 if (!this->getControllableEntity()) 105 return; 102 106 if (stop_) 103 107 return; … … 109 113 { 110 114 this->timeDodged_ += dt; 111 if (this->timeDodged_ > 2.0f)115 if (this->timeDodged_ > 4.0f) 112 116 { 113 117 this->bStartedDodging_ = false; … … 119 123 maneuverCounter_ = 0; 120 124 this->timeOffset_ += dt; 121 if (this->timeOffset_ >= 2. 0f)125 if (this->timeOffset_ >= 2.4f) 122 126 this->timeOffset_ = 0.0f; 123 127 if (timeout_ <= 0) … … 133 137 } 134 138 135 139 if (!this->getControllableEntity()) 140 return; 136 141 if (this->bShooting_) 137 142 { … … 157 162 this->bFirstTick_ = false; 158 163 } 159 164 if (!this->getControllableEntity()) 165 return; 160 166 //maneuver every 0.25 sec -> 161 float currentPeriodTime = this->timeOffset_ - static_cast<int>(this->timeOffset_); 162 if (this->hasTarget() && ((currentPeriodTime >= 0.25f && currentPeriodTime <= 0.5f) || (currentPeriodTime >= 0.75 && currentPeriodTime <= 0.999f)) && !this->bManeuverCalled_) 167 if (this->hasTarget() && 168 ((this->timeOffset_ >= 0.4f && this->timeOffset_ < 0.8f) || 169 (this->timeOffset_ >= 1.2f && this->timeOffset_ < 1.6f) || 170 (this->timeOffset_ >= 1.8f && this->timeOffset_ < 2.0f) || 171 (this->timeOffset_ >= 2.2f && this->timeOffset_ < 2.4f)) && !this->bManeuverCalled_) 163 172 { 164 173 this->bManeuverCalled_ = true; … … 166 175 this->bShooting_ = this->canFire(); 167 176 } 168 if ((currentPeriodTime >= 0.0f && currentPeriodTime <= 0.25f) || (currentPeriodTime >= 0.5f && currentPeriodTime <= 0.75f)) 177 if ((this->timeOffset_ >= 0.0f && this->timeOffset_ < 0.4f) || 178 (this->timeOffset_ >= 0.8f && this->timeOffset_ < 1.2f) || 179 (this->timeOffset_ >= 1.6f && this->timeOffset_ < 1.8f) || 180 (this->timeOffset_ >= 2.0f && this->timeOffset_ < 2.2f)) 169 181 this->bManeuverCalled_ = false; 170 182 SUPER(ActionpointController, tick, dt); … … 183 195 this->startAttackingEnemiesThatAreClose(); 184 196 } 185 186 197 this->deltaHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth() - this->previousHp; 187 198 this->previousHp = orxonox_cast<Pawn*> (this->getControllableEntity())->getHealth(); … … 217 228 { 218 229 this->setAction (Action::FIGHTALL, newTarget); 219 this->action();230 //this->action(); 220 231 } 221 232 else 222 233 { 223 234 this->nextActionpoint(); 224 if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())) 225 { 226 this->action(); 227 } 228 else 229 { 230 } 235 this->executeActionpoint(); 236 231 237 } 232 238 } … … 244 250 { 245 251 this->setAction (Action::FIGHT, newTarget); 246 this->action();252 //this->action(); 247 253 } 248 254 else 249 255 { 250 256 this->nextActionpoint(); 251 this-> action();257 this->executeActionpoint(); 252 258 } 253 259 } … … 269 275 { 270 276 this->nextActionpoint(); 271 this-> action();277 this->executeActionpoint(); 272 278 } 273 279 } … … 279 285 { 280 286 this->nextActionpoint(); 281 this-> action();287 this->executeActionpoint(); 282 288 } 283 289 } … … 287 293 { 288 294 this->nextActionpoint(); 289 this-> action();295 this->executeActionpoint(); 290 296 } 291 297 this->stayNearProtect(); … … 297 303 { 298 304 this->nextActionpoint(); 299 this-> action();305 this->executeActionpoint(); 300 306 } 301 307 } … … 599 605 if (this->bLoop_) 600 606 { 601 if (!this->loopActionpoints_.empty()) 607 if (this->bPatrolling_) 608 { 609 this->loopActionpoints_.pop_back(); 610 this->bPatrolling_ = false; 611 } 612 else if (!this->loopActionpoints_.empty()) 602 613 { 603 614 this->moveBackToTop(); … … 689 700 <= this->attackRange_ ) 690 701 { 691 if (this->bLoop_) 702 this->setTarget(newTarget); 703 if (this->bLoop_ && !this->bPatrolling_) 692 704 { 693 Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, true };705 Point p = { Action::FIGHT, "", Vector3::ZERO, true }; 694 706 this->loopActionpoints_.push_back(p); 695 707 } 696 else 708 else if (!this->bPatrolling_) 697 709 { 698 710 //orxout (internal_error) << "found new target " << CommonController::getName(newTarget) <<endl; 699 Point p = { Action::FIGHT, CommonController::getName(newTarget), Vector3::ZERO, false };711 Point p = { Action::FIGHT, "", Vector3::ZERO, false }; 700 712 this->parsedActionpoints_.push_back(p); 701 713 } 714 this->bPatrolling_ = true; 702 715 this->executeActionpoint(); 703 716 }
Note: See TracChangeset
for help on using the changeset viewer.