
datablock ShapeBaseImageData(BaseVehiclePackImage) 
{ 
mass = 15; 
emap = true; 

shapeFile = "Stackable1l.dts"; 
item = BaseVehiclePack; 
mountPoint = 1; 
offset = "0 -0.2 0"; 

minDeployDis = 0.5;
maxDeployDis = 5000.0;

deployed = Vehicle; //TurretDeployedBase; 
heatSignature = 1; 

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

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

isLarge = true; 
maxDepSlope = 360; 
deploySound = StationDeploySound; 
}; 

datablock ItemData(BaseVehiclePack) 
{ 
className = Pack; 
catagory = "Deployables"; 
shapeFile = "Stackable1l.dts"; 
mass = 3.0; 
elasticity = 0.2; 
friction = 0.6; 
pickupRadius = 1; 
rotate = false; 
image = "BaseVehiclePackImage"; 
pickUpName = "a deployable Vehicle"; 
heatSignature = 0; 

computeCRC = true; 
emap = true; 
}; 


function BaseVehiclePack::onPickup(%this, %obj, %shape, %amount) 
{ 
// created to prevent console errors 
} 


function DeployVehicle(%item, %plyr, %slot) 
{
%plyr.unmountImage(%slot);
%plyr.decInventory(%item.item, 1);
%blockname = %item.deployed; 
%player = %plyr;
// spawns a vehicle at the beacon
   // scoutFlyer = Shrike
   // ScoutVehicle = grav cycle
   // AssaultVehicle = tank
   // BomberFlyer = bomber
   // HAPCFlyer = transport
   // MobileBaseVehicle = mobile base
%team = %player.team;
   if(vehicleCheck(%blockName, %team))
   {
       // Retrieve beacon position and rotation
       %position =  posFromTransform(%plyr.getTransform());
       %rotation =  rotFromTransform(%plyr.getTransform());

       %xy = GetWord(%position,0) SPC GetWord(%position,1);
       %position = %xy SPC GetHeight(%xy SPC "0");
       %position = vectorAdd(%position, %blockName.spawnOffset);
       %rot= -1*GetWord(%rotation,2) * GetWord(%rotation,3)+1.57;
       if (%blockname $= "mobilebasevehicle" || %blockname $= "Assaultvehicle" || %blockName $= "ScoutVehicle")
          %adjust = MCos(%rot) * 8 SPC MSin(%rot) * 8 SPC 0;
       %position = VectorAdd(%position,%adjust);
       // Check to see if we're in the clear... terrain wise
       %mask = $TypeMasks::TerrainObjectType;
       InitContainerRadiusSearch(%position, %blockName.checkRadius, %mask);
       
       // Loop until we get high enough...
       // WARNING ENDLESS LOOP POSSIBLE
       while(%objfound = containerSearchNext() != 0)
       {
           // add some height...
           %position = vectorAdd(%position, %blockName.spawnOffset);
       }
       
       %o = %blockName.create(%team);
       if(%o)
       {
              %o.team = %team;
              %o.gtwteam = %plyr.team;
              %o.GTWID = %plyr.packid;
              $GTWGame.misSaveGame();

              vehicleListAdd(%blockName, %o);
              MissionCleanup.add(%o);

              %o.setTransform(%position @ " " @ %rotation);

              if(%player.lastVehicle)
              {
                     %player.lastVehicle.lastPilot = "";
                     //vehicleAbandonTimeOut(%player.lastVehicle);
                     %obj.player.lastVehicle = "";
              }
              %player.lastVehicle = %o;
              %o.lastPilot = %player;

              //%o.getDataBlock().schedule(10, "mountDriver", %o, %plyr);

              if(%o.getTarget() != -1)
                   setTargetSensorGroup(%o.getTarget(), %plyr.client.getSensorGroup());
       }
    $TeamDeployedCount[%plyr.team, %item.item]++;
    }
}

//SHRIKE

