- Timestamp:
- Dec 11, 2015, 3:16:48 PM (9 years ago)
- Location:
- code/branches/campaignHS15/src/orxonox/controllers
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.cc
r10958 r10968 53 53 this->bDefaultPatrol_ = true; 54 54 this->bDefaultFightAll_ = true; 55 this->stop_ = false;56 55 RegisterObject(ActionpointController); 57 56 … … 75 74 void ActionpointController::tick(float dt) 76 75 { 77 if (!this || !this->getControllableEntity() || !this->isActive() || this->stop_)76 if (!this || !this->getControllableEntity() || !this->isActive()) 78 77 return; 79 78 … … 733 732 if (!this || !this->getControllableEntity()) 734 733 return; 735 736 //if (this->action_ != Action::FIGHT && this->action_ != Action::FIGHTALL) 737 { 738 if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_)) 739 { 740 if (!this || !this->getControllableEntity()) 741 return; 742 Pawn* newTarget = this->closestTarget(); 743 if ( newTarget && 744 CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget)) 745 <= this->attackRange_ ) 746 { 747 if (!this || !this->getControllableEntity()) 748 return; 749 this->setTarget(newTarget); 750 if (this->bLoop_ && !this->bPatrolling_) 751 { 752 Point p = { Action::FIGHT, "", Vector3::ZERO, true }; 753 this->loopActionpoints_.push_back(p); 754 } 755 else if (!this->bPatrolling_) 756 { 757 //orxout (internal_error) << "found new target " << CommonController::getName(newTarget) <<endl; 758 Point p = { Action::FIGHT, "", Vector3::ZERO, false }; 759 this->parsedActionpoints_.push_back(p); 760 } 761 this->bPatrolling_ = true; 762 this->executeActionpoint(); 763 } 734 735 if (!this->target_ || (this->target_ && CommonController::distance (this->getControllableEntity(), this->target_) > this->attackRange_)) 736 { 737 if (!this || !this->getControllableEntity()) 738 return; 739 Pawn* newTarget = this->closestTarget(); 740 if ( newTarget && 741 CommonController::distance (this->getControllableEntity(), static_cast<ControllableEntity*>(newTarget)) 742 <= this->attackRange_ ) 743 { 744 if (!this || !this->getControllableEntity()) 745 return; 746 this->setTarget(newTarget); 747 if (this->bLoop_ && !this->bPatrolling_) 748 { 749 Point p = { Action::FIGHT, "", Vector3::ZERO, true }; 750 this->loopActionpoints_.push_back(p); 751 } 752 else if (!this->bPatrolling_) 753 { 754 Point p = { Action::FIGHT, "", Vector3::ZERO, false }; 755 this->parsedActionpoints_.push_back(p); 756 } 757 this->bPatrolling_ = true; 758 this->executeActionpoint(); 764 759 } 765 760 } -
code/branches/campaignHS15/src/orxonox/controllers/ActionpointController.h
r10955 r10968 216 216 std::vector<Point > parsedActionpoints_;//<! actionpoints as they are stored here after being parsed from XML 217 217 std::vector<Point > loopActionpoints_; //<! actionpoints that are to be looped 218 bool bInLoop_; 218 bool bInLoop_; //<! variable for addActionpoint method 219 219 bool bLoop_; //<! is state machine looping? 220 bool bEndLoop_; 220 bool bEndLoop_; //<! variable for addActionpoint method 221 221 bool bTakenOver_; //<! are actionpoints taken over from the leader when he died? if yes, top actionpoint 222 222 //<! is to be executed for the state machine to start working … … 250 250 //----[Actionpoint methods]---- 251 251 252 bool bDefaultFightAll_; 253 254 bool bPatrolling_; 255 bool bDefaultPatrol_; 256 bool stop_; 252 bool bDefaultFightAll_; //<! if true, when no action set, this will fight all 253 254 bool bPatrolling_; //<! true if current action_ is FIGHT because this found enemies that are close, need this to correctly go back to looping if was looping 255 bool bDefaultPatrol_; //<! if true, this will look out for enemies that are close if this is just flying or doing nothing 257 256 unsigned int ticks_; //<! local tick counter 258 259 257 }; 260 258 } -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
r10953 r10968 23 23 * Gani Aliguzhinov 24 24 * Co-authors: 25 * Dominik Solenicki25 * ... 26 26 * 27 27 */ … … 73 73 bool CommonController::sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype) 74 74 { 75 //uncomment following code if functions stops working due to being a hack 76 /*if (!entity1 || !entity2) 77 return false; 78 return entity1->getTeam() == entity2->getTeam();*/ 75 79 76 if (!entity1 || !entity2) 80 77 return false; -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
r10955 r10968 23 23 * Gani Aliguzhinov 24 24 * Co-authors: 25 * Dominik Solenicki25 * ... 26 26 * 27 27 */ … … 49 49 CommonController(Context* context); 50 50 virtual ~CommonController(); 51 static float randomInRange(float a, float b); 52 static float distance(const ControllableEntity* entity1, const ControllableEntity* entity2); 51 static float randomInRange(float a, float b); //<! returns random number from a to b 52 static float distance(const ControllableEntity* entity1, const ControllableEntity* entity2); //<! returns distance between arguments 53 53 static bool sameTeam (ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gt); 54 static bool isLooking(const ControllableEntity* entityThatLooks, const ControllableEntity* entityBeingLookedAt, float angle 55 static std::string getName(const Pawn* entity 54 static bool isLooking(const ControllableEntity* entityThatLooks, const ControllableEntity* entityBeingLookedAt, float angle) ; 55 static std::string getName(const Pawn* entity) ; 56 56 }; 57 57 } -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
r10953 r10968 79 79 if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())) 80 80 { 81 //when this dies, its follower will execute all its actionpoints, if follower dies before this, wingman will do this 81 82 if (this->myFollower_) 82 83 { -
code/branches/campaignHS15/src/orxonox/controllers/MasterController.cc
r10958 r10968 38 38 { 39 39 RegisterObject(MasterController); 40 // orxout(internal_error) << "MasterController was created" << endl;41 42 40 this->controllers_.clear(); 43 41 this->numberOfTicksPassedSinceLastActionCall_ = 0; … … 50 48 this->controllers_.clear(); 51 49 } 50 /*HACK*/ 51 //the whole idea is a hack 52 52 void MasterController::tick(float dt) 53 53 { … … 55 55 return; 56 56 ++this->ticks_; 57 //orxout(internal_error) << "Tick = " << this->ticks_ << endl;58 57 if (this->ticks_ == 1) 59 58 { … … 66 65 this->controllers_.push_back(*it); 67 66 } 68 //orxout(internal_error) << "I got " << this->controllers_.size() << " controllers" << endl;69 67 } 70 68 else 71 69 { 72 73 70 if (this->controllers_.empty()) 74 71 return; … … 87 84 if (this->numberOfTicksPassedSinceLastActionCall_ > 0) 88 85 { 89 //call maneuver for current index90 86 if (this->numberOfTicksPassedSinceLastActionCall_ == 3) 91 87 { 88 //check if 0ptr 92 89 if (!this->controllers_.at(this->indexOfCurrentController_)) 93 90 { … … 95 92 return; 96 93 } 97 // orxout (internal_error) << "Executing maneuver of Controller # " << this->indexOfCurrentController_ << endl;94 //call maneuver for current index 98 95 this->controllers_.at(this->indexOfCurrentController_)->maneuver(); 99 96 } 100 97 else if (this->numberOfTicksPassedSinceLastActionCall_ == 6) 101 98 { 102 //c all canFire for current index99 //check if 0ptr 103 100 if (!this->controllers_.at(this->indexOfCurrentController_)) 104 101 { … … 106 103 return; 107 104 } 108 // orxout (internal_error) << "Executing maneuver of Controller # " << this->indexOfCurrentController_ << endl;105 //call canFire for current index 109 106 this->controllers_.at(this->indexOfCurrentController_)->bShooting_ = this->controllers_.at(this->indexOfCurrentController_)->canFire(); 110 107 } … … 113 110 else 114 111 { 115 //c all action for current index112 //check if 0ptr 116 113 if (!this->controllers_.at(this->indexOfCurrentController_)) 117 114 { … … 119 116 return; 120 117 } 121 //orxout (internal_error) << "Executing action of Controller # " << this->indexOfCurrentController_ << endl; 122 this->controllers_.at(this->indexOfCurrentController_)->action(); 118 //call action for current index 119 this->controllers_.at(this->indexOfCurrentController_)->action(); 120 123 121 //bCopyOrientation makes ship oscillate like crazy if set to true all the time.s 124 122 this->controllers_.at(this->indexOfCurrentController_)->bCopyOrientation_ = this->ticks_ % 3 == 0; -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10946 r10968 84 84 85 85 this->myDivisionLeader_ = newDivisionLeader; 86 //spread copyOrientation called equally among the division87 88 86 } 89 87 //----If have leader---- … … 111 109 { 112 110 this->keepFormation(); 113 //orxout (internal_error) << "Keeping formation" << endl;114 115 111 } 116 112 else if (!this->myDivisionLeader_->bKeepFormation_) … … 162 158 foundTarget = true; 163 159 target = (*itP); 164 //orxout(internal_error) << "Found target" << endl;165 160 break; 166 161 } -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.h
r10955 r10968 66 66 protected: 67 67 //----action must only be managed by this---- 68 virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.68 virtual void action(); //<! action() is called in regular intervals by MasterController managing the bot's behaviour. 69 69 Vector3 getFormationPosition (); 70 70 void keepFormation(); -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.cc
r10953 r10968 99 99 else if (this->myLeader_) 100 100 { 101 if (this->myLeader_->bKeepFormation_ || !(this->myLeader_->getAction() == Action::FIGHT || this->myLeader_->getAction() == Action::FIGHTALL 101 if (this->myLeader_->bKeepFormation_ || !(this->myLeader_->getAction() == Action::FIGHT 102 || this->myLeader_->getAction() == Action::FIGHTALL 102 103 || this->myLeader_->getAction() == Action::ATTACK)) 103 104 { … … 148 149 else 149 150 { 150 151 151 switch (this->formationMode_){ 152 152 case FormationMode::WALL: … … 215 215 { 216 216 //----Racing conditions---- 217 /*TODO: racing condition check is wrong and redundant, as there is no multithreading here, ticks get called one after another, 218 so it can be simplified to a check of whether leader got a wingman*/ 217 219 if (closestLeader->setWingman(orxonox_cast<ActionpointController*>(this))) 218 220 { 219 if (closestLeader->getIdentifier()->getName() == "SectionController")220 {221 this->actionTime_ = 1.6f;222 }223 else224 {225 this->actionTime_ = 2.0f;226 }227 221 return closestLeader; 228 222 } -
code/branches/campaignHS15/src/orxonox/controllers/WingmanController.h
r10955 r10968 73 73 WeakPtr<ActionpointController> myLeader_; 74 74 bool bFirstAction_; 75 float actionTime_;76 75 77 76
Note: See TracChangeset
for help on using the changeset viewer.