---------------------------------------------------------------------------------------------------------------
Vehicle Booster Rockets Tutorial
---------------------------------------------------------------------------------------------------------------
This tutorial will add a booster to vehicles that is used when the pack button is hit while piloting vehicles. It completely drains the vehicle energy and the amount of boost is based on how much energy is availible.
Step #1
// ------------------------------------------
// Player.cs
// ------------------------------------------
In function Player::use, remove this line:
messageClient( %this.client, 'MsgCantUsePack', '\c2You can\'t use your pack while piloting.~wfx/misc/misc.error.wav' );
Step #2
// ------------------------------------------
// Vehicle.cs
// ------------------------------------------
Add this function to vehicle.cs:
function fireBooster(%this)
{
if (!isObject(%this))
return;
%veh = %this.getObjectMount();
if (isObject(%veh))
{
if (%veh.getType() & $TypeMasks::VehicleObjectType)
{
if (%veh.getMountNodeObject(0) == %this)
{
%vdata = %veh.getDataBlock();
%vec = %this.getVelocity();
%vec = VectorNormalize(%vec);
%pct = %veh.getEnergyLevel() / %vdata.maxEnergy;
%mass = %vdata.mass;
%amount = %mass * 100 * %pct;
%veh.setEnergyLevel(0);
%veh.applyImpulse(%veh.getTransform(), VectorScale(%vec, %amount));
}
}
}
}
Step #3
// ------------------------------------------
// ControlDefaults.cs
// ------------------------------------------
Add this to the top of function ServerCmdStartUseBackpack:
if (%client.player)
if (%client.player.isPilot())
fireBooster(%client.player);