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

UnrealShare.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
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
//=============================================================================
// TriggeredDeath.
// When triggered, kills the player, causing screen flashes and sounds.
//=============================================================================
class TriggeredDeath extends 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   bDestroyItems; // destroy any items which may touch it as well

var float TimePassed[8];
var PlayerPawn Victim[8];

auto state Enabled
{
    function Touch( Actor Other )
    {
        local inventory Inv;
        local Pawn P;
        local int VNum;

        // Something has contacted the death trigger.
        // If it is a PlayerPawn, have it screen flash and
        // die.
        if( Other.bIsPawn )
        {
            P = Pawn(Other);
            P.Weapon = None;
            P.SelectedItem = None;  
            for( Inv=Other.Inventory; Inv!=None; Inv=Inv.Inventory )
                Inv.Destroy();
            
            if ( P.Health <= 0 )
                return;
            if ( Other.IsA('PlayerPawn') )
            {
                Enable('Tick');
                While ( (VNum < 7) && (Victim[VNum] != None) )
                    VNum++;
                Victim[Vnum] = PlayerPawn(Other);
                TimePassed[VNum] = 0;
            }
            else
                KillVictim(P);

            P.Health = 1;
            if ( P.bIsPlayer )
            {
                if( P.bIsFemale )
                    Other.PlaySound( FemaleDeathSound, SLOT_Talk );
                else
                    Other.PlaySound( MaleDeathSound, SLOT_Talk );
            }
            else
                P.Playsound(P.Die, SLOT_Talk);
        }
        else if( bDestroyItems )
            Other.Destroy();
    }

    function KillVictim(Pawn Victim)
    {
        Victim.NextState = '';
        Victim.Health = -1;
        Victim.Died(None, DeathName, Victim.Location);
        Victim.HidePlayer();
    }

    function Tick( float DeltaTime )
    {
        local Float CurScale;
        local vector CurFog;
        local float  TimeRatio;
        local int i, VNum;
        local bool bFoundVictim;

        for ( i=0; i<8; i++ )
            if( Victim[i] != None )
            {
                if ( Victim[i].Health > 1 )
                    Victim[i] = None;
                else
                {
                    // Check the timing
                    TimePassed[i] += DeltaTime;
                    if( TimePassed[i] >= ChangeTime )
                    {
                        TimeRatio = 1;
                        Victim[i].ClientFlash( EndFlashScale, 1000 * EndFlashFog );
                        if ( Victim[i].Health > 0 )
                            KillVictim(Victim[i]);
                        Victim[i] = None;
                    }
                    else 
                    {
                        bFoundVictim = true;
                        // Continue the screen flashing
                        TimeRatio = TimePassed[i]/ChangeTime;
                        CurScale = (EndFlashScale-StartFlashScale)*TimeRatio + StartFlashScale;
                        CurFog   = (EndFlashFog  -StartFlashFog  )*TimeRatio + StartFlashFog;
                        Victim[i].ClientFlash( CurScale, 1000 * CurFog );
                    }
                }
            }
        if ( !bFoundVictim )
            Disable('Tick');
    }
}

defaultproperties
{
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: za 22-4-2006 12:48:02.000 - Creation time: za 22-4-2006 12:49:39.453 - Created with UnCodeX