To anyone who uses tumble(%player, %time); There is a bug in it that Badspot hasn't fixed. When you're tumbling you can click to respawn. If you want to use the tumble function, the below code fixes the bug.
package TumbleFix
{
function observer::onTrigger(%data, %cam, %slot, %bool)
{
if(%slot == 0 && %bool && isObject(%client = %cam.getControllingClient()) &&
isObject(%player = %client.player) &&
isObject(%vehicle = %player.getObjectMount()) &&
isObject(%data = %vehicle.getDataBlock()) &&
%data.getName() $= "deathVehicle")
{
return;
}
parent::onTrigger(%data, %cam, %slot, %bool);
}
};
activatePackage(TumbleFix);
Also, as the
%time variable in the
tumble function never worked in the first place, I made a
tumbleBetter function were it does work.
The usage is
tumbleBetter(%player, %time, %force);%player - The player object you wish to tumble(obviously).
%time - How long you want the player to tumble for, in milliseconds.
%force - An integer from 0 to 3.
0 = Tumble for
%time, then stop if it's safe. Regain control of
player after clicking.
1 = Tumble for
%time, then stop if it's safe. Regain control of
player automatically.
2 = Tumble for
%time, then stop wether it's safe or not. Regain
control of player after clicking.
3 = Tumble for
%time, then stop wether it's safe or not. Regain
control of player automatically.
function tumbleBetter(%player, %time, %force)
{
//===========
// Force
//===========
// 0 = Tumble for %time, then stop if it's safe. Regain control of
//player after clicking.
// 1 = Tumble for %time, then stop if it's safe. Regain control of
//player automatically.
// 2 = Tumble for %time, then stop wether it's safe or not. Regain
//control of player after clicking.
// 3 = Tumble for %time, then stop wether it's safe or not. Regain
//control of player automatically.
if(!isObject(%player))
{
return;
}
if(%player.getClassName() !$= "Player")
{
return;
}
if(%player.getState() $= "Dead")
{
return;
}
if(%time < -1)
{
%time = 2000;
}
%currVehicle = %player.getObjectMount();
%client = %player.client;
%newCar = new WheeledVehicle()
{
dataBlock = deathVehicle;
client = %client;
initialPosition = %player.getPosition();
};
missionCleanup.add(%newCar);
%newCar.setVelocity("0 0 0");
if(!isObject(%newCar))
{
return;
}
%newCar.applyImpulse(%newCar.getPosition(), vectorScale(%newCar.getVelocity() * -1, %newCar.getDataBlock().mass));
%player.canDismount = false;
%newCar.setTransform(%player.getTransform());
%newCar.applyImpulse( %newCar.getPosition(), vectorScale(%player.getVelocity(), %newCar.getDataBlock().mass));
%newCar.mountObject(%player, 0);
if(%time != -1)
{
%newCar.schedule(%time, tumbleCheckBetter, %force);
}
if(isObject(%client.camera))
{
%client.camera.setMode("Corpse", %player);
%client.setControlObject(%client.camera);
}
}
function vehicle::tumbleCheckBetter(%obj, %force)
{
%obj.getDataBlock().tumbleCheckBetter(%obj, %force);
}
function deathVehicle::tumbleCheckBetter(%data, %obj, %force)
{
%player = %obj.getMountedObject(0);
%client = %player.client;
if(vectorLen(%obj.getVelocity()) < 1 || %obj.getWaterCoverage() > 0.3 || %force >= 2)
{
if(isObject(%player))
{
%player.canDismount = true;
%player.stopSkiing();
}
%obj.unMountObject(%player);
%obj.schedule(0, delete);
if(%force == 1 || %force >= 3)
{
if(isObject(%client))
{
%client.camera.getDataBlock().onTrigger(%client.camera, 0, 1);
%client.camera.getDataBlock().schedule(50, onTrigger, %client.camera, 0, 0);
}
else
{
%player.setControlObject(%player);
}
}
}
else if(isObject(%player))
{
%obj.schedule(1000, tumbleCheckBetter, %force);
}
}
NOTE: The tumbleBetter function requires Item_Skis to work.