[Orxonox-commit 5933] r10592 - in code/branches/towerdefenseFabien: data/levels src/modules/towerdefense src/modules/weapons src/modules/weapons/projectiles src/modules/weapons/weaponmodes
fvultier at orxonox.net
fvultier at orxonox.net
Thu Sep 24 13:23:49 CEST 2015
Author: fvultier
Date: 2015-09-24 13:23:47 +0200 (Thu, 24 Sep 2015)
New Revision: 10592
Added:
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h
code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc
code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h
Modified:
code/branches/towerdefenseFabien/data/levels/jump.oxw
code/branches/towerdefenseFabien/data/levels/towerDefense.oxw
code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.cc
code/branches/towerdefenseFabien/src/modules/weapons/WeaponsPrereqs.h
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/BillboardProjectile.cc
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/BillboardProjectile.h
code/branches/towerdefenseFabien/src/modules/weapons/projectiles/CMakeLists.txt
code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/CMakeLists.txt
Log:
New Weapon for the towerDefense minigame: The SplitGun, a weapon that shoots one projectile that splits up into multiple projectiles after a specified time, these new projectiles may split up again... The weapon may be used by any Oxonox Spaceship.
Modified: code/branches/towerdefenseFabien/data/levels/jump.oxw
===================================================================
--- code/branches/towerdefenseFabien/data/levels/jump.oxw 2015-09-17 13:32:50 UTC (rev 10591)
+++ code/branches/towerdefenseFabien/data/levels/jump.oxw 2015-09-24 11:23:47 UTC (rev 10592)
@@ -255,39 +255,6 @@
</JumpCenterpoint>
</attached>
</MovableEntity>
-
- <EventDispatcher>
- <targets>
- <EventTarget target=scoreeffect_right />
- <EventTarget target=scoreeffect_center />
- </targets>
- <events>
- <spawn>
- <EventFilter>
- <names>
- <EventName name=right />
- </names>
- <EventListener event=jumpcenter />
- </EventFilter>
- </spawn>
- </events>
- </EventDispatcher>
- <EventDispatcher>
- <targets>
- <EventTarget target=scoreeffect_left />
- <EventTarget target=scoreeffect_center />
- </targets>
- <events>
- <spawn>
- <EventFilter>
- <names>
- <EventName name=left />
- </names>
- <EventListener event=jumpcenter />
- </EventFilter>
- </spawn>
- </events>
- </EventDispatcher>
-
+
</Scene>
</Level>
Modified: code/branches/towerdefenseFabien/data/levels/towerDefense.oxw
===================================================================
--- code/branches/towerdefenseFabien/data/levels/towerDefense.oxw 2015-09-17 13:32:50 UTC (rev 10591)
+++ code/branches/towerdefenseFabien/data/levels/towerDefense.oxw 2015-09-24 11:23:47 UTC (rev 10592)
@@ -65,7 +65,7 @@
<DefaultWeaponmodeLink firemode=0 weaponmode=0 />
</links>
<Weapon>
- <HsW01 mode=0 munitionpershot=0 muzzleoffset="0,0,-30" damage=2 shielddamage=1 material="Flares/point_lensflare" delay=0/>
+ <HsW01 mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=2 shielddamage=1 material="Flares/point_lensflare" delay=0/>
</Weapon>
</WeaponPack>
</weapons>
@@ -102,12 +102,12 @@
<DefaultWeaponmodeLink firemode=0 weaponmode=0 />
</links>
<Weapon>
- <LightningGun mode=0 munitionpershot=0 muzzleoffset="0,0,-30" damage=2 shielddamage=4 />
+ <LightningGun mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=2 shielddamage=4 />
</Weapon>
</WeaponPack>
</weapons>
<attached>
- <Backlight position="0,-100,0" scale=2.0 colour="0.4, 0.0, 1.0" width=10 length=500 lifetime=0.3 elements=20 trailmaterial="Trail/backlighttrail" material="Examples/Flare" loop=1 />
+ <Backlight position="0,0,0" scale=2.0 colour="0.4, 0.0, 1.0" width=10 length=10 lifetime=0.3 elements=20 trailmaterial="Trail/backlighttrail" material="Examples/Flare" loop=1 />
</attached>
</TowerDefenseTower>
</Template>
@@ -142,7 +142,7 @@
<DefaultWeaponmodeLink firemode=0 weaponmode=0 />
</links>
<Weapon>
- <EnergyDrink mode=0 munitionpershot=0 muzzleoffset="0,0,-30" damage=2 shielddamage=4 />
+ <SplitGun mode=0 munitionpershot=0 damage=9.3 muzzleoffset=" 1.6, 1.3, -2.0" splittime=0.2 numberofsplits=2 numberofchilds=5 spread=0.1 />
</Weapon>
</WeaponPack>
</weapons>
@@ -179,12 +179,12 @@
<DefaultWeaponmodeLink firemode=0 weaponmode=0 />
</links>
<Weapon>
- <FusionFire mode=0 munitionpershot=0 muzzleoffset="0,0,-30" damage=2 shielddamage=4 />
+ <RocketFire mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=2 shielddamage=4 />
</Weapon>
</WeaponPack>
</weapons>
<attached>
- <ParticleSpawner position="0,-100,0" source="Orxonox/sparks" lifetime=3.0 autostart=1 loop=1 />
+ <ParticleSpawner position="0,0,0" source="Orxonox/sparks" lifetime=3.0 autostart=1 loop=1 />
</attached>
</TowerDefenseTower>
</Template>
@@ -219,7 +219,7 @@
<DefaultWeaponmodeLink firemode=0 weaponmode=0 />
</links>
<Weapon>
- <LaserFire mode=0 munitionpershot=0 muzzleoffset="0,0,-30" damage=2 shielddamage=4 />
+ <SimpleRocketFire mode=0 muzzleoffset="0,0,0" damage=30 shielddamage=20 />
</Weapon>
</WeaponPack>
</weapons>
@@ -453,17 +453,17 @@
<SpawnPoint team=0 position="0,0,0"/>
- <Model position="0,0,-1000" pitch=90 lodLevel=1 mesh="TD_S1.mesh" scale=25/>
- <Model position="0,0,-1000" pitch=90 lodLevel=1 mesh="TD_S2.mesh" scale=25/>
- <Model position="0,0,-1000" pitch=90 lodLevel=1 mesh="TD_S3.mesh" scale=25/>
- <Model position="0,0,-1000" pitch=90 lodLevel=1 mesh="TD_S4.mesh" scale=25/>
- <Model position="0,0,-1000" pitch=90 lodLevel=1 mesh="TD_S5.mesh" scale=25/>
- <Model position="0,0,-1000" pitch=90 lodLevel=1 mesh="TD_T1.mesh" scale=25/>
- <Model position="0,0,-1000" pitch=90 lodLevel=1 mesh="TD_T2.mesh" scale=25/>
- <Model position="0,0,-1000" pitch=90 lodLevel=1 mesh="TD_T3.mesh" scale=25/>
- <Model position="0,0,-1000" pitch=90 lodLevel=1 mesh="TD_T4.mesh" scale=25/>
- <Model position="0,0,-1000" pitch=90 lodLevel=1 mesh="TD_T5.mesh" scale=25/>
- <Model position="0,0,-1000" pitch=90 lodLevel=1 mesh="TD_F1.mesh" scale=25/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_S1.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_S2.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_S3.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_S4.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_S5.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_T1.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_T2.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_T3.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_T4.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_T5.mesh" scale=1/>
+ <Model position="0,0,10000" lodLevel=1 mesh="TD_F1.mesh" scale=1/>
<!-- PlayField -->
<TowerDefenseCenterpoint
Modified: code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.cc 2015-09-17 13:32:50 UTC (rev 10591)
+++ code/branches/towerdefenseFabien/src/modules/towerdefense/TowerDefense.cc 2015-09-24 11:23:47 UTC (rev 10592)
@@ -80,10 +80,7 @@
#include "infos/PlayerInfo.h"
#include "chat/ChatManager.h"
#include "core/CoreIncludes.h"
-/* Part of a temporary hack to allow the player to add towers */
-#include "core/command/ConsoleCommand.h"
-
namespace orxonox
{
RegisterUnloadableClass(TowerDefense);
@@ -102,8 +99,6 @@
this->lifes_ = 0;
this->waveSize_ = 0;
offset_ = Vector3(0,0,10);
-
- //this->stats_ = new TowerDefensePlayerStats();
}
TowerDefense::~TowerDefense()
@@ -178,10 +173,6 @@
en1->setTeam(2);
- //orxonox::WeakPtr<WaypointController> controller = new WaypointController(this->center_->getContext());
- //controller->setControllableEntity(en1);
- //en1->setController(controller);
-
WaypointController* controller = (WaypointController*)(en1->getXMLController());
if (controller != NULL && waypoints_.size() > 1)
@@ -339,7 +330,7 @@
++ waveNumber_;
timeSinceLastSpawn_ = 0.0;
- timeUntilNextWave_ = waveNumber_+10;
+ timeUntilNextWave_ = waveNumber_+20;
waveSize_ = waveNumber_+5;
}
Modified: code/branches/towerdefenseFabien/src/modules/weapons/WeaponsPrereqs.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/WeaponsPrereqs.h 2015-09-17 13:32:50 UTC (rev 10591)
+++ code/branches/towerdefenseFabien/src/modules/weapons/WeaponsPrereqs.h 2015-09-24 11:23:47 UTC (rev 10592)
@@ -78,6 +78,7 @@
// projectiles
class BillboardProjectile;
class LightningGunProjectile;
+ class SplitGunProjectile;
class ParticleProjectile;
class Projectile;
class Rocket;
@@ -89,6 +90,7 @@
class HsW01;
class LaserFire;
class LightningGun;
+ class SplitGun;
class RocketFire;
class SimpleRocketFire;
}
Modified: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/BillboardProjectile.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/BillboardProjectile.cc 2015-09-17 13:32:50 UTC (rev 10591)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/BillboardProjectile.cc 2015-09-24 11:23:47 UTC (rev 10592)
@@ -87,6 +87,17 @@
/**
@brief
+ Get the material of the BillboardProjectile.
+ @return
+ The material name.
+ */
+ const std::string& BillboardProjectile::getMaterial()
+ {
+ return this->billboard_.getMaterial();
+ }
+
+ /**
+ @brief
Is called when the visibility of the BillboardProjectile has changed.
*/
void BillboardProjectile::changedVisibility()
Modified: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/BillboardProjectile.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/BillboardProjectile.h 2015-09-17 13:32:50 UTC (rev 10591)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/BillboardProjectile.h 2015-09-24 11:23:47 UTC (rev 10592)
@@ -59,6 +59,7 @@
virtual void setColour(const ColourValue& colour);
virtual void setMaterial(const std::string& material);
+ virtual const std::string& getMaterial();
virtual void changedVisibility();
private:
Modified: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/CMakeLists.txt
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/CMakeLists.txt 2015-09-17 13:32:50 UTC (rev 10591)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/CMakeLists.txt 2015-09-24 11:23:47 UTC (rev 10592)
@@ -4,6 +4,8 @@
ParticleProjectile.cc
Projectile.cc
LightningGunProjectile.cc
+ SplitGunProjectile.cc
Rocket.cc
SimpleRocket.cc
+ SplitGunProjectile.cc
)
Added: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.cc 2015-09-24 11:23:47 UTC (rev 10592)
@@ -0,0 +1,139 @@
+/*
+ * 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:
+ * Joel Smely
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file SplitGunProjectile.h
+ @brief Implementation of the SplitGunProjectile class.
+*/
+
+#include "SplitGunProjectile.h"
+
+#include "core/CoreIncludes.h"
+#include "core/command/Executor.h"
+#include "util/Convert.h"
+#include "util/Math.h"
+
+namespace orxonox
+{
+ RegisterClass(SplitGunProjectile);
+
+ SplitGunProjectile::SplitGunProjectile(Context* context) : BillboardProjectile(context)
+ {
+ RegisterObject(SplitGunProjectile);
+
+ this->numberOfSplits_ = 0;
+ this->numberOfChilds_ = 0;
+ this->splitTime_ = 1.0;
+ this->spread_ = 0.2;
+ }
+
+ void SplitGunProjectile::setNumberOfSplits(int numberOfSplits)
+ {
+ if (numberOfSplits >= 0)
+ {
+ this->numberOfSplits_ = numberOfSplits;
+ }
+ else
+ {
+ this->numberOfSplits_ = 0;
+ }
+ }
+
+ void SplitGunProjectile::setNumberOfChilds(int numberOfChilds)
+ {
+ if (numberOfChilds >= 0)
+ {
+ this->numberOfChilds_ = numberOfChilds;
+ }
+ else
+ {
+ this->numberOfChilds_ = 0;
+ }
+ }
+
+ void SplitGunProjectile::setSplitTime(float splitTime)
+ {
+ if (splitTime >= 0)
+ {
+ this->splitTime_ = splitTime;
+ this->textureTimer_.setTimer(this->splitTime_, false, createExecutor(createFunctor(&SplitGunProjectile::split, this)));
+ }
+ else
+ {
+ this->splitTime_ = 0;
+ }
+ }
+
+ void SplitGunProjectile::setSpread(float spread)
+ {
+ spread_ = spread;
+ }
+
+ void SplitGunProjectile::split()
+ {
+ if (numberOfSplits_ > 0)
+ {
+ -- numberOfSplits_;
+
+ // Calculate a normalized vector (velocityOffset) that is perpendicluar to the velocity of this projectile. Since there are infinitly many perpendicular vectors a random one is chosen.
+ Vector3 velocityInitial = this->getVelocity();
+ Vector3 velocityOffset = velocityInitial.perpendicular();
+ velocityOffset.normalise();
+ Degree angle = Degree(rnd(0,360));
+ velocityOffset = Quaternion(angle, velocityInitial.normalisedCopy()) * velocityOffset;
+ velocityOffset.normalise();
+
+ // Create as many childs as defined by numberOfChilds_
+ for (int i = 0; i < numberOfChilds_; ++i)
+ {
+ // Every child projectile should fly uniform in different directions -> Rotate the velocityOffset in every iteration
+ velocityOffset = Quaternion(Degree(360/numberOfChilds_), velocityInitial.normalisedCopy()) * velocityOffset;
+ velocityOffset.normalise();
+
+ SplitGunProjectile* projectile = new SplitGunProjectile(this->getContext());
+
+ projectile->setMaterial(this->getMaterial());
+ projectile->setOrientation(this->getOrientation());
+ projectile->setPosition(this->getPosition());
+ projectile->setVelocity(velocityInitial + spread_*velocityOffset*velocityInitial.length());
+
+ projectile->setNumberOfSplits(this->numberOfSplits_);
+ projectile->setNumberOfChilds(this->numberOfChilds_);
+ projectile->setSplitTime(this->splitTime_);
+ projectile->setSpread(this->spread_);
+
+ projectile->setShooter(this->getShooter());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+ }
+
+ numberOfSplits_ = 0;
+ }
+ }
+}
Added: code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/projectiles/SplitGunProjectile.h 2015-09-24 11:23:47 UTC (rev 10592)
@@ -0,0 +1,76 @@
+/*
+ * 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:
+ * Joel Smely
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file SplitGunProjectile.h
+ @brief Definition of the SplitGunProjectile class.
+*/
+
+#ifndef _SplitGunProjectile_H__
+#define _SplitGunProjectile_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include <string>
+#include "tools/Timer.h"
+#include "BillboardProjectile.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The SplitGunProjectile is a projectile that is represented by a looped series of billboards.
+
+ @author
+ Joel Smely
+ @ingroup WeaponsProjectiles
+ */
+ class _WeaponsExport SplitGunProjectile : public BillboardProjectile
+ {
+ public:
+ SplitGunProjectile(Context* context);
+ virtual ~SplitGunProjectile() {}
+
+ virtual void setNumberOfSplits(int numberOfSplits);
+ virtual void setNumberOfChilds(int numberOfChilds);
+ virtual void setSplitTime(float splitTime);
+ virtual void setSpread(float spread);
+
+ private:
+ int numberOfSplits_;
+ int numberOfChilds_;
+ float splitTime_;
+ float spread_;
+ Timer textureTimer_;
+
+ virtual void split();
+ };
+}
+
+#endif /* _SplitGunProjectile_H__ */
Modified: code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/CMakeLists.txt
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/CMakeLists.txt 2015-09-17 13:32:50 UTC (rev 10591)
+++ code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/CMakeLists.txt 2015-09-24 11:23:47 UTC (rev 10592)
@@ -4,6 +4,7 @@
LaserFire.cc
HsW01.cc
LightningGun.cc
+ SplitGun.cc
RocketFire.cc
SimpleRocketFire.cc
)
Added: code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.cc 2015-09-24 11:23:47 UTC (rev 10592)
@@ -0,0 +1,107 @@
+/*
+ * 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:
+ * Joel Smely
+ * Co-authors:
+ * simonmie
+ *
+ */
+
+/**
+ @file SplitGun.h
+ @brief Implementation of the SplitGun class.
+*/
+
+#include "SplitGun.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/SplitGunProjectile.h"
+
+namespace orxonox
+{
+ RegisterClass(SplitGun);
+
+ SplitGun::SplitGun(Context* context) : WeaponMode(context)
+ {
+ RegisterObject(SplitGun);
+
+ this->reloadTime_ = 1.0f;
+ this->damage_ = 0.0f;
+ this->speed_ = 750.0f;
+ this->numberOfSplits_ = 2;
+ this->numberOfChilds_ = 3;
+ this->splitTime_ = 0.3;
+ this->spread_ = 0.1;
+
+ this->setMunitionName("LaserMunition");
+ this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
+ }
+
+ SplitGun::~SplitGun()
+ {
+ }
+
+ /**
+ @brief
+ XMLPort for the SplitGun. You can define how often the projectiles split, how many childs should be created per split and the time between two splits.
+ */
+ void SplitGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(SplitGun, XMLPort, xmlelement, mode);
+
+ XMLPortParam(SplitGun, "numberofsplits", setNumberOfSplits, getNumberOfSplits, xmlelement, mode);
+ XMLPortParam(SplitGun, "numberofchilds", setNumberOfChilds, getNumberOfChilds, xmlelement, mode);
+ XMLPortParam(SplitGun, "splittime", setSplitTime, getSplitTime, xmlelement, mode);
+ XMLPortParam(SplitGun, "spread", setSpread, getSpread, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Fires the weapon. Creates a projectile and fires it.
+ */
+ void SplitGun::fire()
+ {
+ SplitGunProjectile* projectile = new SplitGunProjectile(this->getContext());
+ projectile->setMaterial("Flares/energyflare");
+
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+ projectile->setOrientation(this->getMuzzleOrientation());
+ projectile->setPosition(this->getMuzzlePosition());
+ projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+
+ projectile->setNumberOfSplits(getNumberOfSplits());
+ projectile->setNumberOfChilds(getNumberOfChilds());
+ projectile->setSplitTime(getSplitTime());
+ projectile->setSpread(getSpread());
+
+ projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+ }
+}
Added: code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h
===================================================================
--- code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h (rev 0)
+++ code/branches/towerdefenseFabien/src/modules/weapons/weaponmodes/SplitGun.h 2015-09-24 11:23:47 UTC (rev 10592)
@@ -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:
+ * Joel Smely
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file SplitGun.h
+ @brief Definition of the SplitGun class.
+*/
+
+#ifndef _SplitGun_H__
+#define _SplitGun_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/WeaponMode.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ A slow ball of lightning.
+ @author
+ Joel Smely
+ @ingroup WeaponsWeaponModes
+ */
+ class _WeaponsExport SplitGun : public WeaponMode
+ {
+ public:
+ SplitGun(Context* context);
+ virtual ~SplitGun();
+
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void fire();
+
+ inline void setNumberOfSplits(int numberOfSplits)
+ { this->numberOfSplits_ = numberOfSplits; }
+ inline int getNumberOfSplits() const
+ { return this->numberOfSplits_; }
+ inline void setNumberOfChilds(int numberOfChilds)
+ { this->numberOfChilds_ = numberOfChilds; }
+ inline int getNumberOfChilds() const
+ { return this->numberOfChilds_; }
+ inline void setSplitTime(float splitTime)
+ { this->splitTime_ = splitTime; }
+ inline float getSplitTime() const
+ { return this->splitTime_; }
+ inline void setSpread(float spread)
+ { this->spread_ = spread; }
+ inline float getSpread() const
+ { return this->spread_; }
+
+ private:
+ float speed_; //!< The speed of the fired projectile.
+ int numberOfSplits_;
+ int numberOfChilds_;
+ float splitTime_;
+ float spread_;
+ };
+}
+
+#endif /* _SplitGun_H__ */
More information about the Orxonox-commit
mailing list