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

Gameplay.PressureVolume


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
00126
00127
00128
//=============================================================================
// PressureZone.
//=============================================================================
class PressureVolume extends PhysicsVolume;

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

function Trigger( actor Other, pawn EventInstigator )
{
    local Controller P;

    // The pressure zone has been triggered to kill something

    Instigator = EventInstigator;

    if ( (Instigator.Controller != None) && Instigator.Controller.IsA('Bot') )
    {
        // taunt the victim
        for ( P=Level.ControllerList; P!=None; P=P.NextController )
            if( (P.Pawn != None) && (P.Pawn.PhysicsVolume == self) && (P.Pawn.Health > 0) )
            {
                Instigator.Controller.Target = P.Pawn;
                Instigator.Controller.GotoState('VictoryDance');
            }
    }

    // Engage Tick so that death may be slow and dramatic
    TimePassed = 0;
    bTriggered = true;
    bScreamed = false;
    Disable('Trigger');
    Enable('Tick');
}

function Tick( float DeltaTime )
{
    local float         ratio, curScale;
    local vector        curFog;
    local PlayerController  PC;
    local Controller P, Killer;
    local bool bActive;

    if( !bTriggered ) 
    {
        Disable('Tick');
        return;
    }

    TimePassed += DeltaTime;
    ratio = TimePassed/KillTime;
    if( ratio > 1.0 ) ratio = 1.0;

    for ( P=Level.ControllerList; P!=None; P=P.NextController )
    {
        // Ensure player hasn't been dispatched through other means already (suicide?)
        if( (P.Pawn.PhysicsVolume == self) && (P.Pawn.Health > 0) && !P.Pawn.IsA('Spectator') )
        {
            bActive = true;
            P.Pawn.SetDrawScale(1 + (DieDrawScale-1) * ratio);

            // Maybe scream?
            if( !bScreamed && P.bIsPlayer && (Ratio > 0.2) && (FRand() < 2 * DeltaTime) )
            {
                // Scream now (from the terrible pain)
                bScreamed = true;
                P.Pawn.PlayDyingSound();
            }
        
            // Fog & Field of view
            PC = PlayerController(P);
            if( PC != None )
            {
                curScale = (EndFlashScale-StartFlashScale)*ratio + StartFlashScale;
                curFog   = (EndFlashFog  -StartFlashFog  )*ratio + StartFlashFog;
                PC.ClientFlash( curScale, 1000 * curFog );

                PC.SetFOVAngle( (DieFOV-PC.default.FOVAngle)*ratio + PC.default.FOVAngle);
            }
            if ( ratio == 1.0 )
            {   
                if ( Instigator != None )
                    Killer = Instigator.Controller;
                P.Pawn.Died(Killer, class'Depressurized', P.Pawn.Location);
                MakeNormal(P.Pawn);
            }
        }
    }   
    
    if( !bActive && (TimePassed >= KillTime) )
    {
        Disable('Tick');
        Enable('Trigger');
        bTriggered = false;
    }
}

function MakeNormal(Pawn P)
{
    local PlayerController PC;

    P.SetDrawScale(P.Default.DrawScale);
    PC = PlayerController(P.Controller);
    if( PC != None )
        PC.SetFOVAngle( PC.Default.FOVAngle );
}

// When an actor leaves this zone.
event PawnLeavingVolume(Pawn Other)
{
    MakeNormal(Other);
    Super.PawnLeavingVolume(Other);
}

defaultproperties
{
     DieFOV=150.000000
     DamageType=Class'Gameplay.Depressurized'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Tue 24/10/2006 16:57:54.000 - Creation time: Wed 7/2/2007 19:16:49.484 - Created with UnCodeX