Changeset 8965
- Timestamp:
- Dec 7, 2011, 4:00:37 PM (13 years ago)
- Location:
- code/branches/formation/src/orxonox/controllers
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/formation/src/orxonox/controllers/AIController.cc
r8953 r8965 123 123 } 124 124 125 // next enemy 126 random = rnd(maxrand); 127 if (random < 10 && (this->target_)) 128 this->searchNewTarget(); 129 125 130 // shoot 126 131 random = rnd(maxrand); -
code/branches/formation/src/orxonox/controllers/HumanController.cc
r8953 r8965 174 174 { 175 175 if (HumanController::localController_s && HumanController::localController_s->controllableEntity_) 176 { 176 177 HumanController::localController_s->controllableEntity_->fire(firemode); 178 //if human fires, set slaves free. See Masterable::forceFreeSlaves() 179 if (HumanController::localController_s->state_==MASTER && HumanController::localController_s->mode_==NORMAL) 180 { 181 HumanController::localController_s->forceFreeSlaves(); 182 } 183 } 177 184 } 178 185 … … 324 331 break; 325 332 } 326 changedMode(); 327 } 328 } 329 330 void HumanController::changedMode() 331 { 332 333 } 334 333 } 334 } 335 336 337 //used, when slaves are in DEFEND mode. 338 void HumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) 339 { 340 if (!this->formationFlight_ || this->state_!=MASTER || this->mode_!=DEFEND) return; 341 this->masterAttacked(originator); 342 } 343 335 344 void HumanController::addBots(unsigned int amount) 336 345 { -
code/branches/formation/src/orxonox/controllers/HumanController.h
r8953 r8965 88 88 static void toggleFormationFlight(); 89 89 static void FFChangeMode(); 90 static void changedMode(); 90 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, float damage); 91 91 92 92 93 static void addBots(unsigned int amount); -
code/branches/formation/src/orxonox/controllers/Masterable.cc
r8957 r8965 319 319 copyTargetOrientation(); 320 320 } 321 if (distance < 40)322 { 323 this->getControllableEntity()->moveFrontBack( 0.2f*SPEED_MASTER);321 if (distance < 100) 322 { //linear speed reduction 323 this->getControllableEntity()->moveFrontBack(distance/100.0f*0.4f*SPEED_MASTER); 324 324 325 325 } else this->getControllableEntity()->moveFrontBack(1.2f*SPEED_MASTER); … … 451 451 this->state_ = MASTER; 452 452 this->myMaster_ = 0; 453 orxout(debug_output) << "search new master: no master found, but "<<teamSize<<" teammates"<< endl; 454 } else if (this->state_ != SLAVE) 455 orxout(debug_output) << "search new master: no master found, no teammates..."<< endl; 453 } 456 454 } 457 455 /** … … 620 618 (*it)->myMaster_=this; 621 619 } 620 this->myMaster_=0; 622 621 this->state_=MASTER; 623 622 } 624 / /debug623 /*/debug 625 624 if (this->state_==SLAVE) 626 625 {orxout(debug_output) << this << " is slave "<< endl;} … … 628 627 {orxout(debug_output) << this << " is now a master of "<<this->slaves_.size()<<" slaves."<< endl;} 629 628 if (this->state_==FREE) 630 {orxout(debug_output) << this << " is free "<< endl;} 631 } 629 {orxout(debug_output) << this << " is free "<< endl;}*/ 630 } 631 632 void Masterable::masterAttacked(Pawn* originator) 633 { 634 orxout(debug_output)<<"slaves, attack!"<<endl; 635 } 632 636 633 637 … … 904 908 } 905 909 906 /* 907 bool Masterable::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype) 908 { 909 if (!entity1 || !entity2) return false; 910 if (entity1 == entity2) return true; 911 912 if (!gametype) 913 orxout(debug_output) << "gametype NULL"<< endl; 910 bool Masterable::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype) 911 { 912 if (entity1 == entity2) 913 return true; 914 914 915 915 int team1 = -1; 916 916 int team2 = -1; 917 917 918 Controller* controller = 0; 919 if (entity1->getController()) 920 controller = entity1->getController(); 921 else 922 controller = entity1->getXMLController(); 923 if (controller) 924 { 925 Masterable* ac = orxonox_cast<Masterable*>(controller); 926 if (ac) 927 team1 = ac->getTeam(); 928 } 929 930 if (entity2->getController()) 931 controller = entity2->getController(); 932 else 933 controller = entity2->getXMLController(); 934 if (controller) 935 { 936 Masterable* ac = orxonox_cast<Masterable*>(controller); 937 if (ac) 938 team2 = ac->getTeam(); 939 } 940 918 941 TeamDeathmatch* tdm = orxonox_cast<TeamDeathmatch*>(gametype); 919 942 if (tdm) … … 924 947 if (entity2->getPlayer()) 925 948 team2 = tdm->getTeam(entity2->getPlayer()); 926 orxout(debug_output) << "teamdeath okay"<< endl; 927 } 928 929 if (team1!=-1 && team2!=-1) 930 { 931 orxout(debug_output) << "Sameteam: decided in TeamDeathmatch. return "<<(team1 == team2 && team1 != -1)<< endl; 932 return (team1 == team2 && team1 != -1); 933 } 934 team1=team2=-1; 935 orxout(debug_output) << "Sameteam: not in teamdeathmatch."<< endl; 949 } 950 936 951 TeamBaseMatchBase* base = 0; 937 952 base = orxonox_cast<TeamBaseMatchBase*>(entity1); … … 967 982 } 968 983 } 969 970 if (team1!=-1 && team2!=-1)971 return (team1 == team2 && team1 != -1);972 team1=team2=-1;973 974 984 975 985 DroneController* droneController = 0; … … 1004 1014 1005 1015 return (team1 == team2 && team1 != -1); 1006 1007 }*/1008 1009 bool Masterable::sameTeam(ControllableEntity* entity1, ControllableEntity* entity2, Gametype* gametype)1010 {1011 if (entity1 == entity2)1012 return true;1013 1014 int team1 = -1;1015 int team2 = -1;1016 1017 Controller* controller = 0;1018 if (entity1->getController())1019 controller = entity1->getController();1020 else1021 controller = entity1->getXMLController();1022 if (controller)1023 {1024 Masterable* ac = orxonox_cast<Masterable*>(controller);1025 if (ac)1026 team1 = ac->getTeam();1027 }1028 1029 if (entity2->getController())1030 controller = entity2->getController();1031 else1032 controller = entity2->getXMLController();1033 if (controller)1034 {1035 Masterable* ac = orxonox_cast<Masterable*>(controller);1036 if (ac)1037 team2 = ac->getTeam();1038 }1039 1040 TeamDeathmatch* tdm = orxonox_cast<TeamDeathmatch*>(gametype);1041 if (tdm)1042 {1043 if (entity1->getPlayer())1044 team1 = tdm->getTeam(entity1->getPlayer());1045 1046 if (entity2->getPlayer())1047 team2 = tdm->getTeam(entity2->getPlayer());1048 return (team1 == team2 && team1 != -1); //temp solution1049 }1050 1051 TeamBaseMatchBase* base = 0;1052 base = orxonox_cast<TeamBaseMatchBase*>(entity1);1053 if (base)1054 {1055 switch (base->getState())1056 {1057 case BaseState::ControlTeam1:1058 team1 = 0;1059 break;1060 case BaseState::ControlTeam2:1061 team1 = 1;1062 break;1063 case BaseState::Uncontrolled:1064 default:1065 team1 = -1;1066 }1067 }1068 base = orxonox_cast<TeamBaseMatchBase*>(entity2);1069 if (base)1070 {1071 switch (base->getState())1072 {1073 case BaseState::ControlTeam1:1074 team2 = 0;1075 break;1076 case BaseState::ControlTeam2:1077 team2 = 1;1078 break;1079 case BaseState::Uncontrolled:1080 default:1081 team2 = -1;1082 }1083 }1084 1085 DroneController* droneController = 0;1086 droneController = orxonox_cast<DroneController*>(entity1->getController());1087 if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity2)1088 return true;1089 droneController = orxonox_cast<DroneController*>(entity2->getController());1090 if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity1)1091 return true;1092 DroneController* droneController1 = orxonox_cast<DroneController*>(entity1->getController());1093 DroneController* droneController2 = orxonox_cast<DroneController*>(entity2->getController());1094 if (droneController1 && droneController2 && droneController1->getOwner() == droneController2->getOwner())1095 return true;1096 1097 Dynamicmatch* dynamic = orxonox_cast<Dynamicmatch*>(gametype);1098 if (dynamic)1099 {1100 if (dynamic->notEnoughPigs||dynamic->notEnoughKillers||dynamic->notEnoughChasers) {return false;}1101 1102 if (entity1->getPlayer())1103 team1 = dynamic->getParty(entity1->getPlayer());1104 1105 if (entity2->getPlayer())1106 team2 = dynamic->getParty(entity2->getPlayer());1107 1108 if (team1 ==-1 ||team2 ==-1 ) {return false;}1109 else if (team1 == dynamic->chaser && team2 != dynamic->chaser) {return false;}1110 else if (team1 == dynamic->piggy && team2 == dynamic->chaser) {return false;}1111 else if (team1 == dynamic->killer && team2 == dynamic->chaser) {return false;}1112 else return true;1113 }1114 1115 return (team1 == team2 && team1 != -1);1116 1016 } 1117 1017 -
code/branches/formation/src/orxonox/controllers/Masterable.h
r8957 r8965 78 78 inline void setTeam(int team) 79 79 { this->team_ = team; 80 orxout(debug_output) << "Set team to: "<<team<<" in "<<this<< endl;} 80 orxout(debug_output) << "Set team to: "<<team<<" in "<<this<< endl;} 81 81 inline int getTeam() const 82 82 { return this->team_; } … … 134 134 135 135 void takeLeadOfFormation(); 136 void masterAttacked(Pawn* originator); 136 137 137 138 void specificMasterActionHold(); -
code/branches/formation/src/orxonox/controllers/NewHumanController.cc
r8858 r8965 297 297 void NewHumanController::hit(Pawn* originator, btManifoldPoint& contactpoint, float damage) 298 298 { 299 //Used in HumanController for formationFlight 300 HumanController::hit(originator,contactpoint,damage); 301 299 302 if (this->showDamageOverlay_ && !this->controlPaused_ && this->controllableEntity_ && !this->controllableEntity_->isInMouseLook()) 300 303 {
Note: See TracChangeset
for help on using the changeset viewer.