Changeset 9016 for code/trunk/src/orxonox/controllers/HumanController.cc
- Timestamp:
- Feb 15, 2012, 11:51:58 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/orxonox/controllers/HumanController.cc
r8858 r9016 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 79 80 HumanController::localController_s = this; 80 81 this->boostingTimeout_.setTimer(HumanController::BOOSTING_TIME, false, createExecutor(createFunctor(&HumanController::terminateBoosting, this))); … … 84 85 HumanController::~HumanController() 85 86 { 87 if (HumanController::localController_s) 88 { 89 HumanController::localController_s->removeFromFormation(); 90 } 86 91 HumanController::localController_s = 0; 87 92 } … … 95 100 orxout(internal_warning) << "HumanController, Warning: Using a ControllableEntity without Camera" << endl; 96 101 } 102 103 // commandslaves when Master of a formation 104 if (HumanController::localController_s && HumanController::localController_s->state_==MASTER) 105 { 106 if (HumanController::localController_s->formationMode_ != ATTACK) 107 HumanController::localController_s->commandSlaves(); 108 } 97 109 } 98 110 … … 160 172 { 161 173 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 174 { 162 175 HumanController::localController_s->controllableEntity_->fire(firemode); 176 //if human fires, set slaves free. See FormationController::forceFreeSlaves() 177 if (HumanController::localController_s->state_==MASTER && HumanController::localController_s->formationMode_ == NORMAL) 178 { 179 HumanController::localController_s->forceFreeSlaves(); 180 } 181 } 163 182 } 164 183 … … 195 214 this->boosting_ = true; 196 215 this->boostingTimeout_.startTimer(); 197 198 this->controllableEntity_->boost(this->boosting_);216 if(this->controllableEntity_) 217 this->controllableEntity_->boost(this->boosting_); 199 218 // orxout() << "Start boosting" << endl; 200 219 } … … 209 228 this->boosting_ = false; 210 229 this->boostingTimeout_.stopTimer(); 211 212 this->controllableEntity_->boost(this->boosting_);230 if(this->controllableEntity_) 231 this->controllableEntity_->boost(this->boosting_); 213 232 // orxout() << "Stop boosting" << endl; 214 233 } … … 262 281 } 263 282 283 /** 284 @brief 285 toggle the formation. Not usable, if formationflight is disabled generally (formationFlight_) 286 */ 287 void HumanController::toggleFormationFlight() 288 { 289 if (HumanController::localController_s) 290 { 291 if (!HumanController::localController_s->formationFlight_) 292 { 293 return; //dont use when formationFlight is disabled 294 } 295 if (HumanController::localController_s->state_==MASTER) 296 { 297 HumanController::localController_s->loseMasterState(); 298 orxout(message) <<"FormationFlight disabled "<< endl; 299 } else //SLAVE or FREE 300 { 301 HumanController::localController_s->takeLeadOfFormation(); 302 orxout(message) <<"FormationFlight enabled "<< endl; 303 } 304 305 } 306 307 } 308 309 /** 310 @brief 311 Switch through the different Modes of formationflight. You must be a master of a formation to use. 312 */ 313 void HumanController::FFChangeMode() 314 { 315 if (HumanController::localController_s && HumanController::localController_s->state_==MASTER) 316 { 317 switch (HumanController::localController_s->getFormationMode()) { 318 case NORMAL: 319 HumanController::localController_s->setFormationMode(DEFEND); 320 orxout(message) <<"Mode: DEFEND "<< endl; 321 break; 322 case DEFEND: 323 HumanController::localController_s->setFormationMode(ATTACK); 324 orxout(message) <<"Mode: ATTACK "<< endl; 325 break; 326 case ATTACK: 327 HumanController::localController_s->setFormationMode(NORMAL); 328 orxout(message) <<"Mode: NORMAL "<< endl; 329 break; 330 } 331 } 332 } 333 334 335 //used, when slaves are in DEFEND mode. 336 void HumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) 337 { 338 if (!this->formationFlight_ || this->state_!=MASTER || this->formationMode_!=DEFEND) return; 339 this->masterAttacked(originator); 340 } 341 264 342 void HumanController::addBots(unsigned int amount) 265 343 {
Note: See TracChangeset
for help on using the changeset viewer.