[Orxonox-commit 6452] r11108 - in code/trunk: data/levels/includes data/levels/templates src/modules/weapons/munitions src/modules/weapons/projectiles src/modules/weapons/weaponmodes src/orxonox/weaponsystem
fvultier at orxonox.net
fvultier at orxonox.net
Thu Feb 4 23:54:04 CET 2016
Author: fvultier
Date: 2016-02-04 23:54:04 +0100 (Thu, 04 Feb 2016)
New Revision: 11108
Added:
code/trunk/src/modules/weapons/munitions/FlameMunition.cc
code/trunk/src/modules/weapons/munitions/FlameMunition.h
code/trunk/src/modules/weapons/projectiles/FlameGunProjectile.cc
code/trunk/src/modules/weapons/projectiles/FlameGunProjectile.h
code/trunk/src/modules/weapons/weaponmodes/FlameGun.cc
code/trunk/src/modules/weapons/weaponmodes/FlameGun.h
Modified:
code/trunk/data/levels/includes/weaponSettingsFPS.oxi
code/trunk/data/levels/includes/weaponSettingsGhost.oxi
code/trunk/data/levels/templates/pickupRepresentationTemplates.oxt
code/trunk/src/modules/weapons/munitions/CMakeLists.txt
code/trunk/src/modules/weapons/munitions/LaserMunition.cc
code/trunk/src/modules/weapons/projectiles/BasicProjectile.cc
code/trunk/src/modules/weapons/projectiles/BasicProjectile.h
code/trunk/src/modules/weapons/projectiles/CMakeLists.txt
code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc
code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc
code/trunk/src/modules/weapons/projectiles/ParticleProjectile.h
code/trunk/src/modules/weapons/projectiles/Projectile.cc
code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.cc
code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.h
code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt
code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc
code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.h
code/trunk/src/modules/weapons/weaponmodes/FusionFire.cc
code/trunk/src/modules/weapons/weaponmodes/GravityBombFire.cc
code/trunk/src/modules/weapons/weaponmodes/HsW01.cc
code/trunk/src/modules/weapons/weaponmodes/IceGun.cc
code/trunk/src/modules/weapons/weaponmodes/LaserFire.cc
code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc
code/trunk/src/modules/weapons/weaponmodes/MineGun.cc
code/trunk/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
code/trunk/src/modules/weapons/weaponmodes/SplitGun.cc
code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
code/trunk/src/orxonox/weaponsystem/WeaponMode.h
Log:
A few modifications in the weapon system: WeaponModes may play a reload sound now. Fireing Sounds of WeaponModes may overlap now. New weapon: FlameGun, a flame thrower for close combat (e.g. for the FPS player)
Modified: code/trunk/data/levels/includes/weaponSettingsFPS.oxi
===================================================================
--- code/trunk/data/levels/includes/weaponSettingsFPS.oxi 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/data/levels/includes/weaponSettingsFPS.oxi 2016-02-04 22:54:04 UTC (rev 11108)
@@ -9,6 +9,7 @@
<weaponsets>
<WeaponSet firemode=0 />
<WeaponSet firemode=1 />
+ <WeaponSet firemode=2 />
</weaponsets>
<weaponpacks>
<WeaponPack firemode=0>
@@ -18,38 +19,14 @@
<DefaultWeaponmodeLink firemode=2 weaponmode=2 />
</links>
<Weapon>
- <HsW01 mode=0 munitionpershot=0 delay=0.0 damage=2.5 material="Flares/point_lensflare" muzzleoffset=" 0.7, -0.3, -3" />
- <LightningGun mode=1 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20/>
+ <HsW01 mode=0 munitionpershot=0 delay=0.0 damage=2.5 material="Flares/point_lensflare" muzzleoffset="0.7,-0.3,-3" />
+ <FlameGun mode=1 munitionpershot=1 damage=0.5 muzzleoffset="0.7,-0.3,-3"/>
+ <LightningGun mode=2 muzzleoffset="0,0,0" damage=3.14159 shielddamage=20/>
</Weapon>
- <LaserGun
- position="0,0,0"
- munitionType="LaserGunMunition"
- bulletLoadingTime="0.2"
- magazineLoadingTime="5.0"
- speed="1000"
- unlimitedMunition=true
- />
- <!--LaserGun
- position="0,0,0"
- munitionType="LaserGunMunition"
- bulletLoadingTime="0.2"
- magazineLoadingTime="5.0"
- speed="1250"
- unlimitedMunition=true
- />
</WeaponPack>
- <WeaponPack firemode=1>
- <Fusion
- position="0,0,0"
- munitionType="FusionMunition"
- bulletLoadingTime="0.3"
- magazineLoadingTime="3"
- speed="600"
- unlimitedMunition=true
- /-->
- </WeaponPack>
</weaponpacks>
<munition>
<LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=5 replenishamount=1 replenishinterval=7.5/>
+ <FlameMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=20/>
<LightningMunition initialmagazines=2 maxmagazines=2 munitionpermagazine=8 />
</munition>
Modified: code/trunk/data/levels/includes/weaponSettingsGhost.oxi
===================================================================
--- code/trunk/data/levels/includes/weaponSettingsGhost.oxi 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/data/levels/includes/weaponSettingsGhost.oxi 2016-02-04 22:54:04 UTC (rev 11108)
@@ -1,14 +1,13 @@
<weaponslots>
<WeaponSlot position=" 1.3,4.66,-20" />
<WeaponSlot position="-1.3,4.66,-20" />
- <WeaponSlot position="13.7,4.66,-20" />
- <WeaponSlot position="-16.3,4.66,-20" />
+ <WeaponSlot position="0,4.66,-20" />
</weaponslots>
<weaponsets>
<WeaponSet firemode=0 />
<WeaponSet firemode=1 />
<WeaponSet firemode=2 />
- <WeaponSet firemode=2 />
+ <WeaponSet firemode=3 />
</weaponsets>
<weaponpacks>
<WeaponPack>
@@ -16,27 +15,27 @@
<DefaultWeaponmodeLink firemode=0 weaponmode=0 />
<DefaultWeaponmodeLink firemode=1 weaponmode=1 />
<DefaultWeaponmodeLink firemode=2 weaponmode=2 />
+ <DefaultWeaponmodeLink firemode=3 weaponmode=3 />
</links>
<Weapon>
<HsW01 mode=0 munitionpershot=1 healthdamage=3.14159 delay=0 material="Flares/point_lensflare" />
<HsW01 mode=0 munitionpershot=1 healthdamage=3.14159 delay=0.125 material="Flares/point_lensflare" muzzleoffset=" 0.5,0.6,1.7" />
- <LightningGun mode=1 muzzleoffset="0,0,0" damage=30 shielddamage=10 />
+ <FusionFire mode=1 muzzleoffset="0,0,0" damage=30 shielddamage=10 />
</Weapon>
<Weapon>
<HsW01 mode=0 munitionpershot=1 damage=3.14159 delay=0 material="Flares/point_lensflare" />
<HsW01 mode=0 munitionpershot=1 damage=3.14159 delay=0.125 material="Flares/point_lensflare" muzzleoffset="-0.5,0.6,1.7" />
- <LightningGun mode=1 muzzleoffset="0,0,0" damage=30 shielddamage=10 />
+ <FusionFire mode=1 muzzleoffset="0,0,0" damage=30 shielddamage=10 />
</Weapon>
<Weapon>
- <SimpleRocketFire mode=2 munitionpershot=1 muzzleoffset="0,0,0" damage=50 />
+ <FlameGun mode=2 munitionpershot=1 damage=0.5 muzzleoffset="0,0,0"/>
+ <SplitGun mode=3 munitionpershot=1 damage=6.0 muzzleoffset="0.5,0.6,1.7" splittime=0.2 numberofsplits=2 numberofchilds=3 spread=0.1 damagereduction=2.0 />
</Weapon>
- <Weapon>
- <SimpleRocketFire mode=2 munitionpershot=1 muzzleoffset="0,0,0" damage=50 delay=0.1 />
- </Weapon>
</WeaponPack>
</weaponpacks>
<munition>
<LaserMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=10 replenishamount=1 replenishinterval=7.5/>
- <LightningMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
- <RocketMunition initialmagazines=5 maxmagazines=5 munitionpermagazine=1 />
+ <FusionMunition initialmagazines=4 maxmagazines=4 munitionpermagazine=8 />
+ <FlameMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=20/>
+ <SplitMunition initialmagazines=8 maxmagazines=8 munitionpermagazine=5/>
</munition>
Modified: code/trunk/data/levels/templates/pickupRepresentationTemplates.oxt
===================================================================
--- code/trunk/data/levels/templates/pickupRepresentationTemplates.oxt 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/data/levels/templates/pickupRepresentationTemplates.oxt 2016-02-04 22:54:04 UTC (rev 11108)
@@ -359,6 +359,7 @@
<MunitionContainer munitiontype="SplitMunition" munitionamount=16 magazinesamount=0 />
<MunitionContainer munitiontype="RocketMunition" munitionamount=0 magazinesamount=10 />
<MunitionContainer munitiontype="IceMunition" munitionamount=0 magazinesamount=10 />
+ <MunitionContainer munitiontype="FlameMunition" munitionamount=0 magazinesamount=10 />
<MunitionContainer munitiontype="GravityBombMunition" munitionamount=0 magazinesamount=10 />
<MunitionContainer munitiontype="MineMunition" munitionamount=0 magazinesamount=10 />
</munitioncontainers>
Modified: code/trunk/src/modules/weapons/munitions/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/weapons/munitions/CMakeLists.txt 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/munitions/CMakeLists.txt 2016-02-04 22:54:04 UTC (rev 11108)
@@ -5,6 +5,7 @@
RocketMunition.cc
GravityBombMunition.cc
IceMunition.cc
+ FlameMunition.cc
SplitMunition.cc
MineMunition.cc
)
Added: code/trunk/src/modules/weapons/munitions/FlameMunition.cc
===================================================================
--- code/trunk/src/modules/weapons/munitions/FlameMunition.cc (rev 0)
+++ code/trunk/src/modules/weapons/munitions/FlameMunition.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -0,0 +1,56 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file FlameMunition.h
+ @brief Implementation of the FlameMunition class.
+*/
+
+#include "FlameMunition.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ RegisterClass(FlameMunition);
+
+ FlameMunition::FlameMunition(Context* context) : Munition(context)
+ {
+ RegisterObject(FlameMunition);
+
+ this->maxMunitionPerMagazine_ = 90;
+ this->maxMagazines_ = 3;
+ this->unassignedMagazines_ = 3;
+
+ this->deployment_ = MunitionDeployment::Share;
+
+ this->bAllowMunitionRefilling_ = true;
+ this->bAllowMultiMunitionRemovementUnderflow_ = false;
+
+ this->reloadTime_ = 0.5f;
+ }
+}
Added: code/trunk/src/modules/weapons/munitions/FlameMunition.h
===================================================================
--- code/trunk/src/modules/weapons/munitions/FlameMunition.h (rev 0)
+++ code/trunk/src/modules/weapons/munitions/FlameMunition.h 2016-02-04 22:54:04 UTC (rev 11108)
@@ -0,0 +1,58 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file FlameMunition.h
+ @brief Definition of the FlameMunition class.
+*/
+
+#ifndef _FlameMunition_H__
+#define _FlameMunition_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/Munition.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ FlameMunition.
+ @author
+ Fabien Vultier
+ @ingroup WeaponsMunitions
+ */
+ class _WeaponsExport FlameMunition : public Munition
+ {
+ public:
+ FlameMunition(Context* context);
+ virtual ~FlameMunition() = default;
+ };
+}
+
+#endif /* _FlameMunition_H__ */
Modified: code/trunk/src/modules/weapons/munitions/LaserMunition.cc
===================================================================
--- code/trunk/src/modules/weapons/munitions/LaserMunition.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/munitions/LaserMunition.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -54,6 +54,6 @@
this->replenishInterval_ = 7.0f;
this->replenishAmount_ = 1;
- this->reloadTime_ = 0.5f;
+ this->reloadTime_ = 0.6f;
}
}
Modified: code/trunk/src/modules/weapons/projectiles/BasicProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/BasicProjectile.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/projectiles/BasicProjectile.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -53,6 +53,9 @@
this->bDestroy_ = false;
+ // Default is destroying the projectile after collision
+ this->destroyAfterCollision_ = true;
+
// Default damage must be zero, otherwise it would be above zero if no settings are made in the weaponsettings xml file.
// same thing for all weaponmodes files
this->damage_ = 0.0f;
@@ -86,8 +89,12 @@
if (this->isObjectRelatedToShooter(otherObject) || otherObject->isA(Class(BasicProjectile))) // Prevents you from shooting yourself or other projectiles
return false;
- this->bDestroy_ = true; // If something is hit, the object is destroyed and can't hit something else.
- // The projectile is destroyed by its tick()-function (in the following tick).
+ if (getDestroyAfterCollision())
+ {
+ this->bDestroy_ = true; // If something is hit, the object is destroyed and can't hit something else.
+ // The projectile is destroyed by its tick()-function (in the following tick).
+ // TODO: Use destroyLater() for this
+ }
Pawn* victim = orxonox_cast<Pawn*>(otherObject); // If otherObject isn't a Pawn, then victim is nullptr
Modified: code/trunk/src/modules/weapons/projectiles/BasicProjectile.h
===================================================================
--- code/trunk/src/modules/weapons/projectiles/BasicProjectile.h 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/projectiles/BasicProjectile.h 2016-02-04 22:54:04 UTC (rev 11108)
@@ -118,6 +118,10 @@
protected:
bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
void destroyCheck(void);
+ inline void setDestroyAfterCollision(bool destroyAfterCollision)
+ { destroyAfterCollision_ = destroyAfterCollision; }
+ inline bool getDestroyAfterCollision() const
+ { return destroyAfterCollision_; }
private:
bool isObjectRelatedToShooter(WorldEntity* otherObject);
@@ -129,6 +133,7 @@
float shielddamage_; //!< The amount of shield-damage. Shield-damage only reduces shield health.
bool bDestroy_; //!< Boolean, to check whether a projectile should be destroyed.
+ bool destroyAfterCollision_; //!< Boolean, defines whether the projectile gets detroyed after a collision.
};
}
Modified: code/trunk/src/modules/weapons/projectiles/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/weapons/projectiles/CMakeLists.txt 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/projectiles/CMakeLists.txt 2016-02-04 22:54:04 UTC (rev 11108)
@@ -6,6 +6,7 @@
LightningGunProjectile.cc
SplitGunProjectile.cc
IceGunProjectile.cc
+ FlameGunProjectile.cc
Rocket.cc
RocketOld.cc
SimpleRocket.cc
Added: code/trunk/src/modules/weapons/projectiles/FlameGunProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/FlameGunProjectile.cc (rev 0)
+++ code/trunk/src/modules/weapons/projectiles/FlameGunProjectile.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -0,0 +1,85 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file FlameGunProjectile.h
+ @brief Implementation of the FlameGunProjectile class.
+*/
+
+#include "FlameGunProjectile.h"
+
+#include "core/CoreIncludes.h"
+#include "core/command/Executor.h"
+#include "util/Convert.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+ RegisterClass(FlameGunProjectile);
+
+ FlameGunProjectile::FlameGunProjectile(Context* context) : ParticleProjectile(context)
+ {
+ RegisterObject(FlameGunProjectile);
+
+ this->lifetime_ = 1.0f;
+ this->spread_ = 0.1f;
+
+ setDestroyAfterCollision(false);
+ setEffect("Orxonox/fire3");
+ }
+
+ void FlameGunProjectile::setLifetime(float lifetime)
+ {
+ if (lifetime >= 0.0)
+ {
+ this->lifetime_ = lifetime;
+ this->flameTimer_.setTimer(this->lifetime_, false, createExecutor(createFunctor(&FlameGunProjectile::destroy, this)));
+ }
+ else
+ {
+ this->lifetime_ = 0.0;
+ }
+ }
+
+ void FlameGunProjectile::setSpread(float spread)
+ {
+ spread_ = spread;
+ }
+
+ bool FlameGunProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)
+ {
+ bool result = ParticleProjectile::processCollision(otherObject, contactPoint, cs);
+
+ // Every projectile can only deal damage once.
+ setDamage(0.0);
+ setHealthDamage(0.0);
+ setShieldDamage(0.0);
+
+ return result;
+ }
+}
Added: code/trunk/src/modules/weapons/projectiles/FlameGunProjectile.h
===================================================================
--- code/trunk/src/modules/weapons/projectiles/FlameGunProjectile.h (rev 0)
+++ code/trunk/src/modules/weapons/projectiles/FlameGunProjectile.h 2016-02-04 22:54:04 UTC (rev 11108)
@@ -0,0 +1,69 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file FlameGunProjectile.h
+ @brief Definition of the FlameGunProjectile class.
+*/
+
+#ifndef _FlameGunProjectile_H__
+#define _FlameGunProjectile_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include <string>
+#include "tools/Timer.h"
+#include "ParticleProjectile.h"
+
+namespace orxonox
+{
+
+ /**
+ @author
+ Fabien Vultier
+ @ingroup WeaponsProjectiles
+ */
+ class _WeaponsExport FlameGunProjectile : public ParticleProjectile
+ {
+ public:
+ FlameGunProjectile(Context* context);
+ virtual ~FlameGunProjectile() {}
+
+ virtual void setLifetime(float lifetime);
+ virtual void setSpread(float spread);
+ protected:
+ bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
+
+ private:
+ float lifetime_;
+ float spread_;
+ Timer flameTimer_;
+ };
+}
+
+#endif /* _FlameGunProjectile_H__ */
Modified: code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/projectiles/LightningGunProjectile.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -46,7 +46,7 @@
RegisterObject(LightningGunProjectile);
this->textureIndex_ = 1;
- this->setMass(2);
+ this->setMass(0.1f);
this->setCollisionType(CollisionType::Dynamic);
this->maxTextureIndex_ = 8;
this->textureTimer_.setTimer(0.01f, true, createExecutor(createFunctor(&LightningGunProjectile::changeTexture, this)));
Modified: code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/projectiles/ParticleProjectile.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -42,22 +42,13 @@
{
RegisterClass(ParticleProjectile);
- ParticleProjectile::ParticleProjectile(Context* context) : BillboardProjectile(context)
+ ParticleProjectile::ParticleProjectile(Context* context) : Projectile(context)
{
RegisterObject(ParticleProjectile);
- if (GameMode::showsGraphics())
- {
- // Create the particles.
- this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), "Orxonox/shot3_small", LODParticle::Normal);
- this->attachOgreObject(this->particles_->getParticleSystem());
- this->particles_->setKeepParticlesInLocalSpace(0);
+ this->particles_ = nullptr;
- for (unsigned int i = 0; i < this->particles_->getNumEmitters(); ++i)
- this->particles_->getEmitter(i)->setDirection(-WorldEntity::FRONT);
- }
- else
- this->particles_ = nullptr;
+ //setEffect("Orxonox/sparks2");
}
ParticleProjectile::~ParticleProjectile()
@@ -81,4 +72,30 @@
if (this->particles_)
this->particles_->setEnabled(this->isVisible());
}
+
+ void ParticleProjectile::setEffect(const std::string& effect)
+ {
+ // If we already have a particle interface, delete it
+ if (this->particles_)
+ {
+ this->detachOgreObject(this->particles_->getParticleSystem());
+ delete this->particles_;
+ this->particles_ = nullptr;
+ }
+
+ if (GameMode::showsGraphics())
+ {
+ // Create the particles.
+ this->particles_ = new ParticleInterface(this->getScene()->getSceneManager(), effect, LODParticle::Normal);
+ this->attachOgreObject(this->particles_->getParticleSystem());
+ this->particles_->setKeepParticlesInLocalSpace(0);
+
+ for (unsigned int i = 0; i < this->particles_->getNumEmitters(); ++i)
+ this->particles_->getEmitter(i)->setDirection(-WorldEntity::FRONT);
+ }
+ else
+ {
+ this->particles_ = nullptr;
+ }
+ }
}
Modified: code/trunk/src/modules/weapons/projectiles/ParticleProjectile.h
===================================================================
--- code/trunk/src/modules/weapons/projectiles/ParticleProjectile.h 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/projectiles/ParticleProjectile.h 2016-02-04 22:54:04 UTC (rev 11108)
@@ -47,12 +47,13 @@
Fabian 'x3n' Landau
@ingroup WeaponsProjectiles
*/
- class _WeaponsExport ParticleProjectile : public BillboardProjectile
+ class _WeaponsExport ParticleProjectile : public Projectile
{
public:
ParticleProjectile(Context* context);
virtual ~ParticleProjectile();
virtual void changedVisibility() override;
+ virtual void setEffect(const std::string& effect);
private:
ParticleInterface* particles_; //!< The particles.
Modified: code/trunk/src/modules/weapons/projectiles/Projectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/Projectile.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/projectiles/Projectile.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -53,7 +53,7 @@
// Get notification about collisions
if (GameMode::isMaster())
{
- this->setMass(1.0f);
+ this->setMass(0.1f);
this->enableCollisionCallback();
this->setCollisionResponse(false);
this->setCollisionType(CollisionType::Dynamic);
Modified: code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.cc
===================================================================
--- code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -51,8 +51,22 @@
this->splitTime_ = 1.0f;
this->spread_ = 0.2f;
this->damageReduction_ = 1.0f;
+ this->splitSound_ = nullptr;
+
+ this->setSplitSound("sounds/Weapon_SplitGun.ogg", 0.8);
}
+ SplitGunProjectile::~SplitGunProjectile()
+ {
+ if (this->isInitialized())
+ {
+ if (splitSound_)
+ {
+ splitSound_->destroy();
+ }
+ }
+ }
+
void SplitGunProjectile::setNumberOfSplits(int numberOfSplits)
{
if (numberOfSplits >= 0)
@@ -157,6 +171,24 @@
}
numberOfSplits_ = 0;
+
+ if (splitSound_)
+ {
+ splitSound_->play();
+ }
}
}
+
+ void SplitGunProjectile::setSplitSound(const std::string& soundPath, const float soundVolume)
+ {
+ if (!splitSound_)
+ {
+ this->splitSound_ = new WorldSound(this->getContext());
+ this->splitSound_->setLooping(false);
+ this->attach(splitSound_);
+ }
+
+ this->splitSound_->setSource(soundPath);
+ this->splitSound_->setVolume(soundVolume);
+ }
}
Modified: code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.h
===================================================================
--- code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.h 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/projectiles/SplitGunProjectile.h 2016-02-04 22:54:04 UTC (rev 11108)
@@ -27,7 +27,7 @@
*/
/**
- @file IceGunProjectile.h
+ @file SplitGunProjectile.h
@brief Definition of the SplitGunProjectile class.
*/
@@ -39,6 +39,7 @@
#include <string>
#include "tools/Timer.h"
#include "BillboardProjectile.h"
+#include "sound/WorldSound.h"
namespace orxonox
{
@@ -54,13 +55,14 @@
{
public:
SplitGunProjectile(Context* context);
- virtual ~SplitGunProjectile() {}
+ virtual ~SplitGunProjectile();
virtual void setNumberOfSplits(int numberOfSplits);
virtual void setNumberOfChilds(int numberOfChilds);
virtual void setSplitTime(float splitTime);
virtual void setSpread(float spread);
virtual void setDamageReduction(float damageReduction);
+ virtual void setSplitSound(const std::string& soundPath, const float soundVolume = 1.0);
private:
int numberOfSplits_;
@@ -69,6 +71,7 @@
float spread_;
float damageReduction_; //The damage of a child projectile is reduced by this factor
Timer splitTimer_;
+ WorldSound* splitSound_; //Sound played if the projectile splits
virtual void split();
};
Modified: code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/CMakeLists.txt 2016-02-04 22:54:04 UTC (rev 11108)
@@ -6,6 +6,7 @@
LightningGun.cc
SplitGun.cc
IceGun.cc
+ FlameGun.cc
RocketFire.cc
RocketFireOld.cc
SimpleRocketFire.cc
Modified: code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -58,7 +58,9 @@
this->damage_ = 0.0f;
this->speed_ = 750.0f;
this->delay_ = 0.0f;
+ this->timerStarted_ = false;
this->setMunitionName("FusionMunition");
+ this->setFireSound("sounds/Weapon_EnergyDrink.ogg");
this->delayTimer_.setTimer(1.0f, false, createExecutor(createFunctor(&EnergyDrink::shot, this)));
this->delayTimer_.stopTimer();
@@ -92,15 +94,31 @@
*/
void EnergyDrink::fire()
{
- this->delayTimer_.startTimer();
+ if (!timerStarted_)
+ {
+ this->delayTimer_.startTimer();
+ this->timerStarted_ = true;
+ }
}
+ bool EnergyDrink::fire(float* reloadTime)
+ {
+ if (!timerStarted_)
+ {
+ return WeaponMode::fire(reloadTime);
+ }
+
+ return false;
+ }
+
/**
@brief
Executes the shot, be creating the projectile and sending it on its way.
*/
void EnergyDrink::shot()
{
+ this->timerStarted_ = false;
+
// Create the projectile
Projectile* projectile = new Projectile(this->getContext());
Model* model = new Model(projectile->getContext());
Modified: code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.h
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.h 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/EnergyDrink.h 2016-02-04 22:54:04 UTC (rev 11108)
@@ -56,6 +56,7 @@
EnergyDrink(Context* context);
virtual ~EnergyDrink() {}
+ virtual bool fire(float* reloadTime) override;
virtual void fire() override;
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
@@ -88,6 +89,7 @@
float speed_; //!< The speed of the EnergyDrink.
float delay_; //!< The firing delay.
Timer delayTimer_; //!< The timer to delay the firing.
+ bool timerStarted_;
};
}
Added: code/trunk/src/modules/weapons/weaponmodes/FlameGun.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/FlameGun.cc (rev 0)
+++ code/trunk/src/modules/weapons/weaponmodes/FlameGun.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -0,0 +1,136 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file FlameGun.cc
+ @brief Implementation of the FlameGun class.
+*/
+
+#include "FlameGun.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/pawns/Pawn.h"
+
+#include "weapons/projectiles/FlameGunProjectile.h"
+
+namespace orxonox
+{
+ RegisterClass(FlameGun);
+
+ const int FlameGun::PROJECTILES_PER_FIRE = 3;
+
+ FlameGun::FlameGun(Context* context) : WeaponMode(context)
+ {
+ RegisterObject(FlameGun);
+
+ this->reloadTime_ = 0.1f;
+ this->damage_ = 0.0f;
+ this->speed_ = 550.0f;
+ this->lifetime_ = 1.0;
+ this->sideAcceleration_ = 2000.0;
+
+ this->setMunitionName("FlameMunition");
+ this->setFireSound("sounds/Weapon_FlameGun.ogg");
+
+ hudImageString_ = "Orxonox/WSHUD_WM_FlameGun";
+ }
+
+ FlameGun::~FlameGun()
+ {
+ }
+
+ /**
+ @brief
+ XMLPort for the FlameGun. You can define how often the projectiles Flame, how many childs should be created per Flame, the spread and the time between two Flames.
+ */
+ void FlameGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(FlameGun, XMLPort, xmlelement, mode);
+
+ XMLPortParam(FlameGun, "Lifetime", setLifetime, getLifetime, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Fires the weapon. Creates a projectile and fires it.
+ */
+ void FlameGun::fire()
+ {
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+
+ Vector3 muzzleDirection = this->getMuzzleDirection();
+ Vector3 directionOffset = muzzleDirection.perpendicular();
+ directionOffset.normalise();
+ Degree angle = Degree(rnd(0,360));
+ directionOffset = Quaternion(angle, muzzleDirection.normalisedCopy()) * directionOffset;
+ directionOffset.normalise();
+
+ FlameGunProjectile* projectile = new FlameGunProjectile(this->getContext());
+
+ projectile->setOrientation(this->getMuzzleOrientation());
+ projectile->setPosition(this->getMuzzlePosition());
+ projectile->setVelocity(muzzleDirection * this->speed_);
+
+ projectile->setLifetime(getLifetime());
+
+ projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+
+ angle = Degree(360.0/PROJECTILES_PER_FIRE);
+
+ for (int i = 0; i < PROJECTILES_PER_FIRE; ++i)
+ {
+ FlameGunProjectile* projectile = new FlameGunProjectile(this->getContext());
+
+ projectile->setOrientation(this->getMuzzleOrientation());
+ projectile->setPosition(this->getMuzzlePosition());
+ projectile->setVelocity(muzzleDirection * this->speed_);
+ projectile->setAcceleration(directionOffset*sideAcceleration_);
+
+ projectile->setLifetime(getLifetime());
+
+ projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+
+ directionOffset = Quaternion(angle, muzzleDirection.normalisedCopy()) * directionOffset;
+ directionOffset.normalise();
+ }
+
+
+
+
+ }
+}
Added: code/trunk/src/modules/weapons/weaponmodes/FlameGun.h
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/FlameGun.h (rev 0)
+++ code/trunk/src/modules/weapons/weaponmodes/FlameGun.h 2016-02-04 22:54:04 UTC (rev 11108)
@@ -0,0 +1,73 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabien Vultier
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file FlameGun.h
+ @brief Definition of the FlameGun class.
+*/
+
+#ifndef _FlameGun_H__
+#define _FlameGun_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/WeaponMode.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ A WeaponMode that fires burning projectiles.
+ @author
+ Fabien Vultier
+ @ingroup WeaponsWeaponModes
+ */
+ class _WeaponsExport FlameGun : public WeaponMode
+ {
+ public:
+ FlameGun(Context* context);
+ virtual ~FlameGun();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual void fire() override;
+
+ inline void setLifetime(float lifetime)
+ { this->lifetime_ = lifetime; }
+ inline float getLifetime() const
+ { return this->lifetime_; }
+
+ private:
+ float speed_; //The speed of the fired projectile.
+ float lifetime_; //The lifetime of the fired projectile.
+ float sideAcceleration_;
+
+ static const int PROJECTILES_PER_FIRE;
+ };
+}
+
+#endif /* _FlameGun_H__ */
Modified: code/trunk/src/modules/weapons/weaponmodes/FusionFire.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/FusionFire.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/FusionFire.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -57,6 +57,7 @@
this->speed_ = 750.0f;
this->setMunitionName("FusionMunition");
+ this->setFireSound("sounds/Weapon_FusionFire.ogg");
hudImageString_ = "Orxonox/WSHUD_WM_FusionFire";
}
Modified: code/trunk/src/modules/weapons/weaponmodes/GravityBombFire.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/GravityBombFire.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/GravityBombFire.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -29,7 +29,7 @@
this->damage_ = 20.0f; ///< The damage of the Bomb if it hits a pawn.
this->setMunitionName("GravityBombMunition");
- this->setDefaultSoundWithVolume("sounds/Rocket_launch.ogg",0.8); ///< sets sound of the bomb as it is fired.
+ this->setFireSound("sounds/Rocket_launch.ogg",0.8); ///< sets sound of the bomb as it is fired.
hudImageString_ = "Orxonox/WSHUD_WM_GravityBombFire";
}
Modified: code/trunk/src/modules/weapons/weaponmodes/HsW01.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/HsW01.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/HsW01.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -61,13 +61,13 @@
this->delay_ = 0.0f;
this->setMunitionName("LaserMunition");
this->mesh_ = "laserbeam.mesh";
- this->sound_ = "sounds/Weapon_HsW01.ogg";
this->delayTimer_.setTimer(this->delay_, false, createExecutor(createFunctor(&HsW01::shot, this)));
this->delayTimer_.stopTimer();
- this->setDefaultSound(this->sound_);
+ this->setFireSound("sounds/Weapon_HsW01.ogg");
+ this->setReloadSound("sounds/Reload_HsW01.ogg", 0.5);
hudImageString_ = "Orxonox/WSHUD_WM_HsW01";
}
Modified: code/trunk/src/modules/weapons/weaponmodes/IceGun.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/IceGun.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/IceGun.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -59,7 +59,8 @@
this->setFreezeFactor(0.5);
this->setMunitionName("IceMunition");
- this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
+ this->setFireSound("sounds/Weapon_LightningGun.ogg");
+ this->setReloadSound("sounds/Reload_IceGun.ogg", 0.4);
hudImageString_ = "Orxonox/WSHUD_WM_IceGun";
}
Modified: code/trunk/src/modules/weapons/weaponmodes/LaserFire.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/LaserFire.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/LaserFire.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -40,7 +40,7 @@
#include "weaponsystem/WeaponSystem.h"
#include "worldentities/pawns/Pawn.h"
-#include "weapons/projectiles/ParticleProjectile.h"
+#include "weapons/projectiles/BillboardProjectile.h"
namespace orxonox
{
@@ -55,6 +55,8 @@
this->speed_ = 750.0f;
this->setMunitionName("LaserMunition");
+ this->setFireSound("sounds/Weapon_LaserFire.ogg");
+ this->setReloadSound("sounds/Reload_LaserFire.ogg", 0.8);
hudImageString_ = "Orxonox/WSHUD_WM_LaserFire";
}
@@ -65,7 +67,7 @@
*/
void LaserFire::fire()
{
- ParticleProjectile* projectile = new ParticleProjectile(this->getContext());
+ BillboardProjectile* projectile = new BillboardProjectile(this->getContext());
this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
projectile->setOrientation(this->getMuzzleOrientation());
Modified: code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/LightningGun.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -54,7 +54,7 @@
this->speed_ = 750.0f;
this->setMunitionName("LightningMunition");
- this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
+ this->setFireSound("sounds/Weapon_LightningGun.ogg");
hudImageString_ = "Orxonox/WSHUD_WM_LightningGun";
}
Modified: code/trunk/src/modules/weapons/weaponmodes/MineGun.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/MineGun.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/MineGun.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -56,7 +56,7 @@
this->maxTimeUntilExplosion_ = 0.0f;
this->setMunitionName("MineMunition");
- this->setDefaultSound("sounds/mineactivate.ogg");
+ this->setFireSound("sounds/mineactivate.ogg");
hudImageString_ = "Orxonox/WSHUD_WM_MineGun";
}
Modified: code/trunk/src/modules/weapons/weaponmodes/SimpleRocketFire.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/SimpleRocketFire.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/SimpleRocketFire.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -61,7 +61,7 @@
this->speed_ = 500.0f;
this->setMunitionName("RocketMunition");
- this->setDefaultSoundWithVolume("sounds/Rocket_launch.ogg",0.4f);
+ this->setFireSound("sounds/Rocket_launch.ogg",0.4f);
// The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
hudImageString_ = "Orxonox/WSHUD_WM_SimpleRocketFire";
Modified: code/trunk/src/modules/weapons/weaponmodes/SplitGun.cc
===================================================================
--- code/trunk/src/modules/weapons/weaponmodes/SplitGun.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/modules/weapons/weaponmodes/SplitGun.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -60,7 +60,8 @@
this->damageReduction_ = 1.0f;
this->setMunitionName("SplitMunition");
- this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
+ this->setFireSound("sounds/Weapon_SplitGun.ogg", 0.5);
+ this->setReloadSound("sounds/Reload_SplitGun.ogg", 0.8);
hudImageString_ = "Orxonox/WSHUD_WM_SplitGun";
}
Modified: code/trunk/src/orxonox/weaponsystem/WeaponMode.cc
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponMode.cc 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/orxonox/weaponsystem/WeaponMode.cc 2016-02-04 22:54:04 UTC (rev 11108)
@@ -76,23 +76,23 @@
hudImageString_ = "Orxonox/WSHUD_WM_Unknown";
- if( GameMode::isMaster() )
- {
- this->defSndWpnFire_ = new WorldSound(this->getContext());
- this->defSndWpnFire_->setLooping(false);
- this->defSndWpnFire_->setVolume(0.8f);
- this->bSoundAttached_ = false;
- }
- else
- this->defSndWpnFire_ = 0;
+ this->fireSoundPath_ = BLANKSTRING;
+ this->fireSoundVolume_ = 1.0;
+ this->fireSounds_.clear();
+
+ this->reloadSoundPath_ = BLANKSTRING;
+ this->reloadSoundVolume_ = 1.0;
+ this->reloadSound_ = nullptr;
}
WeaponMode::~WeaponMode()
{
if (this->isInitialized())
{
- if (this->defSndWpnFire_)
- this->defSndWpnFire_->destroy();
+ for (auto sound : fireSounds_)
+ {
+ sound->destroy();
+ }
}
}
@@ -120,12 +120,6 @@
bool WeaponMode::fire(float* reloadTime)
{
(*reloadTime) = this->reloadTime_;
- if( !this->bSoundAttached_ && GameMode::isMaster() )
- {
- assert(this->getWeapon());
- this->getWeapon()->attach(this->defSndWpnFire_);
- this->bSoundAttached_ = true;
- }
// Fireing is only possible if this weapon mode is not reloading and there is enough munition
if (!this->bReloading_ && this->munition_ && this->munition_->takeMunition(this->munitionPerShot_, this))
@@ -146,20 +140,24 @@
{
// The time needed to reload is the sum of the reload time of the weapon mode and the magazine.
tempReloadtime = this->reloadTime_ + this->munition_->getReloadTime();
- }
+ }
+ playReloadSound();
}
}
+ // For stacked munition, a reload sound is played after every fired projectile
+ if (this->munition_->getMunitionDeployment() == MunitionDeployment::Stack)
+ {
+ playReloadSound();
+ }
+
// Mark this weapon mode as reloading and start the reload timer
this->bReloading_ = true;
this->reloadTimer_.setInterval(tempReloadtime);
this->reloadTimer_.startTimer();
- if( this->defSndWpnFire_ && !(this->defSndWpnFire_->isPlaying()))
- {
- this->defSndWpnFire_->play();
- }
-
+ // Play the fire sound and fire the weapon mode
+ this->playFireSound();
this->fire();
return true;
@@ -249,10 +247,6 @@
void WeaponMode::reloaded()
{
- if( this->defSndWpnFire_ && this->defSndWpnFire_->isPlaying())
- {
- this->defSndWpnFire_->stop();
- }
this->bReloading_ = false;
}
@@ -281,27 +275,92 @@
return WorldEntity::FRONT;
}
- void WeaponMode::setDefaultSound(const std::string& soundPath)
+ void WeaponMode::setFireSound(const std::string& soundPath, const float soundVolume)
{
- if( this->defSndWpnFire_ )
- this->defSndWpnFire_->setSource(soundPath);
+ fireSoundPath_ = soundPath;
+ fireSoundVolume_ = soundVolume;
}
- const std::string& WeaponMode::getDefaultSound()
+ const std::string& WeaponMode::getFireSound()
{
- if( this->defSndWpnFire_ )
- return this->defSndWpnFire_->getSource();
- else
- return BLANKSTRING;
+ return fireSoundPath_;
}
- void WeaponMode::setDefaultSoundWithVolume(const std::string& soundPath, const float soundVolume)
+ void WeaponMode::setReloadSound(const std::string& soundPath, const float soundVolume)
{
- if (this->defSndWpnFire_)
+ reloadSoundPath_ = soundPath;
+ reloadSoundVolume_ = soundVolume;
+ }
+
+ const std::string& WeaponMode::getReloadSound()
+ {
+ return reloadSoundPath_;
+ }
+
+ void WeaponMode::playFireSound()
+ {
+ WorldSound* unusedSound = nullptr;
+
+ if (!GameMode::isMaster())
{
- this->defSndWpnFire_->setSource(soundPath);
- this->defSndWpnFire_->setVolume(soundVolume);
+ return;
}
+
+ // If no sound path or no weapon was specified, then no sound is played.
+ if (fireSoundPath_ == BLANKSTRING || !this->getWeapon())
+ {
+ return;
+ }
+
+ // Search in the sound list for a WorldSound that may be used. It must be an idle WorldSound instance (i.e. it is not playing a sound now)
+ for (auto sound : fireSounds_)
+ {
+ if( sound && !(sound->isPlaying()))
+ {
+ // Unused sound found
+ unusedSound = sound;
+ break;
+ }
+ }
+
+ // If no unused sound was found, create a new one and add it to the list
+ if (!unusedSound)
+ {
+ unusedSound = new WorldSound(this->getContext());
+ fireSounds_.push_back(unusedSound);
+ unusedSound->setLooping(false);
+ unusedSound->setSource(fireSoundPath_);
+ unusedSound->setVolume(fireSoundVolume_);
+ this->getWeapon()->attach(unusedSound);
+ }
+
+ // Play the fire sound
+ unusedSound->play();
}
+ void WeaponMode::playReloadSound()
+ {
+ if (!GameMode::isMaster())
+ {
+ return;
+ }
+
+ // If no sound path or no weapon was specified, then no sound is played.
+ if (reloadSoundPath_ == BLANKSTRING || !this->getWeapon())
+ {
+ return;
+ }
+
+ // Create a reload WorldSound if not done yet
+ if (!reloadSound_)
+ {
+ reloadSound_ = new WorldSound(this->getContext());
+ reloadSound_->setSource(reloadSoundPath_);
+ reloadSound_->setVolume(reloadSoundVolume_);
+ this->getWeapon()->attach(reloadSound_);
+ }
+
+ // Play the reload sound
+ reloadSound_->play();
+ }
}
Modified: code/trunk/src/orxonox/weaponsystem/WeaponMode.h
===================================================================
--- code/trunk/src/orxonox/weaponsystem/WeaponMode.h 2016-02-04 22:50:17 UTC (rev 11107)
+++ code/trunk/src/orxonox/weaponsystem/WeaponMode.h 2016-02-04 22:54:04 UTC (rev 11108)
@@ -33,6 +33,7 @@
#include "OrxonoxPrereqs.h"
#include <string>
+#include <vector>
#include "util/Math.h"
#include "core/BaseObject.h"
#include "core/class/SubclassIdentifier.h"
@@ -53,14 +54,9 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
- bool fire(float* reloadTime);
+ virtual bool fire(float* reloadTime);
bool reload();
- // Interacting with the default Firing sound
- void setDefaultSound(const std::string& soundPath);
- const std::string& getDefaultSound();
- void setDefaultSoundWithVolume(const std::string& soundPath, const float soundVolume);
-
// Munition
inline Munition* getMunition() const
{ return this->munition_; }
@@ -154,6 +150,16 @@
void updateMunition();
protected:
+ // Interacting with the firing sound
+ void setFireSound(const std::string& soundPath, const float soundVolume = 1.0);
+ const std::string& getFireSound();
+ void playFireSound();
+
+ // Interacting with the reloading sound
+ void setReloadSound(const std::string& soundPath, const float soundVolume = 1.0);
+ const std::string& getReloadSound();
+ void playReloadSound();
+
virtual void fire() = 0;
unsigned int initialMunition_;
@@ -187,8 +193,12 @@
Vector3 muzzlePosition_;
Quaternion muzzleOrientation_;
- WorldSound* defSndWpnFire_;
- bool bSoundAttached_;
+ std::string fireSoundPath_; // The path of the sound played when fireing
+ float fireSoundVolume_; // The volume of the sound played when fireing
+ std::vector<WorldSound*> fireSounds_; // List of sounds used by the weapon mode. Because multiple sounds may overlap, we need mor than one WorldSound instance.
+ std::string reloadSoundPath_; // The path of the sound played when reloading
+ float reloadSoundVolume_; // The volume of the sound played when reloading
+ WorldSound* reloadSound_;
};
}
More information about the Orxonox-commit
mailing list