//--------------------------------------
// RPG launcher
//--------------------------------------

datablock AudioProfile(RPGFireSound)
{
   filename    = "fx/vehicles/bomber_turret_fire.wav";
   description = AudioDefault3d;
   preload = true;
   effect = FireEffect;
};

datablock AudioProfile(RPGReloadSound)
{
   filename    = "fx/vehicles/bomber_turret_reload.wav";
   description = AudioDefault3d;
   preload = true;
   effect = FireEffect;
};

//------------------------------------
// Smoke
//------------------------------------

datablock ParticleData(RPGSmokeParticle)
{
   dragCoeffiecient     = 0.0;
   gravityCoefficient   = -0.2;   // rises slowly
   inheritedVelFactor   = 0.00;

   lifetimeMS           = 700;  // lasts 2 second
   lifetimeVarianceMS   = 150;   // ...more or less

   textureName          = "particleTest";

   useInvAlpha = false;
   spinRandomMin = -30.0;
   spinRandomMax = 30.0;

   colors[0]     = "0.9176 0.2901 0.1098 1.0";
   colors[1]     = "1.0 0.6274 0.1137 0.5";
   colors[2]     = "1.0 0.1 0.1 0.0";

   sizes[0]      = 0.25;
   sizes[1]      = 1.0;
   sizes[2]      = 2.0;

   times[0]      = 0.0;
   times[1]      = 0.2;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(RPGSmokeEmitter)
{
   ejectionPeriodMS = 15;
   periodVarianceMS = 5;

   ejectionVelocity = 4.0;  // A little oomph at the back end
   velocityVariance = 0.50;

   thetaMin         = 0.0;
   thetaMax         = 25.0;

   particles = "RPGSmokeParticle";
};

//--------------------------------------------------------------------------
// Projectile
//--------------------------------------
datablock LinearProjectileData(RPGProjectile)
{
   projectileShapeName = "grenade_projectile.dts";
   emitterDelay        = -1;
   directDamage        = 0.0;
   hasDamageRadius     = true;
   indirectDamage      = 0.3;
   damageRadius        = 10.0;
   radiusDamageType    = $DamageType::Grenade;
   kickBackStrength    = 2500;
   bubbleEmitTime      = 1.0;

   sound 				= GrenadeProjectileSound;
   explosion           = "GrenadeExplosion";
   underwaterExplosion = "UnderwaterGrenadeExplosion";
   splash              = GrenadeSplash;

   baseEmitter         = RPGSmokeEmitter;
   bubbleEmitter       = GrenadeBubbleEmitter;

   dryVelocity       = 75;
   wetVelocity       = 65;
   velInheritFactor  = 0.5;
   fizzleTimeMS      = 5000;
   lifetimeMS        = 5000;
   explodeOnDeath    = true;
   //reflectOnWaterImpactAngle = 15.0;
   explodeOnWaterImpact      = false;
   //deflectionOnWaterImpact   = 0.0;
   fizzleUnderwaterMS        = 5000;

   activateDelayMS = -1;

   hasLight    = true;
   lightRadius = 6.0;
   lightColor  = "0.5 0.35 0.1";
};

//--------------------------------------------------------------------------
// Ammo
//--------------------------------------

datablock ItemData(RPGAmmo)
{
   className = Ammo;
   catagory = "Ammo";
   shapeFile = "ammo_disc.dts";
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;
   pickupRadius = 2;
	pickUpName = "some ray gun capacitors";
};

//--------------------------------------------------------------------------
// Weapon
//--------------------------------------

datablock ShapeBaseImageData(RPGImage)
{
   className = WeaponImage;
   shapeFile = "weapon_disc.dts";
   item = RPG;
   ammo = RPGAmmo;
   offset = "0 0 0";
   emap = true;

   projectile = RPGProjectile;
   projectileType = LinearProjectile;

   // State Data
   stateName[0]                     = "Preactivate";
   stateTransitionOnLoaded[0]       = "Activate";
   stateTransitionOnNoAmmo[0]       = "NoAmmo";

   stateName[1]                     = "Activate";
   stateTransitionOnTimeout[1]      = "Ready";
   stateTimeoutValue[1]             = 0.5;
   stateSequence[1]                 = "Activated";
   stateSound[1]                    = BlasterSwitchSound;

   stateName[2]                     = "Ready";
   stateTransitionOnNoAmmo[2]       = "NoAmmo";
   stateTransitionOnTriggerDown[2]  = "Fire";
   stateSequence[2]                 = "DiscSpin";
   //stateSound[2]                    = DiscLoopSound;

   stateName[3]                     = "Fire";
   stateTransitionOnTimeout[3]      = "Reload";
   stateTimeoutValue[3]             = 0.5;
   stateFire[3]                     = true;
   stateRecoil[3]                   = LightRecoil;
   stateAllowImageChange[3]         = false;
   stateSequence[3]                 = "Fire";
   stateScript[3]                   = "onFire";
   stateSound[3]                    = RPGFireSound;

   stateName[4]                     = "Reload";
   stateTransitionOnNoAmmo[4]       = "NoAmmo";
   stateTransitionOnTimeout[4]      = "Ready";
   stateTimeoutValue[4]             = 0.25; // 0.25 load, 0.25 spinup
   stateAllowImageChange[4]         = false;
   stateSequence[4]                 = "Reload";
   stateSound[4]                    = RPGReloadSound;

   stateName[5]                     = "NoAmmo";
   stateTransitionOnAmmo[5]         = "Reload";
   stateSequence[5]                 = "NoAmmo";
   stateTransitionOnTriggerDown[5]  = "DryFire";

   stateName[6]                     = "DryFire";
   stateSound[6]                    = SentryTurretExpSound;
   stateTimeoutValue[6]             = 0.75;
   stateTransitionOnTimeout[6]      = "NoAmmo";
};

datablock ItemData(RPG)
{
   className = Weapon;
   catagory = "Spawn Items";
   shapeFile = "weapon_disc.dts";
   image = RPGImage;
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;
   pickupRadius = 2;
	pickUpName = "a ray gun";
   emap = true;
};

datablock ShapeBaseImageData(RPGImage2)
{
   shapeFile = "weapon_sniper.dts";
   offset = "0.0 -0.15 -0.005";
   rotation = "0.0 0.0 0.0 0";
};

datablock ShapeBaseImageData(RPGImage3)
{
   shapeFile = "weapon_targeting.dts";
   offset   = "0.0 0.0 0.0";
   rotation = "0.0 1.0 0.0 180";
};

datablock ShapeBaseImageData(RPGImage4)
{
   shapeFile = "weapon_Shocklance.dts";
   offset   = "0.1 0.0 0.0";
   rotation = "0.0 0.0 0.0 0";
};

datablock ShapeBaseImageData(RPGImage5)
{
   shapeFile = "weapon_Shocklance.dts";
   offset   = "-0.1 0.0 0.0";
   rotation = "0.0 0.0 0.0 0";
};

function RPGImage::onMount(%this,%obj,%slot)
{
   Parent::onMount(%this,%obj,%slot);
   %obj.mountImage(RPGImage2, 4);
   %obj.mountImage(RPGImage3, 5);
   %obj.mountImage(RPGImage4, 6);
   %obj.mountImage(RPGImage5, 7);
}

function RPGImage::onUnmount(%this,%obj,%slot)
{
   Parent::onUnmount(%this, %obj, %slot);
   %obj.unmountImage(4);
   %obj.unmountImage(5);
   %obj.unmountImage(6);
   %obj.unmountImage(7);
}
