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

UnrealI.TriggeredDeath


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
//=============================================================================
// TriggeredDeath.
// When triggered, kills the player, causing screen flashes and sounds.
//=============================================================================
class TriggeredDeath expands Triggers;

var() Sound  MaleDeathSound;
var() Sound  FemaleDeathSound;
var() float  StartFlashScale;
var() Vector StartFlashFog;
var() float  EndFlashScale;
var() Vector EndFlashFog;
var() float  ChangeTime;
var() Name   DeathName;
var() bool   bKillPlayer;   // should the player be killed?
var() bool   bDestroyItems; // destroy any items which may touch it as well

var float TimePassed;
var UnrealIPlayer Victim;

function BeginPlay()
{
    Victim = None;
}

function Touch( Actor Other )
{
    // Something has contacted the death trigger.
    // If it is an UnrealIPlayer, have it screen flash and
    // die.
    if( UnrealIPlayer( Other ) != None )
    {
        TimePassed = 0;
        Victim = UnrealIPlayer( Other );
        if( Female( Other ) != None )
            Victim.PlaySound( FemaleDeathSound, SLOT_Talk );
        else
            Victim.PlaySound( MaleDeathSound, SLOT_Talk );
        Enable('Tick');
    }
    else if( bDestroyItems )
    {
        Other.Destroy();
    }
}


function Tick( float DeltaTime )
{
    local Float CurScale;
    local vector CurFog;
    local float  TimeRatio;

    if( Victim != None )
    {
        // Check the timing
        TimePassed += DeltaTime;
        if( TimePassed >= ChangeTime )
        {
            TimeRatio = 1;
            Disable('Tick');
            if( bKillPlayer )
            {
                Victim.level.game.Killed(None, Victim, DeathName);
                Victim.HidePlayer();
                Victim.Level.Game.DiscardInventory(Victim);
                Victim.Health = -1;
                Victim.Score -= 1;
                Victim.GotoState('Dying');
            }
            Victim.ClientFlash( EndFlashScale, 1000 * EndFlashFog );
        }
        else TimeRatio = TimePassed/ChangeTime;

        // Continue the screen flashing
        CurScale = (EndFlashScale-StartFlashScale)*TimeRatio + StartFlashScale;
        CurFog   = (EndFlashFog  -StartFlashFog  )*TimeRatio + StartFlashFog;

        Victim.ClientFlash( CurScale, 1000 * CurFog );
    }
    else Disable('Tick');
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: za 22-4-2006 12:52:32.000 - Creation time: za 22-4-2006 12:53:47.500 - Created with UnCodeX