Wikis / Unreal Wiki / Legacy:Vehicles Pre2004/TakeDamage

Don't kill the driver!

The TakeDamage can be changed so that if the vehicle is destroyed, the driver doesn't die, but takes a lot of damage. This is useful for smaller vehicles like bikes.

function TakeDamage(int Damage, Pawn instigatedBy, Vector hitlocation, 
						Vector momentum, class<DamageType> damageType)
{
	Local Pawn OldDriver; //The driver that just exited
 
	// Avoid damage healing the car!
	if(Damage < 0)
		return;
 
	if(damageType == class'DamTypeSuperShockBeam')
		Health -= 100; // Instagib doesn't work on vehicles
	else
		Health -= 0.5 * Damage; // Weapons do less damage
 
	// The vehicle is dead!
	if(Health <= 0)
	{
		if ( Controller != None )
		{
			OldDriver = Driver;
			KDriverLeave(True); // Get the player out (forced)
			//Let the driver take a lot of damage
			OldDriver.TakeDamage(120, instigatedBy, hitlocation, momentum, damageType);
		}
		Destroy(); // Destroy the vehicle itself (see Destroyed)
	}
	KAddImpulse(momentum, hitlocation);
}

Page Information

2022-11-18T15:42:27.945752Z 2007-11-17T12:49:47Z Dyn-62-56-58-176.dslaccess.co.uk Moved https://wiki.beyondunreal.com/Legacy:Vehicles Pre2004/TakeDamage Attribution-NonCommercial-ShareAlike 3.0