Changeset 10391 for code/branches/weaponFS15
- Timestamp:
- Apr 23, 2015, 4:19:02 PM (10 years ago)
- Location:
- code/branches/weaponFS15/src/modules/weapons
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc
r10369 r10391 19 19 RegisterObject(GravityBomb); 20 20 21 this->setMass(15.0); 21 this->setMass(10.0); 22 this->isDetonated_ = false; 22 23 if (GameMode::isMaster()) 23 24 { 24 25 //Define CollisionType of the bomb 25 this-> velocityAtLastTick_= 1000;26 this->timeToLife_= 5; 26 27 this->setCollisionResponse(false); 27 this->setCollisionType(WorldEntity:: Kinematic);28 this->setCollisionType(WorldEntity::Dynamic); 28 29 this->enableCollisionCallback(); 29 30 … … 46 47 void GravityBomb::tick(float dt) 47 48 { 48 velocityAtLastTick_=getVelocity().length();49 49 SUPER(GravityBomb,tick,dt); 50 if(velocityAtLastTick_ < this->getVelocity().length()) 50 timeToLife_ -= dt; 51 if(timeToLife_ < 0) 51 52 { 52 53 orxout(debug_output) << "bomb has stoped moving" <<endl; 53 54 setVelocity(Vector3::ZERO); 54 55 setAcceleration(Vector3::ZERO); 55 velocityAtLastTick_=0;56 56 detonate(); 57 orxout(debug_output) << "denoting" <<endl;58 57 } 59 58 else 60 59 { 61 velocityAtLastTick_=getVelocity().length(); 62 orxout(debug_output)<< velocityAtLastTick_ <<endl; 63 orxout(debug_output) << "acceleration" << getAcceleration().length() <<endl; 60 orxout(debug_output)<< "Time to live:" << timeToLife_ <<endl; 64 61 destroyCheck(); 65 62 } 63 if(isDetonated_) detonate(); 66 64 } 67 65 68 66 bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint) 69 67 { 70 orxout(debug_output) << "collides" << endl; 71 processCollision(otherObject, contactPoint,cs); 72 //detonate(); 73 return true; 68 if(otherObject != getShooter()) 69 { 70 orxout(debug_output) << "collides" << endl; 71 processCollision(otherObject, contactPoint,cs); 72 isDetonated_ = true; 73 return true; 74 } 75 else{ 76 orxout(debug_output) << "collided with shooter. Has no effect..." << endl; 77 return false; 78 } 74 79 } 75 80 … … 77 82 { 78 83 GravityBombField* field = new GravityBombField(this->getContext()); 79 orxout(debug_output) << "denoting" <<endl; 84 field->setPosition(getPosition()); 85 orxout(debug_output) << "detonating. Creating GravityBombField." <<endl; 86 orxout(debug_output) << "Field is at Position: " << getPosition() << endl; 80 87 this->destroy(); 81 88 } -
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h
r10369 r10391 64 64 virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint); 65 65 void detonate(); 66 67 66 private: 68 69 float velocityAtLastTick_; //Used to check wether the Object is already accelarating in the oposite direction to detect the time to detonate it.67 bool isDetonated_; //Used to check whether the Bomb has to be destroyed during next tick. 68 float timeToLife_; //Time the bomb flies before it explodes. 70 69 71 70 }; -
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc
r10369 r10391 7 7 8 8 #include "GravityBombField.h" 9 #include "graphics/Model.h" 9 10 10 11 namespace orxonox{ 11 12 RegisterClass(GravityBombField); 12 13 13 const float GravityBombField::FORCE_FIELD_LIFETIME = 5;14 const float GravityBombField::FORCE_SPHERE_START_RADIUS = 100;15 const float GravityBombField::FORCE_SPHERE_START_STRENGTH = - 1000;14 const float GravityBombField::FORCE_FIELD_LIFETIME = 100; 15 const float GravityBombField::FORCE_SPHERE_START_RADIUS = 500; 16 const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -500; 16 17 17 18 GravityBombField::GravityBombField(Context* context) : ForceField(context) … … 22 23 setDiameter(FORCE_SPHERE_START_RADIUS); 23 24 setMode(modeInvertedSphere_s); 25 setCollisionResponse(false); 26 27 //Attach Demo Model for debuging. 28 Model* model = new Model(this->getContext()); 29 model->setMeshSource("rocket.mesh"); //Demo Model from SimpleRocket 30 model->scale(0.7f); 31 this->attach(model); 24 32 } 25 33 … … 32 40 if(lifetime_ < 0) 33 41 { 42 orxout(debug_output) << "Timeout. Destroying field." << endl; 34 43 this->destroy(); 35 44 } -
code/branches/weaponFS15/src/modules/weapons/projectiles/LightningGunProjectile.cc
r9667 r10391 47 47 48 48 this->textureIndex_ = 1; 49 this->setMass(2); 50 this->setCollisionType(Dynamic); 49 51 this->maxTextureIndex_ = 8; 50 52 this->textureTimer_.setTimer(0.01f, true, createExecutor(createFunctor(&LightningGunProjectile::changeTexture, this))); -
code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.cc
r10369 r10391 26 26 this->bParallelReload_ = false; 27 27 this->damage_ = 0.0f; 28 this->speed_ = 200.0f; 29 this->slowDownRate_ = -10.0f; 28 this->speed_ = 100.0f; 30 29 31 30 this->setMunitionName("GravityBombMunition"); … … 41 40 bomb->setOrientation(this->getMuzzleOrientation()); 42 41 bomb->setPosition(this->getMuzzlePosition()); 43 bomb->setVelocity(this->getMuzzleDirection() * this->speed_); 44 bomb->setAcceleration(this->getMuzzleDirection()* this->slowDownRate_); 42 bomb->setVelocity(this->getMuzzleDirection() * (this->speed_+this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity().length())); 45 43 46 44 bomb->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); -
code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.h
r10369 r10391 58 58 private: 59 59 float speed_; //!< The initial speed of the bomb when it is launched. 60 float slowDownRate_;61 60 }; 62 61 }
Note: See TracChangeset
for help on using the changeset viewer.