------------------------------------------------------------------------------------------------------------
Hover Pack Tutorial
------------------------------------------------------------------------------------------------------------
This tutorial creates a new pack that suspends people in air as if they were hovering. Since it's impossible to stop gravity in Tribes2 and I don't like bouncing up and down by using impulses, I accomplished this by creating a real small cloaked static object that sits below the person to hold them up and then suspended movement of the person when they use the pack.
Step #1
// ------------------------------------------
// inventoryHud.cs
// ------------------------------------------
$InvPack[17] = "Hover Pack";
$NTInvPack[12] = "Hover Pack";
$NameToInv["Hover Pack"] = "HoverPack";
Step #2
// ------------------------------------------
// Pack.cs
// ------------------------------------------
exec("scripts/packs/HoverPack.cs");
Step #3
// ------------------------------------------
// ControlDefaults.cs
// ------------------------------------------
function quickPackHoverPack(%val)
{
if(%val)
addQuickPackFavorite("Hover Pack");
}
Step #4
// ------------------------------------------
// Player.cs
// ------------------------------------------
4a) Add this to each of the datablocks, recommended for all armor sizes like most packs.
max[HoverPack] = 1;
Step #5
// ------------------------------------------
// HoverPack.cs
// ------------------------------------------
Create a new files called HoverPack.cs in your packs directory. Add all this into it.
// ------------------------------------------------------------------
// Hover PACK
// can be used by any armor type
// Allows Armors to sit stationary in the air
// ------------------------------------------------------------------
datablock ShapeBaseImageData(HoverPackImage)
{
shapeFile = "pack_upgrade_sensorjammer.dts";
item = HoverPack;
mountPoint = 1;
offset = "0 0 0";
usesEnergy = true;
minEnergy = 3;
stateName[0] = "Idle";
stateTransitionOnTriggerDown[0] = "Activate";
stateName[1] = "Activate";
stateScript[1] = "onActivate";
stateTransitionOnTriggerUp[1] = "Deactivate";
stateName[2] = "Deactivate";
stateScript[2] = "onDeactivate";
stateTransitionOnTimeout[2] = "Idle";
stateTimeoutValue[2] = 0.5;
};
datablock ItemData(HoverPack)
{
className = Pack;
catagory = "Packs";
shapeFile = "pack_upgrade_sensorjammer.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 2;
rotate = true;
image = "HoverPackImage";
pickUpName = "a hover pack";
computeCRC = true;
};
datablock StaticShapeData(PlayerPlatform) : StaticShapeDamageProfile
{
shapeFile = "Pmiscf.dts";
isInvincible = true;
};
function HoverPackImage::onMount(%data, %obj, %node)
{
%obj.platform = new StaticShape()
{
dataBlock = PlayerPlatform;
Position = "0 0 -1000";
Scale = "0.05 0.05 0.05";
};
%obj.platform.setCloaked(true);
%obj.platform.setTransform("0 0 -1000 0 0 0 1");
%obj.platform.team = 0;
if(%obj.platform.getTarget() != -1)
setTargetSensorGroup(%obj.platform.getTarget(), %obj.team);
MissionCleanup.add(%obj.platform);
}
function HoverPackImage::onUnmount(%data, %obj, %node)
{
%obj.setMoveState(false);
if (isObject(%obj.platform))
%obj.platform.schedule(100, "delete");
}
function HoverPack::onPickup(%this, %obj, %shape, %amount)
{
// created to prevent console errors
}
function HoverPackImage::onActivate(%data, %obj, %slot)
{
%obj.client.player.setVelocity("0 0 5");
%obj.setMoveState(true);
%xy = getWords(%obj.getTransform(), 0, 1);
%z = getWord(%obj.getTransform(), 2);
%obj.platform.setTransform(%xy SPC %z - 5 SPC "0 0 0 1");
}
function HoverPackImage::onDeactivate(%data, %obj, %slot)
{
%obj.setMoveState(false);
if (isObject(%obj.platform))
%obj.platform.setTransform("0 0 -1000 0 0 0 1");
}