Cogito, ergo sum

Difference between revisions of "Legacy:VitalOverdose/ONSVehicleEjectionTrigger"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
m
(One intermediate revision by one other user not shown)
Line 87: Line 87:
 
}
 
}
 
</uscript>
 
</uscript>
 
===Easy to embed into a level===
 
 
You can download this script as a .UC file [http://www.fataloverdose.copperstream.co.uk/files/protools/onsejectiontrigger/ONSVehicleEjectionTrigger.uc ONSVehicleEjectionTrigger.uc]
 
 
Or download this script as a '[http://www.fataloverdose.copperstream.co.uk/files/protools/onsejectiontrigger/MyLevel.u MyLevel.u]' file that can easily be imported into your level though you actor browser classes/open package.
 
  
 
===Related===
 
===Related===
 
+
*[[Legacy:Vehicles|Vehicles]]
[[Legacy:Vehicle|Vehicle]]
+
*[[Legacy:ONSVehicle|ONSVehicle]]
 
+
*[[Legacy:VitalOverdose/AllMapVehicleFactory | AllMapVehicleFactory]]
[[Legacy:ONSVehicle|ONSVehicle]]
+
*[[Legacy:VitalOverdose/QuickVehicleSpawner | QuickVehicleSpawner]]
 
+
*[[Legacy:VitalOverdose/ONSVehicleTeleporter | ONSVehicleTeleporter]]
[[Legacy:VitalOverdose/ONSVehicleBooster | ONSVehicleBooster]]
+
*[[Legacy:VitalOverdose/ONSVehicleBooster | ONSVehicleBooster]]
 
+
*[[Legacy:VitalOverdose/ONSVehicleEjectionTrigger | ONSVehicleEjectionTrigger]]
[[Legacy:VitalOverdose/VehicleTeleporter | ONSVehicleTeleporter]]
+
*[[Legacy:VitalOverdose/ONSVehicleFXTagger | ONSVehicleFXTagger]]
 
+
[[Legacy:VitalOverdose/ONSVehicleFXTagger| ONSVehicleFxTagger]]
+
  
 
==Discussion==
 
==Discussion==
  
 
[[Category:Legacy Custom Class (UT2004)|{{PAGENAME}}]]
 
[[Category:Legacy Custom Class (UT2004)|{{PAGENAME}}]]

Revision as of 06:20, 14 September 2011

UT2004 :: Actor >> Triggers >> ONSVehicleEjectionTrigger(Package: custom)

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'
}

Related

Discussion