//CHECK THE TIMER

if(gunTimer > 0)
{
	--gunTimer;
}

for(var i = 0; i < pinv.sizeInventory; ++i)
{
    if(pinv.getItemInSlot(i) == null)
    {
    continue;
    }

if(gunTimer <= 0)
{
	var distance = 128;		//The distance the cell can travel
	
	//Get the look vector
	
	var plyrPos = player.position;
	var lookVec = player.lookVec;
	var target = player.lookVec.scale(distance).add(plyrPos);

	//Did we hit anything?
	
	var rayRslt = player.rayTrace(plyrPos, target);
	var posHit = rayRslt[0];
	var blockHit = rayRslt[1];
	var entityHit = rayRslt[2];
	
	if(entityHit != null)
	{
		var entHp = entityHit.getHealth();
		entityHit.heal(-5);
	}

    if(pinv.getItemInSlot(i).getItemID() == 613) //Plasma Gun = 998
    {
        gun = pinv.getItemInSlot(i)
	
        if(gun.getDamage() >= 30)
        {
             for(var i = 0; i < pinv.sizeInventory; ++i)
             {
                 if(pinv.getItemInSlot(i) == null)
                 {
                         continue;
                     }
       
                     if(pinv.getItemInSlot(i).getItemID() == 487) //Plasme Cell = 999
                     {
                          pinv.decrementItem(i, 30);
                          gun.setDamage(0);
						  sound.playSoundUI("items.MP7.reload");
                          break;
                     }
                  }
             }
 
             gun.setDamage(gun.getDamage() -1);
             break;
        }
   }

	//Play the sound! GO BANG!!!!
	sound.playSoundUI("items.mp7.fire");

	//Draw Paticles
	if(posHit.distance(plyrPos) != null)
	{
		var dist= posHit.distance(plyrPos);

		for(var i = 0; i < dist; ++i)

		{
			if(Math.random() <= .1)
			{
			//ONLY PAINT 2 PARTICLES!

			plyrPos.add(lookVec);
			//Plasma Cells are Cyan (0, 255, 255)
			effect.spawnParticle("smoke", plyrPos.x+0.5*Math.random()-0.25, plyrPos.y+0.5*Math.random()-0.25, plyrPos.z+0.5*Math.random()-0.25, 0, 0, 0);
			}
		}
	
	}

	//SET THE TIMER
	gunTimer = 1.1;
}

