Changeset 9255 for code/trunk/src/orxonox/controllers
- Timestamp:
- May 28, 2012, 12:21:45 AM (12 years ago)
- Location:
- code/trunk/src/orxonox/controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/controllers/FormationController.cc
r9016 r9255 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * ... 24 24 * Co-authors: 25 25 * Dominik Solenicki … … 61 61 static const unsigned int STANDARD_MAX_FORMATION_SIZE = 9; 62 62 static const int RADIUS_TO_SEARCH_FOR_MASTERS = 5000; 63 static const int FORMATION_LENGTH = 110;64 static const int FORMATION_WIDTH = 110;63 static const float FORMATION_LENGTH = 110; 64 static const float FORMATION_WIDTH = 110; 65 65 static const int FREEDOM_COUNT = 4; //seconds the slaves in a formation will be set free when master attacks an enemy 66 66 static const float SPEED_MASTER = 0.6f; … … 324 324 { //linear speed reduction 325 325 this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER); 326 326 327 327 } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER); 328 328 … … 383 383 void FormationController::searchNewMaster() 384 384 { 385 if (this->state_==SLAVE) 385 if (this->state_==SLAVE) 386 386 return; 387 387 if (!this->getControllableEntity()) … … 394 394 for (ObjectList<Pawn>::iterator it = ObjectList<Pawn>::begin(); it; ++it) 395 395 { 396 396 397 397 //same team? 398 398 Gametype* gt=this->getGametype(); … … 479 479 bool left=true; 480 480 int i = 1; 481 481 482 482 for(std::vector<FormationController*>::iterator it = slaves_.begin(); it != slaves_.end(); it++) 483 483 { … … 490 490 i++; 491 491 dest+=FORMATION_LENGTH*(orient*WorldEntity::BACK); 492 } 492 } 493 493 (*it)->setTargetOrientation(orient); 494 494 (*it)->setTargetPosition(pos); … … 599 599 600 600 if (this->state_==SLAVE) //become master of this formation 601 { 601 { 602 602 this->slaves_=this->myMaster_->slaves_; 603 603 this->myMaster_->slaves_.clear(); 604 604 this->myMaster_->state_=SLAVE; 605 605 this->myMaster_->myMaster_=this; 606 606 607 607 //delete myself in slavelist 608 608 std::vector<FormationController*>::iterator it2 = std::find(this->slaves_.begin(), this->slaves_.end(), this); … … 647 647 if (i>=slaves_.size()/2) break; //half the formation should attack. 648 648 } 649 } 649 } 650 650 651 651 … … 860 860 void FormationController::setTargetOrientation(const Quaternion& orient) 861 861 { 862 this->targetOrientation_=orient; 862 this->targetOrientation_=orient; 863 863 this->bHasTargetOrientation_=true; 864 864 } -
code/trunk/src/orxonox/controllers/FormationController.h
r9016 r9255 21 21 * 22 22 * Author: 23 * Fabian 'x3n' Landau23 * ... 24 24 * Co-authors: 25 25 * ...
Note: See TracChangeset
for help on using the changeset viewer.