home *** CD-ROM | disk | FTP | other *** search
/ Game Level Design / GLDesign.bin / Software / UnrealEngine2Runtime / UE2Runtime-22262001_Demo.exe / Gameplay / Classes / PressureVolume.uc < prev    next >
Text File  |  2003-12-11  |  3KB  |  130 lines

  1. //=============================================================================
  2. // PressureZone.
  3. //=============================================================================
  4. class PressureVolume extends PhysicsVolume;
  5.  
  6. var() float  KillTime;                    // How long to kill the player?
  7. var() float  StartFlashScale;            // Fog values for client death sequence
  8. var() Vector StartFlashFog;
  9. var() float  EndFlashScale;
  10. var() Vector EndFlashFog;
  11. var   float  DieFOV;                    // Field of view when dead (interpolates)
  12. var   float  DieDrawScale;                // Drawscale when dead
  13. var   float  TimePassed;
  14. var   bool   bTriggered;                // Ensure that it doesn't update until it should
  15. var      bool     bScreamed;
  16.  
  17. function Trigger( actor Other, pawn EventInstigator )
  18. {
  19.     local Controller P;
  20.  
  21.     // The pressure zone has been triggered to kill something
  22.  
  23.     Instigator = EventInstigator;
  24.  
  25.     if ( (Instigator.Controller != None) && Instigator.Controller.IsA('Bot') )
  26.     {
  27.         // taunt the victim
  28.         for ( P=Level.ControllerList; P!=None; P=P.NextController )
  29.             if( (P.Pawn != None) && (P.Pawn.PhysicsVolume == self) && (P.Pawn.Health > 0) )
  30.             {
  31.                 Instigator.Controller.Target = P.Pawn;
  32.                 Instigator.Controller.GotoState('VictoryDance');
  33.             }
  34.     }
  35.  
  36.     // Engage Tick so that death may be slow and dramatic
  37.     TimePassed = 0;
  38.     bTriggered = true;
  39.     bScreamed = false;
  40.     Disable('Trigger');
  41.     Enable('Tick');
  42. }
  43.  
  44. function Tick( float DeltaTime )
  45. {
  46.     local float          ratio, curScale;
  47.     local vector         curFog;
  48.     local PlayerController    PC;
  49.     local Controller P, Killer;
  50.     local bool bActive;
  51.  
  52.     if( !bTriggered ) 
  53.     {
  54.         Disable('Tick');
  55.         return;
  56.     }
  57.  
  58.     TimePassed += DeltaTime;
  59.     ratio = TimePassed/KillTime;
  60.     if( ratio > 1.0 ) ratio = 1.0;
  61.  
  62.     for ( P=Level.ControllerList; P!=None; P=P.NextController )
  63.     {
  64.         // Ensure player hasn't been dispatched through other means already (suicide?)
  65.         if( (P.Pawn.PhysicsVolume == self) && (P.Pawn.Health > 0) && !P.Pawn.IsA('Spectator') )
  66.         {
  67.             bActive = true;
  68.             P.Pawn.SetDrawScale(1 + (DieDrawScale-1) * ratio);
  69.  
  70.             // Maybe scream?
  71.             if( !bScreamed && P.bIsPlayer && (Ratio > 0.2) && (FRand() < 2 * DeltaTime) )
  72.             {
  73.                 // Scream now (from the terrible pain)
  74.                 bScreamed = true;
  75.                 P.Pawn.PlayDyingSound();
  76.             }
  77.         
  78.             // Fog & Field of view
  79.             PC = PlayerController(P);
  80.             if( PC != None )
  81.             {
  82.                 curScale = (EndFlashScale-StartFlashScale)*ratio + StartFlashScale;
  83.                 curFog   = (EndFlashFog  -StartFlashFog  )*ratio + StartFlashFog;
  84.                 PC.ClientFlash( curScale, 1000 * curFog );
  85.  
  86.                 PC.SetFOVAngle( (DieFOV-PC.default.FOVAngle)*ratio + PC.default.FOVAngle);
  87.             }
  88.             if ( ratio == 1.0 )
  89.             {    
  90.                 if ( Instigator != None )
  91.                     Killer = Instigator.Controller;
  92.                 P.Pawn.Died(Killer, class'Depressurized', P.Pawn.Location);
  93.                 MakeNormal(P.Pawn);
  94.             }
  95.         }
  96.     }    
  97.     
  98.     if( !bActive && (TimePassed >= KillTime) )
  99.     {
  100.         Disable('Tick');
  101.         Enable('Trigger');
  102.         bTriggered = false;
  103.     }
  104. }
  105.  
  106. function MakeNormal(Pawn P)
  107. {
  108.     local PlayerController PC;
  109.  
  110.     P.SetDrawScale(P.Default.DrawScale);
  111.     PC = PlayerController(P.Controller);
  112.     if( PC != None )
  113.         PC.SetFOVAngle( PC.Default.FOVAngle );
  114. }
  115.  
  116. // When an actor leaves this zone.
  117. event PawnLeavingVolume(Pawn Other)
  118. {
  119.     MakeNormal(Other);
  120.     Super.PawnLeavingVolume(Other);
  121. }
  122.  
  123. defaultproperties
  124. {
  125.     bTriggered=false
  126.     DamageType=class'Depressurized'
  127.     DieFOV=150
  128. }
  129.  
  130.