------------------------------------------------------------------------------------------------------------
Environment Pack Tutorial
------------------------------------------------------------------------------------------------------------
This tutorial creates a new pack that allows movement underwater as if you were above, removes liquid damage from the wearer, slightly decreases how fast heat raises and increases how quick it drops, slightly decreases falling damage, and provides an air brake that cuts velocity to one quarter when the pack is used (everything but airbrake is always active while pack is warn). The amount it effects heat and falling damage is minor for balancing purposes, but can be adjusted to what you want.
Step #1
// ------------------------------------------
// inventoryHud.cs
// ------------------------------------------
$InvPack[16] = "Environment Pack";
$NTInvPack[11] = "Environment Pack";
$NameToInv["Environment Pack"] = "EnvironmentPack";
Step #2
// ------------------------------------------
// Pack.cs
// ------------------------------------------
exec("scripts/packs/EnvironmentPack.cs");
Step #3
// ------------------------------------------
// ControlDefaults.cs
// ------------------------------------------
function quickPackEnvironmentPack(%val)
{
if(%val)
addQuickPackFavorite("Environment Pack");
}
Step #4
// ------------------------------------------
// Player.cs
// ------------------------------------------
4a) Add this to each of the datablocks, recommended for all armor sizes like most packs.
max[EnvironmentPack] = 1;
4b) Since you can't modify datablocks, we have to create new datablocks to handle the various changes
caused by mounting the environment pack. This makes a copy of all the base armor datablocks and changes
only the parts that we want to work differently in the new datablock. When someone mounts the pack, it
changes the players armor over to these new datablocks (still uses the same armor dts in each
instance, so they can't tell it's being done). If you have new armors that you want to use the environment
pack, you'll need to add the new datablocks for them as well. The name of the new datablocks are the exact
same as the origional, except a 2 is added to the end of the name.
ex: LightMaleHumanArmor becomes LightMaleHumanArmor2
Add these in player.cs:
// --------------------------------------------------------------------------
// Environmental Pack Armors
// --------------------------------------------------------------------------
datablock PlayerData(LightMaleHumanArmor2) : LightMaleHumanArmor
{
drag = 0.01;
maxdrag = 0.05;
maxUnderwaterForwardSpeed = 14;
maxUnderwaterBackwardSpeed = 13;
maxUnderwaterSideSpeed = 13;
underwaterJetForce = 27.51 * 90;
underwaterVertJetFactor = 1;
underwaterJetEnergyDrain = 0.6;
speedDamageScale = 0.003;
heatDecayPerSec = 1.0 / 2.7; // takes 2.7 seconds to clear heat sig.
heatIncreasePerSec = 1.0 / 3.3; // takes 3.3 seconds of constant jet to get full heat sig.
};
datablock PlayerData(MediumMaleHumanArmor2) : MediumMaleHumanArmor
{
drag = 0.01;
maxdrag = 0.05;
maxUnderwaterForwardSpeed = 11;
maxUnderwaterBackwardSpeed = 10;
maxUnderwaterSideSpeed = 10;
underwaterJetForce = 25.83 * 130;
underwaterVertJetFactor = 1;
underwaterJetEnergyDrain = 0.8;
speedDamageScale = 0.003;
heatDecayPerSec = 1.0 / 2.7; // takes 2.7 seconds to clear heat sig.
heatIncreasePerSec = 1.0 / 3.3; // takes 3.3 seconds of constant jet to get full heat sig.
};
datablock PlayerData(HeavyMaleHumanArmor2) : HeavyMaleHumanArmor
{
drag = 0.01;
maxdrag = 0.05;
maxUnderwaterForwardSpeed = 6.5;
maxUnderwaterBackwardSpeed = 5;
maxUnderwaterSideSpeed = 5;
underwaterJetForce = 22.47 * 180;
underwaterVertJetFactor = 1;
underwaterJetEnergyDrain = 0.9;
speedDamageScale = 0.0045;
heatDecayPerSec = 1.0 / 2.7; // takes 2.7 seconds to clear heat sig.
heatIncreasePerSec = 1.0 / 3.3; // takes 3.3 seconds of constant jet to get full heat sig.
};
datablock PlayerData(LightFemaleHumanArmor2) : LightMaleHumanArmor
{
drag = 0.01;
maxdrag = 0.05;
shapeFile = "light_female.dts";
waterBreathSound = WaterBreathFemaleSound;
jetEffect = HumanMediumArmorJetEffect;
maxUnderwaterForwardSpeed = 14;
maxUnderwaterBackwardSpeed = 13;
maxUnderwaterSideSpeed = 13;
underwaterJetForce = 27.51 * 90;
underwaterVertJetFactor = 1;
underwaterJetEnergyDrain = 0.6;
speedDamageScale = 0.003;
heatDecayPerSec = 1.0 / 2.7; // takes 2.7 seconds to clear heat sig.
heatIncreasePerSec = 1.0 / 3.3; // takes 3.3 seconds of constant jet to get full heat sig.
};
datablock PlayerData(MediumFemaleHumanArmor2) : MediumMaleHumanArmor
{
drag = 0.01;
maxdrag = 0.05;
shapeFile = "medium_female.dts";
waterBreathSound = WaterBreathFemaleSound;
jetEffect = HumanArmorJetEffect;
maxUnderwaterForwardSpeed = 11;
maxUnderwaterBackwardSpeed = 10;
maxUnderwaterSideSpeed = 10;
underwaterJetForce = 25.83 * 130;
underwaterVertJetFactor = 1;
underwaterJetEnergyDrain = 0.8;
speedDamageScale = 0.003;
heatDecayPerSec = 1.0 / 2.7; // takes 2.7 seconds to clear heat sig.
heatIncreasePerSec = 1.0 / 3.3; // takes 3.3 seconds of constant jet to get full heat sig.
};
datablock PlayerData(HeavyFemaleHumanArmor2) : HeavyMaleHumanArmor
{
drag = 0.01;
maxdrag = 0.05;
shapeFile = "heavy_male.dts";
waterBreathSound = WaterBreathFemaleSound;
maxUnderwaterForwardSpeed = 6.5;
maxUnderwaterBackwardSpeed = 5;
maxUnderwaterSideSpeed = 5;
underwaterJetForce = 22.47 * 180;
underwaterVertJetFactor = 1;
underwaterJetEnergyDrain = 0.9;
speedDamageScale = 0.0045;
heatDecayPerSec = 1.0 / 2.7; // takes 2.7 seconds to clear heat sig.
heatIncreasePerSec = 1.0 / 3.3; // takes 3.3 seconds of constant jet to get full heat sig.
};
datablock PlayerData(LightMaleBiodermArmor2) : LightMaleHumanArmor
{
drag = 0.01;
maxdrag = 0.05;
shapeFile = "bioderm_light.dts";
jetEmitter = BiodermArmorJetEmitter;
jetEffect = BiodermArmorJetEffect;
debrisShapeName = "bio_player_debris.dts";
//Foot Prints
decalData = LightBiodermFootprint;
decalOffset = 0.3;
waterBreathSound = WaterBreathBiodermSound;
maxUnderwaterForwardSpeed = 14;
maxUnderwaterBackwardSpeed = 13;
maxUnderwaterSideSpeed = 13;
underwaterJetForce = 27.51 * 90;
underwaterVertJetFactor = 1;
underwaterJetEnergyDrain = 0.6;
speedDamageScale = 0.003;
heatDecayPerSec = 1.0 / 2.7; // takes 2.7 seconds to clear heat sig.
heatIncreasePerSec = 1.0 / 3.3; // takes 3.3 seconds of constant jet to get full heat sig.
};
datablock PlayerData(MediumMaleBiodermArmor2) : MediumMaleHumanArmor
{
drag = 0.01;
maxdrag = 0.05;
shapeFile = "bioderm_medium.dts";
jetEmitter = BiodermArmorJetEmitter;
jetEffect = BiodermArmorJetEffect;
debrisShapeName = "bio_player_debris.dts";
//Foot Prints
decalData = MediumBiodermFootprint;
decalOffset = 0.35;
waterBreathSound = WaterBreathBiodermSound;
maxUnderwaterForwardSpeed = 11;
maxUnderwaterBackwardSpeed = 10;
maxUnderwaterSideSpeed = 10;
underwaterJetForce = 25.83 * 130;
underwaterVertJetFactor = 1;
underwaterJetEnergyDrain = 0.8;
speedDamageScale = 0.003;
heatDecayPerSec = 1.0 / 2.7; // takes 2.7 seconds to clear heat sig.
heatIncreasePerSec = 1.0 / 3.3; // takes 3.3 seconds of constant jet to get full heat sig.
};
datablock PlayerData(HeavyMaleBiodermArmor2) : HeavyMaleHumanArmor
{
drag = 0.01;
maxdrag = 0.05;
emap = false;
shapeFile = "bioderm_heavy.dts";
jetEmitter = BiodermArmorJetEmitter;
debrisShapeName = "bio_player_debris.dts";
//Foot Prints
decalData = HeavyBiodermFootprint;
decalOffset = 0.4;
waterBreathSound = WaterBreathBiodermSound;
maxUnderwaterForwardSpeed = 6.5;
maxUnderwaterBackwardSpeed = 5;
maxUnderwaterSideSpeed = 5;
underwaterJetForce = 22.47 * 180;
underwaterVertJetFactor = 1;
underwaterJetEnergyDrain = 0.9;
speedDamageScale = 0.0045;
heatDecayPerSec = 1.0 / 2.7; // takes 2.7 seconds to clear heat sig.
heatIncreasePerSec = 1.0 / 3.3; // takes 3.3 seconds of constant jet to get full heat sig.
};
// --------------------------------------------------------------------------
// End Environmental Pack Armors
// --------------------------------------------------------------------------
4c) Add this to the top of function Armor::onEnterLiquid. It checks to see if the last character of the
armor the player is wearing is 2 (ie: environmentpack armor). If it is, don't apply any liquid damage.
%armorname = %obj.getDatablock().getName();
%length = strlen(%armorname);
%lastchar = getSubStr(%armorname,%length-1,%length);
if (%lastchar == 2)
return;
Step #5
// ------------------------------------------
// EnvironmentPack.cs
// ------------------------------------------
Add all this into a new file called EnvironmentPack.cs in your packs directory.
// ------------------------------------------------------------------
// Environment PACK
// can be used by any armor type
// Increases Movement in Liquids. Makes immune to liquid damage.
// Decreases Impact Damage. Helps hide heat Signature.
// Can be used as an airbreak.
// ------------------------------------------------------------------
datablock ShapeBaseImageData(EnvironmentPackImage)
{
shapeFile = "pack_upgrade_sensorjammer.dts";
item = EnvironmentPack;
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";
stateTransitionOnTimeout[2] = "Idle";
stateTimeoutValue[2] = 2.0;
};
datablock ItemData(EnvironmentPack)
{
className = Pack;
catagory = "Packs";
shapeFile = "pack_upgrade_sensorjammer.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 2;
rotate = true;
image = "EnvironmentPackImage";
pickUpName = "an environment pack";
computeCRC = true;
};
function EnvironmentPackImage::onMount(%data, %obj, %node)
{
%curHeatLvl = %obj.client.player.getHeat();
%curDmgLvl = %obj.client.player.getDamageLevel();
%curEnergyLevel = %obj.client.player.getEnergyLevel();
%armorname = %obj.getDatablock().getName();
%length = strlen(%armorname);
%lastchar = getSubStr(%armorname,%length-1,%length);
%newarmor = %armorname @ 2;
if (%lastchar != 2)
%obj.setDataBlock(%newarmor);
%obj.client.player.setEnergyLevel(%curEnergyLevel);
%obj.client.player.setDamageLevel(%curDmgLvl);
%obj.client.player.setHeat(%curHeatLvl);
}
function EnvironmentPackImage::onUnmount(%data, %obj, %node)
{
%curHeatLvl = %obj.client.player.getHeat();
%curDmgLvl = %obj.client.player.getDamageLevel();
%curEnergyLevel = %obj.client.player.getEnergyLevel();
%armorname = %obj.getDatablock().getName();
%length = strlen(%armorname);
%lastchar = getSubStr(%armorname,%length-1,%length);
%newarmor = getSubStr(%armorname, 0, %length-1);
if (%lastchar == 2)
%obj.setDataBlock(%newarmor);
%obj.client.player.setEnergyLevel(%curEnergyLevel);
%obj.client.player.setDamageLevel(%curDmgLvl);
%obj.client.player.setHeat(%curHeatLvl);
}
function EnvironmentPack::onPickup(%this, %obj, %shape, %amount)
{
// created to prevent console errors
}
function EnvironmentPackImage::onActivate(%data, %obj, %slot)
{
%vec = %obj.client.player.getVelocity();
%vec = VectorScale(%vec, 0.25);
%obj.client.player.setVelocity(%vec);
%obj.setImageTrigger(%slot, false);
}