---------------------------------------------------------------------------------------------------------------
Charging Plasma Cannon Tutorial
---------------------------------------------------------------------------------------------------------------
This tutorial makes a Plasma Cannon weapon that charges while the fire trigger is held down, and fires when released. It has many projectile sizes and strengths based on it's level of charge. Also, the amount of ammo used is based on the size of the projectile. Recommended for only heavies. This tut uses the plasma gun damageType, you may want to add a plasma cannon damageType for it instead.
Step #1
// ------------------------------------------
// inventoryHud.cs
// ------------------------------------------

$InvWeapon[11] = "Plasma Cannon";

$NameToInv["Plasma Cannon"] = "PlasmaCannon";

1b) Add this to buyFavorites and buyDeployableFavorites

         case PlasmaCannon:
            %client.player.setInventory( PlasmaCannonAmmo, 400 );



Step #2
// ------------------------------------------
// weapons.cs
// ------------------------------------------

$WeaponsHudData[14, bitmapName]   = "gui/hud_plasma";
$WeaponsHudData[14, itemDataName] = "PlasmaCannon";
$WeaponsHudData[14, ammoDataName] = "PlasmaCannonAmmo";

$WeaponsHudCount = 14;

exec("scripts/weapons/PlasmaCannon.cs");


Step #3
// ------------------------------------------
// inventory.cs
// ------------------------------------------

3a) Add this with all the other 'case' in the function

function ShapeBase::hasAmmo( %this, %weapon )
{
   switch$ ( %weapon )
   {
      case PlasmaCannon:
         return( %this.getInventory( PlasmaCannonAmmo ) > 0 );
   }
}


3b) Add this with all the other cleared items

function ShapeBase::clearInventory(%this)
{
   %this.setInventory(PlasmaCannon, 0);
   %this.setInventory(PlasmaCannonAmmo, 0);
}


3c)

function serverCmdGiveAll(%client)
{
   if($TestCheats)
   {
      %player.setInventory(PlasmaCannon, 1);
      %player.setInventory(PlasmaCannonAmmo, 999);
   }
}


Step #4
// ------------------------------------------
// player.cs
// ------------------------------------------
4a) Add to player armor datablocks. Probably only want to give it to heavies.

max [PlasmaCannon] = 1;
max [PlasmaCannonAmmo] = 100;


4b)  Add these to function armor::applyConcussion

      if( %weaps[14] = %player.getInventory("PlasmaCannon") > 0 ) %numWeapons++;

and

      case 14:
         %player.use("PlasmaCannon");


Step #5
// ------------------------------------------
// hud.cs
// ------------------------------------------
Ignore this step if you use any server side reticle workarounds.

function clientCmdSetWeaponsHudActive(%slot)
{
   weaponsHud.setActiveWeapon(%slot);
   switch$($WeaponNames[%slot])
   {
      case "PlasmaCannon":
         reticleHud.setBitmap("gui/ret_plasma");
         reticleFrameHud.setVisible(true);
   }
}


Step #6
// ------------------------------------------
// Ammopack.cs
// ------------------------------------------
Add ammo to ammopack, to increase with it.

$ammoItem[9] = PlasmaCannonAmmo;
$numAmmoItems = 10;

datablock ItemData(AmmoPack)
{
   max[PlasmaCannonAmmo] = 50;
}


Step #7
// ------------------------------------------
// OptionsDlg.cs
// ------------------------------------------
$RemapName[$RemapCount] = "Plasma Cannon";
$RemapCmd[$RemapCount] = "usePlasmaCannon";
$RemapCount++;


Step #8
// ------------------------------------------
// ControlDefaults.cs
// ------------------------------------------

function usePlasmaCannon( %val )
{
   if ( %val )
     use( PlasmaCannon );
}


Step #9
// ------------------------------------------
// PlasmaCannon.cs
// ------------------------------------------
Create a file called PlasmaCannon.cs in your weapon's directory. Add all this into it.

//--------------------------------------
// Plasma Cannon
//--------------------------------------

