

datablock ShapeBaseImageData(FusionTurretBarrelImage)
{
   mass = 2.5;
   emap = true;

   shapeFile = "turret_outdoor_deploy.dts";
   item = FusionTurretBarrelPack;
   deployed = FusionTurretBarrel;

   mountPoint = 1;
   offset = "0 0 0";

   stateName[0] = "Idle";
   stateTransitionOnTriggerDown[0] = "Activate";

   stateName[1] = "Activate";
   stateScript[1] = "onActivate";
   stateTransitionOnTriggerUp[1] = "Idle";

   SmallTurretBarrel = true;

   maxDepSlope = 360;
};

datablock ItemData(FusionTurretBarrelPack)
{
   className = Pack;
   catagory = "Deployables";
   shapeFile = "turret_outdoor_deploy.dts";

   image = FusionTurretBarrelImage;

   mass = 2.5;
   elasticity = 0.2;
   friction = 0.6;

   pickupRadius = 1;
   pickUpName = "a Fusion Turret barrel";

   rotate = false;

   DeployPercent = 2.0;

   computeCRC = true;
   emap = true;
   lightOnlyStatic = true;
   lightType = "PulsingLight";
   lightColor = "0.76 0.67 0.0 0.7";
   lightTime = 1200;
   lightRadius = 3;

   isSmallBarrel = true;
};

datablock ShockwaveData(FusionTurretMuzzleFlash)
{
   width = 0.5;
   numSegments = 13;
   numVertSegments = 1;
   velocity = 2.0;
   acceleration = -1.0;
   lifetimeMS = 400;
   height = 0.1;
   verticalCurve = 0.5;

   mapToTerrain = false;
   renderBottom = false;
   orientToNormal = true;
   renderSquare = true;
   
   texture[0] = "special/blasterHit";
   texture[1] = "special/gradient";
   texWrap = 3.0;

   times[0] = 0.0;
   times[1] = 0.5;
   times[2] = 1.0;

   colors[0] = "1 0 0 1.0";
   colors[1] = "1 0 0 1.0";
   colors[2] = "1 0 0 0.0";
};

datablock TracerProjectileData(FusionTurretBolt)
{
   doDynamicClientHits = true;

   directDamage        = 0.0;
   directDamageType    = $DamageType::Energy;
   hasDamageRadius     = true;
   indirectDamage      = 0.2;
   damageRadius        = 3.0;
   kickBackStrength    = 400.0;

   radiusDamageType    = $DamageType::Explosion;
   sound               = BlasterProjectileSound;
   explosion           = PlasmaBoltExplosion;

   dryVelocity       = 50.0;
   wetVelocity       = 35.0;
   velInheritFactor  = 1.0;
   fizzleTimeMS      = 4000;
   lifetimeMS        = 6000;
   explodeOnDeath    = false;

   reflectOnWaterImpactAngle = 0.0;
   explodeOnWaterImpact      = true;
   deflectionOnWaterImpact   = 0.0;
   fizzleUnderwaterMS        = -1;

   activateDelayMS = 100;

   tracerLength    = 5;
   tracerAlpha     = false;
   tracerMinPixels = 3;
   tracerColor     = "0 0 1 1";
   tracerTex[0]    = "special/landSpikeBolt";
   tracerTex[1]    = "special/landSpikeBoltCross";
   tracerWidth     = 0.35;

   crossSize       = 0.79;
   crossViewAng    = 0.990;
   renderCross     = true;

   emap = true;
};

datablock TurretImageData(FusionTurretBarrel)
{
   shapeFile = "weapon_missile_casement.dts";  //turret_muzzlepoint.dts
   item      = FusionTurretBarrelPack;

   offset = "0 -0.075 0";

   projectileType = TracerProjectile;
   projectile = FusionTurretBolt;

   usesEnergy = true;
   fireEnergy = 11.0;
   minEnergy = 13.0;

   lightType = "WeaponFireLight";
   lightColor = "0.25 0.25 0.15 0.2";
   lightTime = "1000";
   lightRadius = "2";

   muzzleFlash = FusionTurretMuzzleFlash;

   // Turret parameters
   activationMS      = 300;
   deactivateDelayMS = 600;
   thinkTimeMS       = 200;
   degPerSecTheta    = 580;
   degPerSecPhi      = 960;
   attackRadius      = 100;

   // State transitions
   stateName[0]                  = "Activate";
   stateTransitionOnNotLoaded[0] = "Dead";
   stateTransitionOnLoaded[0]    = "ActivateReady";

   stateName[1]                  = "ActivateReady";
   stateSequence[1]              = "Activate";
   stateSound[1]                 = OBLSwitchSound;
   stateTimeoutValue[1]          = 1;
   stateTransitionOnTimeout[1]   = "Ready";
   stateTransitionOnNotLoaded[1] = "Deactivate";
   stateTransitionOnNoAmmo[1]    = "NoAmmo";

   stateName[2]                    = "Ready";
   stateTransitionOnNotLoaded[2]   = "Deactivate";
   stateTransitionOnTriggerDown[2] = "Fire";
   stateTransitionOnNoAmmo[2]      = "NoAmmo";

   stateName[3]                = "Fire";
   stateTransitionOnTimeout[3] = "Reload";
   stateTimeoutValue[3]        = 0.3;
   stateFire[3]                = true;
   stateShockwave[3]           = true;
   stateRecoil[3]              = LightRecoil;
   stateAllowImageChange[3]    = false;
   stateSequence[3]            = "Fire";
   stateSound[3]               = OBLFireSound;
   stateScript[3]              = "onFire";

   stateName[4]                  = "Reload";
   stateTimeoutValue[4]          = 1.5;
   stateAllowImageChange[4]      = false;
   stateSequence[4]              = "Reload";
   stateTransitionOnTimeout[4]   = "Ready";
   stateTransitionOnNotLoaded[4] = "Deactivate";
   stateTransitionOnNoAmmo[4]    = "NoAmmo";

   stateName[5]                = "Deactivate";
   stateSequence[5]            = "Activate";
   stateDirection[5]           = false;
   stateTimeoutValue[5]        = 1;
   stateTransitionOnLoaded[5]  = "ActivateReady";
   stateTransitionOnTimeout[5] = "Dead";

   stateName[6]               = "Dead";
   stateTransitionOnLoaded[6] = "ActivateReady";

   stateName[7]             = "NoAmmo";
   stateTransitionOnAmmo[7] = "Reload";
   stateSequence[7]         = "NoAmmo";
};

function FusionTurretBarrelImage::onActivate(%Data, %Pack, %Slot)
{
   checkSmallTurretMount(%Data, %Pack, %Slot);
}

function FusionTurretBarrelImage::onDeactivate(%Data, %Pack, %Slot)
{
   %Pack.setImageTrigger($BackpackSlot, false);
}

function FusionTurretBarrelImage::onPickup(%This, %Pack, %Shape, %Amount)
{
   // created to prevent console errors
}