Changeset 10861
- Timestamp:
- Nov 25, 2015, 8:46:09 PM (9 years ago)
- Location:
- code/branches/campaignHS15
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/campaignHS15/data/levels/AITest.oxw
r10859 r10861 60 60 <!-- HERE ENDS DEMO FOR THE "WAYPOINTS" --> 61 61 62 <!-- HERE STARTS DEMO FOR THE ACTIONPOINTS --> 62 <!-- HERE STARTS DEMO FOR THE ACTIONPOINTS. 63 P.S. Never set protectMe in the first actionpoint: if human didn't spawn, that actionpoint will be skipped --> 63 64 64 65 <Model mesh="cube.mesh" scale=8 position="0,0,0" /> … … 71 72 <DivisionController team=0 formationMode="finger4"> 72 73 <actionpoints> 73 <Actionpoint position="0,0,0" action="FLY" /> 74 <Actionpoint position="0,0,0" action="FLY" /> 74 75 <Actionpoint position="-1000,750,-500" action="ATTACK" attack="ss3" /> 75 <Actionpoint position="-1000,750,-500" action="PROTECt" protect="fuck" /> 76 </actionpoints> 76 <Actionpoint position="-1000,750,-500" action="PROTECt" protectMe=true /> 77 <Actionpoint position="-1000,750,-500" action="PROTECt" protect="fuck" /> 78 <Actionpoint position="-1000,750,-500" action="FIGHTALL" /> 79 </actionpoints> 77 80 </DivisionController> 78 81 </controller> … … 120 123 </templates> 121 124 </SpaceShip> 125 122 126 123 127 <!-- HERE ENDS DEMO FOR THE ACTIONPOINTS --> -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.cc
r10859 r10861 74 74 this->parsedActionpoints_.clear(); 75 75 RegisterObject( CommonController ); 76 76 this->bTakenOver_ = false; 77 77 } 78 78 CommonController::~CommonController() 79 79 { 80 parsedActionpoints_.clear(); 81 actionpoints_.clear(); 80 82 } 81 83 void CommonController::tick(float dt) … … 97 99 std::reverse(parsedActionpoints_.begin(), parsedActionpoints_.end()); 98 100 std::reverse(actionpoints_.begin(), actionpoints_.end()); 101 if (this->parsedActionpoints_.empty()) 102 { 103 this->action_ = Action::FIGHTALL; 104 } 99 105 } 100 106 if (this->bFirstTick_) … … 822 828 { 823 829 std::string protectName = this->loopActionpoints_.back().name; 824 825 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 826 { 827 if (CommonController::getName(*itP) == protectName) 830 if (protectName == "reservedKeyword:human") 831 { 832 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 828 833 { 829 this->setProtect (static_cast<ControllableEntity*>(*itP)); 834 if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController())) 835 { 836 this->setProtect (static_cast<ControllableEntity*>(*itP)); 837 } 830 838 } 839 } 840 else 841 { 842 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 843 { 844 if (CommonController::getName(*itP) == protectName) 845 { 846 this->setProtect (static_cast<ControllableEntity*>(*itP)); 847 } 848 } 831 849 } 832 850 if (!this->getProtect()) … … 915 933 case Action::PROTECT: 916 934 { 935 917 936 std::string protectName = this->parsedActionpoints_.back().name; 918 919 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 920 { 921 if (CommonController::getName(*itP) == protectName) 937 if (protectName == "reservedKeyword:human") 938 { 939 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 922 940 { 923 this->setProtect (static_cast<ControllableEntity*>(*itP)); 941 if (orxonox_cast<ControllableEntity*>(*itP) && ((*itP)->getController()) && orxonox_cast <NewHumanController*> ((*itP)->getController())) 942 { 943 this->setProtect (static_cast<ControllableEntity*>(*itP)); 944 } 924 945 } 946 } 947 else 948 { 949 for (ObjectList<Pawn>::iterator itP = ObjectList<Pawn>::begin(); itP; ++itP) 950 { 951 if (CommonController::getName(*itP) == protectName) 952 { 953 this->setProtect (static_cast<ControllableEntity*>(*itP)); 954 } 955 } 925 956 } 926 957 if (!this->getProtect()) … … 1028 1059 if (!this || !this->getControllableEntity()) 1029 1060 return; 1030 orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl;1061 // orxout (internal_error) << "Size of actions is " << this->parsedActionpoints_.size() << endl; 1031 1062 this->startAttackingEnemiesThatAreClose(); 1032 1063 //No action -> pop one from stack 1033 if (this->action_ == Action::NONE) 1034 { 1064 if (this->action_ == Action::NONE || this->bTakenOver_) 1065 { 1066 if (this->parsedActionpoints_.empty() && this->loopActionpoints_.empty()) 1067 { 1068 Point p = { Action::FIGHTALL, "", Vector3::ZERO, false }; 1069 this->parsedActionpoints_.push_back (p); 1070 } 1035 1071 this->executeActionpoint(); 1072 this->bTakenOver_ = false; 1036 1073 } 1037 1074 //Action fightall -> fight till nobody alive … … 1134 1171 this->parsedActionpoints_ = vector; 1135 1172 this->loopActionpoints_ = loop; 1136 this->bLoop_ = b; 1137 this->setAction (Action::NONE); 1138 // this->setTarget(0); 1139 // this->setTargetPosition (this->getControllableEntity()->getWorldPosition()); 1140 orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl; 1173 this->bLoop_ = this->bLoop_; 1174 this->bTakenOver_ = true; 1175 // orxout(internal_error) << "Top action is " << this->parsedActionpoints_.back().action << endl; 1141 1176 } 1142 1177 void CommonController::boostControl() -
code/branches/campaignHS15/src/orxonox/controllers/CommonController.h
r10859 r10861 229 229 bool bInLoop_; 230 230 bool bLoop_; 231 bool bEndLoop_; 231 bool bEndLoop_; 232 bool bTakenOver_; 232 233 //----[/"Private" variables]---- 233 234 -
code/branches/campaignHS15/src/orxonox/controllers/DivisionController.cc
r10859 r10861 83 83 { 84 84 if (!this->isActive()) 85 return; 85 return; 86 86 SUPER(DivisionController, tick, dt); 87 87 } … … 90 90 if (!this || !this->getControllableEntity()) 91 91 return; 92 92 93 CommonController::action(); 94 if (!this || !this->getControllableEntity()) 95 return; 96 if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())) 97 { 98 if (this->myFollower_) 99 { 100 this->myFollower_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); 101 } 102 else if (this->myWingman_) 103 { 104 this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); 105 } 106 } 93 107 94 108 } -
code/branches/campaignHS15/src/orxonox/controllers/SectionController.cc
r10859 r10861 98 98 if (!myDivisionLeader_) 99 99 { 100 100 101 CommonController::action(); 102 if (!this || !this->getControllableEntity()) 103 return; 104 if (!(this->parsedActionpoints_.empty() && this->loopActionpoints_.empty())) 105 { 106 if (this->myWingman_) 107 { 108 this->myWingman_->takeActionpoints(this->parsedActionpoints_, this->loopActionpoints_, this->bLoop_); 109 } 110 } 101 111 } 102 112 else if (myDivisionLeader_)
Note: See TracChangeset
for help on using the changeset viewer.