

datablock ShapeBaseImageData(IonTurretBarrelImage)
{
   mass = 1.5;
   emap = true;

   shapeFile = "turret_indoor_deployf.dts";
   offset = "0 0 -0.2";
   mountPoint = 1;

   item = IonTurretBarrelPack;
   deployed = IonTurretBarrel;

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

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

   SmallTurretBarrel = true;

   maxDepSlope = 360;
};

datablock ItemData(IonTurretBarrelPack)
{
   className = Pack;
   catagory = "Deployables";
   shapeFile = "turret_indoor_deployf.dts";

   image = IonTurretBarrelImage;

   mass = 1.5;
   elasticity = 0.2;
   friction = 0.6;

   pickupRadius = 1;
   pickUpName = "an Ion Turret barrel";

   DeployPercent = 2.0;

   rotate = false;

   computeCRC = true;
   emap = true;

   lightOnlyStatic = true;
   lightType = "PulsingLight";
   lightColor = "0.94 0.94 0.49 0.7";
   lightTime = 800;
   lightRadius = 3;

   isSmallBarrel = true;
};

datablock ShockwaveData(IonTurretMuzzleFlash)
{
   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] = "0.8 0.2 0.5 1.0";
   colors[1] = "0.5 0.2 0.5 1.0";
   colors[2] = "0.8 0.2 0.5 0.0";
};

datablock LinearFlareProjectileData(IonTurretBolt)
{
   directDamage        = 0.12;
   directDamageType    = $DamageType::Energy;
   explosion           = "BlasterExplosion";
   kickBackStrength    = 150.0;

   dryVelocity       = 160.0;
   wetVelocity       = 80.0;
   velInheritFactor  = 0.5;

   fizzleTimeMS      = 2500;
   lifetimeMS        = 3000;
   explodeOnDeath    = false;

   reflectOnWaterImpactAngle = 0.0;
   explodeOnWaterImpact      = false;
   deflectionOnWaterImpact   = 0.0;
   fizzleUnderwaterMS        = 3000;

   numFlares         = 20;
   size              = 0.35;
   flareColor        = "0.8 0.2 0.5";
   flareModTexture   = "flaremod";
   flareBaseTexture  = "flarebase";

   sound = BlasterProjectileSound;

   hasLight    = true;
   lightRadius = 2.4;
   lightColor  = "0.8 0.2 0.5";
};

datablock TurretImageData(IonTurretBarrel)
{
   shapeFile = "weapon_missile_projectile.dts"; //turret_muzzlepoint.dts
   item      = IonTurretBarrelPack;

   offset = "0 -0.075 0";

   projectile = IonTurretBolt;
   projectileType = LinearFlareProjectile;

   usesEnergy = true;
   fireEnergy = 4.5;
   minEnergy = 6.5;

   lightType = "WeaponFireLight";
   lightColor = "0.8 0.2 0.5 1.0";
   lightTime = "1000";
   lightRadius = "2";

   muzzleFlash = IonTurretMuzzleFlash;

   // Turret parameters
   activationMS      = 150;
   deactivateDelayMS = 300;
   thinkTimeMS       = 150;
   degPerSecTheta    = 580;
   degPerSecPhi      = 960;
   attackRadius      = 75;

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

   stateName[1]                  = "ActivateReady";
   stateSequence[1]              = "Activate";
   stateSound[1]                 = IBLSwitchSound;
   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]               = IBLFireSound;
   stateScript[3]              = "onFire";

   stateName[4]                  = "Reload";
   stateTimeoutValue[4]          = 1.0;
   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 IonTurretBarrelImage::onActivate(%Data, %Pack, %Slot)
{
   checkSmallTurretMount(%Data, %Pack, %Slot);
}

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

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