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
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
//=============================================================================
// 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;          // limit on it's spawning
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;

var() class<Projectile> ProjectileClass;

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 projectile    TempRock;

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

	TempRock = Spawn (ProjectileClass, ,'', SpawnLoc);
	TempRock.instigator=none;
	if ( TempRock != None )
	{
		TempRock.SetRotation(InitialDirection);
		TempRock.velocity = (MinInitialSpeed+
							 (MaxInitialSpeed-MinInitialSpeed)*FRand())*Vector(Rotation);

		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)
	{
		TotalPassedTime=0;
		MakeRock();
		GotoState ('Active');
	}
}

state Active
{
	function Trigger (actor Other, pawn EventInstigator)
	{
		if ( !TimeLimit )
			GotoState ('Triggered');
		else if (TotalPassedTime < TimeLength)
			TotalPassedTime = TimeLength;
		else
			gotostate ('Active','restart');
	}

restart:
	TotalPassedTime=0;

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

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
				minInitialSpeed=500.000000
				maxInitialSpeed=800.000000
				ProjectileClass=Class'UnrealI.BigRock'
				bStatic=False
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: zo 11-11-2012 21:10:30.000 - Creation time: zo 11-11-2012 21:14:19.959 - Created with UnCodeX