Changeset 10974 for code/branches/presentationHS15
- Timestamp:
- Dec 14, 2015, 11:31:30 AM (9 years ago)
- Location:
- code/branches/presentationHS15
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentationHS15
- Property svn:mergeinfo changed
/code/branches/campaignHS15 merged: 10968-10969,10971
- Property svn:mergeinfo changed
-
code/branches/presentationHS15/data/levels/AITest.oxw
r10970 r10974 162 162 <!-- HERE ENDS DEMO FOR THE ACTIONPOINTS --> 163 163 <!-- HERE STARTS DEMO FOR FIGHTING --> 164 <!--164 165 165 166 166 <SpaceShip position="-4000, 1500, -1000" lookat="0,0,0" team=0 name="d1sd1"> … … 238 238 </WingmanController> 239 239 </controller> 240 </SpaceShip> -->240 </SpaceShip> 241 241 242 242 <!-- HERE ENDS DEMO FOR FIGHTING --> 243 243 <!-- HERE STARTS DEMO FOR FORMATIONS --> 244 244 <!-- 245 245 <Model mesh="cube.mesh" scale=8 position=" 0,2000, 0" /> 246 246 <Model mesh="cube.mesh" scale=8 position=" 0,2000,-2000" /> … … 291 291 </controller> 292 292 </SpaceShip> 293 293 --> 294 294 <!-- HERE ENDS DEMO FOR FORMATIONS --> 295 295 <!-- 1 division is roughly equal to 6 AIControllers--!> -
code/branches/presentationHS15/src/orxonox/controllers/ActionpointController.cc
r10970 r10974 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/presentationHS15/src/orxonox/controllers/ActionpointController.h
r10970 r10974 63 63 @note 64 64 ActionpointController will not work, if there is no MasterController in the level! 65 All the demos are in a file called AITest.oxw. In the menu look for New AI Testing Level. 65 66 */ 66 67 namespace Action … … 216 217 std::vector<Point > parsedActionpoints_;//<! actionpoints as they are stored here after being parsed from XML 217 218 std::vector<Point > loopActionpoints_; //<! actionpoints that are to be looped 218 bool bInLoop_; 219 bool bInLoop_; //<! variable for addActionpoint method 219 220 bool bLoop_; //<! is state machine looping? 220 bool bEndLoop_; 221 bool bEndLoop_; //<! variable for addActionpoint method 221 222 bool bTakenOver_; //<! are actionpoints taken over from the leader when he died? if yes, top actionpoint 222 223 //<! is to be executed for the state machine to start working … … 250 251 //----[Actionpoint methods]---- 251 252 252 bool bDefaultFightAll_; 253 254 bool bPatrolling_; 255 bool bDefaultPatrol_; 256 bool stop_; 253 bool bDefaultFightAll_; //<! if true, when no action set, this will fight all 254 255 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 256 bool bDefaultPatrol_; //<! if true, this will look out for enemies that are close if this is just flying or doing nothing 257 257 unsigned int ticks_; //<! local tick counter 258 259 258 }; 260 259 } -
code/branches/presentationHS15/src/orxonox/controllers/CommonController.cc
r10970 r10974 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/presentationHS15/src/orxonox/controllers/CommonController.h
r10970 r10974 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/presentationHS15/src/orxonox/controllers/DivisionController.cc
r10970 r10974 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/presentationHS15/src/orxonox/controllers/DivisionController.h
r10970 r10974 39 39 @note 40 40 ActionpointController will not work, if there is no MasterController in the level! 41 All the demos are in a file called AITest.oxw. In the menu look for New AI Testing Level. 41 42 */ 42 43 class _OrxonoxExport DivisionController : public ActionpointController -
code/branches/presentationHS15/src/orxonox/controllers/FightingController.cc
r10970 r10974 151 151 if (!this->bDodge_) 152 152 { 153 // orxout(internal_error) << "attacking" << endl;154 153 this->bStartedDodging_ = false; 155 154 … … 159 158 else if (bTargetIsLookingAtThis || diffLength < 700.0f) 160 159 { 161 // orxout(internal_error) << "dodging" << endl;162 160 if (!this->bStartedDodging_) 163 161 { … … 170 168 if (diffLength < 1000) 171 169 { 172 // orxout(internal_error) << "looking" << endl;173 170 this->stopMoving(); 174 171 this->startLookingAtTarget(); … … 177 174 else 178 175 { 179 // orxout(internal_error) << "closing up" << endl;180 176 this->setTargetPosition(this->positionOfTarget_ - diffUnit * 300.0f); 181 177 } … … 354 350 if (wName == "RocketFire") 355 351 this->rocketsLeft_ = 10; 356 // this->rocketsLeft_ = orxonox_cast<Pawn*>(this->getControllableEntity())->getWeaponSystem()->getMunition(&munition)->getNumMunitionInCurrentMagazine(wMode);357 352 if(this->getFiremode(wName) == -1) //only add a weapon, if it is "new" 358 353 weaponModes_[wName] = wMode->getMode(); … … 361 356 if(weaponModes_.size())//at least one weapon detected 362 357 this->bSetupWorked = true; 363 } //pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user);358 } 364 359 } 365 360 -
code/branches/presentationHS15/src/orxonox/controllers/MasterController.cc
r10970 r10974 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/presentationHS15/src/orxonox/controllers/SectionController.cc
r10970 r10974 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/presentationHS15/src/orxonox/controllers/SectionController.h
r10970 r10974 38 38 @note 39 39 ActionpointController will not work, if there is no MasterController in the level! 40 All the demos are in a file called AITest.oxw. In the menu look for New AI Testing Level. 40 41 */ 41 42 class _OrxonoxExport SectionController : public ActionpointController … … 66 67 protected: 67 68 //----action must only be managed by this---- 68 virtual void action(); //<! action() is called in regular intervals managing the bot's behaviour.69 virtual void action(); //<! action() is called in regular intervals by MasterController managing the bot's behaviour. 69 70 Vector3 getFormationPosition (); 70 71 void keepFormation(); -
code/branches/presentationHS15/src/orxonox/controllers/WingmanController.cc
r10970 r10974 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/presentationHS15/src/orxonox/controllers/WingmanController.h
r10970 r10974 39 39 @note 40 40 ActionpointController will not work, if there is no MasterController in the level! 41 All the demos are in a file called AITest.oxw. In the menu look for New AI Testing Level. 41 42 */ 42 43 class _OrxonoxExport WingmanController : public ActionpointController … … 73 74 WeakPtr<ActionpointController> myLeader_; 74 75 bool bFirstAction_; 75 float actionTime_;76 76 77 77
Note: See TracChangeset
for help on using the changeset viewer.