Changeset 6918 for code/branches/ai/src/orxonox/controllers
- Timestamp:
- May 17, 2010, 4:36:18 PM (15 years ago)
- Location:
- code/branches/ai/src/orxonox/controllers
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
r6891 r6918 36 36 #include "gametypes/TeamDeathmatch.h" 37 37 #include "controllers/WaypointPatrolController.h" 38 #include "controllers/DroneController.h" 38 39 #include "util/Math.h" 39 40 … … 348 349 void ArtificialController::searchNewTarget() 349 350 { 351 COUT(0) << "search new target - start" << std::endl; 350 352 if (!this->getControllableEntity()) 351 353 return; … … 372 374 } 373 375 } 376 COUT(0) << "search new target - end: " << this->target_ << std::endl; 374 377 } 375 378 -
code/branches/ai/src/orxonox/controllers/CMakeLists.txt
r6854 r6918 8 8 WaypointController.cc 9 9 WaypointPatrolController.cc 10 DroneController.cc 10 DroneController.cc 11 11 ) -
code/branches/ai/src/orxonox/controllers/DroneController.cc
r6891 r6918 47 47 DroneController::DroneController(BaseObject* creator) : ArtificialController(creator) 48 48 { 49 // - do any kind of initialisation50 51 // this checks that our creator really is a drone52 // and saves the pointer to the drone for the controlling commands53 54 55 49 RegisterObject(DroneController); 56 50 … … 86 80 87 81 const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*(ownerPosition-dronePosition); //Vector from Drone To Owner out of drones local coordinate system 88 89 int distance = sqrt( (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x) 90 + (ownerPosition.y-dronePosition.y)*(ownerPosition.y-dronePosition.y) 91 + (ownerPosition.z-dronePosition.z)*(ownerPosition.z-dronePosition.z)); //distance to Owner 92 93 if (distance > 500) { //TODO: variable implementation of maxdistance 94 drone_->moveUpDown(locOwnerDir.y); 95 drone_->moveFrontBack(-locOwnerDir.z); 96 drone_->moveRightLeft(locOwnerDir.x); 97 } 98 99 82 /* 83 int distance_square = (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x) 84 + (ownerPosition.y-dronePosition.y)*(ownerPosition.y-dronePosition.y) 85 + (ownerPosition.z-dronePosition.z)*(ownerPosition.z-dronePosition.z); //distance to Owner squared 86 */ 100 87 random = rnd(maxrand); 101 88 if ( random < 30 && (!this->target_)) 102 89 this->searchNewTarget(); 103 104 105 this->aimAtTarget(); 106 drone_->fire(0); 90 /* 91 //face target 92 drone_->rotateYaw(-targetPosition_.x); 93 drone_->rotatePitch(targetPosition_.y); 94 */ 95 if (this->target_) 96 { 97 this->aimAtTarget(); 98 drone_->fire(0); 99 } 107 100 108 101 109 102 110 111 //COUT(0) << "Drone: " << dronePosition << endl;112 //COUT(0) << "Distance: " << distance << endl;103 /* 104 COUT(0) << "Drone: " << dronePosition << endl; 105 COUT(0) << "Distance: " << distance << endl; 113 106 COUT(0) << "locDrone: " << locOwnerDir << endl; 114 107 COUT(0) << "target: " << targetPosition_ << endl; 115 108 COUT(0) << "Owner: " << ownerPosition << endl; 116 109 COUT(0) << "Rand: " << random << endl; 117 110 */ 118 111 /* 119 112 // search enemy … … 171 164 Drone *myDrone = static_cast<Drone*>(this->getControllableEntity()); 172 165 173 if(myDrone != NULL) { 174 175 setTargetPosition(this->getControllableEntity()->getPosition()); 166 if ((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength() > 150*150) { //TODO: variable implementation of maxdistance 167 this->moveToPosition(this->getOwner()->getWorldPosition()); 176 168 177 169 } -
code/branches/ai/src/orxonox/controllers/DroneController.h
r6891 r6918 47 47 Oli Scheuss 48 48 */ 49 class _OrxonoxExport DroneController : public ArtificialController 49 class _OrxonoxExport DroneController : public ArtificialController, public Tickable 50 50 { 51 51 public:
Note: See TracChangeset
for help on using the changeset viewer.