Cogito, ergo sum
Legacy:VitalOverdose/ONSVehicleEjectionTrigger
From Unreal Wiki, The Unreal Engine Documentation Site
< Legacy:VitalOverdose
Revision as of 18:14, 29 October 2007 by 84-45-226-149.no-dns-yet.enta.net (Talk)
Overview
This custom Triggers actor is designed to detect any ONSVehicles that come within a certain distance and if a driver is present it ejects the driver.
- Optional damage can be applied to the driver : DriverDamage.
- Optional damage to the vehicle : VehicleDamage.
- Also the force of the ejection multiplied : EjectMultiplyer.
- There are optional extra sound FX for when the ONSVehicleEjectionTrigger is touched by a valid/non-valid actor :RejectSoundFx/ValidContactSoundFxand.
- Optional sound FX for the ejection itself.
Both the DamageTypes for the diver and the vehicle can also be set by the mapper.
The Script
///////////////////////////////////////////////////////////////////// // by vitaloverdose Oct 2007. // Http://www.vitaloverdose.com /////////////////////////////////////////////////////////////////////// class ONSVehicleEjectionTrigger extends Triggers Placeable; Var () int VehicleDamage; // Mapper can set in unrealEd. Var () Int DriverDamage; // Mapper can set in unrealEd. Var () float Ejectmultiplyer; // Mapper can set in unrealEd. Var () Sound EjectSoundFx; // Mapper can set in unrealEd. Var () Sound RejectSoundFx; // Mapper can set in unrealEd. Var () Sound ValidContactSoundFx; // Mapper can set in unrealEd. Var () Class< Damagetype > DriverDamageType; // Mapper can set in unrealEd. Var () Class< DamageType > VehicleDamageType; // Mapper can set in unrealEd. simulated Function Touch( Actor Other) { Super.touch(other); if ((!Other.IsA('onsVehicle')) && (onsVehicle(Other).Driver == None) ) { If ( RejectSoundFx!=None) Playsound(RejectSoundFx); return; } // calls the Eject function and passes it the valid reference of the vehicle that touched it. Eject( OnsVehicle(Other)); } simulated Function Eject( OnsVehicle Avehicle) { local pawn EjectedDriver; local float OldEjectMomentum; //the old EjectMomentum is backed up so it can be restored after the ejection OldEjectMomentum = Avehicle.EjectMomentum; //The ejection momentum is then altered on the vehicle Avehicle.EjectMomentum *= Ejectmultiplyer; // the valid reference to the driver is recored before hes ejected EjectedDriver = Avehicle.Driver; // The function EjectDriver() is called on the vehicle which ejects the driver Avehicle.EjectDriver(); //The original ejection force is returned to the vehicle Avehicle.EjectMomentum = OldEjectMomentum; //applies damage to the Driver using the recorded reference. if ( DriverDamage > 1) EjectedDriver.TakeDamage(DriverDamage , Instigator , EjectedDriver.Location , vect(0,0,10000),DriverDamagetype ) ; //applies damage to the vehicle if ( VehicleDamage > 1 ) Avehicle.TakeDamage(VehicleDamage, Instigator , Avehicle.Location , vect(0,0,10000),VehicleDamagetype ); // if the mapper specified sound FX they are played here If ( ValidContactSoundFx!=None) Playsound(ValidContactSoundFx); } defaultproperties { VehicleDamage=1000 DriverDamage=50 Ejectmultiplyer=2.000000 DriverDamageType=Class'Engine.Crushed' VehicleDamageType=Class'UT2k4Assault.DamTypeExploBarrel' }
Easy to embed into a level
You can download this script as a .UC file ONSVehicleEjectionTrigger.uc
Or download this script as a 'MyLevel.u' file that can easily be imported into your level though you actor browser classes/open package.