Changeset 8735
- Timestamp:
- Jul 7, 2011, 3:59:54 PM (13 years ago)
- Location:
- code/branches/ai2/src/orxonox
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai2/src/orxonox/controllers/AIController.cc
r8733 r8735 205 205 if (!this->isActive()) 206 206 return; 207 207 if(this->bDeathFlag_)//If a bot died recently, make him check his weaponsystem. 208 { 209 this->bSetupWorked = false; 210 this->numberOfWeapons = 0; 211 this->resetDeathFlag(); 212 } 208 213 float random; 209 214 float maxrand = 100.0f / ACTION_INTERVAL; -
code/branches/ai2/src/orxonox/controllers/ArtificialController.cc
r8733 r8735 90 90 this->bSetupWorked = false; 91 91 this->numberOfWeapons = 0; 92 this->botlevel_ = 1.0f;92 this->botlevel_ = 0.5f; 93 93 this->mode_ = DEFAULT;////Vector-implementation: mode_.push_back(DEFAULT); 94 94 this->timeout_=0; … … 1043 1043 else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget((1 + 2*botlevel_)*1000) && this->isLookingAtTarget(math::pi / 20.0f)) 1044 1044 { 1045 if (this->isCloseAtTarget(130) && (weapons[1]==1))1045 if (this->isCloseAtTarget(130) &&weapons[1] ) 1046 1046 {//LENSFLARE: short range weapon 1047 1047 this->getControllableEntity()->fire(1); //ai uses lens flare if they're close enough to the target 1048 1048 } 1049 else if( (weapons[3]==3)&& this->isCloseAtTarget(400) /*&&projectiles[3]*/ )1049 else if(weapons[3]&& this->isCloseAtTarget(400) /*&&projectiles[3]*/ ) 1050 1050 {//ROCKET: mid range weapon 1051 1051 //TODO: How many rockets are available? 1052 1052 this->mode_ = ROCKET;//Vector-implementation: mode_.push_back(ROCKET); 1053 this->getControllableEntity()->fire(3);//launch rocket BUG IS TRIGGERED HERE.1053 this->getControllableEntity()->fire(3);//launch rocket 1054 1054 if(this->getControllableEntity()&&this->target_)//after fire(3) getControllableEntity() refers to the rocket! 1055 1055 { … … 1064 1064 this->projectiles[3]-=1;//decrease ammo !! 1065 1065 } 1066 else if ( (weapons[0]==0))//LASER: default weapon1066 else if (weapons[0])//LASER: default weapon 1067 1067 this->getControllableEntity()->fire(0); 1068 1068 } … … 1083 1083 //const std::string wpn = getWeaponname(i, pawn); COUT(0)<<wpn<< std::endl;//Temporary debug info. 1084 1084 /*if(wpn=="") 1085 weapons[i]= -1;1085 weapons[i]=false; 1086 1086 else if(wpn=="LaserMunition")//other munitiontypes are not defined yet :-( 1087 weapons[0]= 0;1087 weapons[0]=true; 1088 1088 else if(wpn=="FusionMunition") 1089 weapons[1]= 1;1089 weapons[1]=true; 1090 1090 else if(wpn=="TargetSeeking Rockets") 1091 weapons[2]=2; 1092 else if(wpn=="ROCKET")//TODO: insert right munition name 1093 weapons[3]=3; 1091 weapons[2]=true; 1092 else if(wpn=="RocketMunition") 1093 weapons[3]=true; 1094 else 1095 COUT(1)<< wpn << + << " has to be added in ArtificialController.cc as new weapon." << std::endl; 1094 1096 */ 1095 1097 if(pawn->getWeaponSet(i)) //main part: find which weapons a pawn can use; hard coded at the moment! 1096 1098 { 1097 weapons[i]= i;1099 weapons[i]=true; 1098 1100 projectiles[i]=1;//TODO: how to express infinite ammo? how to get data?? getWeaponmode(i)->getMunition()->getNumMunition(WeaponMode* user) 1099 1101 numberOfWeapons++; 1100 1102 } 1101 1103 else 1102 weapons[i]=- 1;1104 weapons[i]=-false; 1103 1105 } 1104 1106 //pawn->weaponSystem_->getMunition(SubclassIdentifier< Munition > *identifier)->getNumMunition (WeaponMode *user); -
code/branches/ai2/src/orxonox/controllers/ArtificialController.h
r8723 r8735 149 149 150 150 int numberOfWeapons; //< Used for weapon init function. Displayes number of weapons available for a bot. 151 int weapons[WeaponSystem::MAX_WEAPON_MODES];152 int projectiles[WeaponSystem::MAX_WEAPON_MODES]; 151 bool weapons[WeaponSystem::MAX_WEAPON_MODES]; //<! Displays if a weapon is available - managed by setupWeapons() 152 int projectiles[WeaponSystem::MAX_WEAPON_MODES]; //<! Displays amount of projectiles. - managed by setupWeapons() 153 153 float botlevel_; //< Makes the level of a bot configurable. 154 154 float timeout_; //< Timeout for rocket usage. (If a rocket misses, a bot should stop using it.) … … 156 156 enum Mode {DEFAULT, ROCKET, DEFENCE, MOVING};//TODO; implement DEFENCE, MOVING modes 157 157 Mode mode_; //TODO: replace single value with stack-like implementation: std::vector<Mode> mode_; 158 void setPreviousMode(); 159 160 private: 161 void setupWeapons(); 162 const std::string& getWeaponname(int i, Pawn* pawn); 163 bool bSetupWorked; 158 void setPreviousMode(); 159 void setupWeapons(); //<! Defines which weapons are available for a bot. Is recalled whenever a bot was killed. 160 const std::string& getWeaponname(int i, Pawn* pawn); //<! Function that links a weapon's firemode to its name. 161 bool bSetupWorked; //<! If false, setupWeapons() is called. 164 162 }; 165 163 } -
code/branches/ai2/src/orxonox/controllers/Controller.cc
r6417 r8735 42 42 this->controllableEntity_ = 0; 43 43 this->bGodMode_ = false; 44 this->bDeathFlag_ = false; 44 45 } 45 46 -
code/branches/ai2/src/orxonox/controllers/Controller.h
r8706 r8735 63 63 inline ControllableEntity* getControllableEntity() const 64 64 { return this->controllableEntity_; } 65 inline void setDeathFlag() 66 { this->bDeathFlag_ = true; } 67 inline void resetDeathFlag() 68 { this->bDeathFlag_ = false; } 65 69 virtual void changedControllableEntity() {} 66 70 … … 79 83 PlayerInfo* player_; 80 84 ControllableEntity* controllableEntity_; 85 bool bDeathFlag_; //<! Signal, when a controlled entity died. Flag is set in Pawn.cc and used in AIController. 81 86 private: 82 87 bool bGodMode_; -
code/branches/ai2/src/orxonox/worldentities/pawns/Pawn.cc
r8706 r8735 304 304 if (this->getGametype() && this->getGametype()->allowPawnDeath(this, this->lastHitOriginator_)) 305 305 { 306 if ( this->getController()&& (!this->isHumanShip_) ) //announce death to the ai 307 { 308 this->getController()->setDeathFlag(); 309 } 306 310 // Set bAlive_ to false and wait for PawnManager to do the destruction 307 311 this->bAlive_ = false;
Note: See TracChangeset
for help on using the changeset viewer.