Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

U2.EarthquakeTrigger


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
//=============================================================================
// EarthquakeTrigger.uc
// $Author: Mfox $
// $Date: 7/29/02 7:58p $
// $Revision: 8 $
//
//=============================================================================
class EarthquakeTrigger extends Trigger;

#exec Texture Import File=Textures\QuakeTrigger.pcx Name=S_QuakeTrigger Mips=Off MASKED=1

var() float Duration;				// how long quake should last
var() float ShakeMagnitude;			// roll Magnitudenitude at epicenter, 0 at radius
var() float BaseTossMagnitude;		// toss Magnitudenitude at epicenter, 0 at radius
var() float Radius;					// radius of quake
var() bool	bTossNPCs;				// if true, NPCs in area are tossed around
var() bool	bTossPCs;				// if true, PCs in area are tossed around
var() float	MaxTossedMass;			// if bTossPawns true, only pawns <= this mass are tossed
var() float	TimeBetweenShakes;		// time between each shake
var() string AmbientSoundStr;		// sound for duration of quake
var() string ShakeSoundStr;			// sound for each shake

var private float TimeRemaining;

//-----------------------------------------------------------------------------

state() Waiting
{
	function Trigger( Actor Other, Pawn EventInstigator, optional name EventName )
	{
		Instigator = EventInstigator;

		TimeRemaining = Duration;
		SetTimer( TimeBetweenShakes, false );

		if( AmbientSoundStr != "" )
		{
			AmbientSound = Sound( DynamicLoadObject( AmbientSoundStr, class'Sound') );
		}
					
		Disable( 'Trigger' );
		Disable( 'Touch' );
	}

	//-------------------------------------------------------------------------

	function ShakePawn( Pawn P )
	{
		local float DistanceToEpicenter;
		local vector Momentum;
  		
		class'UtilGame'.static.MakeShake( Self, Location, Radius, ShakeMagnitude, Duration );

		if
		(	P.Mass <= MaxTossedMass
		&&	P.Physics == PHYS_Walking
		&&	(	(P.IsPlayer() && bTossPCs)
			||	(!P.IsPlayer() && bTossNPCs)
			)
		)
		{
			DistanceToEpicenter	= VSize( Location - P.Location );

			Momentum = -0.5 * P.Velocity + 100 * VRand();
			Momentum.Z = BaseTossMagnitude/((0.4 * DistanceToEpicenter + 350) * P.Mass);
			Momentum.Z *= 5.0;

			P.AddVelocity( Momentum );
		}
	}

	//-------------------------------------------------------------------------

	event Timer()
	{
		local Pawn P;

		TimeRemaining -= TimeBetweenShakes;
				
		if ( TimeRemaining > TimeBetweenShakes )
		{
			SetTimer( TimeBetweenShakes, false );
			
			if( ShakeSoundStr != "" )
			{
				PlaySound( Sound( DynamicLoadObject( ShakeSoundStr, class'Sound') ), SLOT_Misc );
			}
		  		
			// shake/toss all pawns in the area every 0.5 seconds until quake over
			//!!mdf-tbd: iterate through pawn list (note: none exists currently and might not be faster than radiusactors anyway)
			ForEach RadiusActors( class 'Pawn', P, Radius )
			{
				ShakePawn( P );
			}
		}
		else
		{
			AmbientSound = None;
			Enable( 'Trigger' );
			Enable( 'Touch' );
		}
	}	
}

//-----------------------------------------------------------------------------

defaultproperties
{
	Duration=10.000000
	ShakeMagnitude=60.000000
	BaseTossMagnitude=2500000.000000
	Radius=2048.000000
	bTossNPCs=true
	bTossPCs=true
	MaxTossedMass=500.000000
	TimeBetweenShakes=0.500000
	InitialState='Waiting'
	Texture=Texture'U2.S_QuakeTrigger'
     UseReticleOnEvents(0)="UseReticleText"
     UseReticleOnEvents(1)="UseReticleCorners"
     UseReticleOnEvents(2)="UseReticleTopBars"
     ProximityReticleOnEvents(0)="ProximityReticleCorners"
     ProximityReticleOnEvents(1)="ProximityReticleTopBars"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: sk 3-1-2016 10:38:42.000 - Creation time: sk 3-1-2016 10:48:38.251 - Created with UnCodeX