- Timestamp:
- Jan 27, 2011, 3:58:04 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
r7401 r7832 84 84 85 85 this->target_.setCallback(createFunctor(&ArtificialController::targetDied, this)); 86 this->bSetupWorked = false; 87 this->numberOfWeapons = 0; 86 88 } 87 89 … … 1016 1018 return (team1 == team2 && team1 != -1); 1017 1019 } 1020 1021 void ArtificialController::doFire() 1022 { 1023 if(!bSetupWorked)//setup: find out which weapons are active ! hard coded: laser is "0", lens flare is "1", ... 1024 { 1025 this->setupWeapons(); 1026 if(numberOfWeapons>0) 1027 bSetupWorked=true; 1028 } 1029 else if(this->getControllableEntity()&&(numberOfWeapons>0)&&this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(math::pi / 20.0f)) 1030 { 1031 if (this->isCloseAtTarget(140) && this->isLookingAtTarget(math::pi / 20.0f)&&(weapons[1]==1) ) 1032 this->getControllableEntity()->fire(1); //ai uses lens flare if they're close enough to the target 1033 1034 //default fire (laser) 1035 else if ((weapons[0]==0)) 1036 this->getControllableEntity()->fire(0); 1037 } 1038 } 1039 void ArtificialController::setupWeapons() 1040 { 1041 if(this->getControllableEntity()) 1042 { 1043 Pawn* pawn = orxonox_cast<Pawn*>(this->getControllableEntity()); 1044 if(pawn) 1045 { 1046 for(unsigned int i=0; i<WeaponSystem::MAX_WEAPON_MODES; i++) 1047 { 1048 if(pawn->getWeaponSet(i)) //main part: find which weapons a pawn can use; hard coded at the moment! 1049 { 1050 weapons[i]=i; 1051 numberOfWeapons++; 1052 } 1053 else 1054 weapons[i]=-1; 1055 } 1056 } 1057 } 1058 } 1018 1059 }
Note: See TracChangeset
for help on using the changeset viewer.