datablock ParticleData(bombTrailParticle)
{
	dragCoefficient = 1.75;
	windCoefficient = 0;
	gravityCoefficient = 0;
	inheritedVelFactor = 0;
	constantAcceleration = 0;
	lifetimeMS = 1500;
	lifetimeVarianceMS = 500;
	textureName = "Add-Ons/Projectile_Pong/Square.png";
	spinSpeed = 0;
	spinRandomMin = -300;
	spinRandomMax = 300;
	useInvAlpha = false;

colors[0] = "1 0.5 0 0.3"; //light color
	colors[1] = "1 0.20 0 0.3"; //dark color
	colors[2] = "255 128 0 0.3"; //barley noticeable color
	sizes[0] = 0.2;
	sizes[1] = 0.4;
};
datablock ParticleEmitterData(bombTrailEmitter)
{
	ejectionPeriodMS = 15;
	periodVarianceMS = 0;
	ejectionVelocity = 1.5;
	velocityVariance = 1;
	ejectionOffset = 0.0;
	thetaMin = 0;
	thetaMax = 180;
	phiReferenceVel = 0;
	phiVariance = 360;
	overrideAdvance = false;
	particles = bombTrailParticle;
	   useEmitterColors = true;

	uiName = "Orange Pixel";
};
datablock ParticleData(bombParticle)
{
	dragCoefficient = 1.75;
	windCoefficient = 0;
	gravityCoefficient = 0;
	inheritedVelFactor = 0;
	constantAcceleration = 0;
	lifetimeMS = 1500;
	lifetimeVarianceMS = 500;
	textureName = "Add-Ons/Projectile_Pong/Square.png";
	spinSpeed = 0;
	spinRandomMin = -300;
	spinRandomMax = 300;
	useInvAlpha = false;

colors[0] = "1 0.5 0 0.3"; //light color
	colors[1] = "1 0.20 0 0.3"; //dark color
	colors[2] = "255 128 0 0.3"; //barley noticeable color
	sizes[0] = 0.1;
	sizes[1] = 0.2;
};
datablock ParticleEmitterData(bombEmitter)
{
	ejectionPeriodMS = 15;
	periodVarianceMS = 0;
	ejectionVelocity = 1.5;
	velocityVariance = 1;
	ejectionOffset = 0.0;
	thetaMin = 0;
	thetaMax = 180;
	phiReferenceVel = 0;
	phiVariance = 360;
	overrideAdvance = false;
	particles = bombParticle;

	uiName = "";
};
datablock ParticleData(bombExplosionParticle)
{
	dragCoefficient      = 5;
	gravityCoefficient   = 0.0;
	inheritedVelFactor   = 1.0;
	constantAcceleration = 0.0;
	lifetimeMS           = 500;
	lifetimeVarianceMS   = 300;
	textureName          = "Add-Ons/Projectile_Pong/Square.png";
	spinSpeed		= 0.0;
	spinRandomMin		= -0.0;
	spinRandomMax		= 0.0;
colors[0] = "1 0.5 0 0.3"; //light color
	colors[1] = "1 0.20 0 0.3"; //dark color
	colors[2] = "255 128 0 0.3"; //barley noticeable color
	sizes[0]      = 3.9;
	sizes[1]      = 5.4;
};

datablock ParticleEmitterData(bombExplosionEmitter)
{
   ejectionPeriodMS = 7;
   periodVarianceMS = 0;
   ejectionVelocity = 5;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "bombExplosionParticle";

   useEmitterColors = true;

   uiName = "";
};
datablock ParticleData(bombExplosion2Particle)
{
   dragCoefficient      = 10;
   gravityCoefficient   = 0.0;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 300;
   lifetimeVarianceMS   = 290;
   spinSpeed		= 0.0;
	spinRandomMin		= -150.0;
	spinRandomMax		= 150.0;
   textureName          = "Add-Ons/Projectile_Pong/Square.png";
 colors[0] = "1 0.5 0 0.3"; //light color
	colors[1] = "1 0.20 0 0.3"; //dark color
	colors[2] = "255 128 0 0.3"; //barley noticeable color

   sizes[0]      = 0.0;
   sizes[1]      = 0.7;
   sizes[2]      = 2.0;

   times[0] = 0.0;
   times[1] = 0.9;
   times[2] = 1.0;
};