datablock ShapeBaseImageData(BaseShrikePackImage) : BaseVehiclePackImage
{ 
shapeFile = "vehicle_air_scout_debris.dts";
offset = "0 -1.8 0"; 
item = BaseShrikePack; 
deployed = scoutFlyer; //TurretDeployedBase; 
isLarge = True; 
deploySound = StationDeploySound; 
}; 


datablock ItemData(BaseShrikePack) : BaseVehiclePack
{
 shapeFile = "vehicle_air_scout_debris.dts"; 
className = Pack; 
catagory = "Deployables"; 
image = "BaseShrikePackImage"; 
pickUpName = "a deployable Shrike"; 
pickupRadius = 1; 

computeCRC = true; 
emap = true; 
}; 

function BaseShrikepackImage::onDeploy(%item, %plyr, %slot) 
{
//%parent = baseVehiclePackImage;
DeployVehicle(%item,%plyr,%slot);
}

function BaseShrikePack::onPickup(%this, %pack, %player, %amount)
{
%player.packid = %pack.GTWID;
//%deplObj.GTWID = %plyr.packid;
//GTWGame.misSaveGame();
}

function BaseShrikePack::onThrow(%this,%pack,%player)
{
 %this.GTWID = %player.packid;
 serverPlay3D(ItemThrowSound, %player.getTransform());
 %pack.schedulePop();
}

//Grav Cycle
datablock ShapeBaseImageData(BasegravcyclePackImage) : BaseVehiclePackImage
{ 
shapeFile = "vehicle_grav_scout_debris.dts"; 
item = BasegravcyclePack;
offset = "0 -0.6 0.4"; 
deployed = scoutVehicle; //TurretDeployedBase; 
isLarge = true; 
deploySound = StationDeploySound; 
}; 


datablock ItemData(BasegravcyclePack) : BaseVehiclePack
{
shapeFile = "vehicle_grav_scout_debris.dts";
className = Pack; 
catagory = "Deployables"; 
image = "BasegravcyclePackImage";
pickUpName = "a deployable gravcycle";
pickupRadius = 1; 

computeCRC = true; 
emap = true; 
}; 

function BasegravcyclepackImage::onDeploy(%item, %plyr, %slot) 
{
//%parent = baseVehiclePackImage;
DeployVehicle(%item,%plyr,%slot);
}


function BasegravcyclePack::onPickup(%this, %pack, %player, %amount)
{
%player.packid = %pack.GTWID;
//%deplObj.GTWID = %plyr.packid;
//GTWGame.misSaveGame();
}

function BasegravcyclePack::onThrow(%this,%pack,%player)
{
 %this.GTWID = %player.packid;
 serverPlay3D(ItemThrowSound, %player.getTransform());
 %pack.schedulePop();
}

///TANK

datablock ShapeBaseImageData(BasetankPackImage) : BaseVehiclePackImage
{ 
shapeFile = "Stackable2l.dts"; 
offset = "0 -0.8 -1"; 
item = BasetankPack; 
deployed = AssaultVehicle; //TurretDeployedBase; 
isLarge = true; 
deploySound = StationDeploySound; 
}; 


datablock ItemData(BasetankPack) : BaseVehiclePack
{
 shapeFile = "Stackable2l.dts"; 
className = Pack; 
catagory = "Deployables"; 
image = "BasetankPackImage"; 
pickUpName = "a deployable tank"; 
pickupRadius = 1; 

computeCRC = true; 
emap = true; 
}; 

function BasetankpackImage::onDeploy(%item, %plyr, %slot) 
{
//%parent = baseVehiclePackImage;
DeployVehicle(%item,%plyr,%slot);
}


function BaseTankPack::onPickup(%this, %pack, %player, %amount)
{
%player.packid = %pack.GTWID;
//%deplObj.GTWID = %plyr.packid;
//GTWGame.misSaveGame();
}

function BaseTankPack::onThrow(%this,%pack,%player)
{
 %this.GTWID = %player.packid;
 serverPlay3D(ItemThrowSound, %player.getTransform());
 %pack.schedulePop();
}

//BOMBER


