Changeset 10859 for code/branches/campaignHS15/src/orxonox/controllers
- Timestamp:
- Nov 25, 2015, 6:46:20 PM (9 years ago)
- Location:
- code/branches/campaignHS15/src/orxonox/controllers
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
r10856 r10859 63 63 CommonController::CommonController( Context* context ): Controller( context ) 64 64 { 65 this->squaredaccuracy_ = 10000;65 this->squaredaccuracy_ = 2500; 66 66 this->bFirstTick_ = true; 67 67 this->tolerance_ = 50; … … 71 71 this->bInLoop_ = false; 72 72 this->bLoop_ = false; 73 this->bEndLoop_ = false; 74 this->parsedActionpoints_.clear(); 73 75 RegisterObject( CommonController ); 76 74 77 } 75 78 CommonController::~CommonController() 76 79 { 77 78 80 } 79 81 void CommonController::tick(float dt) … … 161 163 Vector3 position; 162 164 std::string targetName; 163 bool inLoop ;165 bool inLoop = false; 164 166 Point p; 165 167 if (static_cast<Actionpoint*> (actionpoint)) … … 170 172 position = ap->getWorldPosition(); 171 173 172 if (!this->bInLoop_ && ap->getStartLoop()) 174 if (this->bEndLoop_) 175 { 176 this->bInLoop_ = false; 177 } 178 if (!this->bInLoop_ && ap->getLoopStart()) 173 179 { 174 180 this->bInLoop_ = true; 175 181 } 176 if (this->bInLoop_ && ap->get EndLoop())177 { 178 this->b InLoop_ = false;182 if (this->bInLoop_ && ap->getLoopEnd()) 183 { 184 this->bEndLoop_ = true; 179 185 } 180 186 inLoop = this->bInLoop_; … … 197 203 ThrowException( ParseError, std::string( "Attempting to set an unknown Action: '" )+ actionName + "'." ); 198 204 p.action = value; p.name = targetName; p.position = position; p.inLoop = inLoop; 199 parsedActionpoints_.push_back(p);200 205 } 201 206 else … … 519 524 while( diff>math::twoPi )diff-=math::twoPi; 520 525 while( diff<-math::twoPi )diff+=math::twoPi; 521 this->getControllableEntity() ->rotateRoll( diff* ROTATEFACTOR * dt );526 this->getControllableEntity() ->rotateRoll( diff*0.2f*ROTATEFACTOR * dt ); 522 527 } 523 528 void CommonController::copyTargetOrientation( float dt ) … … 975 980 void CommonController::nextActionpoint() 976 981 { 982 if (!this || !this->getControllableEntity()) 983 return; 977 984 if (this->bLoop_) 978 985 { … … 1019 1026 void CommonController::action() 1020 1027 { 1028 if (!this || !this->getControllableEntity()) 1029 return; 1030 orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl; 1021 1031 this->startAttackingEnemiesThatAreClose(); 1022 1032 //No action -> pop one from stack … … 1126 1136 this->bLoop_ = b; 1127 1137 this->setAction (Action::NONE); 1128 this->setTarget(0);1129 this->setTargetPosition (this->getControllableEntity()->getWorldPosition());1138 // this->setTarget(0); 1139 // this->setTargetPosition (this->getControllableEntity()->getWorldPosition()); 1130 1140 orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl; 1131 1141 } -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
r10856 r10859 138 138 virtual void stayNearProtect(); 139 139 virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour. 140 140 virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b); 141 141 142 protected: 142 143 //----[Flying methods]---- … … 227 228 bool bFirstTick_; 228 229 bool bInLoop_; 229 bool bLoop_; 230 bool bLoop_; 231 bool bEndLoop_; 230 232 //----[/"Private" variables]---- 231 virtual void takeActionpoints (std::vector<Point > vector, std::vector<Point > loop, bool b);232 233 233 234 }; -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
r10858 r10859 50 50 DivisionController::~DivisionController() 51 51 { 52 if (this->myFollower_) 53 { 54 this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); 55 if (this->myWingman_) 56 { 57 this->myWingman_->setAction(Action::FIGHTALL); 58 } 59 } 60 else if (this->myWingman_) 61 { 62 this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); 63 } 52 // if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())) 53 // { 54 // if (this->myFollower_) 55 // { 56 // this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); 57 // if (this->myWingman_) 58 // { 59 // this->myWingman_->setAction(Action::FIGHTALL); 60 // } 61 // } 62 // else if (this->myWingman_) 63 // { 64 // this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); 65 // } 66 // } 64 67 for (size_t i = 0; i < this->actionpoints_.size(); ++i) 65 68 { … … 85 88 void DivisionController::action() 86 89 { 90 if (!this || !this->getControllableEntity()) 91 return; 87 92 CommonController::action(); 93 88 94 } 89 95 void DivisionController::stayNearProtect() -
code/branches/campaignHS15/src/orxonox/controllers/LeaderController.cc
r10856 r10859 52 52 } 53 53 54 54 55 55 56 56 } -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10858 r10859 51 51 SectionController::~SectionController() 52 52 { 53 if (this->myWingman_)54 {55 this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_);56 }53 // if (this->myWingman_) 54 // { 55 // this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); 56 // } 57 57 for (size_t i = 0; i < this->actionpoints_.size(); ++i) 58 58 { … … 82 82 void SectionController::action() 83 83 { 84 if (!this || !this->getControllableEntity()) 85 return; 84 86 85 87 //----If no leader, find one---- -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10858 r10859 130 130 return; 131 131 } 132 132 133 ControllableEntity* leaderEntity = this->myLeader_->getControllableEntity(); 133 134 Quaternion orient = leaderEntity->getWorldOrientation(); … … 176 177 case FormationMode::WALL: 177 178 { 178 targetRelativePosition OfWingman= new Vector3 (400, 0, 0);179 targetRelativePosition = new Vector3 (400, 0, 0); 179 180 break; 180 181 } 181 182 case FormationMode::FINGER4: 182 183 { 183 targetRelativePosition OfWingman= new Vector3 (400, 0, 200);184 targetRelativePosition = new Vector3 (400, 0, 200); 184 185 break; 185 186 } 186 187 case FormationMode::DIAMOND: 187 188 { 188 targetRelativePosition OfWingman= new Vector3 (400, 0, 200);189 targetRelativePosition = new Vector3 (400, 0, 200); 189 190 break; 190 191 } … … 193 194 else 194 195 { 196 195 197 switch (this->formationMode_){ 196 198 case FormationMode::WALL: 197 199 { 198 targetRelativePosition OfWingman= new Vector3 (-400, 0, 0);200 targetRelativePosition = new Vector3 (-400, 0, 0); 199 201 break; 200 202 } 201 203 case FormationMode::FINGER4: 202 204 { 203 targetRelativePosition OfWingman= new Vector3 (-400, 0, 200);205 targetRelativePosition = new Vector3 (-400, 0, 200); 204 206 break; 205 207 } 206 208 case FormationMode::DIAMOND: 207 209 { 208 targetRelativePosition OfWingman= new Vector3 (400, -200, 0);210 targetRelativePosition = new Vector3 (400, -200, 0); 209 211 break; 210 212 }
Note: See TracChangeset
for help on using the changeset viewer.