Changeset 10080 in orxonox.OLD for branches/playability/src
- Timestamp:
- Dec 15, 2006, 11:48:40 PM (18 years ago)
- Location:
- branches/playability/src/world_entities
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/playability/src/world_entities/projectiles/swarm_projectile.cc
r10079 r10080 49 49 this->lifeSpan = 4.0; 50 50 this->agility = 3.5; 51 this->maxVelocity = 100;52 51 53 52 this->emitter = new DotEmitter(100, 5, M_2_PI); … … 55 54 this->emitter->setSpread(M_PI, M_PI); 56 55 57 this->target = NULL; 56 this->turningSpeed = 30; 57 58 this->physDamage = 200; 58 59 } 59 60 … … 151 152 this->destroy( entity ); 152 153 this->hitEntity = entity; 153 dynamic_cast<SpaceShip*>(entity)->damage(this->getDamage(),0); 154 dynamic_cast<SpaceShip*>(entity)->damage(this->getPhysDamage(),0); 155 } 156 157 158 void SwarmProjectile::setTarget(PNode* target) 159 { 160 this->target = target; 154 161 } 155 162 … … 167 174 if (unlikely(curDirection.len() == 0)) 168 175 return curDirection; 169 printf("recalculating direction\n");170 float tmp = angle Deg( curDirection, estTargetDir);176 //printf("recalculating direction\n"); 177 float tmp = angleRad ( curDirection, estTargetDir); 171 178 if ( unlikely(tmp == 0) ) { return curDirection * maxVelocity / curDirection.len(); } 179 // printf("turning angle: %f\ntemp: %f\n", angle, tmp); 172 180 173 181 if( fabsf(angle) > fabsf(tmp) ) { angle = tmp; } … … 220 228 this->shiftCoor(v);*/ 221 229 222 //float projectileVelocity = this->getVelocity().len();230 float projectileVelocity = this->getVelocity().len(); 223 231 // if (target != NULL){ 224 //float tti; //Time To Impact225 // //float targetVelocity = this->target->getVelocity().len();226 // // /* if (unlikely(projectileVelocity == 0 && targetVelocity == 0)) // TODO calculate this reasonably*/ 227 //tti = 1; // we do have a problem....228 // // //else229 // // //tti = (this->getAbsCoor() - this->target->getAbsCoor()).len() / sqrt ( projectileVelocity * projectileVelocity + targetVelocity * targetVelocity);230 // Vector estTargetDir = this->getAbsCoor() - this->target->getAbsCoor() + this->target->getVelocity() * (0.5);231 // // this->setVelocity((this->getAbsCoor() - this->target->getAbsCoor()).getNormalized() * this->velocity.len());232 // this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time ) * this->maxVelocity;232 float tti; //Time To Impact 233 float targetVelocity = this->target->getVelocity().len(); 234 if (unlikely(projectileVelocity == 0 && targetVelocity == 0)) // TODO calculate this reasonably 235 tti = 1; // we do have a problem.... 236 else 237 tti = (this->getAbsCoor() - this->target->getAbsCoor()).len() / sqrt ( projectileVelocity * projectileVelocity + targetVelocity * targetVelocity); 238 Vector estTargetDir = (this->target->getAbsCoor() - this->getAbsCoor()).getNormalized() * maxVelocity; 239 // Vector estTargetDir = (this->target->getAbsCoor() - (Vector(2000, 30, 300) + VECTOR_RAND(20))).getNormalized() * projectileVelocity; 240 this->velocity = this->newDirection(this->velocity, estTargetDir, this->turningSpeed * time ); 233 241 // } 234 242 // else 235 243 // if (likely(projectileVelocity != 0)) 236 244 // this->velocity *= (this->maxVelocity / projectileVelocity); // set speed to max 237 /* 238 Vector v = this->velocity + this->target->getAbsCoor() - this->getAbsCoor();239 v.normalize();240 v *= projectileVelocity;*/ 241 this->shiftCoor( velocity * (time));245 246 // printf("position: %f, %f, %f\n", this->getAbsCoor().x, this->getAbsCoor().y, this->getAbsCoor().z); 247 // printf("target position: %f, %f, %f\n", this->target->getAbsCoor().x, this->target->getAbsCoor().y, this->target->getAbsCoor().z); 248 249 this->shiftCoor(this->velocity * (time)); 242 250 243 251 if(this->tickLifeCycle(time)) … … 287 295 288 296 } 289 -
branches/playability/src/world_entities/projectiles/swarm_projectile.h
r10079 r10080 32 32 virtual void draw () const; 33 33 34 void setTarget(PNode* target); 34 35 35 36 private: … … 45 46 Vector correctionVector; 46 47 47 WorldEntity* target;48 49 48 WorldEntity* hitEntity; // FIXME TEMPORARY 50 49 -
branches/playability/src/world_entities/weapons/swarm_launcher.cc
r10079 r10080 19 19 #include "weapon_manager.h" 20 20 #include "world_entities/projectiles/projectile.h" 21 #include "world_entities/projectiles/swarm_projectile.h" 21 22 22 23 #include "model.h" … … 158 159 pj->setAbsCoor(this->getEmissionPoint()); 159 160 pj->setAbsDir(this->getAbsDir()); 160 pj->setTarget( dynamic_cast<WorldEntity*>(*eIterator));161 dynamic_cast<SwarmProjectile*>(pj)->setTarget( (PNode*)(*eIterator) ); 161 162 pj->activate(); 162 163
Note: See TracChangeset
for help on using the changeset viewer.