Changeset 6891 for code/branches
- Timestamp:
- May 10, 2010, 4:40:44 PM (15 years ago)
- Location:
- code/branches/ai
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/ai/data/levels/pickup.oxw
r6782 r6891 24 24 25 25 <Template name=droneTemplate> 26 <Drone name="meineDrohne" primarythrust="80" auxilarythrust="10" rotationthrust="10"mass= "50" linearDamping = "0.9" angularDamping = "0.7">26 <Drone name="meineDrohne" mass= "50" linearDamping = "0.9" angularDamping = "0.7"> 27 27 <attached> 28 <Model scale="1 0" mesh="drone.mesh"/>28 <Model scale="1" mesh="drone.mesh"/> 29 29 </attached> 30 30 <collisionShapes> 31 <BoxCollisionShape position="0,0,0" halfExtents="1 0, 10, 10" />31 <BoxCollisionShape position="0,0,0" halfExtents="1, 1, 1" /> 32 32 </collisionShapes> 33 33 -
code/branches/ai/src/modules/pickup/items/DronePickup.cc
r6847 r6891 134 134 135 135 //Attach to pawn 136 Drone* drone = new Drone( this);136 Drone* drone = new Drone(pawn->getCreator()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something) 137 137 drone->addTemplate(this->getDroneTemplate()); 138 pawn->attach(drone); 138 139 139 Controller* controller = drone->getController(); 140 140 DroneController* droneController = dynamic_cast<DroneController*>(controller); … … 143 143 droneController->setOwner(pawn); 144 144 } 145 145 146 Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(30,0,-30); 147 drone->setPosition(spawnPosition); 148 146 149 //! The pickup has been used up. 147 150 this->setUsed(false); -
code/branches/ai/src/orxonox/controllers/AIController.cc
r6888 r6891 102 102 this->searchRandomTargetPosition(); 103 103 104 104 /* 105 105 random = rnd(maxrand); 106 106 if (random < 75 && (this->target_ && !this->bShooting_)) … … 110 110 random = rnd(maxrand); 111 111 if (random < 25 && (this->bShooting_)) 112 this->bShooting_ = false; 112 this->bShooting_ = false; */ 113 113 114 114 } -
code/branches/ai/src/orxonox/controllers/ArtificialController.cc
r6888 r6891 501 501 } 502 502 503 DroneController* droneController = 0; 504 droneController = orxonox_cast<DroneController*>(entity1->getController()); 505 if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity2) 506 return true; 507 droneController = orxonox_cast<DroneController*>(entity2->getController()); 508 if (droneController && static_cast<ControllableEntity*>(droneController->getOwner()) == entity1) 509 return true; 510 503 511 return (team1 == team2 && team1 != -1); 504 512 } -
code/branches/ai/src/orxonox/controllers/DroneController.cc
r6847 r6891 59 59 60 60 this->actionTimer_.setTimer(ACTION_INTERVAL, true, createExecutor(createFunctor(&DroneController::action, this))); 61 62 this->owner_.setCallback(createFunctor(&DroneController::ownerDied, this)); 61 63 } 62 64 … … 83 85 const Vector3& dronePosition = getDrone()->getWorldPosition(); 84 86 85 const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*( dronePosition-ownerPosition); //Vector from Drone To Owner out of drones local coordinate system87 const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*(ownerPosition-dronePosition); //Vector from Drone To Owner out of drones local coordinate system 86 88 87 89 int distance = sqrt( (ownerPosition.x-dronePosition.x)*(ownerPosition.x-dronePosition.x) … … 90 92 91 93 if (distance > 500) { //TODO: variable implementation of maxdistance 92 drone_->moveUpDown( -locOwnerDir.y);93 drone_->moveFrontBack( locOwnerDir.z);94 drone_->moveRightLeft( -locOwnerDir.x);94 drone_->moveUpDown(locOwnerDir.y); 95 drone_->moveFrontBack(-locOwnerDir.z); 96 drone_->moveRightLeft(locOwnerDir.x); 95 97 } 96 98 99 100 random = rnd(maxrand); 101 if ( random < 30 && (!this->target_)) 102 this->searchNewTarget(); 103 104 105 this->aimAtTarget(); 106 drone_->fire(0); 107 108 109 110 111 //COUT(0) << "Drone: " << dronePosition << endl; 112 //COUT(0) << "Distance: " << distance << endl; 113 COUT(0) << "locDrone: " << locOwnerDir << endl; 114 COUT(0) << "target: " << targetPosition_ << endl; 97 115 COUT(0) << "Owner: " << ownerPosition << endl; 98 COUT(0) << "Drone: " << dronePosition << endl; 99 COUT(0) << "Distance: " << distance << endl; 100 COUT(0) << "locDrone: " << locOwnerDir << endl; 101 116 COUT(0) << "Rand: " << random << endl; 102 117 103 118 /* … … 160 175 setTargetPosition(this->getControllableEntity()->getPosition()); 161 176 162 /* myDrone->setRotationThrust(25);163 myDrone->setAuxilaryThrust(30);164 myDrone->rotateYaw(10*dt); */165 177 } 166 178 167 179 SUPER(AIController, tick, dt); 168 180 169 // you can use the following commands for steering 170 // - moveFrontBack, moveRightLeft, moveUpDown 171 // - rotatePitch, rotateYaw, rotateRoll 172 // - apply the to myDrone (e.g. myDrone->rotateYaw(..) ) 181 } 173 182 183 void DroneController::ownerDied() 184 { 185 if (this->drone_) 186 this->drone_->destroy(); 187 else 188 this->destroy(); 174 189 } 175 190 } -
code/branches/ai/src/orxonox/controllers/DroneController.h
r6847 r6891 33 33 34 34 #include "AIController.h" 35 #include "core/WeakPtr.h" 35 36 #include "tools/interfaces/Tickable.h" 36 37 … … 64 65 protected: 65 66 virtual void action(); 67 void ownerDied(); 66 68 67 69 private: 68 70 Timer actionTimer_; 69 Pawn*owner_;71 WeakPtr<Pawn> owner_; 70 72 Drone* drone_; 71 73 };
Note: See TracChangeset
for help on using the changeset viewer.