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

UnrealI.RockSlide


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
//=============================================================================
// RockSlide.
//=============================================================================
class RockSlide extends KeyPoint;

// Spawns a set of rocks within a cubical volume.  The rocks are
// produced at random intervals, and the entirety of the effect
// lasts for a set amount of time.  MZM

var() vector   CubeDimensions;
var() bool     TimeLimit;          // Is there a limit on it's lifespan?
var() float    TimeLength;
var() float    MinBetweenTime;
var() float    MaxBetweenTime;
var() float    MinScaleFactor;
var() float    MaxScaleFactor;
var() rotator  InitialDirection;
var() float    minInitialSpeed;
var() float    maxInitialSpeed;

var   float  NextRockTime;
var   float  TotalPassedTime;


function BeginPlay() 
{
    // Initialize and check the values of variables.
    MaxScaleFactor = FMin(1.0, MaxScaleFactor);
    MinScaleFactor = FMax(0.0, MinScaleFactor);
    if (MinBetweenTime >= MaxBetweenTime) 
        MaxBetweenTime=MinBetweenTime + 0.1;
    if (MinScaleFactor >= MaxScaleFactor) 
        MaxScaleFactor=MinScaleFactor;

    Super.BeginPlay();
}

function MakeRock () 
{
    // Spawns another rock somewhere within the cube,
    // of a randomized size and shape.  The rock has
    // falling physics but no initial velocity, so it 
    // needs to fall a distance before it becomes dangerous.

    local vector  SpawnLoc;
    local BigRock    TempRock;
    
    SpawnLoc = Location - (CubeDimensions*0.5);
    SpawnLoc.X += FRand()*CubeDimensions.X;
    SpawnLoc.Y += FRand()*CubeDimensions.Y;
    SpawnLoc.Z += FRand()*CubeDimensions.Z;

    TempRock = Spawn (class 'BigRock', ,'', SpawnLoc);
    if ( TempRock != None )
    {
        TempRock.SetRotation(InitialDirection);
        TempRock.Speed = (MinInitialSpeed+
                        (MaxInitialSpeed-MinInitialSpeed)*FRand());

        TempRock.DrawScale = (MaxScaleFactor-MinScaleFactor)*FRand()+MinScaleFactor;
        TempRock.SetCollisionSize(TempRock.CollisionRadius*TempRock.DrawScale/TempRock.Default.DrawScale, 
                                     TempRock.CollisionHeight*TempRock.DrawScale/TempRock.Default.DrawScale);
    }
}

auto state() Triggered 
{
    function Trigger (actor Other, pawn EventInstigator) 
    {
        MakeRock();
        GotoState ('Active');
    }
}

state Active
{
Begin:
    // A loop which lasts for the total time allowed for the
    // effect, producing rocks at randomized intervals.
    MakeRock();
    NextRockTime = FRand()*(MaxBetweenTime-MinBetweenTime)+ MinBetweenTime;
    TotalPassedTime += NextRockTime;
    sleep (NextRockTime);
    if ( !TimeLimit || (TotalPassedTime < TimeLength) ) 
        goto 'RocksFall';
    Destroy();
}

defaultproperties
{
     CubeDimensions=(X=50.000000,Y=50.000000,Z=50.000000)
     TimeLength=10.000000
     MinBetweenTime=1.000000
     MaxBetweenTime=3.000000
     MinScaleFactor=0.500000
     MaxScaleFactor=1.000000
     bStatic=False
     Tag=Event1
     Texture=Texture'UnrealShare.S_Bubble2'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Do 19.5.2005 19:42:14.000 - Creation time: Fr 7.6.2013 13:15:56.662 - Created with UnCodeX