//--------------------------------------------------------------------------
// Force-Feedback Effects
//--------------------------------------
datablock EffectProfile(PlasmaCannonSwitchEffect)
{
   effectname = "weapons/plasma_rifle_activate";
   minDistance = 2.5;
   maxDistance = 2.5;
};

datablock EffectProfile(PlasmaCannonFireEffect)
{
   effectname = "weapons/plasma_fire";
   minDistance = 2.5;
   maxDistance = 2.5;
};

datablock EffectProfile(PlasmaCannonDryFireEffect)
{
   effectname = "weapons/plasma_dryfire";
   minDistance = 2.5;
   maxDistance = 2.5;
};

datablock EffectProfile(PlasmaCannonIdleEffect)
{
   effectname = "weapons/plasma_rifle_idle";
   minDistance = 2.5;
};

datablock EffectProfile(PlasmaCannonReloadEffect)
{
   effectname = "weapons/plasma_rifle_reload";
   minDistance = 2.5;
   maxDistance = 2.5;
};

datablock EffectProfile(PlasmaCannonExpEffect)
{
   effectname = "explosions/explosion.xpl10";
   minDistance = 10;
   maxDistance = 25;
};

//--------------------------------------------------------------------------
// Sounds
//--------------------------------------
datablock AudioProfile(PlasmaCannonSwitchSound)
{
   filename    = "fx/weapons/plasma_rifle_activate.wav";
   description = AudioClosest3d;
   preload = true;
   effect = PlasmaCannonSwitchEffect;
};

datablock AudioProfile(PlasmaCannonFireSound)
{
   filename    = "fx/weapons/plasma_rifle_fire.wav";
   description = AudioDefault3d;
   preload = true;
   effect = PlasmaCannonFireEffect;
};

datablock AudioProfile(PlasmaCannonIdleSound)
{
   filename    = "fx/weapons/plasma_rifle_idle.wav";
   description = ClosestLooping3d;
   preload = true;
   //effect = PlasmaCannonIdleEffect;
};

datablock AudioProfile(PlasmaCannonReloadSound)
{
   filename    = "fx/weapons/plasma_rifle_reload.wav";
   description = Audioclosest3d;
   preload = true;
   effect = PlasmaCannonReloadEffect;
};

datablock AudioProfile(PlasmaCannonExpSound)
{
   filename    = "fx/explosions/explosion.xpl10.wav";
   description = AudioExplosion3d;
   effect = PlasmaCannonExpEffect;
};

datablock AudioProfile(PlasmaCannonProjectileSound)
{
   filename    = "fx/weapons/plasma_rifle_projectile.WAV";
   description = ProjectileLooping3d;
   preload = true;
};

datablock AudioProfile(PlasmaCannonDryFireSound)
{
   filename    = "fx/weapons/plasma_dryfire.wav";
   description = AudioClose3d;
   preload = true;
   effect = PlasmaCannonDryFireEffect;
};

datablock AudioProfile(PlasmaCannonFireWetSound)
{
   filename    = "fx/weapons/plasma_fizzle.wav";
   description = AudioClose3d;
   preload = true;
};
//--------------------------------------------------------------------------
// Explosion
//--------------------------------------
datablock ParticleData(PlasmaCannonExplosionParticle)
{
   dragCoefficient      = 2;
   gravityCoefficient   = 0.2;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 750;
   lifetimeVarianceMS   = 150;
   textureName          = "particleTest";
   colors[0]     = "0.56 0.36 0.26 1.0";
   colors[1]     = "0.56 0.36 0.26 0.0";
   sizes[0]      = 0.5;
   sizes[1]      = 2;
};

datablock ParticleEmitterData(PlasmaCannonExplosionEmitter)
{
   ejectionPeriodMS = 7;
   periodVarianceMS = 0;
   ejectionVelocity = 5;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 60;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   particles = "PlasmaCannonExplosionParticle";
};

