Changeset 7060
- Timestamp:
- May 31, 2010, 4:44:02 PM (14 years ago)
- Location:
- code/branches/presentation3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/data/levels/templates/pickup_representation_templates.oxt
r7038 r7060 429 429 430 430 <Template name=droneTemplate> 431 <Drone name="meineDrohne" mass= "50" linearDamping = "0.7" angularDamping = "0.99999" maxDistanceToOwner_=150 minDistanceToOwner_= 50 primaryThrust_=250 auxilaryThrust_=250 rotationThrust_=50>431 <Drone name="meineDrohne" mass= "50" linearDamping = "0.7" angularDamping = "0.99999" maxDistanceToOwner_=150 minDistanceToOwner_=75 maxShootingRange_=1000 primaryThrust_=250 auxilaryThrust_=250 rotationThrust_=50> 432 432 <attached> 433 433 <Model scale="1" mesh="drone.mesh"/> -
code/branches/presentation3/src/orxonox/controllers/DroneController.cc
r7038 r7060 75 75 float random; 76 76 float maxrand = 100.0f / ACTION_INTERVAL; 77 float distanceToTargetSquared; 77 78 78 // const Vector3& ownerPosition = getOwner()->getWorldPosition();79 // const Vector3& dronePosition = getDrone()->getWorldPosition();80 81 // const Vector3& locOwnerDir = getDrone()->getOrientation().UnitInverse()*(ownerPosition-dronePosition); //Vector from Drone To Owner out of drones local coordinate system82 79 if (target_) { 80 const Vector3& locTargetDir = getDrone()->getOrientation().UnitInverse()*((getDrone()->getWorldPosition())-(target_->getWorldPosition())); //Vector from Drone To target out of drones local coordinate system 81 distanceToTargetSquared = locTargetDir.squaredLength(); 82 } 83 83 84 random = rnd(maxrand); 84 if ( random < 30 && (!this->target_))85 if ( random < 30 || (!this->target_) || distanceToTargetSquared > (this->getDrone()->getMaxShootingRange()*this->getDrone()->getMaxShootingRange())) 85 86 this->searchNewTarget(); 86 87 87 if (random < 50 && this->target_ )88 if (random < 50 && this->target_ && distanceToTargetSquared < (this->getDrone()->getMaxShootingRange()*this->getDrone()->getMaxShootingRange())) 88 89 { 89 90 this->isShooting_ = true; … … 105 106 void DroneController::tick(float dt) 106 107 { 107 // Drone *myDrone = static_cast<Drone*>(this->getControllableEntity());108 108 float maxDistanceSquared = this->getDrone()->getMaxDistanceToOwner()*this->getDrone()->getMaxDistanceToOwner(); 109 109 float minDistanceSquared = this->getDrone()->getMinDistanceToOwner()*this->getDrone()->getMinDistanceToOwner(); 110 110 if ((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength() > maxDistanceSquared) { 111 this->moveToPosition(this->getOwner()->getWorldPosition()); 111 this->moveToPosition(this->getOwner()->getWorldPosition()); //fly towards owner 112 112 } 113 113 else if((this->getDrone()->getWorldPosition() - this->getOwner()->getWorldPosition()).squaredLength() < minDistanceSquared) { 114 this->moveToPosition(-this->getOwner()->getWorldPosition()); 114 this->moveToPosition(-this->getOwner()->getWorldPosition()); //fly away from owner 115 115 } 116 116 else if(!isShooting_) { … … 131 131 void DroneController::ownerDied() 132 132 { 133 // if (this->target_) { //Drone has some kind of Stockholm-Syndrom --> gets attached to Owners Killer 134 // this->setOwner(target_); 135 // this->searchNewTarget(); 136 // } 133 137 if (this->drone_) 134 138 this->drone_->destroy(); -
code/branches/presentation3/src/orxonox/worldentities/Drone.cc
r7039 r7060 79 79 XMLPortParam(Drone, "maxDistanceToOwner_", setMaxDistanceToOwner, getMaxDistanceToOwner, xmlelement, mode); 80 80 XMLPortParam(Drone, "minDistanceToOwner_", setMinDistanceToOwner, getMinDistanceToOwner, xmlelement, mode); 81 XMLPortParam(Drone, "maxShootingRange_", setMaxShootingRange, getMaxShootingRange, xmlelement, mode); 81 82 } 82 83 -
code/branches/presentation3/src/orxonox/worldentities/Drone.h
r7039 r7060 114 114 inline void setMinDistanceToOwner( float distance) 115 115 { this->minDistanceToOwner_=distance; } 116 inline void setMaxShootingRange( float distance) 117 { this->maxShootingRange_=distance; } 116 118 117 119 … … 130 132 inline float getMinDistanceToOwner() 131 133 { return this->minDistanceToOwner_; } 134 inline float getMaxShootingRange() 135 { return this->maxShootingRange_; } 132 136 133 137 private: … … 141 145 float maxDistanceToOwner_; //Maximum Distance to owner 142 146 float minDistanceToOwner_; //Minimum Distance to owner 147 float maxShootingRange_; 143 148 }; 144 149
Note: See TracChangeset
for help on using the changeset viewer.