[Orxonox-commit 5728] r10391 - in code/branches/weaponFS15/src/modules/weapons: projectiles weaponmodes
meggiman at orxonox.net
meggiman at orxonox.net
Thu Apr 23 16:19:02 CEST 2015
Author: meggiman
Date: 2015-04-23 16:19:02 +0200 (Thu, 23 Apr 2015)
New Revision: 10391
Modified:
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h
code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc
code/branches/weaponFS15/src/modules/weapons/projectiles/LightningGunProjectile.cc
code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.cc
code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.h
Log:
Implemented all necessary classes. No the weapon works without bugs.
Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc 2015-04-23 14:08:35 UTC (rev 10390)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc 2015-04-23 14:19:02 UTC (rev 10391)
@@ -18,13 +18,14 @@
{
RegisterObject(GravityBomb);
- this->setMass(15.0);
+ this->setMass(10.0);
+ this->isDetonated_ = false;
if (GameMode::isMaster())
{
//Define CollisionType of the bomb
- this->velocityAtLastTick_= 1000;
+ this->timeToLife_= 5;
this->setCollisionResponse(false);
- this->setCollisionType(WorldEntity::Kinematic);
+ this->setCollisionType(WorldEntity::Dynamic);
this->enableCollisionCallback();
//Add Collision Shape
@@ -45,38 +46,44 @@
void GravityBomb::tick(float dt)
{
- velocityAtLastTick_=getVelocity().length();
SUPER(GravityBomb,tick,dt);
- if(velocityAtLastTick_ < this->getVelocity().length())
+ timeToLife_ -= dt;
+ if(timeToLife_ < 0)
{
orxout(debug_output) << "bomb has stoped moving" <<endl;
setVelocity(Vector3::ZERO);
setAcceleration(Vector3::ZERO);
- velocityAtLastTick_=0;
detonate();
- orxout(debug_output) << "denoting" <<endl;
}
else
{
- velocityAtLastTick_=getVelocity().length();
- orxout(debug_output)<< velocityAtLastTick_ <<endl;
- orxout(debug_output) << "acceleration" << getAcceleration().length() <<endl;
+ orxout(debug_output)<< "Time to live:" << timeToLife_ <<endl;
destroyCheck();
}
+ if(isDetonated_) detonate();
}
bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
{
- orxout(debug_output) << "collides" << endl;
- processCollision(otherObject, contactPoint,cs);
- //detonate();
- return true;
+ if(otherObject != getShooter())
+ {
+ orxout(debug_output) << "collides" << endl;
+ processCollision(otherObject, contactPoint,cs);
+ isDetonated_ = true;
+ return true;
+ }
+ else{
+ orxout(debug_output) << "collided with shooter. Has no effect..." << endl;
+ return false;
+ }
}
void GravityBomb::detonate()
{
GravityBombField* field = new GravityBombField(this->getContext());
- orxout(debug_output) << "denoting" <<endl;
+ field->setPosition(getPosition());
+ orxout(debug_output) << "detonating. Creating GravityBombField." <<endl;
+ orxout(debug_output) << "Field is at Position: " << getPosition() << endl;
this->destroy();
}
}
Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h 2015-04-23 14:08:35 UTC (rev 10390)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h 2015-04-23 14:19:02 UTC (rev 10391)
@@ -63,11 +63,10 @@
virtual bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint);
void detonate();
-
private:
+ bool isDetonated_; //Used to check whether the Bomb has to be destroyed during next tick.
+ float timeToLife_; //Time the bomb flies before it explodes.
- float velocityAtLastTick_; //Used to check wether the Object is already accelarating in the oposite direction to detect the time to detonate it.
-
};
}
#endif /* GravityBOMB_H_ */
Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc 2015-04-23 14:08:35 UTC (rev 10390)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc 2015-04-23 14:19:02 UTC (rev 10391)
@@ -6,13 +6,14 @@
*/
#include "GravityBombField.h"
+#include "graphics/Model.h"
namespace orxonox{
RegisterClass(GravityBombField);
- const float GravityBombField::FORCE_FIELD_LIFETIME = 5;
- const float GravityBombField::FORCE_SPHERE_START_RADIUS = 100;
- const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -1000;
+ const float GravityBombField::FORCE_FIELD_LIFETIME = 100;
+ const float GravityBombField::FORCE_SPHERE_START_RADIUS = 500;
+ const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -500;
GravityBombField::GravityBombField(Context* context) : ForceField(context)
{
@@ -21,6 +22,13 @@
setVelocity(FORCE_SPHERE_START_STRENGTH);
setDiameter(FORCE_SPHERE_START_RADIUS);
setMode(modeInvertedSphere_s);
+ setCollisionResponse(false);
+
+ //Attach Demo Model for debuging.
+ Model* model = new Model(this->getContext());
+ model->setMeshSource("rocket.mesh"); //Demo Model from SimpleRocket
+ model->scale(0.7f);
+ this->attach(model);
}
GravityBombField::~GravityBombField(){}
@@ -31,6 +39,7 @@
lifetime_-=dt;
if(lifetime_ < 0)
{
+ orxout(debug_output) << "Timeout. Destroying field." << endl;
this->destroy();
}
}
Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/LightningGunProjectile.cc
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/LightningGunProjectile.cc 2015-04-23 14:08:35 UTC (rev 10390)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/LightningGunProjectile.cc 2015-04-23 14:19:02 UTC (rev 10391)
@@ -46,6 +46,8 @@
RegisterObject(LightningGunProjectile);
this->textureIndex_ = 1;
+ this->setMass(2);
+ this->setCollisionType(Dynamic);
this->maxTextureIndex_ = 8;
this->textureTimer_.setTimer(0.01f, true, createExecutor(createFunctor(&LightningGunProjectile::changeTexture, this)));
Modified: code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.cc
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.cc 2015-04-23 14:08:35 UTC (rev 10390)
+++ code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.cc 2015-04-23 14:19:02 UTC (rev 10391)
@@ -25,8 +25,7 @@
this->reloadTime_ = 0.50f;
this->bParallelReload_ = false;
this->damage_ = 0.0f;
- this->speed_ = 200.0f;
- this->slowDownRate_ = -10.0f;
+ this->speed_ = 100.0f;
this->setMunitionName("GravityBombMunition");
// The firing sound of the Rocket is played in Rocket.cc (because of OpenAl sound positioning)
@@ -40,8 +39,7 @@
this->computeMuzzleParameters(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getAimPosition());
bomb->setOrientation(this->getMuzzleOrientation());
bomb->setPosition(this->getMuzzlePosition());
- bomb->setVelocity(this->getMuzzleDirection() * this->speed_);
- bomb->setAcceleration(this->getMuzzleDirection()* this->slowDownRate_);
+ bomb->setVelocity(this->getMuzzleDirection() * (this->speed_+this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn()->getVelocity().length()));
bomb->setShooter(this->getWeapon()->getWeaponPack()->getWeaponSystem()->getPawn());
bomb->setDamage(this->getDamage());
Modified: code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.h
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.h 2015-04-23 14:08:35 UTC (rev 10390)
+++ code/branches/weaponFS15/src/modules/weapons/weaponmodes/GravityBombFire.h 2015-04-23 14:19:02 UTC (rev 10391)
@@ -57,7 +57,6 @@
private:
float speed_; //!< The initial speed of the bomb when it is launched.
- float slowDownRate_;
};
}
More information about the Orxonox-commit
mailing list