- Timestamp:
- Dec 2, 2015, 10:31:23 AM (9 years ago)
- Location:
- code/branches/campaignHS15
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/data/levels/AITest.oxw
r10912 r10915 37 37 <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/> 38 38 <TeamSpawnPoint team=0 position="2000, 2000, 2000" lookat="1,1,-1" spawnclass=SpaceShip pawndesign=spaceshipassff /> 39 39 40 40 41 <!-- … … 91 92 <!-- HERE STARTS DEMO FOR THE ACTIONPOINTS. 92 93 P.S. Never set protectMe in the first actionpoint: if human didn't spawn, that actionpoint will be skipped --> 93 <!--94 <!-- 94 95 <Model mesh="cube.mesh" scale=8 position="0,0,0" /> 95 96 -
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 } -
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
r10912 r10915 87 87 { 88 88 public: 89 89 90 ActionpointController(Context* context); 90 91 virtual ~ActionpointController(); -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
r10912 r10915 68 68 return; 69 69 SUPER(DivisionController, tick, dt); 70 if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0. 5f && !this->bActionCalled_)70 if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_) 71 71 { 72 72 this->action(); 73 73 this->bActionCalled_ = true; 74 74 } 75 if (this->timeOffset_ > 1. 0f)75 if (this->timeOffset_ > 1.6f) 76 76 { 77 77 this->bActionCalled_ = false; … … 99 99 } 100 100 } 101 101 102 102 103 } … … 154 155 return false; 155 156 } 157 156 158 } -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.h
r10886 r10915 67 67 //----private variables----- 68 68 Timer actionTimer_; //<! Regularly calls action(). 69 69 70 70 71 }; -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10913 r10915 74 74 75 75 SUPER(SectionController, tick, dt); 76 if (this->timeOffset_ > = 0.5f && this->timeOffset_ <= 1.0f && !this->bActionCalled_)76 if (this->timeOffset_ > 0.8f && this->timeOffset_ <= 1.6f && !this->bActionCalled_) 77 77 { 78 78 this->action(); 79 79 this->bActionCalled_ = true; 80 80 } 81 if (this->timeOffset_ > 1.5f)81 if (this->timeOffset_ > 2.0f) 82 82 { 83 83 this->bActionCalled_ = false; 84 84 } 85 85 86 } 86 87 … … 154 155 } 155 156 } 157 156 158 this->actionCounter_ += this->actionCounter_ < 100000 ? 1 : -this->actionCounter_ ; 157 159 } … … 294 296 return 0; 295 297 } 298 296 299 bool SectionController::setWingman(ActionpointController* newWingman) 297 300 { -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
r10886 r10915 69 69 Timer actionTimer_; //<! Regularly calls action(). 70 70 bool bFirstAction_; 71 72 71 73 72 }; 74 73 } -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10909 r10915 68 68 69 69 SUPER(WingmanController, tick, dt); 70 if (this->timeOffset_ >= this->actionTime_ && this->timeOffset_ <= this->actionTime_ + 0.5f && !this->bActionCalled_) 71 { 72 this->action(); 73 this->bActionCalled_ = true; 74 } 75 if (this->timeOffset_ <= 0.5f) 76 { 77 this->bActionCalled_ = false; 78 } 70 if (!this->myLeader_) 71 { 72 if (this->actionTime_ == 2.0f) 73 { 74 if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_) 75 { 76 this->action(); 77 this->bActionCalled_ = true; 78 } 79 if (this->timeOffset_ > 1.6f) 80 { 81 this->bActionCalled_ = false; 82 } 83 } 84 else 85 { 86 if (this->timeOffset_ > 0.8f && this->timeOffset_ <= 1.6f && !this->bActionCalled_) 87 { 88 this->action(); 89 this->bActionCalled_ = true; 90 } 91 if (this->timeOffset_ > 2.0f) 92 { 93 this->bActionCalled_ = false; 94 } 95 } 96 } 97 else 98 { 99 if (this->timeOffset_ >= this->actionTime_ && this->timeOffset_ <= this->actionTime_ + 0.4f && !this->bActionCalled_) 100 { 101 this->action(); 102 this->bActionCalled_ = true; 103 } 104 if (this->timeOffset_ <= 0.5f) 105 { 106 this->bActionCalled_ = false; 107 } 108 } 109 110 79 111 } 80 112 … … 240 272 if (closestLeader->getIdentifier()->getName() == "SectionController") 241 273 { 242 this->actionTime_ = 1. 0f;274 this->actionTime_ = 1.6f; 243 275 } 244 276 else 245 277 { 246 this->actionTime_ = 1.5f;278 this->actionTime_ = 2.0f; 247 279 } 248 280 return closestLeader; -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
r10909 r10915 71 71 bool bFirstAction_; 72 72 float actionTime_; 73 74 73 75 }; 74 76 }
Note: See TracChangeset
for help on using the changeset viewer.