Index: branches/adm/src/world_entities/weapons/bsp_weapon.cc
===================================================================
--- branches/adm/src/world_entities/weapons/bsp_weapon.cc	(revision 10690)
+++ branches/adm/src/world_entities/weapons/bsp_weapon.cc	(revision 10694)
@@ -21,7 +21,10 @@
 
 #include "environments/bsp_entity.h"
+#include "loading/fast_factory.h"
 
 ObjectListDefinition(BspWeapon);
 CREATE_FACTORY(BspWeapon);
+
+ObjectListDefinition(MuzzleFlash);
 
 /**
@@ -73,6 +76,8 @@
 		LOAD_PARAM_START_CYCLE(root, element);
 		{
-			LoadParam_CYCLE(element, "addPoint", this, BspWeapon, addPoint)
-			.describe("Adds a new Point for Gunfire");
+			if (root != 0){
+				LoadParam_CYCLE(element, "addPoint", this, BspWeapon, addPoint)
+				.describe("Adds a new Point for Gunfire");
+			}
 		}
 		LOAD_PARAM_END_CYCLE(element);
@@ -82,11 +87,7 @@
 void BspWeapon::addPoint(float x, float y, float z)
 {
-	if (element == 1 ){
-		gunFire1->setRelCoor(Vector(x,y,z));
-		element++;
-	}
-	if (element == 2 ){
-		gunFire2->setRelCoor(Vector(x,y,z));
-	}
+  gunFire.push_back( new MuzzleFlash() );
+	gunFire.back()->setParent( this->getParent() );
+	gunFire.back()->setRelCoor(x, y, z);
 }
 
@@ -107,4 +108,5 @@
 			bRate = 0;
 	}
+
 }
 
@@ -112,10 +114,9 @@
 {
 	bRate = 0;
-	bFire = true;
+	bFire = false;
 	range = 1000;
 	damage = 10;
 	fireRate = 0.5;
 	alwaysHits = true;
-	element=1;
 
 	this->registerObject(this, BspWeapon::_objectList);
@@ -123,10 +124,17 @@
 	this->aimingSystem->setParent( this );
 	this->aimingSystem->toList(OM_GROUP_00);
+	
 }
 
 void BspWeapon::shoot()
 {
-	gunFire.explode(gunFire1,Vector(2,2,2));
-	gunFire.explode(gunFire2,Vector(2,2,2));
+	//gunFirExpl.explode(gunFire1,Vector(2,2,2));
+	//gunFirExpl.explode(gunFire2,Vector(2,2,2));
+
+  for ( std::list<MuzzleFlash*>::iterator it = gunFire.begin(); it!=gunFire.end(); it++)
+	{
+    (*it)->explode( 0.2 );
+	}
+
 	std::list<WorldEntity*>::iterator entityIterator;
 	// for all bsp managers check all entities
@@ -151,9 +159,7 @@
 
 	if ( target == NULL )
-		printf("NOTING HIT\n");
+		printf("NO TARGET\n");
 	else
 	{
-		printf( "HIT %s\n", target->getClassName().c_str() );
-
 		if (!alwaysHits){
 			float r = rand();
@@ -161,6 +167,11 @@
 			float res = (target->getAbsCoor() - this->getAbsCoor()).len();
 			float p = 1 - res*res/range/range;
-			if (r < p )
+			if (r < p ){
 				hit = true;
+				printf( "HIT %s\n", target->getClassName().c_str() );
+			}
+			else
+				printf( "MISHIT %s\n", target->getClassName().c_str() );
+			
 		}
 		else hit = true;
@@ -169,9 +180,9 @@
 	if ( !hit )
 	{
-		Vector explosionPos = this->getAbsCoor() + this->getAbsDir().apply( Vector( 1, 0, 0 ) )*shortestDist;
+		//Vector explosionPos = this->getAbsCoor() + this->getAbsDir().apply( Vector( 1, 0, 0 ) )*shortestDist;
 
 		//TODO create explosion at explosionPos
 	}
-
+	
 	
 }
@@ -181,5 +192,9 @@
   WorldEntity::draw();
 
-
+  for ( std::list<MuzzleFlash*>::const_iterator it = gunFire.begin(); it!=gunFire.end(); it++)
+  {
+    (*it)->draw();
+  }
+#if 0
   glMatrixMode(GL_MODELVIEW);
   glPushMatrix();
@@ -207,4 +222,96 @@
   glPopAttrib();
   glPopMatrix();
-  
-}
+#endif
+}
+
+void MuzzleFlash::draw( ) const
+{
+  if (explosionParticles) explosionParticles->draw();
+}
+
+void MuzzleFlash::activate()
+{
+	if (unlikely(explosionParticles == NULL))
+	{
+		explosionParticles = new SpriteParticles(5000);
+		explosionParticles->setName("MuzzleFlashExplosionParticles");
+		explosionParticles->setMaterialTexture("textures/radial-trans-noise.png");
+		explosionParticles->setLifeSpan(0.1, 0);
+		explosionParticles->setRadius(0.0, 8);
+		explosionParticles->setRadius(.5, 6.0);
+		explosionParticles->setRadius(1.0, 2.0);
+		explosionParticles->setColor(0.0, 1,0.7,0,1);
+		explosionParticles->setColor(0.4, 0.8,.5,0,1);
+		explosionParticles->setColor(0.8, 0.5,0,0,.8);
+		explosionParticles->setColor(1.0, 0,0,0,.6);
+    explosionParticles->toList(OM_DEAD_TICK);
+  }
+			
+	this->emitter->setSystem(explosionParticles);
+	this->emitter->updateNode(.01);
+	this->emitter->updateNode(.01);
+	this->toList(OM_DEAD_TICK);
+	this->lifeCycle = 0.0;
+}
+
+void MuzzleFlash::explode(float lifetime)
+{
+	MuzzleFlash* explosion = this;
+	//explosion->setAbsCoor(this->getAbsCoor());
+	explosion->emitter->setSize(1, 1, 1);
+	explosion->activate();
+	explosion->lifeTime = lifetime;
+}
+
+MuzzleFlash::MuzzleFlash ()
+{
+  this->explosionParticles = NULL;
+  this->registerObject(this, MuzzleFlash::_objectList);
+  this->toList(OM_DEAD_TICK);
+
+  this->emitter = new BoxEmitter(Vector(10,10,10), 200, 45, M_2_PI);
+  this->emitter->addNodeFlags(PNODE_PROHIBIT_DELETE_WITH_PARENT);
+  this->emitter->setParent(this);
+  this->emitter->setSpread(M_PI, M_PI);
+
+  this->lifeCycle = 0.0f;
+  this->lifeTime = .5f;
+
+}
+
+
+/**
+ *  standard deconstructor
+*/
+MuzzleFlash::~MuzzleFlash ()
+{
+  delete this->emitter;
+
+  /* this is normaly done by World.cc by deleting the ParticleEngine */
+  if (explosionParticles != NULL)
+  {
+    delete explosionParticles;
+    MuzzleFlash::explosionParticles = NULL;
+  }
+}
+
+void MuzzleFlash::deactivate()
+{
+  this->emitter->setSystem(NULL);
+  this->toList(OM_DEAD);
+}
+
+
+/**
+ *  signal tick, time dependent things will be handled here
+ * @param time since last tick
+*/
+void MuzzleFlash::tick (float dt)
+{
+  this->lifeCycle += dt;
+  if(this->lifeTime < this->lifeCycle)
+    this->deactivate();
+}
+
+
+
