- Timestamp:
- Nov 25, 2015, 8:46:09 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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()
Note: See TracChangeset
for help on using the changeset viewer.