//--------------------------------------
// Dance Inducer Gun
//--------------------------------------

//--------------------------------------------------------------------------
// Explosion
//--------------------------------------
datablock ParticleData(DanceExplosionParticle1)
{
   dragCoefficient      = 2;
   gravityCoefficient   = 0.0;
   inheritedVelFactor   = 0.2;
   constantAcceleration = -0.0;
   lifetimeMS           = 600;
   lifetimeVarianceMS   = 000;
   textureName          = "special/crescent4";
   colors[0] = "1.0 0.1 1.0 1.0";
   colors[1] = "0.7 0.1 1.0 1.0";
   colors[2] = "0.0 0.0 1.0 0.0";
   sizes[0]      = 0.25;
   sizes[1]      = 0.5;
   sizes[2]      = 1.0;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(DanceExplosionEmitter)
{
   ejectionPeriodMS = 7;
   periodVarianceMS = 0;
   ejectionVelocity = 2;
   velocityVariance = 1.5;
   ejectionOffset   = 0.0;
   thetaMin         = 70;
   thetaMax         = 80;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = true;
   lifetimeMS       = 200;
   particles = "DanceExplosionParticle1";
};

datablock ParticleData(DanceExplosionParticle2)
{
   dragCoefficient      = 2;
   gravityCoefficient   = 0.0;
   inheritedVelFactor   = 0.2;
   constantAcceleration = -0.0;
   lifetimeMS           = 600;
   lifetimeVarianceMS   = 000;
   textureName          = "special/blasterHit";
   colors[0] = "1.0 0.1 1.0 1.0";
   colors[1] = "0.6 0.1 1.0 0.5";
   colors[2] = "0.0 0.0 1.0 0.0";
   sizes[0]      = 0.3;
   sizes[1]      = 0.90;
   sizes[2]      = 1.50;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(DanceExplosionEmitter2)
{
   ejectionPeriodMS = 30;
   periodVarianceMS = 0;
   ejectionVelocity = 1;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 80;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = false;
   lifetimeMS       = 200;
   particles = "DanceExplosionParticle2";
};

datablock ExplosionData(DanceExplosion)
{
   soundProfile   = DanceExpSound;
   emitter[0]     = DanceExplosionEmitter;
   emitter[1]     = DanceExplosionEmitter2;
};


//--------------------------------------------------------------------------
// Projectile
//--------------------------------------

datablock LinearFlareProjectileData(DanceBolt)
{
   doDynamicClientHits = true;

   directDamage        = 0;
   directDamageType    = $DamageType::Default;
   radiusDamageType    = $DamageType::Default;
   explosion           = DanceExplosion;
   splash              = BlasterSplash;

   sound = IonBoltProjectileSound;

   grenadeElasticity = 0.998;
   grenadeFriction   = 0.0;
   armingDelayMS     = 500;

   dryVelocity       = 120.0;
   wetVelocity       = 100;
   velInheritFactor  = 1.0;
   fizzleTimeMS      = 1800;
   lifetimeMS        = 1800;
   explodeOnDeath    = true;
   reflectOnWaterImpactAngle = 0.0;
   explodeOnWaterImpact      = false;
   deflectionOnWaterImpact   = 0.0;
   fizzleUnderwaterMS        = -1;

   activateDelayMS = 100;

   scale             = "0.8 0.8 0.8";
   numFlares         = 10;
   flareColor        = "1.0 0.1 1.0";
   flareModTexture   = "flaremod";
   flareBaseTexture  = "flarebase";
};


//--------------------------------------------------------------------------
// Weapon
//--------------------------------------
datablock ShapeBaseImageData(DanceGunImage)
{
   className = WeaponImage;
   shapeFile = "weapon_energy.dts";
   item = DanceGun;
   projectile = DanceBolt;
   projectileType = LinearFlareProjectile;

   usesEnergy = true;
   fireEnergy = 4;
   minEnergy = 4;

   stateName[0] = "Activate";
   stateTransitionOnTimeout[0] = "ActivateReady";
   stateTimeoutValue[0] = 0.5;
   stateSequence[0] = "Activate";
   stateSound[0] = BlasterSwitchSound;

   stateName[1] = "ActivateReady";
   stateTransitionOnLoaded[1] = "Ready";
   stateTransitionOnNoAmmo[1] = "NoAmmo";

   stateName[2] = "Ready";
   stateTransitionOnNoAmmo[2] = "NoAmmo";
   stateTransitionOnTriggerDown[2] = "Fire";

   stateName[3] = "Fire";
   stateTransitionOnTimeout[3] = "Reload";
   stateTimeoutValue[3] = 0.3;
   stateFire[3] = true;
   stateRecoil[3] = NoRecoil;
   stateAllowImageChange[3] = false;
   stateSequence[3] = "Fire";
   stateSound[3] = BlasterFireSound;
   stateScript[3] = "onFire";

   stateName[4] = "Reload";
   stateTransitionOnNoAmmo[4] = "NoAmmo";
   stateTransitionOnTimeout[4] = "Ready";
   stateAllowImageChange[4] = false;
   stateSequence[4] = "Reload";

   stateName[5] = "NoAmmo";
   stateTransitionOnAmmo[5] = "Reload";
   stateSequence[5] = "NoAmmo";
   stateTransitionOnTriggerDown[5] = "DryFire";
   
   stateName[6] = "DryFire";
   stateTimeoutValue[6] = 0.3;
   stateSound[6] = BlasterDryFireSound;
   stateTransitionOnTimeout[6] = "Ready";
};

datablock ItemData(DanceGun)
{
   className = Weapon;
   catagory = "Spawn Items";
   shapeFile = "weapon_energy.dts";
   image = DanceGunImage;
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;
   pickupRadius = 2;
	pickUpName = "a dance inducer gun";
};

function DanceBolt::onCollision(%data, %projectile, %targetObject, %modifier, %position, %normal)
{
   //Verify that they're actually an armor, rather than something else, then cause a dance.
   InitContainerRadiusSearch(%position, 5, $TypeMasks::PlayerObjectType);
//   echo("Dance Bolt: "@ %position);
   while ((%tObject = containerSearchNext()) != 0)
   {
     if(%tObject.getDataBlock().getClassName() $= "PlayerData")
     {
	%i = getRandom(8)+1;
//	echo("Inducing animation cel" @  %i);
	serverCmdPlayAnim(%tObject.client,"cel" @ %i);
     }
   }
   Parent::onCollision(%data, %projectile, %targetObject, %modifier, %position, %normal);
}

