Game Development Community

Player Ejection on destroy

by ebee t · in Technical Issues · 10/23/2007 (8:09 pm) · 3 replies

Having some issues with player still mounted in sitting position on vehicle destroy. I have done the code before that works for this, but I seem to be having troubles this time,
Many thanks in advance.
The following code I added to my vehicle.cs

function WheeledVehicleData::damage(%this,%obj,%type,%vel,%damage,%damageType)
{
echo("Vehicle IS HIT");
%obj.applyDamage(%damage);
//if(%obj.getDamageState() $= "Destroyed" )
if(%obj.getDamageLevel() == 60)
{
getOut();//a function that I cant seem to get working to eject the player
echo("getDamageLevel is " @ %obj.getDamageLevel());
%obj.startFade(4000, 0, true);
%obj.schedule(5000, "delete");

}
}

#1
10/24/2007 (6:23 pm)
Is it calling the getOut() function at all, and how about everything else within the if?
#2
10/24/2007 (11:04 pm)
How does the getOut function know which vehicle was destroyed and/or which player needs to get out?
#3
10/24/2007 (11:12 pm)
Thanks Guys, seems I was barking up the wrong tree with the code, I managed to find what I needed and it works to eject the player. Turns out that the simple code just didnt work to call that function.

function WheeledVehicleData::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
if (%obj.getDamageState() $= "Destroyed")
return;

%obj.applyDamage(%damage);
%location = "Body";

%client = %obj.client;
%sourceClient = %sourceObject ? %sourceObject.client : 0;

if (%obj.getDamageState() $= "Destroyed")
%client.onDeath(%sourceObject, %sourceClient, %damageType, %location);
}

function WheeledVehicleData::onDamage(%this, %obj, %delta)
{
%damage = %obj.getDamageLevel();
echo("damage flagged");

if (%damage >= %this.destroyedLevel)
{
if(%obj.getDamageState() !$= "Destroyed")
{
%obj.setDamageState(Destroyed);
}
}
else
{
if(%obj.getDamageState() !$= "Enabled")
%obj.setDamageState(Enabled);
}

function WheeledVehicleData::onDestroyed(%data, %obj, %prevState)
{
echo("destroyed level");

getout();
%obj.startFade(4000, 0, true);
%obj.schedule(5000, "delete");

}