UnrealShare
Class TriggeredDeath

source: e:\games\UnrealTournament\UnrealShare\Classes\TriggeredDeath.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Triggers
         |
         +--UnrealShare.TriggeredDeath
Direct Known Subclasses:None

class TriggeredDeath
extends Engine.Triggers

//============================================================================= // TriggeredDeath. // When triggered, kills the player, causing screen flashes and sounds. //=============================================================================
Variables
 float ChangeTime
 Name DeathName
 Vector EndFlashFog
 float EndFlashScale
 Sound FemaleDeathSound
 Sound MaleDeathSound
 Vector StartFlashFog
 float StartFlashScale
 float TimePassed[8]
           destroy any items which may touch it as well
 PlayerPawn Victim[8]
           destroy any items which may touch it as well
 bool bDestroyItems
           destroy any items which may touch it as well

States
Enabled
State Enabled Function Summary
 void Tick(float DeltaTime)
 void KillVictim(Pawn Victim)
 void Touch(Actor Other)



Source Code


00001	//=============================================================================
00002	// TriggeredDeath.
00003	// When triggered, kills the player, causing screen flashes and sounds.
00004	//=============================================================================
00005	class TriggeredDeath extends Triggers;
00006	
00007	var() Sound  MaleDeathSound;
00008	var() Sound  FemaleDeathSound;
00009	var() float  StartFlashScale;
00010	var() Vector StartFlashFog;
00011	var() float  EndFlashScale;
00012	var() Vector EndFlashFog;
00013	var() float  ChangeTime;
00014	var() Name   DeathName;
00015	var() bool   bDestroyItems;	// destroy any items which may touch it as well
00016	
00017	var float TimePassed[8];
00018	var PlayerPawn Victim[8];
00019	
00020	auto state Enabled
00021	{
00022		function Touch( Actor Other )
00023		{
00024			local inventory Inv;
00025			local Pawn P;
00026			local int VNum;
00027	
00028			// Something has contacted the death trigger.
00029			// If it is a PlayerPawn, have it screen flash and
00030			// die.
00031			if( Other.bIsPawn )
00032			{
00033				P = Pawn(Other);
00034				P.Weapon = None;
00035				P.SelectedItem = None;
00036				P.DropWhenKilled = None;
00037				Level.Game.DiscardInventory(P);	
00038				
00039				if ( P.Health <= 0 )
00040					return;
00041				if ( Other.IsA('PlayerPawn') )
00042				{
00043					Enable('Tick');
00044					While ( (VNum < 7) && (Victim[VNum] != None) )
00045						VNum++;
00046					Victim[Vnum] = PlayerPawn(Other);
00047					TimePassed[VNum] = 0;
00048				}
00049				else
00050					KillVictim(P);
00051	
00052				P.Health = 1;
00053				if ( P.bIsPlayer )
00054				{
00055					if( P.bIsFemale )
00056						Other.PlaySound( FemaleDeathSound, SLOT_Talk );
00057					else
00058						Other.PlaySound( MaleDeathSound, SLOT_Talk );
00059				}
00060				else
00061					P.Playsound(P.Die, SLOT_Talk);
00062			}
00063			else if( bDestroyItems )
00064				Other.Destroy();
00065		}
00066	
00067		function KillVictim(Pawn Victim)
00068		{
00069			Victim.NextState = '';
00070			Victim.Health = -1;
00071			if (DeathName == '')
00072				Victim.Died(None, 'Fell', Victim.Location);
00073			else
00074				Victim.Died(None, DeathName, Victim.Location);
00075			Victim.HidePlayer();
00076		}
00077	
00078		function Tick( float DeltaTime )
00079		{
00080			local Float CurScale;
00081			local vector CurFog;
00082			local float  TimeRatio;
00083			local int i, VNum;
00084			local bool bFoundVictim;
00085	
00086			for ( i=0; i<8; i++ )
00087				if( Victim[i] != None )
00088				{
00089					if ( Victim[i].Health > 1 )
00090						Victim[i] = None;
00091					else
00092					{
00093						// Check the timing
00094						TimePassed[i] += DeltaTime;
00095						if( TimePassed[i] >= ChangeTime )
00096						{
00097							TimeRatio = 1;
00098							Victim[i].ClientFlash( EndFlashScale, 1000 * EndFlashFog );
00099							if ( Victim[i].Health > 0 )
00100								KillVictim(Victim[i]);
00101							Victim[i] = None;
00102						}
00103						else 
00104						{
00105							bFoundVictim = true;
00106							// Continue the screen flashing
00107							TimeRatio = TimePassed[i]/ChangeTime;
00108							CurScale = (EndFlashScale-StartFlashScale)*TimeRatio + StartFlashScale;
00109							CurFog   = (EndFlashFog  -StartFlashFog  )*TimeRatio + StartFlashFog;
00110							Victim[i].ClientFlash( CurScale, 1000 * CurFog );
00111						}
00112					}
00113				}
00114			if ( !bFoundVictim )
00115				Disable('Tick');
00116		}
00117	}
00118	
00119	defaultproperties
00120	{
00121	}

End Source Code