//--------------------------------------
// FireworksGun
//--------------------------------------
//--------------------------------------------------------------------------
// Force-Feedback Effects
//--------------------------------------
datablock EffectProfile(FireworksGunSwitchEffect)
{
   effectname = "weapons/plasma_rifle_activate";
   minDistance = 2.5;
   maxDistance = 2.5;
};

datablock EffectProfile(FireworksGunFireEffect)
{
   effectname = "weapons/plasma_fire";
   minDistance = 2.5;
   maxDistance = 2.5;
};

datablock EffectProfile(FireworksGunDryFireEffect)
{
   effectname = "weapons/plasma_dryfire";
   minDistance = 2.5;
   maxDistance = 2.5;
};

datablock EffectProfile(FireworksGunIdleEffect)
{
   effectname = "weapons/plasma_rifle_idle";
   minDistance = 2.5;
};

datablock EffectProfile(FireworksGunReloadEffect)
{
   effectname = "weapons/plasma_rifle_reload";
   minDistance = 2.5;
   maxDistance = 2.5;
};

datablock EffectProfile(FireworksGunExpEffect)
{
   effectname = "explosions/explosion.xpl10";
   minDistance = 500;
   maxDistance = 500;
};

//--------------------------------------------------------------------------
// Sounds
//--------------------------------------
datablock AudioProfile(FireworksGunSwitchSound)
{
   filename    = "fx/weapons/plasma_rifle_activate.wav";
   description = AudioClosest3d;
   preload = true;
   effect = FireworksGunSwitchEffect;
};

datablock AudioProfile(FireworksGunFireSound)
{
   filename    = "fx/weapons/plasma_rifle_fire.wav";
   description = AudioDefault3d;
   preload = true;
   effect = FireworksGunFireEffect;
};

datablock AudioProfile(FireworksGunIdleSound)
{
   filename    = "fx/weapons/plasma_rifle_idle.wav";
   description = ClosestLooping3d;
   preload = true;
};

datablock AudioProfile(FireworksGunReloadSound)
{
   filename    = "fx/weapons/plasma_rifle_reload.wav";
   description = Audioclosest3d;
   preload = true;
   effect = FireworksGunReloadEffect;
};

datablock AudioProfile(FireworksGunExpSound)
{
   filename    = "fx/powered/turret_mortar_explode.wav";
   description = AudioBIGExplosion3d;
   effect = FireworksGunExpEffect;
   minDistance = 500;
   maxDistance = 500;
};

datablock AudioProfile(FireworksGunProjectileSound)
{
   filename    = "fx/weapons/plasma_rifle_projectile.WAV";
   description = ProjectileLooping3d;
   preload = true;
};

datablock AudioProfile(FireworksGunDryFireSound)
{
   filename    = "fx/weapons/plasma_dryfire.wav";
   description = AudioClose3d;
   preload = true;
   effect = FireworksGunDryFireEffect;
};

datablock AudioProfile(FireworksGunFireWetSound)
{
   filename    = "fx/weapons/plasma_fizzle.wav";
   description = AudioClose3d;
   preload = true;
};
//--------------------------------------------------------------------------
// FireworksGun Particle effects
//--------------------------------------------------------------------------
//blue burst
datablock ParticleData(Fw1Sparks)
{
   dragCoefficient      = 0;
   gravityCoefficient   = 1.0;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 5000;
   lifetimeVarianceMS   = 3500;
   textureName          = "special/bigSpark";
   colors[0]     = "0.56 0.36 1.0 1.0";
   colors[1]     = "0.56 0.36 1.0 1.0";
   colors[2]     = "1.0 0.36 1.0 0.0";
   sizes[0]      = 5;
   sizes[1]      = 2.5;
   sizes[2]      = 2.5;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;

};

datablock ParticleEmitterData(Fw1Emitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 120;
   velocityVariance = 67.75;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = true;
   lifetimeMS       = 100;
   particles = "fw1Sparks";
};

