[Orxonox-commit 6232] r10889 - in code/branches/particleEffectsHS15: data/levels/includes src/modules/weapons src/modules/weapons/projectiles src/modules/weapons/weaponmodes
fvultier at orxonox.net
fvultier at orxonox.net
Sun Nov 29 21:05:26 CET 2015
Author: fvultier
Date: 2015-11-29 21:05:26 +0100 (Sun, 29 Nov 2015)
New Revision: 10889
Modified:
code/branches/particleEffectsHS15/data/levels/includes/weaponSettingsEscort.oxi
code/branches/particleEffectsHS15/src/modules/weapons/WeaponsPrereqs.h
code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc
code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.h
code/branches/particleEffectsHS15/src/modules/weapons/projectiles/Projectile.h
code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.cc
code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.h
Log:
promised wor for Jannis.
Modified: code/branches/particleEffectsHS15/data/levels/includes/weaponSettingsEscort.oxi
===================================================================
--- code/branches/particleEffectsHS15/data/levels/includes/weaponSettingsEscort.oxi 2015-11-29 17:36:21 UTC (rev 10888)
+++ code/branches/particleEffectsHS15/data/levels/includes/weaponSettingsEscort.oxi 2015-11-29 20:05:26 UTC (rev 10889)
@@ -13,7 +13,7 @@
<DefaultWeaponmodeLink firemode=1 weaponmode=1 />
</links>
<Weapon>
- <MineGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" />
+ <MineGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" maxtimeuntilexplosion=5 timeuntilactivation=1.5/>
</Weapon>
<Weapon>
<SplitGun mode=0 munitionpershot=0 delay=0.125 damage=9.3 muzzleoffset=" 0.1, 1.4,-3" />
Modified: code/branches/particleEffectsHS15/src/modules/weapons/WeaponsPrereqs.h
===================================================================
--- code/branches/particleEffectsHS15/src/modules/weapons/WeaponsPrereqs.h 2015-11-29 17:36:21 UTC (rev 10888)
+++ code/branches/particleEffectsHS15/src/modules/weapons/WeaponsPrereqs.h 2015-11-29 20:05:26 UTC (rev 10889)
@@ -92,6 +92,7 @@
class HsW01;
class LaserFire;
class LightningGun;
+ class MineGun;
class RocketFire;
class RocketFireOld;
class SimpleRocketFire;
Modified: code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc
===================================================================
--- code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc 2015-11-29 17:36:21 UTC (rev 10888)
+++ code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.cc 2015-11-29 20:05:26 UTC (rev 10889)
@@ -34,71 +34,136 @@
#include "MineProjectile.h"
#include "core/CoreIncludes.h"
-#include "core/command/Executor.h"
-#include "util/Convert.h"
-#include "util/Math.h"
-
-#include "core/CoreIncludes.h"
#include "graphics/Model.h"
-#include "graphics/ParticleSpawner.h"
-#include "Scene.h"
#include "core/command/Executor.h"
-#include "tools/ParticleInterface.h"
namespace orxonox
{
RegisterClass(MineProjectile);
- MineProjectile::MineProjectile(Context* context) : Projectile(context)
+ MineProjectile::MineProjectile(Context* context) : MovableEntity(context), BasicProjectile()
{
RegisterObject(MineProjectile);
- this->lifeTime_ = 1.0f;
+ this->bActive_ = false;
+ this->maxTimeUntilExplosion_ = 10.0f;
+ this->timeUntilActivation_ = 1.0f;
- Model* model = new Model(this->getContext());
- model->setMeshSource("sphere.mesh");
- model->setScale(15.0);
- this->attach(model);
- model->setPosition(Vector3(0,0,0));
+ rings_ = new MovableEntity(this->getContext());
+ this->attach(rings_);
+ rings_->setPosition(Vector3(0.0,0.0,0.0));
+ rings_->setAngularVelocity(Vector3(0.0,5.0,0.0));
+
+ modelCore_ = new Model(this->getContext());
+ modelCore_->setMeshSource("Mine_Core.mesh");
+ modelCore_->setScale(15.0);
+ this->attach(modelCore_);
+ modelCore_->setPosition(Vector3(0,0,0));
+
+ modelRing1_ = new Model(this->getContext());
+ modelRing1_->setMeshSource("Mine_Ring.mesh");
+ modelRing1_->setScale(15.0);
+ rings_->attach(modelRing1_);
+ modelRing1_->setPosition(Vector3(0,0,0));
+ modelRing1_->yaw(Degree(0));
+
+ modelRing2_ = new Model(this->getContext());
+ modelRing2_->setMeshSource("Mine_Ring.mesh");
+ modelRing2_->setScale(15.0);
+ rings_->attach(modelRing2_);
+ modelRing2_->setPosition(Vector3(0,0,0));
+ modelRing2_->yaw(Degree(180));
+
+ if (GameMode::isMaster())
+ {
+ this->setMass(10.0f);
+ this->setFriction(100.0f);
+ this->enableCollisionCallback();
+ this->setCollisionResponse(false);
+ this->setCollisionType(Dynamic);
+
+ // Create a sphere collision shape and attach it to the projectile.
+ collisionShape_ = new SphereCollisionShape(this->getContext());
+ collisionShape_->setRadius(10.0f);
+ this->attachCollisionShape(collisionShape_);
+
+ // Create a distance trigger and attach it to the projectile.
+ distanceTrigger_ = new DistanceTrigger(this->getContext());
+ this->attach(distanceTrigger_);
+ distanceTrigger_->setPosition(Vector3(0,0,0));
+ distanceTrigger_->setDistance(40.0f);
+ distanceTrigger_->addTarget("Pawn");
+ distanceTrigger_->setStayActive(true);
+ }
}
-
+ MineProjectile::~MineProjectile()
+ {
+ /*if (modelCore_ != NULL)
+ {
+ modelCore_->destroy();
+ }*/
+ /*if (distanceTrigger_ != NULL)
+ {
+ distanceTrigger_->destroy();
+ }*/
+ }
+
/**
@brief
- This function starts a timer that will cause the projectile to Mine after a time defined by the argument @param LifeTime.
+ TODO
*/
- void MineProjectile::setLifeTime(float lifeTime)
+ void MineProjectile::setMaxTimeUntilExplosion(float maxTimeUntilExplosion)
{
- orxout() << lifeTime << endl;
-
- if (lifeTime >= 0)
+ if (maxTimeUntilExplosion >= 0)
{
- this->lifeTime_ = lifeTime;
- this->explodeTimer.setTimer(this->lifeTime_, false, createExecutor(createFunctor(&MineProjectile::Explode, this)));
+ this->maxTimeUntilExplosion_ = maxTimeUntilExplosion;
+ if (GameMode::isMaster())
+ {
+ this->explodeTimer_.setTimer(this->maxTimeUntilExplosion_, false, createExecutor(createFunctor(&MineProjectile::Explode, this)));
+ }
}
else
{
- this->lifeTime_ = 0;
+ this->maxTimeUntilExplosion_ = 0;
}
}
-
/**
@brief
- This is the setter function for the damageReduction_ variable. The value of the variable is bounded between 0 and 1.
+ TODO
*/
+ void MineProjectile::setTimeUntilActivation(float timeUntilActivation)
+ {
+ timeUntilActivation_ = timeUntilActivation;
+ if (GameMode::isMaster())
+ {
+ this->activationTimer_.setTimer(this->timeUntilActivation_, false, createExecutor(createFunctor(&MineProjectile::Activate, this)));
+ }
+ }
/**
@brief
- If this function is called the projectile Mines up into many child projectiles. The original projectiles does not get destroyed but it will never Mine up again.
+ TODO
*/
void MineProjectile::Explode()
{
- orxout() << "Explode" << endl;
+ orxout() << "MineProjectile::Explode" << endl;
this->destroyLater();
}
+
+ /**
+ @brief
+ TODO
+ */
+ void MineProjectile::Activate()
+ {
+ orxout() << "MineProjectile::Activate" << endl;
+
+ bActive_ = true;
+ }
}
Modified: code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.h
===================================================================
--- code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.h 2015-11-29 17:36:21 UTC (rev 10888)
+++ code/branches/particleEffectsHS15/src/modules/weapons/projectiles/MineProjectile.h 2015-11-29 20:05:26 UTC (rev 10889)
@@ -27,7 +27,7 @@
*/
/**
- @file IceGunProjectile.h
+ @file MineProjectile.h
@brief Definition of the MineProjectile class.
*/
@@ -35,36 +35,45 @@
#define _MineProjectile_H__
#include "weapons/WeaponsPrereqs.h"
-
-#include <string>
#include "tools/Timer.h"
-#include "Projectile.h"
+#include "worldentities/MovableEntity.h"
+#include "objects/collisionshapes/SphereCollisionShape.h"
+#include "objects/triggers/DistanceTrigger.h"
+#include "BasicProjectile.h"
namespace orxonox
{
/**
@brief
- The MineProjectile is a projectile that may Mine up into many child projectiles.
- @author
- Fabien Vultier
+ TODO
@ingroup WeaponsProjectiles
*/
- class _WeaponsExport MineProjectile : public Projectile
+ class _WeaponsExport MineProjectile : public MovableEntity, public BasicProjectile
{
public:
MineProjectile(Context* context);
- virtual ~MineProjectile() {}
+ virtual ~MineProjectile();
- virtual void setLifeTime(float LifeTime);
-
+ virtual void setMaxTimeUntilExplosion(float maxTimeUntilExplosion);
+ virtual void setTimeUntilActivation(float timeUntilActivation);
+ private:
+ bool bActive_; // The mine can only explode if it is active
+ float maxTimeUntilExplosion_;
+ float timeUntilActivation_;
+ Timer activationTimer_;
+ Timer explodeTimer_;
+ Model* modelCore_;
+ Model* modelRing1_;
+ Model* modelRing2_;
+ MovableEntity* rings_;
- private:
- float lifeTime_;
- Timer explodeTimer;
+ WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile.
+ WeakPtr<DistanceTrigger> distanceTrigger_;
- virtual void Explode();
+ virtual void Activate();
+ virtual void Explode();
};
}
Modified: code/branches/particleEffectsHS15/src/modules/weapons/projectiles/Projectile.h
===================================================================
--- code/branches/particleEffectsHS15/src/modules/weapons/projectiles/Projectile.h 2015-11-29 17:36:21 UTC (rev 10888)
+++ code/branches/particleEffectsHS15/src/modules/weapons/projectiles/Projectile.h 2015-11-29 20:05:26 UTC (rev 10889)
@@ -68,11 +68,11 @@
protected:
virtual void setCollisionShapeRadius(float radius);
+ float lifetime_; //!< The time the projectile exists.
private:
- float lifetime_; //!< The time the projectile exists.
Timer destroyTimer_; //!< Timer to destroy the projectile after its lifetime has run out.
- WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile.
+ WeakPtr<SphereCollisionShape> collisionShape_; // The collision shape of the projectile.
};
}
Modified: code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.cc
===================================================================
--- code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.cc 2015-11-29 17:36:21 UTC (rev 10888)
+++ code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.cc 2015-11-29 20:05:26 UTC (rev 10889)
@@ -50,10 +50,10 @@
{
RegisterObject(MineGun);
+ this->speed_ = 0.0f;
this->reloadTime_ = 1.0f;
this->damage_ = 0.0f;
- this->speed_ = 0.0f;
- this->lifeTime_ = 7500.0f;
+ this->maxTimeUntilExplosion_ = 0.0f;
this->setMunitionName("MineMunition");
this->setDefaultSound("sounds/Weapon_LightningGun.ogg");
@@ -65,12 +65,14 @@
/**
@brief
- XMLPort for the MineGun. You can define how often the projectiles Mine, how many childs should be created per Mine, the spread and the time between two Mines.
+ XMLPort for the MineGun.
*/
void MineGun::XMLPort(Element& xmlelement, XMLPort::Mode mode)
{
SUPER(MineGun, XMLPort, xmlelement, mode);
- XMLPortParam(MineGun, "Lifetime", setLifeTime, getLifeTime, xmlelement, mode);
+
+ XMLPortParam(MineGun, "maxtimeuntilexplosion", setMaxTimeUntilExplosion, getMaxTimeUntilExplosion, xmlelement, mode).defaultValues(10.0f);
+ XMLPortParam(MineGun, "timeuntilactivation", setTimeUntilActivation, getTimeUntilActivation, xmlelement, mode).defaultValues(3.0f);
}
/**
@@ -80,19 +82,14 @@
void MineGun::fire()
{
MineProjectile* projectile = new MineProjectile(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_);
- // Pass important information to the projectile: Number of Mines, Number of childs, Mine time, spread and the damage reduction
- /*projectile->setNumberOfMines(getNumberOfMines());
- projectile->setNumberOfChilds(getNumberOfChilds());*/
- projectile->setLifeTime(getLifeTime());
- /*projectile->setSpread(getSpread());
- projectile->setDamageReduction(getDamageReduction());*/
+ projectile->setMaxTimeUntilExplosion(getMaxTimeUntilExplosion());
+ projectile->setTimeUntilActivation(getTimeUntilActivation());
projectile->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
projectile->setDamage(this->getDamage());
Modified: code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.h
===================================================================
--- code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.h 2015-11-29 17:36:21 UTC (rev 10888)
+++ code/branches/particleEffectsHS15/src/modules/weapons/weaponmodes/MineGun.h 2015-11-29 20:05:26 UTC (rev 10889)
@@ -43,8 +43,6 @@
/**
@brief
A Mine that explodes when a ship is too close
- @author
- Fabien Vultier
@ingroup WeaponsWeaponModes
*/
class _WeaponsExport MineGun : public WeaponMode
@@ -55,15 +53,20 @@
virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
virtual void fire();
- inline void setLifeTime(float lifeTime)
- { this->lifeTime_ = lifeTime; }
- inline float getLifeTime() const
- { return this->lifeTime_; }
- private:
+ inline float getMaxTimeUntilExplosion() const
+ { return this->maxTimeUntilExplosion_; }
+ inline float getTimeUntilActivation() const
+ { return this->timeUntilActivation_; }
+ protected:
+ inline void setMaxTimeUntilExplosion(float maxTimeUntilExplosion)
+ { this->maxTimeUntilExplosion_ = maxTimeUntilExplosion; }
+ inline void setTimeUntilActivation(float timeUntilActivation)
+ { this->timeUntilActivation_ = timeUntilActivation; }
+ private:
float speed_; //The speed of the fired projectile.
- float lifeTime_;
-
+ float maxTimeUntilExplosion_;
+ float timeUntilActivation_;
};
}
More information about the Orxonox-commit
mailing list