
// --------------------------------------------------------------
// Outdoor Deployable Turret
// --------------------------------------------------------------

// --------------------------------------------------------------
// Sound datablocks
// --------------------------------------------------------------

datablock AudioProfile(OBLSwitchSound)
{
   filename    = "fx/powered/turret_light_activate.wav";
   description = AudioClose3d;
   preload = true;
};

datablock AudioProfile(OBLFireSound)
{
   filename    = "fx/powered/turret_outdoor_fire.wav";
   description = AudioDefault3d;
   preload = true;
};

datablock ShapeBaseImageData(TurretOutdoorDeployableImage)
{
   mass = 12;

   shapeFile = "pack_deploy_turreto.dts";
   item = TurretOutdoorDeployable;
   mountPoint = 1;
   offset = "0 0 0";
   deployed = TurretDeployedOutdoor;

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

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

   maxDamage = 4.5;
   destroyedLevel = 4.5;
   disabledLevel = 4.0;

   isLarge = true;
   emap = true;

   maxDepSlope = 40;
   deploySound = TurretDeploySound;
};

datablock ItemData(TurretOutdoorDeployable)
{
   className = Pack;
   catagory = "Deployables";
   shapeFile = "pack_deploy_turreto.dts";
   mass = 3.0;
   elasticity = 0.2;
   friction = 0.6;
   pickupRadius = 1;
   rotate = false;
   image = "TurretOutdoorDeployableImage";
   pickUpName = "a landspike turret pack";

   computeCRC = true;
   emap = true;

   isTurret = true;
};

// --------------------------------------------------------------
// Sensor
// --------------------------------------------------------------

datablock SensorData(DeployedOutdoorTurretSensor)
{
   detects = true;
   detectsUsingLOS = true;
   detectsPassiveJammed = false;
   detectsActiveJammed = false;
   detectsCloaked = false;
   detectionPings = true;
   detectRadius = 70;
};

// --------------------------------------------------------------
// Turret Base
// --------------------------------------------------------------

datablock TurretData(TurretDeployedOutdoor) : TurretDamageProfile
{
   className = DeployedTurret;
   shapeFile = "turret_outdoor_deploy.dts";

   mass = 8.5;
   maxDamage = 0.80;
   destroyedLevel = 0.80;
   disabledLevel = 0.5;
   repairRate = 0;
   explosion = HandGrenadeExplosion;
	
   deployedObject = true;

   thetaMin = 0;
   thetaMax = 145;
   thetaNull = 90;

   isShielded = true;
   energyPerDamagePoint = 100;
   maxEnergy = 60;
   rechargeRate = 0.15;

   item = TurretOutdoorDeployable;

   renderWhenDestroyed = false;
   DefaultBarrel = FusionTurretBarrel;
   SmallTurretBase = true;

   engType = "SmallTurret";
   Name = "Land Spike Turret Base";

   heatSignature = 0;

   canControl = false;
   cmdCategory = "DTactical";
   cmdIcon = CMDTurretIcon;
   cmdMiniIconName = "commander/MiniIcons/com_turret_grey";
   targetNameTag = 'Landspike';
   targetTypeTag = 'Turret';
   sensorData = DeployedOutdoorTurretSensor;
   sensorRadius = DeployedOutdoorTurretSensor.detectRadius;
   sensorColor = "191 0 226";

   firstPersonOnly = true;

   debrisShapeName = "debris_generic_small.dts";
   debris = TurretDebrisSmall;
};

function TurretDeployedOutdoor::ItemSwap(%Data, %Object)
{
   %Transform = %Object.getTransform();
   %Position = posFromTransform(%Transform);

   %Item = %Object.getDataBlock().item;

   %NewItem = new Item()
   {
      dataBlock = %Item;
      position = %Position;
   };
   MissionCleanup.add(%NewItem);

   %Item.Barrel = %Object.getMountedImage(0);

   $TeamDeployedCount[%Object.team, %Item]--;

   %NewItem.applyImpulse(%Position, "0 0 8");

   %Object.delete();
   %NewItem.schedulePop();
}
