[Orxonox-commit 7688] r12281 - in code/branches/OrxoBlox_FS19: data/levels src/modules/OrxoBlox/BallGun src/modules/weapons/munitions src/modules/weapons/projectiles src/modules/weapons/weaponmodes
pomselj at orxonox.net
pomselj at orxonox.net
Thu Apr 4 16:37:19 CEST 2019
Author: pomselj
Date: 2019-04-04 16:37:19 +0200 (Thu, 04 Apr 2019)
New Revision: 12281
Added:
code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/BallMunition.cc
code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/BallMunition.h
code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.cc
code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.h
code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/BallGun.cc
code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/BallGun.h
Modified:
code/branches/OrxoBlox_FS19/data/levels/towerDefense.oxw
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.h
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.h
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.cc
code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.h
code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/CMakeLists.txt
code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BasicProjectile.h
code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/CMakeLists.txt
code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/CMakeLists.txt
Log:
weapon stuff
Modified: code/branches/OrxoBlox_FS19/data/levels/towerDefense.oxw
===================================================================
--- code/branches/OrxoBlox_FS19/data/levels/towerDefense.oxw 2019-04-04 14:26:09 UTC (rev 12280)
+++ code/branches/OrxoBlox_FS19/data/levels/towerDefense.oxw 2019-04-04 14:37:19 UTC (rev 12281)
@@ -105,13 +105,13 @@
<DefaultWeaponmodeLink firemode=0 weaponmode=0 />
</links>
<Weapon>
- <LightningGun mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=2 shielddamage=4 />
+ <BallGun mode=0 munitionpershot=0 muzzleoffset="0,0,0" damage=200 shielddamage=4 />
</Weapon>
</WeaponPack>
</weaponpacks>
<munition>
- <LightningMunition initialmagazines=1 maxmagazines=1 munitionpermagazine=10/>
- </munition>
+ <BallMunition initialmagazines=1 maxmagazines=1 munitionpermagazine=10/>
+ </munition>x
<attached>
<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>
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.cc 2019-04-04 14:26:09 UTC (rev 12280)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.cc 2019-04-04 14:37:19 UTC (rev 12281)
@@ -20,27 +20,32 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabien Vultier
+ * Hagen Seifert
* Co-authors:
- * ...
+ * simonmie
*
*/
/**
- @file IceGun.cc
- @brief Implementation of the IceGun class.
+ @file HsW01.h
+ @brief Implementation of the HsW01 class.
*/
#include "BallGun.h"
#include "core/CoreIncludes.h"
-#include "core/XMLPort.h"
+#include "core/XMLPort.h"
+#include "core/command/Executor.h"
+
+#include "graphics/Model.h"
#include "weaponsystem/Weapon.h"
#include "weaponsystem/WeaponPack.h"
#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/WorldEntity.h"
#include "worldentities/pawns/Pawn.h"
-#include "BallProjectile.h"
+#include "weapons/projectiles/Projectile.h"
+#include "weapons/MuzzleFlash.h"
namespace orxonox
{
@@ -50,17 +55,21 @@
{
RegisterObject(BallGun);
- // Default values
- this->reloadTime_ = 1.0f;
- this->damage_ = 0.0f;
- this->speed_ = 1200.0f;
+ this->reloadTime_ = 0.25f;
+ this->damage_ = 0.0f; //default 15
+ this->speed_ = 750.0f;
+ this->delay_ = 0.0f;
+ this->setMunitionName("BallMunition");
+ this->mesh_ = "laserbeam.mesh";
- this->setMunitionName("BallMunition");
- this->setFireSound("sounds/Weapon_LightningGun.ogg");
- this->setReloadSound("sounds/Reload_IceGun.ogg", 0.4);
+ this->delayTimer_.setTimer(this->delay_, false, createExecutor(createFunctor(&BallGun::shot, this)));
+ this->delayTimer_.stopTimer();
- hudImageString_ = "Orxonox/WSHUD_WM_IceGun";
+ this->setFireSound("sounds/Weapon_HsW01.ogg");
+ this->setReloadSound("sounds/Reload_HsW01.ogg", 0.5);
+
+ hudImageString_ = "Orxonox/WSHUD_WM_HsW01";
}
BallGun::~BallGun()
@@ -67,14 +76,51 @@
{
}
+ void BallGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(BallGun, XMLPort, xmlelement, mode);
+
+ XMLPortParam(BallGun, "delay", setDelay, getDelay, xmlelement, mode);
+ XMLPortParam(BallGun, "material", setMaterial, getMaterial, xmlelement, mode);
+ XMLPortParam(BallGun, "projectileMesh", setMesh, getMesh, xmlelement, mode);
+ XMLPortParam(BallGun, "sound", setSound, getSound, xmlelement, mode);
+ }
+
/**
@brief
- Fires the weapon. Creates a projectile and fires it.
+ Set the firing delay.
+ @param delay
+ The firing delay in seconds.
*/
+ void BallGun::setDelay(float delay)
+ {
+ orxout() << "delay" << endl;
+ this->delay_ = delay;
+ this->delayTimer_.setInterval(this->delay_);
+ }
+
void BallGun::fire()
{
- BallProjectile* projectile = new BallProjectile(this->getContext());
+ orxout() << "fire" << endl;
+ this->delayTimer_.startTimer();
+ }
+ /**
+ @brief
+ Fires the weapon. Creates a projectile and fires it.
+ */
+ void BallGun::shot()
+ {
+ assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
+ orxout() << "sajkfg" << endl;
+ // Create the projectile.
+ Projectile* projectile = new Projectile(this->getContext());
+ Model* model = new Model(projectile->getContext());
+ model->setMeshSource(mesh_);
+ model->setCastShadows(false);
+ projectile->attach(model);
+ model->setScale(5);
+
this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
projectile->setOrientation(this->getMuzzleOrientation());
projectile->setPosition(this->getMuzzlePosition());
@@ -84,5 +130,20 @@
projectile->setDamage(this->getDamage());
projectile->setShieldDamage(this->getShieldDamage());
projectile->setHealthDamage(this->getHealthDamage());
+
+ // Display the muzzle flash.
+ this->BallGun::muzzleflash();
}
+
+ /**
+ @brief
+ Displays the muzzle flash.
+ */
+ void BallGun::muzzleflash()
+ {
+ MuzzleFlash *muzzleFlash = new MuzzleFlash(this->getContext());
+ this->getWeapon()->attach(muzzleFlash);
+ muzzleFlash->setPosition(this->getMuzzleOffset());
+ muzzleFlash->setMaterial(this->material_);
+ }
}
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.h 2019-04-04 14:26:09 UTC (rev 12280)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallGun.h 2019-04-04 14:37:19 UTC (rev 12281)
@@ -20,7 +20,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Author:
- * Fabien Vultier
+ * Hagen Seifert
* Co-authors:
* ...
*
@@ -27,8 +27,8 @@
*/
/**
- @file IceGun.h
- @brief Definition of the IceGun class.
+ @file HsW01.h
+ @brief Definition of the HsW01 class.
*/
#ifndef _BallGun_H__
@@ -35,6 +35,8 @@
#define _BallGun_H__
#include "weapons/WeaponsPrereqs.h"
+
+#include "tools/Timer.h"
#include "weaponsystem/WeaponMode.h"
namespace orxonox
@@ -42,9 +44,9 @@
/**
@brief
- A Gun that fires ice arrows that slow down any SpaceShip object that gets hit.
+ Shoots laser beams.
@author
- Fabien Vultier
+ Hagen Seifert
@ingroup WeaponsWeaponModes
*/
class _WeaponsExport BallGun : public WeaponMode
@@ -54,10 +56,71 @@
virtual ~BallGun();
virtual void fire() override;
-
- private:
- float speed_; //The speed of the fired projectile.
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+
+ protected:
+ /**
+ @brief Set the mesh.
+ @param mesh The mesh name.
+ */
+ void setMesh(const std::string& mesh)
+ { this->mesh_ = mesh; }
+
+ /**
+ @brief Get the mesh.
+ @return Returns the mesh name.
+ */
+ const std::string& getMesh() const
+ { return this->mesh_; }
+
+ /**
+ @brief Set the sound.
+ @param sound The Sound name.
+ */
+ void setSound(const std::string& sound)
+ { this->sound_ = sound; }
+
+ /**
+ @brief Get the sound.
+ @return Returns the sound name.
+ */
+ const std::string& getSound() const
+ { return this->sound_; }
+
+ /**
+ @brief Set the material.
+ @param material The material name.
+ */
+ void setMaterial(const std::string& material)
+ { this->material_ = material; }
+ /**
+ @brief Get the material.
+ @return Returns the material name.
+ */
+ const std::string& getMaterial() const
+ { return this->material_; }
+
+ void setDelay(float delay);
+ /**
+ @brief Get the firing delay.
+ @return Returns the firing delay in seconds.
+ */
+ float getDelay() const
+ { return this->delay_; }
+
+ virtual void shot();
+ void muzzleflash();
+
+ std::string material_; //!< The material.
+ std::string mesh_; //!< The mesh.
+ std::string sound_; //!< The sound.
+
+
+
+ float speed_; //!< The speed of the fired projectile.
+ float delay_; //!< The firing delay.
+ Timer delayTimer_; //!< A timer to delay the firing.
};
}
-#endif /* _IceGun_H__ */
+#endif /* _HsW01_H__ */
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.cc 2019-04-04 14:26:09 UTC (rev 12280)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.cc 2019-04-04 14:37:19 UTC (rev 12281)
@@ -38,19 +38,22 @@
{
RegisterClass(BallMunition);
- BallMunition::BallMunition(Context* context) : Munition(context)
+ BallMunition::BallMunition(Context* context) : ReplenishingMunition(context)
{
RegisterObject(BallMunition);
- this->maxMunitionPerMagazine_ = 1;
- this->maxMagazines_ = 50;
- this->unassignedMagazines_ = 25;
+ this->maxMunitionPerMagazine_ = 20;
+ this->maxMagazines_ = 10;
+ this->unassignedMagazines_ = 10;
- this->deployment_ = MunitionDeployment::Stack;
+ this->deployment_ = MunitionDeployment::Separate;
this->bAllowMunitionRefilling_ = true;
- this->bAllowMultiMunitionRemovementUnderflow_ = false;
+ this->bAllowMultiMunitionRemovementUnderflow_ = true;
- this->reloadTime_ = 0.5f;
+ this->replenishInterval_ = 7.0f;
+ this->replenishAmount_ = 1;
+
+ this->reloadTime_ = 0.6f;
}
}
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.h 2019-04-04 14:26:09 UTC (rev 12280)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallMunition.h 2019-04-04 14:37:19 UTC (rev 12281)
@@ -35,7 +35,7 @@
#define _BallMunition_H__
#include "weapons/WeaponsPrereqs.h"
-#include "weaponsystem/Munition.h"
+#include "weaponsystem/ReplenishingMunition.h"
namespace orxonox
{
@@ -47,7 +47,7 @@
Fabien Vultier
@ingroup WeaponsMunitions
*/
- class _WeaponsExport BallMunition : public Munition
+ class _WeaponsExport BallMunition : public ReplenishingMunition
{
public:
BallMunition(Context* context);
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.cc 2019-04-04 14:26:09 UTC (rev 12280)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.cc 2019-04-04 14:37:19 UTC (rev 12281)
@@ -37,30 +37,56 @@
#include "core/CoreIncludes.h"
#include "tools/ParticleInterface.h"
#include "Scene.h"
+#include "core/command/Executor.h"
+#include "util/Convert.h"
namespace orxonox
{
RegisterClass(BallProjectile);
- BallProjectile::BallProjectile(Context* context) : Projectile(context)
+ BallProjectile::BallProjectile(Context* context) : BillboardProjectile(context)
{
RegisterObject(BallProjectile);
-
- this->particles_ = nullptr;
+ orxout() << "It's a bird, it's a plane' it's a BallParticle..." << endl;
+ this->textureIndex_ = 1;
+ this->setMass(0.1f);
+ this->maxTextureIndex_ = 8;
this->setDestroyAfterCollision(false); //I want the ball to bounce, not to be destroyed
//setEffect("Orxonox/sparks2");
}
- BallProjectile::~BallProjectile()
+ void BallProjectile::registerVariables()
{
- if (this->isInitialized() && this->particles_)
- {
- this->detachOgreObject(this->particles_->getParticleSystem());
- delete this->particles_;
- }
+ registerVariable(this->materialBase_);
}
+ /**
+ @brief
+ Set the material.
+ @param material
+ The name of the material. Material names with 1 to 8 appended must exist.
+ */
+ void BallProjectile::setMaterial(const std::string& material)
+ {
+ this->materialBase_ = material;
+
+ BillboardProjectile::setMaterial(material + multi_cast<std::string>(this->textureIndex_));
+ }
+
+ /**
+ @brief
+ Change the texture.
+ */
+ void BallProjectile::changeTexture()
+ {
+ this->textureIndex_++;
+ if (this->textureIndex_ > this->maxTextureIndex_)
+ this->textureIndex_ = 1;
+
+ this->setMaterial(this->materialBase_);
+ }
+
void BallProjectile::Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs) {
Vector3 velocity = this->getVelocity();
@@ -67,19 +93,20 @@
Vector3 positionOtherObject = otherObject->getPosition();
Vector3 contactPosition = this->getPosition();
- if (positionOtherObject.y < 0) {
- this->destroy();
- }
- else {
+ //if (positionOtherObject.y < 0) {
+ //this.destroy()
+ //}
+ //else {
+
int distance_X = positionOtherObject.x - contactPosition.x;
+ int distance_Y = positionOtherObject.y - contactPosition.y;
if (distance_X < 0)
- distance_X = -distance_X;
+ distance_Y = -distance_Y;
+
- int distance_Y = positionOtherObject.y - contactPosition.y;
-
if (distance_Y < 0)
- distance_Y = -distance_Y;
+ distance_X = -distance_X;
if (distance_X < distance_Y)
velocity.x = -velocity.x;
@@ -89,10 +116,9 @@
velocity.x = -velocity.x;
velocity.y = -velocity.y;
}
- }
+ //}
}
-
/**
@brief
The function called when a projectile hits another thing.
@@ -109,65 +135,22 @@
@see Pawn.h
*/
-
- bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)
+ /*
+ bool BallProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
{
- if (GameMode::isMaster())
- {
+ orxout() << "I collided against something" << endl;
+ return this->processCollision(otherObject, contactPoint, cs);
+ }
+ */
+
+ bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape*)
+ {
- Pawn* victim = orxonox_cast<Pawn*>(otherObject); // If otherObject isn't a Pawn, then victim is nullptr
+ orxout() << "wanna bounce..." << endl;
+ bool result = BasicProjectile::processCollision(otherObject, contactPoint, cs);
+ Bounce(otherObject, contactPoint, cs);
+ orxout() << "BOUNCED!" << endl;
- WorldEntity* entity = orxonox_cast<WorldEntity*>(this);
- assert(entity); // The projectile must not be a WorldEntity.
-
- // If visual effects after destruction cause problems, put this block below the effects code block
- if (victim)
- {
- victim->hit(this->getShooter(), contactPoint, cs, this->getDamage(), this->getHealthDamage(), this->getShieldDamage());
- victim->startShieldRechargeCountdown();
- }
-
- // Visual effects for being hit, depending on whether the shield is hit or not
- if (this->getShooter()) // If the owner does not exist (anymore?), no effects are displayed.
- {
- // Damping and explosion effect is only played if the victim is no Pawn (see cast above)
- // or if the victim is a Pawn, has no shield left, is still alive and any damage goes to the health
- if (!victim || (victim && !victim->hasShield() && victim->getHealth() > 0.0f && (this->getDamage() > 0.0f || this->getHealthDamage() > 0.0f)))
- {
- {
- ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());
- effect->setPosition(entity->getPosition());
- effect->setOrientation(entity->getOrientation());
- effect->setDestroyAfterLife(true);
- effect->setSource("Orxonox/explosion3");
- effect->setLifetime(2.0f);
- }
- // Second effect with same condition
- {
- ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());
- effect->setPosition(entity->getPosition());
- effect->setOrientation(entity->getOrientation());
- effect->setDestroyAfterLife(true);
- effect->setSource("Orxonox/smoke4");
- effect->setLifetime(3.0f);
- }
- }
-
- // victim->isAlive() is not false until the next tick, so getHealth() > 0 is used instead
- if (victim && victim->hasShield() && (this->getDamage() > 0.0f || this->getShieldDamage() > 0.0f) && victim->getHealth() > 0.0f)
- {
- ParticleSpawner* effect = new ParticleSpawner(this->getShooter()->getContext());
- effect->setDestroyAfterLife(true);
- effect->setSource("Orxonox/Shield");
- effect->setLifetime(0.5f);
- victim->attach(effect);
- }
- }
-
- Bounce(otherObject, contactPoint, cs);
-
- return true;
- }
- return false;
+ return result;
}
}
Modified: code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.h 2019-04-04 14:26:09 UTC (rev 12280)
+++ code/branches/OrxoBlox_FS19/src/modules/OrxoBlox/BallGun/BallProjectile.h 2019-04-04 14:37:19 UTC (rev 12281)
@@ -47,15 +47,23 @@
Fabian 'x3n' Landau
@ingroup WeaponsProjectiles
*/
- class _WeaponsExport BallProjectile : public Projectile
+ class _WeaponsExport BallProjectile : public BillboardProjectile
{
public:
BallProjectile(Context* context);
- virtual ~BallProjectile();
- virtual void Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
- virtual bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
+ void Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
+ //bool BallProjectile::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
+ bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape*);
+ virtual void setMaterial(const std::string& material) override;
+
private:
- ParticleInterface* particles_; //!< The particles.
+
+ void registerVariables();
+ void changeTexture();
+
+ unsigned int textureIndex_; //!< The current index of the texture. (i.e. the index of the currently displayed texture)
+ unsigned int maxTextureIndex_; //!< The maximal index.
+ std::string materialBase_; //!< The base name of the material.
};
}
Added: code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/BallMunition.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/BallMunition.cc (rev 0)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/BallMunition.cc 2019-04-04 14:37:19 UTC (rev 12281)
@@ -0,0 +1,59 @@
+/*
+ * 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 IceMunition.cc
+ @brief Implementation of the IceMunition class.
+*/
+
+#include "BallMunition.h"
+#include "core/CoreIncludes.h"
+
+namespace orxonox
+{
+ RegisterClass(BallMunition);
+
+ BallMunition::BallMunition(Context* context) : ReplenishingMunition(context)
+ {
+ RegisterObject(BallMunition);
+
+ this->maxMunitionPerMagazine_ = 20;
+ this->maxMagazines_ = 10;
+ this->unassignedMagazines_ = 10;
+
+ this->deployment_ = MunitionDeployment::Separate;
+
+ this->bAllowMunitionRefilling_ = true;
+ this->bAllowMultiMunitionRemovementUnderflow_ = true;
+
+ this->replenishInterval_ = 7.0f;
+ this->replenishAmount_ = 1;
+
+ this->reloadTime_ = 0.6f;
+ }
+}
Added: code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/BallMunition.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/BallMunition.h (rev 0)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/BallMunition.h 2019-04-04 14:37:19 UTC (rev 12281)
@@ -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 IceMunition.h
+ @brief Definition of the IceMunition class.
+*/
+
+#ifndef _BallMunition_H__
+#define _BallMunition_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weaponsystem/ReplenishingMunition.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ IceMunition.
+ @author
+ Fabien Vultier
+ @ingroup WeaponsMunitions
+ */
+ class _WeaponsExport BallMunition : public ReplenishingMunition
+ {
+ public:
+ BallMunition(Context* context);
+ virtual ~BallMunition() = default;
+ };
+}
+
+#endif /* _SplitMunition_H__ */
Modified: code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/CMakeLists.txt
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/CMakeLists.txt 2019-04-04 14:26:09 UTC (rev 12280)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/munitions/CMakeLists.txt 2019-04-04 14:37:19 UTC (rev 12281)
@@ -8,4 +8,5 @@
FlameMunition.cc
SplitMunition.cc
MineMunition.cc
+ BallMunition.cc
)
Added: code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.cc (rev 0)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.cc 2019-04-04 14:37:19 UTC (rev 12281)
@@ -0,0 +1,147 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file ParticleProjectile.h
+ @brief Implementation of the ParticleProjectile class.
+*/
+
+#include "BallProjectile.h"
+
+#include <OgreParticleEmitter.h>
+#include "core/CoreIncludes.h"
+#include "tools/ParticleInterface.h"
+#include "Scene.h"
+#include "core/command/Executor.h"
+#include "util/Convert.h"
+
+namespace orxonox
+{
+ RegisterClass(BallProjectile);
+
+ BallProjectile::BallProjectile(Context* context) : BillboardProjectile(context)
+ {
+ RegisterObject(BallProjectile);
+ this->textureIndex_ = 1;
+ this->setMass(0.1f);
+ this->maxTextureIndex_ = 8;
+ this->setDestroyAfterCollision(false); //I want the ball to bounce, not to be destroyed
+
+ //setEffect("Orxonox/sparks2");
+ }
+
+ void BallProjectile::registerVariables()
+ {
+ registerVariable(this->materialBase_);
+ }
+
+ /**
+ @brief
+ Set the material.
+ @param material
+ The name of the material. Material names with 1 to 8 appended must exist.
+ */
+ void BallProjectile::setMaterial(const std::string& material)
+ {
+ this->materialBase_ = material;
+
+ BillboardProjectile::setMaterial(material + multi_cast<std::string>(this->textureIndex_));
+ }
+
+ /**
+ @brief
+ Change the texture.
+ */
+ void BallProjectile::changeTexture()
+ {
+ this->textureIndex_++;
+ if (this->textureIndex_ > this->maxTextureIndex_)
+ this->textureIndex_ = 1;
+
+ this->setMaterial(this->materialBase_);
+ }
+
+ void BallProjectile::Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs) {
+
+ Vector3 velocity = this->getVelocity();
+ Vector3 positionOtherObject = otherObject->getPosition();
+ Vector3 contactPosition = this->getPosition();
+
+ //if (positionOtherObject.y < 0) {
+ //this.destroy()
+ //}
+ //else {
+
+ int distance_X = positionOtherObject.x - contactPosition.x;
+ int distance_Y = positionOtherObject.y - contactPosition.y;
+
+ if (distance_X < 0)
+ distance_Y = -distance_Y;
+
+
+ if (distance_Y < 0)
+ distance_X = -distance_X;
+
+ if (distance_X < distance_Y)
+ velocity.x = -velocity.x;
+ if (distance_Y < distance_X)
+ velocity.y = -velocity.y;
+ else {
+ velocity.x = -velocity.x;
+ velocity.y = -velocity.y;
+ }
+ //}
+ }
+
+/**
+ @brief
+ The function called when a projectile hits another thing.
+ Calls the hit-function, starts the shield recharge countdown, displays visual hit effects defined in Pawn.
+ Needs to be called in the collidesAgainst() function by every Class directly inheriting from BasicProjectile.
+ @param otherObject
+ A pointer to the object the Projectile has collided against.
+ @param contactPoint
+ A btManifoldPoint indicating the point of contact/impact.
+ @param cs
+ The btCollisionShape of the other object
+ @return
+ Returns true if the collision resulted in a successful hit.
+ @see Pawn.h
+ */
+
+ bool BallProjectile::processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs)
+ {
+
+ orxout() << "wanna bounce..." << endl;
+ bool result = BasicProjectile::processCollision(otherObject, contactPoint, cs);
+ Bounce(otherObject, contactPoint, cs);
+ orxout() << "BOUNCED!" << endl;
+
+ return result;
+ }
+}
Added: code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.h (rev 0)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BallProjectile.h 2019-04-04 14:37:19 UTC (rev 12281)
@@ -0,0 +1,71 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file ParticleProjectile.h
+ @brief Definition of the ParticleProjectile class.
+*/
+
+#ifndef _BallProjectile_H__
+#define _BallProjectile_H__
+
+#include "weapons/WeaponsPrereqs.h"
+#include "weapons/projectiles/BillboardProjectile.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ A projectile that is represented by particles.
+ @author
+ Fabian 'x3n' Landau
+ @ingroup WeaponsProjectiles
+ */
+ class _WeaponsExport BallProjectile : public BillboardProjectile
+ {
+ public:
+ BallProjectile(Context* context);
+ void Bounce(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
+ virtual void setMaterial(const std::string& material) override;
+
+ protected:
+ bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs) override;
+
+ private:
+
+ void registerVariables();
+ void changeTexture();
+
+ unsigned int textureIndex_; //!< The current index of the texture. (i.e. the index of the currently displayed texture)
+ unsigned int maxTextureIndex_; //!< The maximal index.
+ std::string materialBase_; //!< The base name of the material.
+ };
+}
+
+#endif /* _ParticleProjectile_H__ */
Modified: code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BasicProjectile.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BasicProjectile.h 2019-04-04 14:26:09 UTC (rev 12280)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/BasicProjectile.h 2019-04-04 14:37:19 UTC (rev 12281)
@@ -116,7 +116,7 @@
virtual void destroyObject(void);
protected:
- bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
+ virtual bool processCollision(WorldEntity* otherObject, btManifoldPoint& contactPoint, const btCollisionShape* cs);
void destroyCheck(void);
inline void setDestroyAfterCollision(bool destroyAfterCollision)
{ destroyAfterCollision_ = destroyAfterCollision; }
Modified: code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/CMakeLists.txt
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/CMakeLists.txt 2019-04-04 14:26:09 UTC (rev 12280)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/projectiles/CMakeLists.txt 2019-04-04 14:37:19 UTC (rev 12281)
@@ -14,4 +14,5 @@
GravityBombField.cc
MineProjectile.cc
WagnisProjectile.cc
+ BallProjectile.cc
)
Added: code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/BallGun.cc
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/BallGun.cc (rev 0)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/BallGun.cc 2019-04-04 14:37:19 UTC (rev 12281)
@@ -0,0 +1,150 @@
+/*
+ * 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:
+ * Hagen Seifert
+ * Co-authors:
+ * simonmie
+ *
+ */
+
+/**
+ @file HsW01.h
+ @brief Implementation of the HsW01 class.
+*/
+
+#include "BallGun.h"
+
+#include "core/CoreIncludes.h"
+#include "core/XMLPort.h"
+#include "core/command/Executor.h"
+
+#include "graphics/Model.h"
+#include "weaponsystem/Weapon.h"
+#include "weaponsystem/WeaponPack.h"
+#include "weaponsystem/WeaponSystem.h"
+#include "worldentities/WorldEntity.h"
+#include "worldentities/pawns/Pawn.h"
+
+#include "weapons/projectiles/Projectile.h"
+#include "weapons/MuzzleFlash.h"
+#include "weapons/projectiles/BallProjectile.h"
+
+namespace orxonox
+{
+ RegisterClass(BallGun);
+
+ BallGun::BallGun(Context* context) : WeaponMode(context)
+ {
+ RegisterObject(BallGun);
+
+ this->reloadTime_ = 0.25f;
+ this->damage_ = 0.0f; //default 15
+ this->speed_ = 750.0f;
+ this->delay_ = 0.0f;
+ this->setMunitionName("BallMunition");
+ this->mesh_ = "laserbeam.mesh";
+
+
+ this->delayTimer_.setTimer(this->delay_, false, createExecutor(createFunctor(&BallGun::shot, this)));
+ this->delayTimer_.stopTimer();
+
+ this->setFireSound("sounds/Weapon_HsW01.ogg");
+ this->setReloadSound("sounds/Reload_HsW01.ogg", 0.5);
+
+ hudImageString_ = "Orxonox/WSHUD_WM_HsW01";
+ }
+
+ BallGun::~BallGun()
+ {
+ }
+
+ void BallGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
+ {
+ SUPER(BallGun, XMLPort, xmlelement, mode);
+
+ XMLPortParam(BallGun, "delay", setDelay, getDelay, xmlelement, mode);
+ XMLPortParam(BallGun, "material", setMaterial, getMaterial, xmlelement, mode);
+ XMLPortParam(BallGun, "projectileMesh", setMesh, getMesh, xmlelement, mode);
+ XMLPortParam(BallGun, "sound", setSound, getSound, xmlelement, mode);
+ }
+
+ /**
+ @brief
+ Set the firing delay.
+ @param delay
+ The firing delay in seconds.
+ */
+ void BallGun::setDelay(float delay)
+ {
+ orxout() << "delay" << endl;
+ this->delay_ = delay;
+ this->delayTimer_.setInterval(this->delay_);
+ }
+
+ void BallGun::fire()
+ {
+ orxout() << "fire" << endl;
+ this->delayTimer_.startTimer();
+ }
+
+ /**
+ @brief
+ Fires the weapon. Creates a projectile and fires it.
+ */
+ void BallGun::shot()
+ {
+ assert( this->getWeapon() && this->getWeapon()->getWeaponPack() && this->getWeapon()->getWeaponPack()->getWeaponSystem() && this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn() );
+ orxout() << "SHOT!" << endl;
+ // Create the projectile.
+ Projectile* projectile = new BallProjectile(this->getContext());
+ Model* model = new Model(projectile->getContext());
+ model->setMeshSource(mesh_);
+ model->setCastShadows(false);
+ projectile->attach(model);
+ model->setScale(5);
+
+ this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
+ projectile->setOrientation(this->getMuzzleOrientation());
+ projectile->setPosition(this->getMuzzlePosition());
+ projectile->setVelocity(this->getMuzzleDirection() * this->speed_);
+
+ projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
+ projectile->setDamage(this->getDamage());
+ projectile->setShieldDamage(this->getShieldDamage());
+ projectile->setHealthDamage(this->getHealthDamage());
+
+ // Display the muzzle flash.
+ this->BallGun::muzzleflash();
+ }
+
+ /**
+ @brief
+ Displays the muzzle flash.
+ */
+ void BallGun::muzzleflash()
+ {
+ MuzzleFlash *muzzleFlash = new MuzzleFlash(this->getContext());
+ this->getWeapon()->attach(muzzleFlash);
+ muzzleFlash->setPosition(this->getMuzzleOffset());
+ muzzleFlash->setMaterial(this->material_);
+ }
+}
Added: code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/BallGun.h
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/BallGun.h (rev 0)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/BallGun.h 2019-04-04 14:37:19 UTC (rev 12281)
@@ -0,0 +1,126 @@
+/*
+ * 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:
+ * Hagen Seifert
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file HsW01.h
+ @brief Definition of the HsW01 class.
+*/
+
+#ifndef _BallGun_H__
+#define _BallGun_H__
+
+#include "weapons/WeaponsPrereqs.h"
+
+#include "tools/Timer.h"
+#include "weaponsystem/WeaponMode.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Shoots laser beams.
+ @author
+ Hagen Seifert
+ @ingroup WeaponsWeaponModes
+ */
+ class _WeaponsExport BallGun : public WeaponMode
+ {
+ public:
+ BallGun(Context* context);
+ virtual ~BallGun();
+
+ virtual void fire() override;
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override;
+
+ protected:
+ /**
+ @brief Set the mesh.
+ @param mesh The mesh name.
+ */
+ void setMesh(const std::string& mesh)
+ { this->mesh_ = mesh; }
+
+ /**
+ @brief Get the mesh.
+ @return Returns the mesh name.
+ */
+ const std::string& getMesh() const
+ { return this->mesh_; }
+
+ /**
+ @brief Set the sound.
+ @param sound The Sound name.
+ */
+ void setSound(const std::string& sound)
+ { this->sound_ = sound; }
+
+ /**
+ @brief Get the sound.
+ @return Returns the sound name.
+ */
+ const std::string& getSound() const
+ { return this->sound_; }
+
+ /**
+ @brief Set the material.
+ @param material The material name.
+ */
+ void setMaterial(const std::string& material)
+ { this->material_ = material; }
+ /**
+ @brief Get the material.
+ @return Returns the material name.
+ */
+ const std::string& getMaterial() const
+ { return this->material_; }
+
+ void setDelay(float delay);
+ /**
+ @brief Get the firing delay.
+ @return Returns the firing delay in seconds.
+ */
+ float getDelay() const
+ { return this->delay_; }
+
+ virtual void shot();
+ void muzzleflash();
+
+ std::string material_; //!< The material.
+ std::string mesh_; //!< The mesh.
+ std::string sound_; //!< The sound.
+
+
+
+ float speed_; //!< The speed of the fired projectile.
+ float delay_; //!< The firing delay.
+ Timer delayTimer_; //!< A timer to delay the firing.
+ };
+}
+
+#endif /* _HsW01_H__ */
Modified: code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/CMakeLists.txt
===================================================================
--- code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/CMakeLists.txt 2019-04-04 14:26:09 UTC (rev 12280)
+++ code/branches/OrxoBlox_FS19/src/modules/weapons/weaponmodes/CMakeLists.txt 2019-04-04 14:37:19 UTC (rev 12281)
@@ -13,4 +13,5 @@
GravityBombFire.cc
MineGun.cc
WagnisGun.cc
+ BallGun.cc
)
More information about the Orxonox-commit
mailing list