Changeset 8719 for code/branches/ai/src/orxonox
- Timestamp:
- Jun 30, 2011, 5:20:39 PM (14 years ago)
- Location:
- code/branches/ai/src/orxonox/controllers
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
r8711 r8719 44 44 #include "controllers/NewHumanController.h" 45 45 #include "controllers/DroneController.h" 46 #include "weaponsystem/WeaponMode.h" 47 #include "weaponsystem/WeaponPack.h" 48 #include "weaponsystem/Weapon.h" 46 49 47 50 namespace orxonox … … 85 88 86 89 this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this)); 87 88 89 90 90 this->bSetupWorked = false; 91 this->numberOfWeapons = 0; 92 this->botlevel_ = 1.0f; 93 this->mode_ = DEFAULT; 91 94 this->timeout_=0; 92 95 } … … 1071 1074 if(pawn) 1072 1075 { 1073 for(unsigned int i=0; i<WeaponSystem::MAX_WEAPON_MODES; i++) 1074 { 1075 if(pawn->getWeaponSet(i)) //main part: find which weapons a pawn can use; hard coded at the moment! 1076 { 1077 weapons[i]=i; 1078 projectiles[i]=1;//TODO: how to express infinite ammo? how to get data?? 1076 for(unsigned int i=0; i<WeaponSystem::MAX_WEAPON_MODES; i++) 1077 { 1078 const std::string wpn = getWeaponname(i, pawn); COUT(0)<<wpn<< std::endl;//Temporary debug info. 1079 /*if(wpn=="") 1080 weapons[i]=-1; 1081 else if(wpn=="LaserMunition")//other munitiontypes are not defined yet :-( 1082 weapons[0]=0; 1083 else if(wpn=="LENSFLARE")//TODO: insert right munition name 1084 weapons[1]=1; 1085 else if(wpn=="SIMPLEROCKET")//TODO: insert right munition name 1086 weapons[2]=2; 1087 else if(wpn=="ROCKET")//TODO: insert right munition name 1088 weapons[3]=3; 1089 */ 1090 if(pawn->getWeaponSet(i)) //main part: find which weapons a pawn can use; hard coded at the moment! 1091 { 1092 weapons[i]=i; 1093 projectiles[i]=1;//TODO: how to express infinite ammo? how to get data?? getWeaponmode(i)->getMunition()->getNumMunition(WeaponMode* user) 1079 1094 numberOfWeapons++; 1080 1081 1082 1083 1095 } 1096 else 1097 weapons[i]=-1; 1098 } 1084 1099 //pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user); 1085 1100 } 1086 1101 } 1087 1102 } 1103 1104 const std::string& ArtificialController::getWeaponname(int i, Pawn* pawn) 1105 {//is there a way to minimize this long if-return structure, without triggering nullpointer exceptions? 1106 if(!pawn) return ""; 1107 WeaponPack* wPack = pawn->getWeaponPack(i); 1108 if(!wPack) return ""; 1109 Weapon* wpn = wPack->getWeapon(i); 1110 if(!wpn) return ""; 1111 WeaponMode* wMode = wpn->getWeaponmode(i); 1112 if(!wMode) return ""; 1113 return wMode->getMunitionName(); 1114 }//pawn->getWeaponpack(i)->getWeapon(i)->getWeaponmode(i)->getMunitionName() 1088 1115 1089 1116 -
code/branches/ai/src/orxonox/controllers/ArtificialController.h
r8711 r8719 158 158 private: 159 159 void setupWeapons(); 160 const std::string& getWeaponname(int i, Pawn* pawn); 160 161 bool bSetupWorked; 161 162 };
Note: See TracChangeset
for help on using the changeset viewer.