datablock ExplosionData(PlasmaCannonBoltExplosion)
{
   explosionShape = "effect_plasma_explosion.dts";
   soundProfile   = PlasmaCannonExpSound;
   particleEmitter = PlasmaCannonExplosionEmitter;
   particleDensity = 150;
   particleRadius = 1.25;
   faceViewer = true;

   sizes[0] = "1.0 1.0 1.0";
   sizes[1] = "1.0 1.0 1.0";
   times[0] = 0.0;
   times[1] = 1.5;
};

datablock ExplosionData(PlasmaCannonBoltExplosion2)
{
   explosionShape = "effect_plasma_explosion.dts";
   soundProfile   = PlasmaCannonExpSound;
   particleEmitter = PlasmaCannonExplosionEmitter;
   particleDensity = 150;
   particleRadius = 2.5;
   faceViewer = true;

   sizes[0] = "1.5 1.5 1.5";
   sizes[1] = "1.5 1.5 1.5";
   times[0] = 0.0;
   times[1] = 1.5;
};

datablock ExplosionData(PlasmaCannonBoltExplosion3)
{
   explosionShape = "effect_plasma_explosion.dts";
   soundProfile   = PlasmaCannonExpSound;
   particleEmitter = PlasmaCannonExplosionEmitter;
   particleDensity = 150;
   particleRadius = 3.75;
   faceViewer = true;

   sizes[0] = "2.25 2.25 2.25";
   sizes[1] = "2.25 2.25 2.25";
   times[0] = 0.0;
   times[1] = 1.5;
};

datablock ExplosionData(PlasmaCannonBoltExplosion4)
{
   explosionShape = "effect_plasma_explosion.dts";
   soundProfile   = PlasmaCannonExpSound;
   particleEmitter = PlasmaCannonExplosionEmitter;
   particleDensity = 150;
   particleRadius = 5.00;
   faceViewer = true;

   sizes[0] = "3.375 3.375 3.375";
   sizes[1] = "3.375 3.375 3.375";
   times[0] = 0.0;
   times[1] = 1.5;
};

datablock ExplosionData(PlasmaCannonBoltExplosion5)
{
   explosionShape = "effect_plasma_explosion.dts";
   soundProfile   = PlasmaCannonExpSound;
   particleEmitter = PlasmaCannonExplosionEmitter;
   particleDensity = 150;
   particleRadius = 6.25;
   faceViewer = true;

   sizes[0] = "5.0625 5.0625 5.0625";
   sizes[1] = "5.0625 5.0625 5.0625";
   times[0] = 0.0;
   times[1] = 1.5;
};

datablock ExplosionData(PlasmaCannonBoltExplosion6)
{
   explosionShape = "effect_plasma_explosion.dts";
   soundProfile   = PlasmaCannonExpSound;
   particleEmitter = PlasmaCannonExplosionEmitter;
   particleDensity = 150;
   particleRadius = 7.5;
   faceViewer = true;

   sizes[0] = "7.59 7.59 7.59";
   sizes[1] = "7.59 7.59 7.59";
   times[0] = 0.0;
   times[1] = 1.5;
};