/////////////
//red burst
datablock ParticleData(Fw2Sparks)
{
   dragCoefficient      = 2;
   gravityCoefficient   = 0.5;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 4000;
   lifetimeVarianceMS   = 3500;
   textureName          = "special/bigSpark";
   colors[0]     = "1 0.5 0.5 1.0";
   colors[1]     = "1 0.35 0.35 1.0";
   colors[2]     = "0.5 0.2 0.2 0.0";
   sizes[0]      = 5;
   sizes[1]      = 2.5;
   sizes[2]      = 2.5;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(Fw2Emitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 100;
   velocityVariance = 67.75;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = true;
   lifetimeMS       = 100;
   particles = "fw2Sparks";
};

///////////////
//purple crescents
datablock ParticleData( Fw3Particle)
{
   dragCoefficient      = 0;
   gravityCoefficient   = 0;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 1000;
   lifetimeVarianceMS   = 900;
   textureName          = "special/crescent3";
   colors[0] = "0.8 0.8 1.0 1.00";
   colors[1] = "0.8 0.5 1.0 0.20";
   colors[2] = "0.2 0.8 1.0 0.0";
   sizes[0]      = 20.0;
   sizes[1]      = 40.0;
   sizes[2]      = 50.0;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData( Fw3Emitter )
{
   ejectionPeriodMS = 2;
   periodVarianceMS = 0;
   ejectionVelocity = 90;
   velocityVariance = 30;
   ejectionOffset   = 2;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = true;
   lifetimeMS       = 100;
   particles = "Fw3Particle";
};


////////////////////////////
//white burst
datablock ParticleData(Fw4Sparks)
{
   dragCoefficient      = 2;
   gravityCoefficient   = 1;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 4000;
   lifetimeVarianceMS   = 2500;
   textureName          = "special/crescent3";
   colors[0]     = "1 1 1 1";
   colors[1]     = "1 1 1 1";
   colors[2]     = "1 1 1 0";
   sizes[0]      = 3;
   sizes[1]      = 2;
   sizes[2]      = 2;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;

};

datablock ParticleEmitterData(Fw4Emitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 55;
   velocityVariance = 40;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = true;
   lifetimeMS       = 100;
   particles = "fw4Sparks";
};

///////////////////////
//yellow burst
datablock ParticleData(Fw5Sparks)
{
   dragCoefficient      = 2;
   gravityCoefficient   = 2.0;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 3000;
   lifetimeVarianceMS   = 1500;
   textureName          = "special/bigSpark";
   colors[0]     = "0.66 0.66 0.46 1.0";
   colors[1]     = "0.56 0.36 0.26 1.0";
   colors[2]     = "1.0 0.36 0.26 0.0";
   sizes[0]      = 5;
   sizes[1]      = 2.5;
   sizes[2]      = 2.5;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(Fw5Emitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 120;
   velocityVariance = 67.75;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = true;
   lifetimeMS       = 100;
   particles = "fw5Sparks";
};

////////////////////
//clouds
datablock ParticleData(Fw6Sparks)
{
   dragCoefficient      = 2;
   gravityCoefficient   = 0.5;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 6000;
   lifetimeVarianceMS   = 3500;
   textureName          = "special/LightFalloffMono";
   colors[0]     = "0.05 0.05 0.05 1";
   colors[1]     = "0.2 0.2 0.2 1";
   colors[2]     = "0.1 0.1 0.1 1";
   sizes[0]      = 20;
   sizes[1]      = 45;
   sizes[2]      = 65;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};


datablock ParticleEmitterData(Fw6Emitter)
{
   ejectionPeriodMS = 50;
   periodVarianceMS = 10;
   ejectionVelocity = 5;
   velocityVariance = 2;
   ejectionOffset   = 0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = true;
   lifetimeMS       = 6;
   particles = "fw6Sparks";
};

///////////////
//red flare
datablock ParticleData(Fw7Sparks)
{
   dragCoefficient      = 2;
   gravityCoefficient   = 3.0;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 40000;
   lifetimeVarianceMS   = 3000;
   textureName          = "special/flare3";
   colors[0]     = "1 1 1 1";
   colors[1]     = "1 1 1 1";
   colors[2]     = "1 1 1 0";
   sizes[0]      = 5;
   sizes[1]      = 2.5;
   sizes[2]      = 2.5;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(Fw7Emitter)
{
   ejectionPeriodMS = 4;
   periodVarianceMS = 2;
   ejectionVelocity = 50;
   velocityVariance = 47;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = false;
   lifetimeMS       = 100;
   particles = "fw7Sparks";
};

////////////////////
//clouds
datablock ParticleData(FwCloudSparks)
{
   dragCoefficient      = 3;
   gravityCoefficient   = 0.1;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 8000;
   lifetimeVarianceMS   = 3500;
   textureName          = "special/LightFalloffMono";
   colors[0]     = "0.2 0.2 0.2 1";
   colors[1]     = "0.1 0.1 0.1 1";
   colors[2]     = "0 0 0 1";
   sizes[0]      = 10;
   sizes[1]      = 25;
   sizes[2]      = 45;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(FwCloudEmitter)
{
   ejectionPeriodMS = 10;
   periodVarianceMS = 0;
   ejectionVelocity = 100;
   velocityVariance = 80;
   ejectionOffset   = 0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = false;
   lifetimeMS       = 100;
   particles = "fwCloudSparks";
};

/////////////
//blueies
datablock ParticleData(Fw8Sparks)
{
   dragCoefficient      = 1;
   gravityCoefficient   = 0;
   inheritedVelFactor   = 0;
   constantAcceleration = 0;
   lifetimeMS           = 3501;
   lifetimeVarianceMS   = 3500;
   textureName          = "particletest";
   colors[0]     = "0.7 0.7 1 1.0";
   colors[1]     = "0.4 0.4 1 1";
   colors[2]     = "0 0.1 1 0.0";
   sizes[0]      = 5;
   sizes[1]      = 2.5;
   sizes[2]      = 2.5;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(Fw8Emitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 120;
   velocityVariance = 0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 180;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = false;
   lifetimeMS       = 150;
   particles = "fw8Sparks";
};

//--------------------------------------------------------------------------
// Explosion
//--------------------------------------
datablock ExplosionData(FireworksGunSubExplosion1)
{
   offset = 88.0;
   emitter[0] = Fw7Emitter;
   explosionShape = "energy_explosion.dts";
   scale ="7 7 7";
   playSpeed = 1.5;
};

datablock ExplosionData(FireworksGunSubExplosion2)
{
   offset = 88.0;
   emitter[0] = Fw2Emitter;
   explosionShape = "energy_explosion.dts";
   scale ="7 7 7";
   playSpeed = 1.5;
};

datablock ExplosionData(FireworksGunSubExplosion3)
{
   offset = 88.0;
   emitter[0] = Fw8Emitter;
   explosionShape = "energy_explosion.dts";
   scale ="7 7 7";
   playSpeed = 1.5;
};

datablock ExplosionData(FireworksGunSubExplosion4)
{
   offset = 88.0;
   emitter[0] = Fw4Emitter;
   explosionShape = "energy_explosion.dts";
   scale ="7 7 7";
   playSpeed = 1.5;
};

datablock ExplosionData(FireworksGunSubExplosion5)
{
   offset = 88.0;
   emitter[0] = Fw5Emitter;
   explosionShape = "energy_explosion.dts";
   scale ="7 7 7";
   playSpeed = 1.5;
};

datablock ExplosionData(FireworksGunSubExplosion6)
{
   offset = 88.0;
   emitter[0] = Fw6Emitter;
   explosionShape = "energy_explosion.dts";
   scale ="7 7 7";
   playSpeed = 1.5;
};

datablock ExplosionData(FireworksGunSubExplosion7)
{
   offset = 88.0;
   emitter[0] = Fw7Emitter;
   explosionShape = "energy_explosion.dts";
   scale ="7 7 7";
   playSpeed = 1.5;
};

datablock ExplosionData(FireworksGunExplosion)
{
   soundProfile   = FireworksGunExpSound;

   emitter[0]     = Fw8Emitter;

   subExplosion[0] = FireworksGunSubExplosion1;
   subExplosion[1] = FireworksGunSubExplosion2;
   subExplosion[2] = FireworksGunSubExplosion3;
   subExplosion[3] = FireworksGunSubExplosion4;
   subExplosion[4] = FireworksGunSubExplosion5;
   subExplosion[5] = FireworksGunSubExplosion6;
   subExplosion[6] = FireworksGunSubExplosion7;

   shakeCamera = true;
   camShakeFreq = "12.0 13.0 11.0";
   camShakeAmp = "35.0 35.0 35.0";
   camShakeDuration = 1.0;
   camShakeRadius = 15.0;
};

//--------------------------------------------------------------------------
// Projectile
//--------------------------------------
datablock LinearFlareProjectileData(Fireworks)
{
   projectileShapeName = "weapon_missile_projectile.dts";
   scale               = "5.0 5.0 5.0";
   faceViewer          = true;
   directDamage        = 0.0;
   hasDamageRadius     = false;
   indirectDamage      = 0;
   damageRadius        = 0;
   kickBackStrength    = 0.0;
   radiusDamageType    = $DamageType::Plasma;

   explosion           = "FireworksGunExplosion";

   dryVelocity       = 95.0;
   wetVelocity       = -1;
   velInheritFactor  = 0.3;
   fizzleTimeMS      = 3500;
   lifetimeMS        = 3500;
   explodeOnDeath    = true;
   reflectOnWaterImpactAngle = 0.0;
   explodeOnWaterImpact      = true;
   deflectionOnWaterImpact   = 0.0;
   fizzleUnderwaterMS        = -1;

   activateDelayMS = -1;

   size[0]           = 1.2;
   size[1]           = 1.5;
   size[2]           = 1.1;


   numFlares         = 50;
   flareColor        = "0.25 0.25 1";
   flareModTexture   = "flaremod";
   flareBaseTexture  = "flarebase";

	sound        = FireworksGunProjectileSound;
   fireSound    = FireworksGunFireSound;
   wetFireSound = FireworksGunFireWetSound;

   hasLight    = true;
   lightRadius = 3.0;
   lightColor  = "1 0.75 0.25";
};

//--------------------------------------------------------------------------
// Ammo
//--------------------------------------

datablock ItemData(FireworksGunAmmo)
{
   className = Ammo;
   catagory = "Ammo";
   shapeFile = "ammo_plasma.dts";
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;
   pickupRadius = 2;
	pickUpName = "some gun powder";
};

//--------------------------------------------------------------------------
// Weapon
//--------------------------------------
datablock ItemData(FireworksGun)
{
   className = Weapon;
   catagory = "Spawn Items";
   shapeFile = "weapon_plasma.dts";
   image = FireworksGunImage;
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;
   pickupRadius = 2;
	pickUpName = "a fireworks gun";
};

datablock ShapeBaseImageData(FireworksGunImage)
{
   className = WeaponImage;
   shapeFile = "weapon_plasma.dts";
   item = FireworksGun;
   ammo = FireworksGunAmmo;
   offset = "0 0 0";

   projectile = Fireworks;
   projectileType = LinearFlareProjectile;
   
   isfireworks = true;
   
   projectileSpread = 0.0 / 1000.0;

   stateName[0]                     = "Activate";
   stateTransitionOnTimeout[0]      = "ActivateReady";
   stateSound[0]                    = FireworksGunSwitchSound;
   stateTimeoutValue[0]             = 0.5;
   stateSequence[0]                 = "Activate";

   stateName[1]                     = "ActivateReady";
   stateTransitionOnLoaded[1]       = "Ready";
   stateTransitionOnNoAmmo[1]       = "NoAmmo";

   stateName[2]                     = "Ready";
   stateTransitionOnNoAmmo[2]       = "NoAmmo";
   stateTransitionOnTriggerDown[2]  = "CheckWet";

// ----------------------
// Multiple Projectiles
// there are 6 shots per fire
   stateName[3]                     = "Fire";
   stateSequence[3]                 = "Fire";
   stateSequenceRandomFlash[3]      = true;
   stateTimeoutValue[3]             = 0;
   stateTransitionOnTimeout[3]      = "Fire1";
   stateFire[3]                     = true;
   stateAllowImageChange[3]         = false;
   stateScript[3]                   = "onFire";
   stateEjectShell[3]               = false;

   stateName[4]                     = "Fire1";
   stateSequence[4]                 = "Fire1";
   stateSequenceRandomFlash[4]	= true;
   stateTimeoutValue[4]             = 0;
   stateTransitionOnTimeout[4]      = "Fire2";
   stateFire[4]                     = true;
   stateAllowImageChange[4]         = false;
   stateScript[4]                   = "onFire";
   stateEjectShell[4]			= false;

   stateName[5]                     = "Fire2";
   stateSequence[5]                 = "Fire2";
   stateSequenceRandomFlash[5]	= true;
   stateTimeoutValue[5]             = 0;
   stateTransitionOnTimeout[5]      = "Reload";
   stateFire[5]                     = true;
   stateAllowImageChange[5]         = false;
   stateScript[5]                   = "onFire";
   stateEjectShell[5]			= false;

   stateName[6]                     = "Reload";
   stateTransitionOnTimeout[6]      = "Ready";
   stateTransitionOnNoAmmo[6]		= "NoAmmo";
   stateTimeoutValue[6]             = 0.5;
   stateAllowImageChange[6]         = false;
   stateSequence[6]                 = "Reload";
   stateSound[6]				= FireworksGunReloadSound;

   stateName[7]				= "CheckWet";
   stateTransitionOnWet[7]		= "Fire";
   stateTransitionOnNotWet[7]	= "Fire";

   stateName[8]				= "NoAmmo";
   stateTransitionOnAmmo[8]		= "Reload";
   stateTransitionOnTriggerDown[8]	= "DryFire";
   stateSequence[8]			= "NoAmmo";

   stateName[9]				= "DryFire";
   stateSound[9]				= FireworksGunDryFireSound;
   stateTimeoutValue[9]		= 0.5;
   stateTransitionOnTimeout[9]	= "NoAmmo";
};

datablock ShapeBaseImageData(FireworksImage1) : FireworksGunImage
{
   shapeFile = "weapon_grenade_launcher.dts";
   offset = "0.3 0 0";
   rotation = "0 1 0 45";
   scale = "10 10 10";
   stateScript[3] = "onFire";
   stateScript[4] = "onFire";
   stateScript[5] = "onFire";
};

datablock ShapeBaseImageData(FireworksImage2) : FireworksGunImage
{
   shapeFile = "weapon_grenade_launcher.dts";
   offset = "-0.3 0 0";
   rotation = "0 1 0 -45";
   scale = "10 10 10";
   stateScript[3] = "onFire";
   stateScript[4] = "onFire";
   stateScript[5] = "onFire";
};

function FireworksGunImage::onMount(%this,%obj,%slot)
{
   Parent::onMount(%this,%obj,%slot);
   %obj.mountImage(FireworksImage1,4);
   %obj.mountImage(FireworksImage2,5);
}

function FireworksGunImage::onUnmount(%this, %obj, %slot)
{
   Parent::onMount(%this,%obj,%slot);
   %obj.unmountImage(4);
   %obj.unmountImage(5);
}
