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

UnrealShare.StochasticTrigger


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
//=============================================================================
// StochasticTrigger.
//=============================================================================
class StochasticTrigger extends Triggers;

// Works like a DynamicAmbientSound, only events are called instead of
// sounds. M

var() name   Events[6];             // What events to call (must be at least one event)
var() float  triggerProbability;    // The chance of the event occuring effect playing
var() float  minReCheckTime;    // Try to re-trigger the event after (min amount)
var() float     maxReCheckTime;     // Try to re-trigger the event after (max amount)
var   bool  bIsActive;          // This trigger dispacher is activated/deactivated
var   float     reTriggerTime;
var   int       numEvents;          // The number of events available
var   actor  triggerInstigator;     // Who enabled this actor to dispach?

function BeginPlay () 
{
    local int i;
    
    // Calculate how many events the user specified
    numEvents=6;
    for (i=0; i<6; i++) {
        if (Events[i] == '') {
            numEvents=i;
            break;
        }
    }

    reTriggerTime = (maxReCheckTime-minReCheckTime)*FRand() + minReCheckTime;
    SetTimer(reTriggerTime, False);
}

state() TriggeredActive
{
    function Trigger( actor Other, pawn EventInstigator )
    {
        // StochasticTrigger is active
        if ( triggerInstigator == None )
            triggerInstigator = EventInstigator;
        else
            triggerInstigator = Other;
        Instigator = EventInstigator;
        bIsActive = true;
    }

    function UnTrigger( actor Other, pawn EventInstigator )
    {
        // StochasticTrigger is inactive
        if ( triggerInstigator == None )
            triggerInstigator = EventInstigator;
        else
            triggerInstigator = Other;
        Instigator = EventInstigator;
        bIsActive = false;
    }
Begin:
    bIsActive = false;      // initially the trigger dispacher is inactive
}

state() AlwaysActive
{
Begin:
    bIsActive = true;
}

function Timer () 
{
    local int   i;
    local actor     A;

    if (FRand() <= triggerProbability && bIsActive == true) 
    {
        // Trigger an event
        // Which event should be initiated?
        i = Rand(numEvents);

        // Broadcast the Trigger message to all matching actors.
        if( Events[i] != '' )
            foreach AllActors( class 'Actor', A, Events[i] )
                A.Trigger( triggerInstigator, Instigator );
    }

    reTriggerTime = (maxReCheckTime-minReCheckTime)*FRand() + minReCheckTime;
    SetTimer(reTriggerTime, False);
}

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.140 - Created with UnCodeX