datablock ParticleEmitterData(bombExplosion2Emitter)
{
	lifeTimeMS = 50;

   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 15;
   velocityVariance = 4.0;
   ejectionOffset   = 2.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "bombExplosion2Particle";

   uiName = "";
};
datablock ParticleData(bombsmokeParticle)
{
	dragCoefficient      = 8;
	gravityCoefficient   = 1;
	inheritedVelFactor   = 0.2;
	constantAcceleration = 0.0;
	lifetimeMS           = 150;
	lifetimeVarianceMS   = 400;
	textureName          = "base/data/particles/cloud";
	spinSpeed		= 10.0;
	spinRandomMin		= -50.0;
	spinRandomMax		= 50.0;
colors[0] = "1 0.5 0 0.3"; //light color
	colors[1] = "1 0.20 0 0.3"; //dark color
	colors[2] = "255 128 0 0.3"; //barley noticeable color
	sizes[0]      = 4.6;
	sizes[1]      = 7.6;

	useInvAlpha = true;
};
datablock ParticleEmitterData(bombsmokeEmitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 2;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 89;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "bombsmokeParticle";

   useEmitterColors = true;
   uiName = "";
};
datablock ExplosionData(bombExplosion)
{
   //explosionShape = "";
	soundProfile = pixelexplodeSound;
	   explosionShape = "Add-Ons/Weapon_Rocket_Launcher/explosionSphere1.dts";

   lifeTimeMS = 150;

   particleEmitter = bombExplosionEmitter;
   particleDensity = 10;
   particleRadius = 0.2;

   emitter[0] = bombsmokeEmitter;
   emitter[1] = bombExplosion2Emitter;
   

   faceViewer     = true;
   explosionScale = "1 1 1";

   shakeCamera = false;
   camShakeFreq = "10.0 11.0 10.0";
   camShakeAmp = "1.0 1.0 1.0";
   camShakeDuration = 0.5;
   camShakeRadius = 10.0;

   // Dynamic light
   lightStartRadius = 10;
   lightEndRadius = 25;
   lightStartColor = "1 1 0 1";
   lightEndColor = "0 0 0";
   
   damageRadius = 8;
   radiusDamage = 100;

   impulseRadius = 10;
   impulseForce = 4000;
};
AddDamageType("bomb", '<bitmap:Add-Ons/Weapon_PixelSpells/ci_bomb> %1', '%2 <bitmap:Add-Ons/Weapon_PixelSpells/ci_bomb> %1', 0.2, 1);
datablock ProjectileData(bombProjectile)
{
   projectileShapeName = "base/data/shapes/empty.dts";
   directDamage        = 0;
   directDamageType  = $DamageType::bomb;
   radiusDamageType  = $DamageType::bomb;
   impactImpulse	   = 200;
   verticalImpulse	   = 200;
   explosion           = bombExplosion;
   particleEmitter     = bombTrailEmitter;

   brickExplosionRadius			= 0;
   brickExplosionImpact			= false;
   brickExplosionForce				= 0;
   brickExplosionMaxVolume			= 0;
   brickExplosionMaxVolumeFloating	= 0;

   muzzleVelocity      = 45;
   velInheritFactor    = 0;
   explodeOnDeath = true;
     explodeOnPlayerImpact = true;

   armingDelay         = 2500; 
   lifetime            = 1250;
   fadeDelay           = 3000;
   bounceElasticity    = 0.4;
   bounceFriction      = 0.3;
   isBallistic         = true;
   gravityMod = 1.0;

   hasLight    = true;
   lightRadius = 5.0;
   lightColor  = "1 0.5 0 1";

   uiName = "Pixel Bomb";
};
datablock ItemData(bombItem)
{
	category = "Weapon";  // Mission editor category
	className = "Weapon"; // For inventory system

	 // Basic Item Properties
	shapeFile = "./pixelitem.dts";
	rotate = false;
	mass = 1;
	density = 0.2;
	elasticity = 0.2;
	friction = 0.6;
	emap = true;

	//gui stuff
	uiName = "Bomb Pixel";
	iconName = "./bomb";
	doColorShift = true;
	colorShiftColor = "0.15 0.08 0 1";

	 // Dynamic properties defined by the scripts
	image = bombImage;
	canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(bombImage)
{
   // Basic Item properties
   shapeFile = "./emptyWeapon.dts";
   emap = true;

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0; //"0.7 1.2 -0.5";
   rotation = eulerToMatrix( "0 0 0" );

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off.  
   correctMuzzleVector = true;

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "WeaponImage";

   // Projectile && Ammo.
   item = BowItem;
   ammo = " ";
   projectile = bombProjectile;
   projectileType = Projectile;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = true;
   

   doColorShift = true;
   colorShiftColor = bombItem.colorShiftColor;//"0.400 0.196 0 1.000";
   
    minShotTime = 700; 
   
   	stateName[0]                     = "Activate";
	stateTimeoutValue[0]             = 0.40;
	stateTransitionOnTimeout[0]       = "Ready";
	stateSound[0]					= pixelequip4Sound;
	stateEmitter[0] 				= bombEmitter;
	stateEmitterTime[0]            = 600;

	stateName[1]                     = "Ready";
	stateTransitionOnTriggerDown[1]  = "Fire";
	stateAllowImageChange[1]         = true;
	stateSequence[1]	= "Ready";

	stateName[2]                    = "Fire";
	stateTransitionOnTimeout[2]     = "Smoke";
	stateTimeoutValue[2]            = 0.14;
	stateFire[2]                    = true;
	stateAllowImageChange[2]        = false;
	stateSequence[2]                = "Fire";
	stateScript[2]                  = "onFire";
	stateWaitForTimeout[2]			= true;
	stateSound[2]					= pixelfire3Sound;

	stateName[3] = "Smoke";
	stateTimeoutValue[3]            = 0.70;
	stateTransitionOnTimeout[3]     = "Reload";

	stateName[4]			= "Reload";
	stateSequence[4]                = "Reload";
	stateTransitionOnTriggerUp[4]     = "Ready";
	stateSequence[4]	= "Ready";

};

function bombImage::onFire(%this,%obj,%slot)
{
	if(%obj.getDamagePercent() < 1.0)
	%obj.playThread(2, shiftAway);
	%obj.spawnExplosion(feedbackProjectile,"1 1 1");
	Parent::onFire(%this,%obj,%slot);	
}
function bombProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
	serverPlay3D(pixelhitSound,%obj.getTransform());
}
function bombItem::onAdd(%this, %obj)
{
%obj.canPickup = true;

%obj.playThread(0, rotate);
%obj.rotate = true;
Parent::onAdd(%this, %obj);
}
