RuneI
Class MudBubble

source: c:\runehov\RuneI\Classes\MudBubble.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Effects
         |
         +--RuneI.MudBubble
Direct Known Subclasses:OtherBubble

class MudBubble
extends Engine.Effects

//============================================================================= // MudBubble. //=============================================================================
Variables
 vector BaseLocation
 byte BubbleRadius
 float DelayMax
 float DelayMin
 float RandPosSize
 float ScaleMax
 float ScaleMin
 bool bBubbleActive

States
Bubbling

Function Summary
 void BeginPlay()
     
//=============================================================================
//
// BeginPlay
//
//=============================================================================
 float BubbleDelay()
     
//=============================================================================
//
// BubbleDelay
//
//=============================================================================
 void Burst()
     
//=============================================================================
//
// Burst
//
//=============================================================================
 void SetNewLocation()
     
//=============================================================================
//
// SetNewLocation
//
//=============================================================================
 void Trigger(Actor Other, Pawn EventInstigator)
     
//=============================================================================
//
// Trigger
//
//=============================================================================


State Bubbling Function Summary



Source Code


00001	//=============================================================================
00002	// MudBubble.
00003	//=============================================================================
00004	class MudBubble expands Effects;
00005	
00006	var() float		DelayMin;
00007	var() float		DelayMax;
00008	var() float		ScaleMin;
00009	var() float		ScaleMax;
00010	var() byte		BubbleRadius;
00011	
00012	var bool		bBubbleActive;
00013	var vector		BaseLocation;
00014	var float		RandPosSize;
00015	
00016	// FUNCTIONS ------------------------------------------------------------------
00017	
00018	//=============================================================================
00019	//
00020	// BeginPlay
00021	//
00022	//=============================================================================
00023	
00024	function BeginPlay()
00025	{
00026		Super.BeginPlay();
00027	
00028		bHidden = true;
00029		bBubbleActive = false;
00030		BaseLocation = Location;
00031		BaseLocation.x -= BubbleRadius;
00032		BaseLocation.y -= BubbleRadius;
00033		RandPosSize = float(BubbleRadius) * 2;
00034	}
00035	
00036	//=============================================================================
00037	//
00038	// Trigger
00039	//
00040	//=============================================================================
00041	
00042	function Trigger(actor Other, pawn EventInstigator)
00043	{
00044		if(bBubbleActive)
00045		{ // Turn the bubble off... it will set itself into a NULL state after the next burst
00046			bBubbleActive = false;
00047		}		
00048		else
00049		{
00050			bBubbleActive = true;
00051			GotoState('Bubbling');
00052		}
00053	}
00054	
00055	//=============================================================================
00056	//
00057	// Burst
00058	//
00059	//=============================================================================
00060	
00061	function Burst()
00062	{
00063		local int i, globCount;
00064		local MudGlob glob;
00065		local actor a;
00066	
00067		Spawn(class'MudRipple');
00068		Spawn(class'SteamBlast',,, Location+Vect(0, 0, 8));
00069	
00070	//	PlaySound(Sound'EnvironmentalSnd.Mud.MudBurst',, 0.2+FRand()*0.2,,
00071	//		1024, 0.8+FRand()*0.4);
00072	
00073		a = Spawn(class'MudSplat');
00074		if(a != None)
00075		{
00076			a.DrawScale = 0.4;
00077			a.SetRotation(Rotator(Vect(0, 0, 1)));
00078		}
00079	
00080		globCount = 1+Rand(3);
00081		for(i = 0; i < globCount; i++)
00082		{
00083			if(FRand() < 0.5)
00084				glob = Spawn(class'MudGlob');
00085			else
00086				glob = Spawn(class'MudGlob2');
00087			if(glob == None)
00088				continue;
00089			glob.Velocity = VRand()*65;
00090			glob.Velocity.Z = 90+FRand()*90;
00091			glob.MudZ = Location.Z;
00092		}
00093	}
00094	
00095	//=============================================================================
00096	//
00097	// BubbleDelay
00098	//
00099	//=============================================================================
00100	
00101	function float BubbleDelay()
00102	{
00103		return FMin(DelayMin, DelayMax)+Abs(DelayMax-DelayMin)*FRand();
00104	}
00105	
00106	//=============================================================================
00107	//
00108	// SetNewLocation
00109	//
00110	//=============================================================================
00111	
00112	function SetNewLocation()
00113	{
00114		local vector v;
00115	
00116		if(BubbleRadius > 0)
00117		{
00118			v = VRand()*RandPosSize;
00119			v.z = 0;
00120			SetLocation(BaseLocation+v);
00121		}
00122	}
00123	
00124	// STATES ---------------------------------------------------------------------
00125	
00126	state Bubbling
00127	{
00128		event Tick(float deltaTime)
00129		{
00130			if(DrawScale < ScaleMax)
00131				DrawScale += 0.8 * deltaTime;
00132		}
00133	
00134	begin:
00135		Sleep(BubbleDelay() * 0.5);
00136		while(bBubbleActive)
00137		{
00138			DrawScale = ScaleMin;
00139			SetNewLocation();
00140			bHidden = false;
00141			PlayAnim('bubble',, 0);
00142			FinishAnim();
00143			bHidden = true;
00144			Burst();
00145			Sleep(BubbleDelay());
00146		}
00147		GotoState('');
00148	}
00149	
00150	defaultproperties
00151	{
00152	     DelayMin=2.000000
00153	     DelayMax=8.000000
00154	     ScaleMin=0.100000
00155	     ScaleMax=2.500000
00156	     DrawType=DT_SkeletalMesh
00157	     LODCurve=LOD_CURVE_NONE
00158	     bShadowCast=False
00159	     Skeletal=SkelModel'objects.MudBubble'
00160	}

End Source Code