Changeset 10935
- Timestamp:
- Dec 7, 2015, 3:14:40 PM (9 years ago)
- Location:
- code/branches/campaignHS15/src/orxonox/controllers
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
r10934 r10935 54 54 this->action_ = Action::NONE; 55 55 this->squaredaccuracy_ = 2500; 56 this->bFirstTick_ = true;57 56 this->bStartedDodging_ = false; 58 57 this->bDefaultPatrol_ = true; … … 65 64 { 66 65 SUPER( ActionpointController, XMLPort, xmlelement, mode ); 67 // XMLPortEventSink(ActionpointController, BaseObject, "stop", stop, xmlelement, mode);68 // XMLPortEventSink(ActionpointController, BaseObject, "go", stop, xmlelement, mode);69 66 70 67 XMLPortObject(ActionpointController, WorldEntity, "actionpoints", addActionpoint, getActionpoint, xmlelement, mode); … … 72 69 XMLPortParam(ActionpointController, "defaultPatrol", setDefaultPatrol, getDefaultPatrol, xmlelement, mode).defaultValues(true); 73 70 } 74 // void ActionpointController::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) 75 // { 76 // SUPER(ActionpointController, XMLEventPort, xmlelement, mode); 77 // XMLPortEventSink(ActionpointController, BaseObject, "stop", stop, xmlelement, mode); 78 // XMLPortEventSink(ActionpointController, BaseObject, "go", stop, xmlelement, mode); 79 80 // } 81 // bool ActionpointController::stop(bool bTriggered, BaseObject* trigger) 82 // { 83 // this->stop_ = true; 84 // return true; 85 // } 86 // bool ActionpointController::go(bool bTriggered, BaseObject* trigger) 87 // { 88 // this->stop_ = false; 89 // return true; 90 // } 71 91 72 ActionpointController::~ActionpointController() 92 73 { … … 95 76 actionpoints_.clear(); 96 77 this->actionpointControllerId_ = 0; 97 /*ActionpointController::nextActionpointControllerId_--; 98 if (ActionpointController::nextActionpointControllerId_ < 0) 99 ActionpointController::nextActionpointControllerId_ = 0;*/ 78 100 79 } 101 80 void ActionpointController::tick(float dt) 102 81 { 103 if (!this || !this->getControllableEntity() || !this->isActive() )82 if (!this || !this->getControllableEntity() || !this->isActive() || this->stop_) 104 83 return; 105 84 ++this->ticks_; … … 126 105 //orxout (internal_error) << "first tick was called by id = " << this->actionpointControllerId_ << ", total = " << ActionpointController::nextActionpointControllerId_ << endl; 127 106 } 128 if (ActionpointController::sTicks_ == 1) 129 { 130 this->bActionCalled_ = false; 131 132 this->bFirstTick_ = false; 133 } 134 /* if (ActionpointController::sTicks_ % (ActionpointController::nextActionpointControllerId_+1) != this->actionpointControllerId_) 135 { 136 return; 137 }*/ 107 138 108 if (!this || !this->getControllableEntity()) 139 109 return; … … 151 121 if (!this || !this->getControllableEntity()) 152 122 return; 153 154 if (stop_)155 return;156 157 123 158 124 if (timeout_ <= 0) … … 223 189 if (!this || !this->getControllableEntity()) 224 190 return; 225 if (!this->getControllableEntity() || !orxonox_cast<Pawn*> (this->getControllableEntity())) 226 return; 191 227 192 if (this->bDefaultPatrol_ || (this->action_ != Action::FLY && this->action_ != Action::NONE)) 228 193 { … … 232 197 return; 233 198 234 235 if (!this || !this->getControllableEntity())236 return;237 238 // if (this->actionCounter_ % 2 == 0)239 199 //No action -> pop one from stack 240 200 if (this->action_ == Action::NONE || this->bTakenOver_) … … 247 207 this->executeActionpoint(); 248 208 this->bTakenOver_ = false; 249 // this->action();250 209 } 251 210 if (!this || !this->getControllableEntity()) … … 262 221 { 263 222 this->setAction (Action::FIGHTALL, newTarget); 264 //this->action();265 223 } 266 224 else … … 284 242 { 285 243 this->setAction (Action::FIGHT, newTarget); 286 //this->action();287 244 } 288 245 else … … 760 717 } 761 718 } 762 int ActionpointController::nextActionpointControllerId_ = 0;763 int ActionpointController::sTicks_ = 0;719 unsigned int ActionpointController::nextActionpointControllerId_ = 0; 720 unsigned int ActionpointController::sTicks_ = 0; 764 721 } -
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
r10934 r10935 170 170 bool getDefaultPatrol () 171 171 { return this->bDefaultPatrol_; } 172 // Trigger interface 173 // bool stop(bool bTriggered, BaseObject* trigger); 174 // bool go(bool bTriggered, BaseObject* trigger); 175 // virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); 172 176 173 177 174 virtual void stayNearProtect(); … … 243 240 void nextActionpoint(); 244 241 //----[Actionpoint methods]---- 245 bool bFirstTick_; 246 247 /* void setSpawners(); 248 Vector3 bestHealthPickup (float searchRadius); 249 // Point closestPickup(PickupType::Value pickupType); 250 std::multimap <int, std::pair<PickupSpawner*, bool> > healthSpawners_; 251 std::multimap <int, std::pair<PickupSpawner*, bool> > damageSpawners_; 252 std::multimap <int, std::pair<PickupSpawner*, bool> > speedSpawners_; 253 */ 254 bool bActionCalled_; 255 bool bManeuverCalled_; 242 256 243 bool bDefaultFightAll_; 257 244 258 bool bActive_;259 245 bool bPatrolling_; 260 246 bool bDefaultPatrol_; 261 247 bool stop_; 262 static int sTicks_; 263 static int nextActionpointControllerId_; 264 int actionpointControllerId_; 265 int ticks_; 248 static unsigned int sTicks_; //<! a hack? I don't want action() and maneuver() to be called multiple times in a tick, so I keep 249 //<! track of ticks and if current tick is "assigned" to this object, than I call maneuver()/action() 250 static unsigned int nextActionpointControllerId_; //<! if level has 16 ActionpointControllers, than this variable equals to 17 after first tick 251 unsigned int actionpointControllerId_; //<! integer from 0 to nextActionpointControllerId_, different for every ActionpointController in level 252 unsigned int ticks_; //<! local tick counter 266 253 267 254 -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
r10923 r10935 43 43 this->myFollower_ = 0; 44 44 this->myWingman_ = 0; 45 //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DivisionController::action, this)));46 45 } 47 46 … … 61 60 SUPER(DivisionController, XMLPort, xmlelement, mode); 62 61 63 //XMLPortParam(DivisionController, "target_", setTarget, getTarget, xmlelement, mode).defaultValues(100.0f);64 62 } 65 63 void DivisionController::tick(float dt) … … 68 66 return; 69 67 SUPER(DivisionController, tick, dt); 70 /*if (this->timeOffset_ >= 0.0f && this->timeOffset_ <= 0.8f && !this->bActionCalled_)71 {72 this->action();73 this->bActionCalled_ = true;74 }75 if (this->timeOffset_ > 1.6f)76 {77 this->bActionCalled_ = false;78 }*/79 80 68 81 69 } -
code/branches/campaignHS15/src/orxonox/controllers/FightingController.cc
r10934 r10935 149 149 if (!this || !this->getControllableEntity()) 150 150 return; 151 // if (this->actionCounter_ % 3 == 0)152 151 if (!this->bDodge_) 153 152 { … … 286 285 if (pawn) 287 286 pawn->setAimPosition (this->positionOfTarget_); 288 // if (pawn->getHealth() < 100) 289 // orxout(internal_error) << "not full, hp = " << pawn->getHealth() << endl; 287 290 288 int firemode; 291 289 float distance = CommonController::distance (this->getControllableEntity(), this->target_); 292 290 293 // firemode = distance < 1500 ? (distance > 800 && distance < 1200 ? 294 // (this->rocketsLeft_ > 0 && !this->bFiredRocket_ ? getFiremode("RocketFire") : getFiremode ("HsW01")) 295 // : getFiremode("HsW01")) : 296 // (distance < 2500 ? getFiremode("LightningGun") : getFiremode("HsW01")); 291 292 297 293 if (distance < 1500) 298 294 { … … 310 306 311 307 } 312 // else if (distance < 1000) 313 // { 314 // if (this->rocketsLeft_ > 0 && !this->bFiredRocket_) 315 // { 316 // firemode = getFiremode ("RocketFire"); 317 // } 318 // else 319 // { 320 // firemode = getFiremode ("HsW01"); 321 // } 322 // } 308 309 323 310 else if (distance < 2000) 324 311 { … … 377 364 } 378 365 379 //orxout (internal_error) << this->rocketsLeft_ << " rockets left" << endl;380 366 } 381 367 -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10925 r10935 28 28 29 29 #include "SectionController.h" 30 //TODO: formation vectors are wrong, fix it. 31 // split classes. 32 // weaponsystem. 33 //-> Math ? 34 30 35 31 namespace orxonox 36 32 { … … 44 40 this->setFormationMode(FormationMode::FINGER4); 45 41 46 //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&SectionController::action, this)));47 42 this->myWingman_ = 0; 48 43 this->myDivisionLeader_ = 0; 49 44 this->bFirstAction_ = true; 50 //orxout(internal_error) << this << "Was created" << endl;51 45 52 46 } … … 74 68 75 69 SUPER(SectionController, tick, dt); 76 /*if (this->timeOffset_ > 0.8f && this->timeOffset_ <= 1.6f && !this->bActionCalled_) 77 { 78 this->action(); 79 this->bActionCalled_ = true; 80 } 81 if (this->timeOffset_ > 2.0f) 82 { 83 this->bActionCalled_ = false; 84 }*/ 85 70 86 71 } 87 72 … … 137 122 { 138 123 this->chooseTarget(); 139 //orxout (internal_error) << "Section ain't got no target" << endl;140 124 } 141 if (this->hasTarget()) 142 { 143 // this->maneuver(); 144 // this->bShooting_ = this->canFire(); 145 // Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length()); 146 // if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_) 147 // { 148 // //----choose where to go---- 149 // this->maneuver(); 150 // } 151 // else 152 // { 153 // this->dodgeTowards(healthPosition); 154 // } 155 // //----fire if you can---- 156 // this->bShooting_ = this->canFire(); 157 } 125 158 126 } 159 127 } -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
r10915 r10935 67 67 private: 68 68 //----private variables----- 69 Timer actionTimer_; //<! Regularly calls action().70 69 bool bFirstAction_; 71 70 -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10925 r10935 39 39 { 40 40 RegisterObject(WingmanController); 41 //this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&WingmanController::action, this)));42 41 this->myLeader_ = 0; 43 42 this->bFirstAction_ = true; … … 68 67 69 68 SUPER(WingmanController, tick, dt); 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 else85 {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 else98 {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 69 111 70 } … … 157 116 this->setTarget(this->myLeader_->getTarget()); 158 117 } 159 if (this->hasTarget()) 160 { 161 // this->maneuver(); 162 // this->bShooting_ = this->canFire(); 163 // Vector3 healthPosition = bestHealthPickup((this->target_->getWorldPosition() - this->getControllableEntity()->getWorldPosition()).length()); 164 // if ((this->getControllableEntity()->getWorldPosition() - healthPosition).length() < this->tolerance_) 165 // { 166 // //----choose where to go---- 167 // this->maneuver(); 168 // } 169 // else 170 // { 171 // this->dodgeTowards(healthPosition); 172 // } 173 // //----fire if you can---- 174 // this->bShooting_ = this->canFire(); 175 } 118 176 119 } 177 120 } -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
r10915 r10935 68 68 //----private variables----- 69 69 WeakPtr<ActionpointController> myLeader_; 70 Timer actionTimer_; //<! Regularly calls action().71 70 bool bFirstAction_; 72 71 float actionTime_;
Note: See TracChangeset
for help on using the changeset viewer.