- Timestamp:
- Nov 15, 2015, 4:47:35 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AI_HS15/src/orxonox/controllers/CommonController.cc
r10803 r10805 55 55 this->executingManeuver_ = false; 56 56 this->executingMoveToPoint_ = false; 57 this->action_ = Action::FLY; 57 58 this->stopLookingAtTarget(); 58 59 this->maneuverType_ = ManeuverType::NONE; … … 63 64 CommonController::~CommonController() 64 65 { 66 orxout(internal_error) << "I died, my Rank is " << rank_ << endl; 65 67 } 66 68 … … 118 120 } 119 121 } 122 Action::Value CommonController::getAction () 123 { 124 return this->action_; 125 } 126 127 void CommonController::setAction (Action::Value action, ControllableEntity* target) 128 { 129 this->action_ = action; 130 if (action == Action::FIGHT) 131 { 132 if (target) 133 this->setTarget (target); 134 } 135 else if (action == Action::PROTECT) 136 { 137 } 138 } 139 void CommonController::setAction (Action::Value action, const Vector3& target) 140 { 141 this->action_ = action; 142 if (action == Action::FLY) 143 { 144 this->setTargetPosition (target); 145 } 146 else if (action == Action::PROTECT) 147 { 148 149 } 150 } 151 void CommonController::setAction (Action::Value action, const Vector3& target, const Quaternion& orient ) 152 { 153 this->action_ = action; 154 if (action == Action::FLY) 155 { 156 this->setTargetPosition (target); 157 this->setTargetOrientation (orient); 158 } 159 else if (action == Action::PROTECT) 160 { 161 162 } 163 } 120 164 void CommonController::maneuver() 121 165 { … … 145 189 146 190 //bool bThisIsLookingAtTarget = this->isLooking ( getControllableEntity(), this->target_, math::pi/4 ); 147 bool bTargetIsLookingAtThis = this->isLooking ( this->target_, getControllableEntity(), math::pi/ 8.0f );191 bool bTargetIsLookingAtThis = this->isLooking ( this->target_, getControllableEntity(), math::pi/5.0f ); 148 192 149 193 150 194 151 195 //too far? well, come closer then 152 if ( diffLength > 5000 )196 if ( diffLength > 3000 ) 153 197 { 154 198 if (diffLength < 6000) 155 199 { 156 this->bEngaging_ = true; 200 157 201 } 158 202 else 159 203 { 160 this->bEngaging_ = false;161 204 } 162 205 this->setTargetPosition( this->positionOfTarget_ ); 163 206 } 164 207 //too close? How do u expect to dodge anything? Just attack! 165 else if ( diffLength < 600 )208 else if ( diffLength < 500 ) 166 209 { 167 210 //at this point, just look and shoot 168 if ( diffLength < 300 )211 if ( diffLength < 250 ) 169 212 { 170 213 this->stopMoving(); … … 205 248 if ( this->getControllableEntity() && !this->target_ ) 206 249 { 207 this->bEngaging_ = false; 250 208 251 this->maneuverType_ = ManeuverType::NONE; 209 252 } 210 orxout ( internal_error ) << "ManeuverType = " << this->maneuverType_ << endl;253 //orxout ( internal_error ) << "ManeuverType = " << this->maneuverType_ << endl; 211 254 } 212 255 ControllableEntity* CommonController::getTarget() … … 305 348 { 306 349 this->target_ = target; 307 orxout ( internal_error ) << " TARGET SET " << endl;350 //orxout ( internal_error ) << " TARGET SET " << endl; 308 351 309 352 if ( this->target_ ) … … 376 419 void CommonController::moveToPosition( const Vector3& target, float dt ) 377 420 { 378 float factor = 1; 379 if ( !this->getControllableEntity() ) 380 return; 381 if ( this->rank_ == Rank::DIVISIONLEADER ) 382 factor = 0.9; 383 if ( this->rank_ == Rank::SECTIONLEADER ) 384 factor = 0.95; 421 385 422 386 423 //100 is ( so far )the smallest tolerance ( empirically found )that can be reached, … … 421 458 } 422 459 423 this->getControllableEntity() ->moveFrontBack( SPEED *factor* dt );460 this->getControllableEntity() ->moveFrontBack( SPEED * dt ); 424 461 } 425 462 else … … 560 597 float squaredDistance = squaredDistanceToTarget(); 561 598 562 if ( squaredDistance < 25000000.0f && this->isLookingAtTarget( math::pi / 10.0f)) {599 if ( squaredDistance < 9000000.0f && this->isLookingAtTarget( math::pi / 10.0f)) { 563 600 return true; 564 601 }
Note: See TracChangeset
for help on using the changeset viewer.