datablock ShapeBaseImageData(BasebomberPackImage) : BaseVehiclePackImage
{ 
shapeFile = "Stackable2l.dts"; 
offset = "0 -0.8 -1"; 
item = BasebomberPack; 
deployed = BomberFlyer; //TurretDeployedBase; 
isLarge = true; 
deploySound = StationDeploySound; 
}; 


datablock ItemData(BasebomberPack) : BaseVehiclePack
{
 shapeFile = "Stackable2l.dts"; 
className = Pack; 
catagory = "Deployables"; 
image = "BasebomberPackImage"; 
pickUpName = "a deployable bomber"; 
pickupRadius = 1; 

computeCRC = true; 
emap = true; 
}; 
function BasebomberpackImage::onDeploy(%item, %plyr, %slot) 
{
//%parent = baseVehiclePackImage;
DeployVehicle(%item,%plyr,%slot);
}


function BasebomberPack::onPickup(%this, %pack, %player, %amount)
{
%player.packid = %pack.GTWID;
//%deplObj.GTWID = %plyr.packid;
//GTWGame.misSaveGame();
}

function BasebomberPack::onThrow(%this,%pack,%player)
{
 %this.GTWID = %player.packid;
 serverPlay3D(ItemThrowSound, %player.getTransform());
 %pack.schedulePop();
}

//TRANSPORT

datablock ShapeBaseImageData(BasetransportPackImage) : BaseVehiclePackImage
{ 
shapeFile = "Stackable1l.dts"; 
offset = "0 -0.8 -1"; 
item = BasetransportPack; 
deployed = HAPCFlyer; //TurretDeployedBase; 
isLarge = true; 
deploySound = StationDeploySound; 
}; 


datablock ItemData(BasetransportPack) : BaseVehiclePack
{
 shapeFile = "Stackable1l.dts"; 
className = Pack; 
catagory = "Deployables"; 
image = "BasetransportPackImage"; 
pickUpName = "a deployable transport"; 
pickupRadius = 1; 

computeCRC = true; 
emap = true; 
}; 
function BasetransportpackImage::OnDeploy(%item, %plyr, %slot) 
{
//%parent = baseVehiclePackImage;
DeployVehicle(%item,%plyr,%slot);
}


function BasetransportPack::onPickup(%this, %pack, %player, %amount)
{
%player.packid = %pack.GTWID;
//%deplObj.GTWID = %plyr.packid;
//GTWGame.misSaveGame();
}

function BasetransportPack::onThrow(%this,%pack,%player)
{
 %this.GTWID = %player.packid;
 serverPlay3D(ItemThrowSound, %player.getTransform());
 %pack.schedulePop();
}

//MPB

datablock ShapeBaseImageData(BasempbPackImage) : BaseVehiclePackImage
{ 
shapeFile = "Stackable1l.dts"; 
offset = "0 -0.8 -1"; 
item = BasempbPack; 
deployed = MobileBaseVehicle; //TurretDeployedBase; 
isLarge = true; 
deploySound = StationDeploySound; 
}; 


datablock ItemData(BasempbPack) : BaseVehiclePack
{
 shapeFile = "Stackable1l.dts"; 
className = Pack; 
catagory = "Deployables"; 
image = "BasempbPackImage"; 
pickUpName = "a deployable mpb"; 
pickupRadius = 1; 

computeCRC = true; 
emap = true; 
}; 
function BasempbpackImage::OnDeploy(%item, %plyr, %slot) 
{
//%parent = baseVehiclePackImage;
DeployVehicle(%item,%plyr,%slot);
}


function BaseMPBPack::onPickup(%this, %pack, %player, %amount)
{
%player.packid = %pack.GTWID;
//%deplObj.GTWID = %plyr.packid;
//GTWGame.misSaveGame();
}

function BaseMPBPack::onThrow(%this,%pack,%player)
{
 %this.GTWID = %player.packid;
 serverPlay3D(ItemThrowSound, %player.getTransform());
 %pack.schedulePop();
}
