Changeset 6640 for code/branches/ai/src/orxonox/controllers/AIController.cc
- Timestamp:
- Mar 29, 2010, 4:23:08 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/src/orxonox/controllers/AIController.cc
r5929 r6640 56 56 float maxrand = 100.0f / ACTION_INTERVAL; 57 57 58 // search enemy 59 random = rnd(maxrand); 60 if (random < 15 && (!this->target_)) 61 this->searchNewTarget(); 58 if (this->state_==0) 59 { 62 60 63 // forget enemy64 random = rnd(maxrand);65 if (random < 5 && (this->target_))66 this->forgetTarget();61 // search master 62 random = rnd(maxrand); 63 if (random < 50 && (!this->target_)) 64 this->searchNewMaster(); 67 65 68 // next enemy 69 random = rnd(maxrand); 70 if (random < 10 && (this->target_)) 71 this->searchNewTarget(); 66 //this->state_=1; 72 67 73 // fly somewhere 74 random = rnd(maxrand); 75 if (random < 50 && (!this->bHasTargetPosition_ && !this->target_)) 76 this->searchRandomTargetPosition(); 68 } 77 69 78 // stop flying79 random = rnd(maxrand);80 if (random < 10 && (this->bHasTargetPosition_ && !this->target_))81 this->bHasTargetPosition_ = false;70 if (this->state_==-1) 71 { 72 73 } 82 74 83 // fly somewhere else 84 random = rnd(maxrand); 85 if (random < 30 && (this->bHasTargetPosition_ && !this->target_)) 86 this->searchRandomTargetPosition(); 75 if (this->state_==1) 76 { 77 // search enemy 78 random = rnd(maxrand); 79 if (random < 15 && (!this->target_)) 80 this->searchNewTarget(); 87 81 88 // shoot89 random = rnd(maxrand);90 if (random < 75 && (this->target_ && !this->bShooting_))91 this->bShooting_ = true;82 // forget enemy 83 random = rnd(maxrand); 84 if (random < 5 && (this->target_)) 85 this->forgetTarget(); 92 86 93 // stop shooting 94 random = rnd(maxrand); 95 if (random < 25 && (this->bShooting_)) 96 this->bShooting_ = false; 87 // next enemy 88 random = rnd(maxrand); 89 if (random < 10 && (this->target_)) 90 this->searchNewTarget(); 91 92 // fly somewhere 93 random = rnd(maxrand); 94 if (random < 50 && (!this->bHasTargetPosition_ && !this->target_)) 95 this->searchRandomTargetPosition(); 96 97 // stop flying 98 random = rnd(maxrand); 99 if (random < 10 && (this->bHasTargetPosition_ && !this->target_)) 100 this->bHasTargetPosition_ = false; 101 102 // fly somewhere else 103 random = rnd(maxrand); 104 if (random < 30 && (this->bHasTargetPosition_ && !this->target_)) 105 this->searchRandomTargetPosition(); 106 107 // shoot 108 random = rnd(maxrand); 109 if (random < 75 && (this->target_ && !this->bShooting_)) 110 this->bShooting_ = true; 111 112 // stop shooting 113 random = rnd(maxrand); 114 if (random < 25 && (this->bShooting_)) 115 this->bShooting_ = false; 116 } 97 117 } 98 118 … … 102 122 return; 103 123 104 if (this->target_) 105 this->aimAtTarget(); 124 if (this->state_==1) 125 { 126 if (this->target_) 127 this->aimAtTarget(); 106 128 107 if (this->bHasTargetPosition_)108 this->moveToTargetPosition();129 if (this->bHasTargetPosition_) 130 this->moveToTargetPosition(); 109 131 110 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f)) 111 this->getControllableEntity()->fire(0); 132 if (this->getControllableEntity() && this->bShooting_ && this->isCloseAtTarget(1000) && this->isLookingAtTarget(Ogre::Math::PI / 20.0f)) 133 this->getControllableEntity()->fire(0); 134 } 135 136 if (this->state_==-1) 137 { 138 //this->state_=1; 139 140 141 } 112 142 113 143 SUPER(AIController, tick, dt);
Note: See TracChangeset
for help on using the changeset viewer.