Botpack
Class PressureZone

source: e:\games\UnrealTournament\Botpack\Classes\PressureZone.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.ZoneInfo
            |
            +--Botpack.PressureZone
Direct Known Subclasses:None

class PressureZone
extends Engine.ZoneInfo

//============================================================================= // PressureZone. //=============================================================================
Variables
 float DieDrawScale
           Drawscale when dead
 float DieFOV
           Field of view when dead (interpolates)
 byte DieFatness
           Fatness when dead
 Vector EndFlashFog
           Fog values for client death sequence
 float EndFlashScale
           Fog values for client death sequence
 float KillTime
           How long to kill the player?
 Vector StartFlashFog
           Fog values for client death sequence
 float StartFlashScale
           Fog values for client death sequence
 float TimePassed
           Drawscale when dead
 bool bTriggered
           Ensure that it doesn't update until it should


Function Summary
 void BeginPlay()
 void MakeNormal(Pawn P)
 void Tick(float DeltaTime)
 void Trigger(Actor Other, Pawn EventInstigator)



Source Code


00001	//=============================================================================
00002	// PressureZone.
00003	//=============================================================================
00004	class PressureZone extends ZoneInfo;
00005	
00006	var() float  KillTime;					// How long to kill the player?
00007	var() float  StartFlashScale;			// Fog values for client death sequence
00008	var() Vector StartFlashFog;
00009	var() float  EndFlashScale;
00010	var() Vector EndFlashFog;
00011	var() float  DieFOV;					// Field of view when dead (interpolates)
00012	var() float  DieDrawScale;				// Drawscale when dead
00013	var   float  TimePassed;
00014	var() byte   DieFatness;				// Fatness when dead
00015	var   bool   bTriggered;				// Ensure that it doesn't update until it should
00016	var	  bool	 bScreamed;
00017	
00018	function BeginPlay()
00019	{
00020		Super.BeginPlay();
00021		Disable('Tick');
00022		bTriggered = false;
00023		DieFOV = FClamp( DieFOV, 1, 170 );
00024		DieFatness = Clamp( DieFatness, 1, 255 );
00025	}
00026	
00027	function Trigger( actor Other, pawn EventInstigator )
00028	{
00029		local Pawn p;
00030	
00031		// The pressure zone has been triggered to kill something
00032	
00033		Instigator = EventInstigator;
00034	
00035		if ( Instigator.IsA('bot') )
00036		{
00037			// taunt the victim
00038			for ( P=Level.PawnList; P!=None; P=P.NextPawn )
00039				if( (P.Region.Zone == self) && (P.Health > 0) )
00040				{
00041					Instigator.Target = P;
00042					Instigator.GotoState('VictoryDance');
00043				}
00044		}
00045	
00046		// Engage Tick so that death may be slow and dramatic
00047		TimePassed = 0;
00048		bTriggered = true;
00049		bScreamed = false;
00050		Disable('Trigger');
00051		Enable('Tick');
00052	}
00053	
00054	function Tick( float DeltaTime )
00055	{
00056		local float  		ratio, curScale;
00057		local vector 		curFog;
00058		local PlayerPawn	pPawn;
00059		local Pawn P;
00060		local bool bActive;
00061	
00062		if( !bTriggered ) 
00063		{
00064			Disable('Tick');
00065			return;
00066		}
00067	
00068		TimePassed += DeltaTime;
00069		ratio = TimePassed/KillTime;
00070		if( ratio > 1.0 ) ratio = 1.0;
00071	
00072		for ( P=Level.PawnList; P!=None; P=P.NextPawn )
00073		{
00074			// Ensure player hasn't been dispatched through other means already (suicide?)
00075			if( (P.Region.Zone == self) && (P.Health > 0) && !P.IsA('Spectator') )
00076			{
00077				bActive = true;
00078					
00079				// Fatness
00080				P.Fatness   = byte( 128 + Int( (Float(DieFatness)-128) * ratio ));
00081				P.DrawScale = 1 + (DieDrawScale-1) * ratio;
00082	
00083				// Maybe scream?
00084				if( !bScreamed && P.bIsPlayer && (Ratio > 0.2) && (FRand() < 2 * DeltaTime) )
00085				{
00086					// Scream now (from the terrible pain)
00087					bScreamed = true;
00088					P.PlaySound( P.Die, SLOT_Talk );
00089				}
00090			
00091				// Fog & Field of view
00092				pPawn = PlayerPawn(P);
00093				if( pPawn != None )
00094				{
00095					curScale = (EndFlashScale-StartFlashScale)*ratio + StartFlashScale;
00096					curFog   = (EndFlashFog  -StartFlashFog  )*ratio + StartFlashFog;
00097					pPawn.ClientFlash( curScale, 1000 * curFog );
00098	
00099					pPawn.SetFOVAngle( (DieFOV-pPawn.default.FOVAngle)*ratio + pPawn.default.FOVAngle);
00100				}
00101				if ( ratio == 1.0 )
00102				{	
00103					Level.Game.SpecialDamageString = DamageString;
00104					P.health = -1000; //make sure gibs
00105					P.Died(Instigator, 'SpecialDamage', P.Location);
00106					MakeNormal(P);
00107				}
00108			}
00109		}	
00110		
00111		if( !bActive && (TimePassed >= KillTime) )
00112		{
00113			Disable('Tick');
00114			Enable('Trigger');
00115			bTriggered = false;
00116		}
00117	}
00118	
00119	function MakeNormal(Pawn P)
00120	{
00121		local PlayerPawn PPawn;
00122		// set the fatness back to normal
00123		P.Fatness = P.Default.Fatness;
00124		P.DrawScale = P.Default.DrawScale;
00125		PPawn = PlayerPawn(P);
00126		if( PPawn != None )
00127			PPawn.SetFOVAngle( PPawn.Default.FOVAngle );
00128	}
00129	
00130	// When an actor leaves this zone.
00131	event ActorLeaving( actor Other )
00132	{
00133		if( Other.bIsPawn )
00134			MakeNormal(Pawn(Other));
00135		Super.ActorLeaving(Other);
00136	}
00137	
00138	defaultproperties
00139	{
00140	     DamageType=SpecialDamage
00141	     DamageString="%o was depressurized by %k."
00142	     bStatic=False
00143	}

End Source Code