//--------------------------------------------------------------------------
// Splash
//--------------------------------------------------------------------------
datablock ParticleData(PlasmaCannonMist)
{
   dragCoefficient      = 2.0;
   gravityCoefficient   = -0.05;
   inheritedVelFactor   = 0.0;
   constantAcceleration = 0.0;
   lifetimeMS           = 400;
   lifetimeVarianceMS   = 100;
   useInvAlpha          = false;
   spinRandomMin        = -90.0;
   spinRandomMax       = 500.0;
   textureName          = "particleTest";
   colors[0]     = "0.7 0.8 1.0 1.0";
   colors[1]     = "0.7 0.8 1.0 0.5";
   colors[2]     = "0.7 0.8 1.0 0.0";
   sizes[0]      = 0.5;
   sizes[1]      = 0.5;
   sizes[2]      = 0.8;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData(PlasmaCannonMistEmitter)
{
   ejectionPeriodMS = 5;
   periodVarianceMS = 0;
   ejectionVelocity = 3.0;
   velocityVariance = 2.0;
   ejectionOffset   = 0.0;
   thetaMin         = 85;
   thetaMax         = 85;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   lifetimeMS       = 250;
   particles = "PlasmaCannonMist";
};

datablock ParticleData( PlasmaCannonSplashParticle2 )
{

   dragCoeffiecient     = 0.4;
   gravityCoefficient   = -0.03;   // rises slowly
   inheritedVelFactor   = 0.025;

   lifetimeMS           = 600;
   lifetimeVarianceMS   = 300;

   textureName          = "particleTest";

   useInvAlpha =  false;
   spinRandomMin = -200.0;
   spinRandomMax =  200.0;


   colors[0]     = "0.7 0.8 1.0 1.0";
   colors[1]     = "0.7 0.8 1.0 0.5";
   colors[2]     = "0.7 0.8 1.0 0.0";
   sizes[0]      = 0.5;
   sizes[1]      = 1.0;
   sizes[2]      = 2.0;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData( PlasmaCannonSplashEmitter2 )
{
   ejectionPeriodMS = 25;
   ejectionOffset = 0.2;
   periodVarianceMS = 0;
   ejectionVelocity = 2.25;
   velocityVariance = 0.50;
   thetaMin         = 0.0;
   thetaMax         = 30.0;
   lifetimeMS       = 250;

   particles = "PlasmaCannonSplashParticle2";
};


datablock ParticleData( PlasmaCannonSplashParticle )
{
   dragCoefficient      = 1;
   gravityCoefficient   = 0.2;
   inheritedVelFactor   = 0.2;
   constantAcceleration = -0.0;
   lifetimeMS           = 600;
   lifetimeVarianceMS   = 0;
   textureName          = "special/droplet";
   colors[0]     = "0.7 0.8 1.0 1.0";
   colors[1]     = "0.7 0.8 1.0 0.5";
   colors[2]     = "0.7 0.8 1.0 0.0";
   sizes[0]      = 0.5;
   sizes[1]      = 0.5;
   sizes[2]      = 0.5;
   times[0]      = 0.0;
   times[1]      = 0.5;
   times[2]      = 1.0;
};

datablock ParticleEmitterData( PlasmaCannonSplashEmitter )
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 3;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 60;
   thetaMax         = 80;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvances = false;
   orientParticles  = true;
   lifetimeMS       = 100;
   particles = "PlasmaCannonSplashParticle";
};


datablock SplashData(PlasmaCannonSplash)
{
   numSegments = 15;
   ejectionFreq = 0.0001;
   ejectionAngle = 45;
   ringLifetime = 0.5;
   lifetimeMS = 400;
   velocity = 5.0;
   startRadius = 0.0;
   acceleration = -3.0;
   texWrap = 5.0;

   texture = "special/water2";

   emitter[0] = PlasmaCannonSplashEmitter;
   emitter[1] = PlasmaCannonSplashEmitter2;
   emitter[2] = PlasmaCannonMistEmitter;

   colors[0] = "0.7 0.8 1.0 0.0";
   colors[1] = "0.7 0.8 1.0 1.0";
   colors[2] = "0.7 0.8 1.0 0.0";
   colors[3] = "0.7 0.8 1.0 0.0";
   times[0] = 0.0;
   times[1] = 0.4;
   times[2] = 0.8;
   times[3] = 1.0;
};

//--------------------------------------------------------------------------
// Projectile
//--------------------------------------
datablock ParticleData(PlasmaCannonParticle)
{
   dragCoefficient      = 2.75;
   gravityCoefficient   = 0.1;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 550;
   lifetimeVarianceMS   = 0;
   textureName          = "particleTest";
   colors[0]     = "0.46 0.36 0.26 1.0";
   colors[1]     = "0.46 0.36 0.26 0.0";
   sizes[0]      = 0.25;
   sizes[1]      = 0.20;
};

datablock ParticleEmitterData(PlasmaCannonRifleEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 10;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 12;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance  = true;
   particles = "PlasmaCannonParticle";
};



//--------------------------------------------------------------------------
// Projectile
//--------------------------------------
datablock LinearFlareProjectileData(PlasmaCannonBolt1)
{
   projectileShapeName = "plasmabolt.dts";
   scale               = "2.0 2.0 2.0";
   faceViewer          = true;
   directDamage        = 0.0;
   hasDamageRadius     = true;
   indirectDamage      = 0.3;
   damageRadius        = 5.0;
   kickBackStrength    = 0.0;
   radiusDamageType    = $DamageType::Plasma;

   explosion           = "PlasmaCannonBoltExplosion";
   splash              = PlasmaCannonSplash;

   dryVelocity       = 151.875;
   wetVelocity       = -1;
   velInheritFactor  = 0.3;
   fizzleTimeMS      = 4938;
   lifetimeMS        = 5938;
   explodeOnDeath    = false;
   reflectOnWaterImpactAngle = 0.0;
   explodeOnWaterImpact      = true;
   deflectionOnWaterImpact   = 0.0;
   fizzleUnderwaterMS        = -1;

   //activateDelayMS = 100;
   activateDelayMS = -1;

   size[0]           = 0.1;
   size[1]           = 0.25;
   size[2]           = 0.05;


   numFlares         = 35;
   flareColor        = "1 0.75 0.25";
   flareModTexture   = "flaremod";
   flareBaseTexture  = "flarebase";

	sound        = PlasmaCannonProjectileSound;
   fireSound    = PlasmaCannonFireSound;
   wetFireSound = PlasmaCannonFireWetSound;

   hasLight    = true;
   lightRadius = 3.0;
   lightColor  = "1 0.75 0.25";
};

datablock LinearFlareProjectileData(PlasmaCannonBolt2)
{
   projectileShapeName = "plasmabolt.dts";
   scale               = "3.0 3.0 3.0";
   faceViewer          = true;
   directDamage        = 0.0;
   hasDamageRadius     = true;
   indirectDamage      = 0.75;
   damageRadius        = 7.5;
   kickBackStrength    = 0.0;
   radiusDamageType    = $DamageType::Plasma;

   explosion           = "PlasmaCannonBoltExplosion2";
   splash              = PlasmaCannonSplash;

   dryVelocity       = 101.25;
   wetVelocity       = -1;
   velInheritFactor  = 0.3;
   fizzleTimeMS      = 7407;
   lifetimeMS        = 8407;
   explodeOnDeath    = true;
   reflectOnWaterImpactAngle = 0.0;
   explodeOnWaterImpact      = true;
   deflectionOnWaterImpact   = 0.0;
   fizzleUnderwaterMS        = -1;

   //activateDelayMS = 100;
   activateDelayMS = -1;

   size[0]           = 0.2;
   size[1]           = 0.5;
   size[2]           = 0.1;


   numFlares         = 35;
   flareColor        = "1 0.75 0.25";
   flareModTexture   = "flaremod";
   flareBaseTexture  = "flarebase";

	sound        = PlasmaCannonProjectileSound;
   fireSound    = PlasmaCannonFireSound;
   wetFireSound = PlasmaCannonFireWetSound;

   hasLight    = true;
   lightRadius = 3.0;
   lightColor  = "1 0.75 0.25";
};

datablock LinearFlareProjectileData(PlasmaCannonBolt3)
{
   projectileShapeName = "plasmabolt.dts";
   scale               = "4.5 4.5 4.5";
   faceViewer          = true;
   directDamage        = 0.0;
   hasDamageRadius     = true;
   indirectDamage      = 1.25;
   damageRadius        = 11.25;
   kickBackStrength    = 0.0;
   radiusDamageType    = $DamageType::Plasma;

   explosion           = "PlasmaCannonBoltExplosion3";
   splash              = PlasmaCannonSplash;

   dryVelocity       = 67.5;
   wetVelocity       = -1;
   velInheritFactor  = 0.3;
   fizzleTimeMS      = 11111;
   lifetimeMS        = 12111;
   explodeOnDeath    = true;
   reflectOnWaterImpactAngle = 0.0;
   explodeOnWaterImpact      = true;
   deflectionOnWaterImpact   = 0.0;
   fizzleUnderwaterMS        = -1;

   //activateDelayMS = 100;
   activateDelayMS = -1;

   size[0]           = 0.3;
   size[1]           = 0.75;
   size[2]           = 0.15;


   numFlares         = 35;
   flareColor        = "1 0.75 0.25";
   flareModTexture   = "flaremod";
   flareBaseTexture  = "flarebase";

	sound        = PlasmaCannonProjectileSound;
   fireSound    = PlasmaCannonFireSound;
   wetFireSound = PlasmaCannonFireWetSound;

   hasLight    = true;
   lightRadius = 3.0;
   lightColor  = "1 0.75 0.25";
};

datablock LinearFlareProjectileData(PlasmaCannonBolt4)
{
   projectileShapeName = "plasmabolt.dts";
   scale               = "6.75 6.75 6.75";
   faceViewer          = true;
   directDamage        = 0.0;
   hasDamageRadius     = true;
   indirectDamage      = 1.85;
   damageRadius        = 16.875;
   kickBackStrength    = 0.0;
   radiusDamageType    = $DamageType::Plasma;

   explosion           = "PlasmaCannonBoltExplosion4";
   splash              = PlasmaCannonSplash;

   dryVelocity       = 45.0;
   wetVelocity       = -1;
   velInheritFactor  = 0.3;
   fizzleTimeMS      = 16667;
   lifetimeMS        = 17667;
   explodeOnDeath    = true;
   reflectOnWaterImpactAngle = 0.0;
   explodeOnWaterImpact      = true;
   deflectionOnWaterImpact   = 0.0;
   fizzleUnderwaterMS        = -1;

   //activateDelayMS = 100;
   activateDelayMS = -1;

   size[0]           = 0.4;
   size[1]           = 1.0;
   size[2]           = 0.2;


   numFlares         = 35;
   flareColor        = "1 0.75 0.25";
   flareModTexture   = "flaremod";
   flareBaseTexture  = "flarebase";

	sound        = PlasmaCannonProjectileSound;
   fireSound    = PlasmaCannonFireSound;
   wetFireSound = PlasmaCannonFireWetSound;

   hasLight    = true;
   lightRadius = 3.0;
   lightColor  = "1 0.75 0.25";
};

datablock LinearFlareProjectileData(PlasmaCannonBolt5)
{
   projectileShapeName = "plasmabolt.dts";
   scale               = "10.125 10.125 10.125";
   faceViewer          = true;
   directDamage        = 0.0;
   hasDamageRadius     = true;
   indirectDamage      = 2.45;
   damageRadius        = 25.3125;
   kickBackStrength    = 0.0;
   radiusDamageType    = $DamageType::Plasma;

   explosion           = "PlasmaCannonBoltExplosion5";
   splash              = PlasmaCannonSplash;

   dryVelocity       = 30.0;
   wetVelocity       = -1;
   velInheritFactor  = 0.3;
   fizzleTimeMS      = 25000;
   lifetimeMS        = 26000;
   explodeOnDeath    = true;
   reflectOnWaterImpactAngle = 0.0;
   explodeOnWaterImpact      = true;
   deflectionOnWaterImpact   = 0.0;
   fizzleUnderwaterMS        = -1;

   //activateDelayMS = 100;
   activateDelayMS = -1;

   size[0]           = 0.5;
   size[1]           = 1.25;
   size[2]           = 0.25;


   numFlares         = 35;
   flareColor        = "1 0.75 0.25";
   flareModTexture   = "flaremod";
   flareBaseTexture  = "flarebase";

	sound        = PlasmaCannonProjectileSound;
   fireSound    = PlasmaCannonFireSound;
   wetFireSound = PlasmaCannonFireWetSound;

   hasLight    = true;
   lightRadius = 3.0;
   lightColor  = "1 0.75 0.25";
};

datablock LinearFlareProjectileData(PlasmaCannonBolt6)
{
   projectileShapeName = "plasmabolt.dts";
   scale               = "15.1875 15.1875 15.1875";
   faceViewer          = true;
   directDamage        = 0.0;
   hasDamageRadius     = true;
   indirectDamage      = 3.0;
   damageRadius        = 37.969;
   kickBackStrength    = 0.0;
   radiusDamageType    = $DamageType::Plasma;

   explosion           = "PlasmaCannonBoltExplosion6";
   splash              = PlasmaCannonSplash;

   dryVelocity       = 20.0;
   wetVelocity       = -1;
   velInheritFactor  = 0.3;
   fizzleTimeMS      = 37500;
   lifetimeMS        = 40000;
   explodeOnDeath    = true;
   reflectOnWaterImpactAngle = 0.0;
   explodeOnWaterImpact      = true;
   deflectionOnWaterImpact   = 0.0;
   fizzleUnderwaterMS        = -1;

   //activateDelayMS = 100;
   activateDelayMS = -1;

   size[0]           = 0.6;
   size[1]           = 1.5;
   size[2]           = 0.3;


   numFlares         = 35;
   flareColor        = "1 0.75 0.25";
   flareModTexture   = "flaremod";
   flareBaseTexture  = "flarebase";

	sound        = PlasmaCannonProjectileSound;
   fireSound    = PlasmaCannonFireSound;
   wetFireSound = PlasmaCannonFireWetSound;

   hasLight    = true;
   lightRadius = 3.0;
   lightColor  = "1 0.75 0.25";
};


//--------------------------------------------------------------------------
// Ammo
//--------------------------------------

datablock ItemData(PlasmaCannonAmmo)
{
   className = Ammo;
   catagory = "Ammo";
   shapeFile = "ammo_plasma.dts";
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;
   pickupRadius = 2;
	pickUpName = "some plasma cannon ammo";
};

//--------------------------------------------------------------------------
// Weapon
//--------------------------------------
datablock ItemData(PlasmaCannon)
{
   className = Weapon;
   catagory = "Spawn Items";
   shapeFile = "weapon_plasma.dts";
   image = PlasmaCannonImage;
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;
   pickupRadius = 2;
	pickUpName = "a plasma cannon";
};

datablock ShapeBaseImageData(PlasmaCannonImage)
{
   className = WeaponImage;
   shapeFile = "weapon_plasma.dts";
   item = PlasmaCannon;
   showname = "Plasma Cannon";
   ammo = PlasmaCannonAmmo;
   offset = "0 0 0";

   projectile = PlasmaCannonBolt;
   projectileType = LinearFlareProjectile;

   stateName[0] = "Activate";
   stateTransitionOnTimeout[0] = "ActivateReady";
   stateTimeoutValue[0] = 0.5;
   stateSequence[0] = "Activate";
   stateSound[0] = PlasmaCannonSwitchSound;

   stateName[1] = "ActivateReady";
   stateTransitionOnLoaded[1] = "Ready";
   stateTransitionOnNoAmmo[1] = "NoAmmo";

   stateName[2] = "Ready";
   stateTransitionOnNoAmmo[2] = "NoAmmo";
   stateTransitionOnTriggerDown[2] = "Charge";

   stateName[3] = "Charge";
   stateTransitionOnNoAmmo[3] = "NoAmmo";
   stateTransitionOnTimeout[3] = "Charge";
   stateTimeoutValue[3] = 0.1;
   stateScript[3] = "onCharge";
   stateTransitionOnTriggerUp[3] = "CheckWet";

   stateName[4] = "Fire";
   stateTransitionOnTimeout[4] = "Reload";
   stateTimeoutValue[4] = 0.1;
   stateFire[4] = true;
   stateRecoil[4] = LightRecoil;
   stateAllowImageChange[4] = false;
   stateScript[4] = "onFire";
   stateEmitterTime[4] = 0.2;
   stateSound[4] = PlasmaCannonFireSound;

   stateName[5] = "Reload";
   stateTransitionOnNoAmmo[5] = "NoAmmo";
   stateTransitionOnTimeout[5] = "Ready";
   stateTimeoutValue[5] = 0.6;
   stateAllowImageChange[5] = false;
   stateSequence[5] = "Reload";
   stateSound[5] = PlasmaCannonReloadSound;

   stateName[6] = "NoAmmo";
   stateTransitionOnAmmo[6] = "Reload";
   stateSequence[6] = "NoAmmo";
   stateTransitionOnTriggerDown[6] = "DryFire";

   stateName[7]       = "DryFire";
   stateSound[7]      = PlasmaCannonDryFireSound;
   stateTimeoutValue[7]        = 1.5;
   stateTransitionOnTimeout[7] = "NoAmmo";

   stateName[8]       = "WetFire";
   stateSound[8]      = PlasmaCannonFireWetSound;
   stateTimeoutValue[8]        = 1.5;
   stateTransitionOnTimeout[8] = "Ready";

   stateName[9]               = "CheckWet";
   stateTransitionOnWet[9]    = "WetFire";
   stateTransitionOnNotWet[9] = "Fire";
};

function PlasmaCannonImage::onCharge(%data, %obj, %slot)
{
   if (%obj.cannonfire == 0)
      %obj.cannonfire = 2;
   else
      %obj.cannonfire += 1;
   %obj.client.player.setHeat(1);

   if (%obj.cannoncount $= "")
      %obj.cannoncount = 2;
   %obj.cannoncount += 1;
   if (%obj.cannoncount > 10)
      %obj.cannoncount = 1;

   if ((%obj.cannonfire < 100) && (%obj.cannoncount == 1))
   {
      %message = "Plasma Cannon " @ %obj.cannonfire @ "\% Charged.";
      CommandToClient(%obj.client, 'BottomPrint', %message, 2, 1 );
   }
   else if (%obj.cannoncount == 1)
   {
      %message = "Plasma Cannon Fully Charged!";
      CommandToClient(%obj.client, 'BottomPrint', %message, 2, 1 );
   }
}

function PlasmaCannonImage::onFire(%data, %obj, %slot)
{

   %obj.client.player.setHeat(1);
   if ((%obj.cannonfire > 99) && (%obj.getInventory( %data.ammo ) > 19))
   {
      %datab = PlasmaCannonBolt6;
      %ammoloss = 20;
   }
   else if ((%obj.cannonfire > 79) && (%obj.getInventory( %data.ammo ) > 14))
   {
      %datab = PlasmaCannonBolt5;
      %ammoloss = 15;
   }
   else if ((%obj.cannonfire > 59) && (%obj.getInventory( %data.ammo ) > 9))
   {
      %datab = PlasmaCannonBolt4;
      %ammoloss = 10;
   }
   else if ((%obj.cannonfire > 39) && (%obj.getInventory( %data.ammo ) > 4))
   {
      %datab = PlasmaCannonBolt3;
      %ammoloss = 5;
   }
   else if ((%obj.cannonfire > 19) && (%obj.getInventory( %data.ammo ) > 1))
   {
      %datab = PlasmaCannonBolt2;
      %ammoloss = 2;
   }
   else
   {
      %datab = PlasmaCannonBolt1;
      %ammoloss = 1;
   }

   %p = new (%data.projectileType)() {
      dataBlock        = %datab;
      initialDirection = %obj.getMuzzleVector(%slot);
      initialPosition  = %obj.getMuzzlePoint(%slot);
      sourceObject     = %obj;
      sourceSlot       = %slot;
      vehicleObject    = %vehicle;
   };

   if (isObject(%obj.lastProjectile) && %obj.deleteLastProjectile)
      %obj.lastProjectile.delete();

   %obj.lastProjectile = %p;
   %obj.deleteLastProjectile = %data.deleteLastProjectile;
   MissionCleanup.add(%p);

   // AI hook
   if(%obj.client)
      %obj.client.projectile = %p;

   %obj.decInventory(%data.ammo, %ammoloss);
   %obj.cannonfire = 0;
   %obj.cannoncount = 2;
}

function PlasmaCannonImage::onUnmount(%this, %obj, %slot)
{
   %obj.cannonfire = 0;
   %obj.cannoncount = 2;
   Parent::onMount(%this,%obj,%slot);
}