- Timestamp:
- Dec 16, 2011, 8:36:41 PM (13 years ago)
- Location:
- code/branches/presentation2011
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation2011
- Property svn:mergeinfo changed
/code/branches/formation (added) merged: 8885,8908,8939,8943,8948,8953,8957,8965,8967,8978,8985,8989-8991
- Property svn:mergeinfo changed
-
code/branches/presentation2011/src/orxonox/controllers/HumanController.cc
r8980 r8992 50 50 SetConsoleCommand("HumanController", "rotatePitch", &HumanController::rotatePitch ).addShortcut().setAsInputCommand(); 51 51 SetConsoleCommand("HumanController", "rotateRoll", &HumanController::rotateRoll ).addShortcut().setAsInputCommand(); 52 SetConsoleCommand("HumanController", "toggleFormationFlight", &HumanController::toggleFormationFlight).addShortcut().keybindMode(KeybindMode::OnPress); 53 SetConsoleCommand("HumanController", "FFChangeMode", &HumanController::FFChangeMode).addShortcut().keybindMode(KeybindMode::OnPress); 52 54 SetConsoleCommand("HumanController", __CC_fire_name, &HumanController::fire ).addShortcut().keybindMode(KeybindMode::OnHold); 53 55 SetConsoleCommand("HumanController", "reload", &HumanController::reload ).addShortcut(); … … 69 71 /*static*/ const float HumanController::BOOSTING_TIME = 0.1f; 70 72 71 HumanController::HumanController(BaseObject* creator) : Controller(creator)73 HumanController::HumanController(BaseObject* creator) : FormationController(creator) 72 74 { 73 75 RegisterObject(HumanController); … … 76 78 this->boosting_ = false; 77 79 this->boosting_ = false; 78 80 this->tempMaster=NULL; 79 81 HumanController::localController_s = this; 80 82 this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this))); 81 83 this->boostingTimeout_.stopTimer(); 84 this->state_=FREE; 82 85 } 83 86 84 87 HumanController::~HumanController() 85 88 { 89 if (HumanController::localController_s) 90 { 91 HumanController::localController_s->removeFromFormation(); 92 } 86 93 HumanController::localController_s = 0; 87 94 } … … 95 102 orxout(internal_warning) << "HumanController, Warning: Using a ControllableEntity without Camera" << endl; 96 103 } 104 105 // commandslaves when Master of a formation 106 if (HumanController::localController_s && HumanController::localController_s->state_==MASTER) 107 { 108 if (HumanController::localController_s->formationMode_ != ATTACK) 109 HumanController::localController_s->commandSlaves(); 110 } 97 111 } 98 112 … … 160 174 { 161 175 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 176 { 162 177 HumanController::localController_s->controllableEntity_->fire(firemode); 178 //if human fires, set slaves free. See FormationController::forceFreeSlaves() 179 if (HumanController::localController_s->state_==MASTER && HumanController::localController_s->formationMode_ == NORMAL) 180 { 181 HumanController::localController_s->forceFreeSlaves(); 182 } 183 } 163 184 } 164 185 … … 262 283 } 263 284 285 /** 286 @brief 287 toggle the formation. Not usable, if formationflight is disabled generally (formationFlight_) 288 */ 289 void HumanController::toggleFormationFlight() 290 { 291 if (HumanController::localController_s) 292 { 293 if (!HumanController::localController_s->formationFlight_) 294 { 295 return; //dont use when formationFlight is disabled 296 } 297 if (HumanController::localController_s->state_==MASTER) 298 { 299 HumanController::localController_s->loseMasterState(); 300 orxout(message) <<"FormationFlight disabled "<< endl; 301 } else //SLAVE or FREE 302 { 303 HumanController::localController_s->takeLeadOfFormation(); 304 orxout(message) <<"FormationFlight enabled "<< endl; 305 } 306 307 } 308 309 } 310 311 /** 312 @brief 313 Switch through the different Modes of formationflight. You must be a master of a formation to use. 314 */ 315 void HumanController::FFChangeMode() 316 { 317 if (HumanController::localController_s && HumanController::localController_s->state_==MASTER) 318 { 319 switch (HumanController::localController_s->getFormationMode()) { 320 case NORMAL: 321 HumanController::localController_s->setFormationMode(DEFEND); 322 orxout(message) <<"Mode: DEFEND "<< endl; 323 break; 324 case DEFEND: 325 HumanController::localController_s->setFormationMode(ATTACK); 326 orxout(message) <<"Mode: ATTACK "<< endl; 327 break; 328 case ATTACK: 329 HumanController::localController_s->setFormationMode(NORMAL); 330 orxout(message) <<"Mode: NORMAL "<< endl; 331 break; 332 } 333 } 334 } 335 336 337 //used, when slaves are in DEFEND mode. 338 void HumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) 339 { 340 if (!this->formationFlight_ || this->state_!=MASTER || this->formationMode_!=DEFEND) return; 341 this->masterAttacked(originator); 342 } 343 264 344 void HumanController::addBots(unsigned int amount) 265 345 {
Note: See TracChangeset
for help on using the changeset viewer.