Changeset 8706 for code/trunk/src/modules/weapons
- Timestamp:
- Jun 14, 2011, 8:53:28 PM (13 years ago)
- Location:
- code/trunk
- Files:
-
- 15 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/weapons/projectiles/CMakeLists.txt
r7163 r8706 6 6 Rocket.cc 7 7 SimpleRocket.cc 8 BasicProjectile.cc 8 9 ) -
code/trunk/src/modules/weapons/projectiles/Projectile.cc
r7284 r8706 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 41 41 CreateFactory(Projectile); 42 42 43 Projectile::Projectile(BaseObject* creator) : MovableEntity(creator) 43 Projectile::Projectile(BaseObject* creator) : MovableEntity(creator), BasicProjectile() 44 44 { 45 45 RegisterObject(Projectile); 46 46 47 47 this->setConfigValues(); 48 this->bDestroy_ = false;49 48 this->owner_ = 0; 50 this->damage_ = 15;51 49 52 50 // Get notification about collisions 53 54 51 if (GameMode::isMaster()) 55 52 { … … 84 81 return; 85 82 86 if (this-> bDestroy_)83 if (this->getBDestroy()) 87 84 this->destroy(); // TODO: use a scheduler instead of deleting the object right here in tick() 88 85 } … … 94 91 } 95 92 93 /* Calls the collidesAgainst function of BasicProjectile 94 */ 96 95 bool Projectile::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 97 96 { 98 if (!this->bDestroy_ && GameMode::isMaster()) 99 { 100 if (otherObject == this->owner_) 101 return false; 102 103 this->bDestroy_ = true; 104 105 if (this->owner_) 106 { 107 { 108 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 109 effect->setPosition(this->getPosition()); 110 effect->setOrientation(this->getOrientation()); 111 effect->setDestroyAfterLife(true); 112 effect->setSource("Orxonox/explosion3"); 113 effect->setLifetime(2.0f); 114 } 115 { 116 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 117 effect->setPosition(this->getPosition()); 118 effect->setOrientation(this->getOrientation()); 119 effect->setDestroyAfterLife(true); 120 effect->setSource("Orxonox/smoke4"); 121 effect->setLifetime(3.0f); 122 } 123 } 124 125 Pawn* victim = orxonox_cast<Pawn*>(otherObject); 126 if (victim) 127 victim->hit(this->owner_, contactPoint, this->damage_); 128 } 129 return false; 97 return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this); 130 98 } 131 99 -
code/trunk/src/modules/weapons/projectiles/Projectile.h
r5929 r8706 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 35 35 #include "worldentities/MovableEntity.h" 36 36 37 #include "BasicProjectile.h" 38 37 39 namespace orxonox 38 40 { 39 class _WeaponsExport Projectile : public MovableEntity 41 class _WeaponsExport Projectile : public MovableEntity, public BasicProjectile 40 42 { 41 43 public: … … 49 51 virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint); 50 52 51 inline void setDamage(float damage)52 { this->damage_ = damage; }53 inline float getDamage() const54 { return this->damage_; }55 56 53 void setOwner(Pawn* owner); 57 54 inline Pawn* getOwner() const 58 55 { return this->owner_; } 59 56 57 60 58 private: 61 59 WeakPtr<Pawn> owner_; 62 60 float lifetime_; 63 float damage_;64 bool bDestroy_;65 61 Timer destroyTimer_; 66 62 }; -
code/trunk/src/modules/weapons/projectiles/Rocket.cc
r7848 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 52 52 Constructor. Registers the object and initializes some default values. 53 53 */ 54 Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator) 54 Rocket::Rocket(BaseObject* creator) : ControllableEntity(creator), BasicProjectile() 55 55 { 56 56 RegisterObject(Rocket);// - register the Rocket class to the core 57 57 58 58 this->localAngularVelocity_ = 0; 59 this->bDestroy_ = false;60 59 this->lifetime_ = 100; 61 60 … … 146 145 { 147 146 this->owner_ = owner; 148 this->player_ = this-> owner_->getPlayer();149 this-> owner_->getPlayer()->startTemporaryControl(this);147 this->player_ = this->getOwner()->getPlayer(); 148 this->getOwner()->getPlayer()->startTemporaryControl(this); 150 149 151 150 if( GameMode::isMaster() ) … … 175 174 if( GameMode::isMaster() ) 176 175 { 177 if( this-> bDestroy_)176 if( this->getBDestroy() ) 178 177 this->destroy(); 179 178 … … 181 180 } 182 181 182 /* Calls the collidesAgainst function of BasicProjectile 183 */ 183 184 bool Rocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 184 185 { 185 if (!this->bDestroy_ && GameMode::isMaster()) 186 { 187 if (otherObject == this->owner_) 188 return false; 189 190 this->bDestroy_ = true; 191 192 if (this->owner_) 193 { 194 { 195 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 196 effect->setPosition(this->getPosition()); 197 effect->setOrientation(this->getOrientation()); 198 effect->setDestroyAfterLife(true); 199 effect->setSource("Orxonox/explosion4"); 200 effect->setLifetime(2.0f); 201 } 202 203 { 204 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 205 effect->setPosition(this->getPosition()); 206 effect->setOrientation(this->getOrientation()); 207 effect->setDestroyAfterLife(true); 208 effect->setSource("Orxonox/smoke4"); 209 effect->setLifetime(3.0f); 210 } 211 } 212 213 Pawn* victim = orxonox_cast<Pawn*>(otherObject); 214 if (victim) 215 victim->hit(this->owner_, contactPoint, this->damage_); 216 // this->destroy(); 217 } 218 return false; 186 return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this); 219 187 } 220 188 … … 233 201 void Rocket::fired(unsigned int firemode) 234 202 { 235 // if (this->owner_) 236 // { 237 this->destroy(); 238 // } 203 this->destroy(); 239 204 } 240 205 … … 242 207 { 243 208 ParticleSpawner *effect1, *effect2; 244 if( this-> owner_)245 { 246 effect1 = new ParticleSpawner(this-> owner_->getCreator());247 effect2 = new ParticleSpawner(this-> owner_->getCreator());209 if( this->getOwner() ) 210 { 211 effect1 = new ParticleSpawner(this->getOwner()->getCreator()); 212 effect2 = new ParticleSpawner(this->getOwner()->getCreator()); 248 213 } 249 214 else -
code/trunk/src/modules/weapons/projectiles/Rocket.h
r7163 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 34 34 #include "tools/Timer.h" 35 35 #include "worldentities/ControllableEntity.h" 36 37 #include "BasicProjectile.h" 36 38 37 39 namespace orxonox … … 46 48 Oli Scheuss 47 49 */ 48 class _WeaponsExport Rocket : public ControllableEntity 50 class _WeaponsExport Rocket : public ControllableEntity, public BasicProjectile 49 51 { 50 52 public: … … 109 111 { return this->owner_; } 110 112 111 inline void setDamage(float damage)112 { this->damage_ = damage; }113 inline float getDamage() const114 { return this->damage_; }115 113 virtual void fired(unsigned int firemode); 116 114 … … 118 116 WeakPtr<Pawn> owner_; 119 117 Vector3 localAngularVelocity_; 120 float damage_;121 bool bDestroy_;122 118 123 119 WeakPtr<PlayerInfo> player_; -
code/trunk/src/modules/weapons/projectiles/SimpleRocket.cc
r7163 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 48 48 CreateFactory(SimpleRocket); 49 49 50 SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator) 50 SimpleRocket::SimpleRocket(BaseObject* creator) : ControllableEntity(creator), BasicProjectile() 51 51 { 52 52 RegisterObject(SimpleRocket);// - register the SimpleRocket class to the core 53 53 54 54 this->localAngularVelocity_ = 0; 55 this->bDestroy_ = false;56 55 this->lifetime_ = 120; 57 56 58 57 this->setMass(15); 59 COUT(4) << "simplerocket constructed\n";58 // COUT(4) << "simplerocket constructed\n"; 60 59 61 60 if (GameMode::isMaster()) … … 115 114 this->disableFire(); 116 115 117 if( this-> bDestroy_)116 if( this->getBDestroy() ) 118 117 this->destroy(); 119 118 } … … 159 158 { 160 159 this->owner_ = owner; 161 this->player_ = this-> owner_->getPlayer();162 } 163 164 165 166 160 this->player_ = this->getOwner()->getPlayer(); 161 } 162 163 164 /* Calls the collidesAgainst function of BasicProjectile 165 */ 167 166 bool SimpleRocket::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 168 167 { 169 if (!this->bDestroy_ && GameMode::isMaster()) 170 { 171 if (otherObject == this->owner_) 172 return false; 173 174 this->bDestroy_ = true; 175 176 if (this->owner_) 177 { 178 { 179 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 180 effect->setPosition(this->getPosition()); 181 effect->setOrientation(this->getOrientation()); 182 effect->setDestroyAfterLife(true); 183 effect->setSource("Orxonox/explosion4"); 184 effect->setLifetime(2.0f); 185 } 186 187 { 188 ParticleSpawner* effect = new ParticleSpawner(this->owner_->getCreator()); 189 effect->setPosition(this->getPosition()); 190 effect->setOrientation(this->getOrientation()); 191 effect->setDestroyAfterLife(true); 192 effect->setSource("Orxonox/smoke4"); 193 effect->setLifetime(3.0f); 194 } 195 } 196 197 float dmg = this->damage_; 198 // if (this->owner_) 199 // dmg = this->owner_->getPickups().processModifiers(ModifierType::Damage, dmg, false); 200 201 Pawn* victim = orxonox_cast<Pawn*>(otherObject); 202 if (victim) 203 victim->hit(this->owner_, contactPoint, dmg); 204 } 205 return false; 168 return BasicProjectile::basicCollidesAgainst(otherObject,contactPoint,this->getOwner(),this); 206 169 } 207 170 -
code/trunk/src/modules/weapons/projectiles/SimpleRocket.h
r7163 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 36 36 #include "graphics/ParticleSpawner.h" 37 37 38 #include "BasicProjectile.h" 39 38 40 namespace orxonox 39 41 { … … 46 48 Gabriel Nadler (Original file: Oli Scheuss) 47 49 */ 48 class _WeaponsExport SimpleRocket : public ControllableEntity 50 class _WeaponsExport SimpleRocket : public ControllableEntity, public BasicProjectile 49 51 { 50 52 public: … … 111 113 inline Pawn* getOwner() const 112 114 { return this->owner_; } 115 113 116 inline bool hasFuel() const 114 117 { return this->fuel_; } 115 116 inline void setDamage(float damage)117 { this->damage_ = damage; }118 inline float getDamage() const119 { return this->damage_; }120 118 121 119 … … 123 121 WeakPtr<Pawn> owner_; 124 122 Vector3 localAngularVelocity_; 125 float damage_;126 bool bDestroy_;127 123 bool fuel_; //!< Bool is true while the rocket "has fuel" 128 124 -
code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc
r7284 r8706 23 23 * Hagen Seifert 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 50 50 51 51 this->reloadTime_ = 0.25; 52 this->damage_ = 15;52 this->damage_ = 0; //default 15 53 53 this->speed_ = 2500; 54 54 this->delay_ = 0; … … 97 97 } 98 98 99 /* Creates the projectile object, sets its properties to the EnergyDrink properties, calls muendungsfeuer() 100 */ 99 101 void EnergyDrink::shot() 100 102 { … … 112 114 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 113 115 projectile->setDamage(this->getDamage()); 116 projectile->setShieldDamage(this->getShieldDamage()); 117 projectile->setHealthDamage(this->getHealthDamage()); 114 118 115 119 EnergyDrink::muendungsfeuer(); -
code/trunk/src/modules/weapons/weaponmodes/FusionFire.cc
r6732 r8706 23 23 * Martin Polak 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 48 48 this->reloadTime_ = 1.0; 49 49 this->bParallelReload_ = false; 50 this->damage_ = 40;50 this->damage_ = 0; //default 40 51 51 this->speed_ = 1250; 52 52 … … 54 54 } 55 55 56 /* Creates the projectile (BillboardProjectile) object, sets its properties to the FusionFire properties 57 */ 56 58 void FusionFire::fire() 57 59 { … … 65 67 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 66 68 projectile->setDamage(this->getDamage()); 69 projectile->setShieldDamage(this->getShieldDamage()); 70 projectile->setHealthDamage(this->getHealthDamage()); 71 67 72 projectile->setColour(ColourValue(1.0f, 0.7f, 0.3f, 1.0f)); 68 73 } -
code/trunk/src/modules/weapons/weaponmodes/HsW01.cc
r7284 r8706 23 23 * Hagen Seifert 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 51 51 52 52 this->reloadTime_ = 0.25; 53 this->damage_ = 15;53 this->damage_ = 0; //default 15 54 54 this->speed_ = 2500; 55 55 this->delay_ = 0; … … 109 109 } 110 110 111 /* Creates the projectile object, sets its properties to the HsW01 properties, calls muendungsfeuer() 112 */ 111 113 void HsW01::shot() 112 114 { … … 126 128 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 127 129 projectile->setDamage(this->getDamage()); 130 projectile->setShieldDamage(this->getShieldDamage()); 131 projectile->setHealthDamage(this->getHealthDamage()); 128 132 129 133 HsW01::muendungsfeuer(); -
code/trunk/src/modules/weapons/weaponmodes/LaserFire.cc
r6732 r8706 23 23 * Martin Polak 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 45 45 46 46 this->reloadTime_ = 0.25; 47 this->damage_ = 15;47 this->damage_ = 0; //default 15 48 48 this->speed_ = 1250; 49 49 … … 51 51 } 52 52 53 /* Creates the projectile object, sets its properties to the LaserFire properties 54 */ 53 55 void LaserFire::fire() 54 56 { … … 61 63 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 62 64 projectile->setDamage(this->getDamage()); 65 projectile->setShieldDamage(this->getShieldDamage()); 66 projectile->setHealthDamage(this->getHealthDamage()); 63 67 } 64 68 } -
code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc
r6732 r8706 23 23 * Joel Smely 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 45 45 46 46 this->reloadTime_ = 1; 47 this->damage_ = 100;47 this->damage_ = 0; //default 100 48 48 this->speed_ = 150; 49 49 … … 56 56 } 57 57 58 /* Creates the projectile (LightningGunProjectile) object, sets its properties to the LightningGun properties 59 */ 58 60 void LightningGun::fire() 59 61 { … … 69 71 projectile->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 70 72 projectile->setDamage(this->getDamage()); 73 projectile->setShieldDamage(this->getShieldDamage()); 74 projectile->setHealthDamage(this->getHealthDamage()); 71 75 } 72 76 } -
code/trunk/src/modules/weapons/weaponmodes/RocketFire.cc
r7846 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 48 48 this->reloadTime_ = 0.20f; 49 49 this->bParallelReload_ = false; 50 this->damage_ = 100;50 this->damage_ = 0; 51 51 this->speed_ = 500; 52 52 … … 59 59 } 60 60 61 /* Creates the Rocket object, sets its properties to the RocketFire properties 62 */ 61 63 void RocketFire::fire() 62 64 { … … 71 73 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 72 74 rocket->setDamage(this->getDamage()); 75 rocket->setShieldDamage(this->getShieldDamage()); 76 rocket->setHealthDamage(this->getHealthDamage()); 73 77 } 74 78 } -
code/trunk/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
r7846 r8706 23 23 * Oliver Scheuss 24 24 * Co-authors: 25 * ...25 * simonmie 26 26 * 27 27 */ … … 50 50 this->reloadTime_ = 1; 51 51 this->bParallelReload_ = false; 52 this->damage_ = 100;52 this->damage_ = 0; 53 53 this->speed_ = 500; 54 54 … … 62 62 } 63 63 64 /* Creates the Rocket (RocketController) object, sets its properties to the SimpleRocketFire properties, sets target 65 */ 64 66 void SimpleRocketFire::fire() 65 67 { … … 71 73 rocket->setVelocity(this->getMuzzleDirection()*this->speed_); 72 74 rocket->setOwner(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()); 75 73 76 rocket->setDamage(this->damage_); 77 rocket->setShieldDamage(this->getShieldDamage()); 78 rocket->setHealthDamage(this->getHealthDamage()); 79 74 80 WorldEntity* pawnn=static_cast<ControllableEntity*>(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn())->getTarget(); 75 81 if (pawnn) con->setTarget(pawnn);
Note: See TracChangeset
for help on using the changeset viewer.