Botpack
Class VacuumZone

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

class VacuumZone
extends Engine.ZoneInfo

//============================================================================= // VacuumZone. //=============================================================================
Variables
 float DieDrawScale
           Drawscale when dead
 float DieFOV
           Field of view when dead (interpolates)
 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


Function Summary
 void BeginPlay()
 void MakeNormal(Pawn P)
 void Tick(float DeltaTime)



Source Code


00001	//=============================================================================
00002	// VacuumZone.
00003	//=============================================================================
00004	class VacuumZone 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	
00014	function BeginPlay()
00015	{
00016		Super.BeginPlay();
00017		Disable('Tick');
00018		DieFOV = FClamp( DieFOV, 1, 170 );
00019	}
00020	
00021	event ActorEntered( actor Other )
00022	{
00023		local Pawn P;
00024	
00025		Super.ActorEntered(Other);
00026	
00027		if ( Other.bIsPawn )
00028		{
00029			P = Pawn(Other);
00030	
00031			// Maybe scream?
00032			if( P.bIsPlayer )
00033			{
00034				// Scream now (from the terrible pain)
00035				P.PlaySound( P.Die, SLOT_Talk );
00036			}
00037	
00038			Enable('Tick');
00039		}
00040	}
00041	
00042	function Tick( float DeltaTime )
00043	{
00044		local float  		ratio, curScale;
00045		local vector 		curFog;
00046		local PlayerPawn	pPawn;
00047		local Pawn P;
00048		local bool bActive;
00049		local int OldFatness;
00050	
00051		for ( P=Level.PawnList; P!=None; P=P.NextPawn )
00052		{
00053			// Ensure player hasn't been dispatched through other means already (suicide?)
00054			if( (P.Region.Zone == self) && (P.Health > 0) )
00055			{
00056				ratio = FMax(0.01,float(Max(P.Fatness,128) - P.Default.Fatness)/FMax(1,(255 - P.Default.Fatness)));
00057				ratio += DeltaTime/KillTime;
00058				bActive = true;
00059				// Fatness
00060				OldFatness = P.Fatness;
00061				P.Fatness = Max(P.Fatness,128) + Max(1, ratio * (255 - P.Default.Fatness) - (P.Fatness - P.Default.Fatness));
00062				if ( P.Fatness < Max(OldFatness,P.Default.Fatness) )
00063					P.Fatness = 255;
00064	
00065				// Fog & Field of view
00066				pPawn = PlayerPawn(P);
00067				if( pPawn != None )
00068				{
00069					curScale = (EndFlashScale-StartFlashScale)*ratio + StartFlashScale;
00070					curFog   = (EndFlashFog  -StartFlashFog  )*ratio + StartFlashFog;
00071					pPawn.ClientFlash( curScale, 1000 * curFog );
00072	
00073					pPawn.SetFOVAngle( (DieFOV-pPawn.default.FOVAngle)*ratio + pPawn.default.FOVAngle);
00074				}
00075				if ( P.Fatness > 250 )
00076				{	
00077					Level.Game.SpecialDamageString = DamageString;		
00078					P.TakeDamage
00079					(
00080						10000,
00081						P,
00082						P.Location,
00083						Vect(0,0,0),
00084						DamageType				
00085					);
00086					MakeNormal(P);
00087				}
00088			}
00089		}	
00090		
00091		if( !bActive )
00092			Disable('Tick');
00093	}
00094	
00095	function MakeNormal(Pawn P)
00096	{
00097		local PlayerPawn PPawn;
00098		// set the fatness back to normal
00099		P.Fatness = P.Default.Fatness;
00100		P.DrawScale = P.Default.DrawScale;
00101		PPawn = PlayerPawn(P);
00102		if( PPawn != None )
00103			PPawn.SetFOVAngle( PPawn.Default.FOVAngle );
00104	}
00105	
00106	// When an actor leaves this zone.
00107	event ActorLeaving( actor Other )
00108	{
00109		if( Other.bIsPawn )
00110			MakeNormal(Pawn(Other));
00111		Super.ActorLeaving(Other);
00112	}
00113	
00114	defaultproperties
00115	{
00116	     KillTime=2.500000
00117	     StartFlashScale=1.000000
00118	     EndFlashScale=1.000000
00119	     DieFOV=90.000000
00120	     DieDrawScale=1.000000
00121	     DamageType=SpecialDamage
00122	     DamageString="%o was depressurized"
00123	     bStatic=False
00124	}

End Source Code