[Orxonox-commit 5842] r10502 - code/branches/weaponFS15/src/modules/weapons/projectiles

meggiman at orxonox.net meggiman at orxonox.net
Wed May 27 16:23:45 CEST 2015


Author: meggiman
Date: 2015-05-27 16:23:44 +0200 (Wed, 27 May 2015)
New Revision: 10502

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
Log:
Bugfix: Game crashed if a pawn was directly hit by the bomb. Changed Radar Color to red.

Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc	2015-05-27 13:08:53 UTC (rev 10501)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.cc	2015-05-27 14:23:44 UTC (rev 10502)
@@ -11,7 +11,7 @@
 namespace orxonox{
 	RegisterClass(GravityBomb);
 
-	const float GravityBomb::LIFETIME = 5;  ///< The gravity bomb lifetime in seconds.
+	const float GravityBomb::LIFETIME = 2.5;  ///< The gravity bomb lifetime in seconds.
 
 	GravityBomb::GravityBomb(Context* context):
 				BasicProjectile(),
@@ -21,7 +21,7 @@
 			RegisterObject(GravityBomb);
 
 			this->setMass(10.0);
-			this->isDetonated_ = false;
+			this->hasCollided_ = false;
 			if (GameMode::isMaster())
 			{
 				//Define CollisionType of the bomb
@@ -66,35 +66,26 @@
 
 	void GravityBomb::tick(float dt)
 	{
-			timeToLife_ -= dt;
-			if(timeToLife_ < 0)
-			{
-				//orxout(debug_output) << "bomb has stoped moving" <<endl;
-				setVelocity(Vector3::ZERO); //Stop the bomb.
-				isDetonated_ = true;
-			}
-			else
-			{
-				//orxout(debug_output)<< "Time to live:" << timeToLife_ <<endl;
-				destroyCheck(); //Every BasicProjectil has to call this method in each tick.
-			}
-			if(isDetonated_) detonate();
-			else SUPER(GravityBomb, tick, dt);
+		SUPER(GravityBomb, tick, dt);
+		timeToLife_ -= dt;
+		if (timeToLife_ < 0)
+		{
+			//orxout(debug_output) << "bomb has stoped moving" <<endl;
+			setVelocity(Vector3::ZERO); //Stop the bomb.
+			detonate();
+			this->destroy();
+		}
+		else 
+		{
+			if (hasCollided_) detonate();
+			destroyCheck(); //Bomb is going to be destroyed by destroyCheck(). As written in BasicProectile, this Method should be called by every Projectile.
+		}
 	}
 
 	bool GravityBomb::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* cs, btManifoldPoint& contactPoint)
 	{
-		if(otherObject != getShooter()) //Ensure that the bomb cannot collide with its shooter.
-		{
-			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;
-		}
+		hasCollided_ = processCollision(otherObject, contactPoint, cs);
+		return hasCollided_;
 	}
 
 	void GravityBomb::detonate()
@@ -105,7 +96,6 @@
 		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-05-27 13:08:53 UTC (rev 10501)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBomb.h	2015-05-27 14:23:44 UTC (rev 10502)
@@ -47,7 +47,7 @@
 		private:
 		static const float LIFETIME;
 
-		bool isDetonated_; //Used to check whether the Bomb has to be destroyed during next tick.
+		bool hasCollided_;
 		float timeToLife_; //Time the bomb flies before it explodes.
 		WorldSound* bombSound_;
 	};

Modified: code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc
===================================================================
--- code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc	2015-05-27 13:08:53 UTC (rev 10501)
+++ code/branches/weaponFS15/src/modules/weapons/projectiles/GravityBombField.cc	2015-05-27 14:23:44 UTC (rev 10502)
@@ -15,7 +15,7 @@
 	
 	const float GravityBombField::FORCE_FIELD_LIFETIME = 15;
 	const float GravityBombField::FORCE_SPHERE_START_RADIUS = 250;
-	const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -500;
+	const float GravityBombField::FORCE_SPHERE_START_STRENGTH = -700;
 	const float GravityBombField::PEAK_EXPLOSION_FORCE = 5e4;
 	const float GravityBombField::FORCE_FIELD_EXPLOSION_DAMMAGE = 100;
 	const float GravityBombField::EXPLOSION_DURATION = 1;
@@ -39,9 +39,9 @@
 		setCollisionResponse(false);
 
 		//Make the Field visible on Radar and minimap.
-		this->setRadarObjectColour(ColourValue(0.2, 0.2, 1.0,1)); // Blue
+		this->setRadarObjectColour(ColourValue(1.0, 0.0, 0.2,1)); // Red
 		this->setRadarObjectShape(RadarViewable::Dot);
-		this->setRadarObjectScale(0.5f);
+		this->setRadarObjectScale(1.0f);
 		
 
 		//Attach Model




More information about the Orxonox-commit mailing list