UnrealShare
Class ThrowStuff

source: e:\games\UnrealTournament\UnrealShare\Classes\ThrowStuff.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Keypoint
         |
         +--UnrealShare.ThrowStuff
Direct Known Subclasses:None

class ThrowStuff
extends Engine.Keypoint

//============================================================================= // ThrowStuff. // throw pawns, inventory (non-item), and decorations around //=============================================================================
Variables
 byte Numthrows
 bool bRandomize
 float baseSize
 float interval
 byte remainingThrows
 vector throwVect


Function Summary
 void PreBeginPlay()
 void Throwing()
 void Timer()
 void Trigger(Actor Other, Pawn EventInstigator)



Source Code


00001	//=============================================================================
00002	// ThrowStuff.
00003	// throw pawns, inventory (non-item), and decorations around
00004	//=============================================================================
00005	class ThrowStuff extends Keypoint;
00006	
00007	var() vector throwVect;
00008	var() bool	bRandomize;
00009	var() float	interval;
00010	var() byte	Numthrows;
00011	var byte remainingThrows;
00012	var float	baseSize;
00013	
00014		function PreBeginPlay()
00015		{
00016			if (bRandomize)
00017				baseSize = VSize(throwVect);
00018			Super.PreBeginPlay();
00019		}
00020	
00021		function Trigger(actor Other, pawn EventInstigator)
00022		{
00023			remainingThrows = Numthrows;
00024			Throwing();
00025		}
00026	
00027		function Throwing()
00028		{
00029			local actor A;
00030			local float throwSize, oldZ;
00031			if ( event != '' )
00032				ForEach AllActors(class 'Actor', A, event)
00033				{
00034					A.SetPhysics(PHYS_Falling);		
00035					if ( Pawn(A) != None )
00036						Pawn(A).AddVelocity(throwVect);
00037					else if ( ((Decoration(A) != None) && Decoration(A).bPushable)
00038						|| ((Inventory(A) != None) && !A.bHidden) )
00039						A.Velocity = throwVect;
00040					if (bRandomize)
00041					{
00042						oldZ = throwVect.Z;
00043						throwSize = VSize(throwVect);
00044						if (throwSize > 1.5 * baseSize)
00045							throwSize = baseSize;
00046						else if (throwSize < 0.5 * baseSize)
00047							throwSize = baseSize;
00048						throwVect = throwSize * (Normal(throwVect) + 0.5 * VRand());
00049						if ( (oldZ > 0) != (throwVect.Z > 0) )
00050							throwVect.Z *= -1;
00051					}
00052				}		
00053			
00054			if (Remainingthrows > 1)
00055			{
00056				Remainingthrows--;
00057				SetTimer(interval, false);
00058			}
00059		}
00060		
00061		function Timer()
00062		{
00063			Throwing();	
00064		}
00065	
00066	defaultproperties
00067	{
00068	     Numthrows=1
00069	     bStatic=False
00070	}

End Source Code