RuneI
Class RockAvalanche

source: c:\runehov\RuneI\Classes\RockAvalanche.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Decoration
         |
         +--RuneI.DecorationRune
            |
            +--RuneI.RockAvalanche
Direct Known Subclasses:RockAvalancheHuge, RockAvalancheLarge, RockAvalancheMed, RockAvalancheSmall

class RockAvalanche
extends RuneI.DecorationRune

//============================================================================= // RockAvalanche. //=============================================================================
States
FallingRock

Function Summary
 EMatterType MatterForJoint(int joint)
     
//============================================================
//
// MatterForJoint
//
// Returns what kind of material joint is associated with
//============================================================
 void SpawnDebris()
     
// Find appropriate size of chunks
	scale = (CollisionRadius*CollisionRadius*CollisionHeight) / (numchunks*500);
	scale = scale ** 0.3333333;
	for (NumSourceGroups=1; NumSourceGroups<16; NumSourceGroups++)
	{
		if (SkelGroupSkins[NumSourceGroups] == None)
			break;
	}

	for (i=0; i
 void SpawnDebris()
     
// Find appropriate size of chunks
	scale = (CollisionRadius*CollisionRadius*CollisionHeight) / (numchunks*500);
	scale = scale ** 0.3333333;
	for (NumSourceGroups=1; NumSourceGroups<16; NumSourceGroups++)
	{
		if (SkelGroupSkins[NumSourceGroups] == None)
			break;
	}

	for (i=0; i


State FallingRock Function Summary
 void Timer()
 void HitWall(vector hitNormal, Actor hitWall)
 void Landed(vector HitNormal, Actor HitActor)
 void Touch(Actor Other)
 void MakeHitSound(vector hitNormal, float speed)
 void BeginState()



Source Code


00001	//=============================================================================
00002	// RockAvalanche.
00003	//=============================================================================
00004	class RockAvalanche expands DecorationRune;
00005	
00006	var(Sounds) sound ImpactSound;
00007	
00008	
00009	//============================================================
00010	//
00011	// MatterForJoint
00012	//
00013	// Returns what kind of material joint is associated with
00014	//============================================================
00015	function EMatterType MatterForJoint(int joint)
00016	{
00017		return MATTER_STONE;
00018	}
00019	
00020	
00021	/*	too expensive
00022	function SpawnDebris()
00023	{
00024		local EMatterType matter;
00025		local class<debris> debristype;
00026		local int i, numchunks, NumSourceGroups;
00027		local debris d;
00028		local debriscloud c;
00029		local vector loc;
00030		local float scale;
00031	
00032		// Determine type of debris
00033		matter = MatterForJoint(0);
00034		debristype = class'debrisstone';
00035	
00036		// Spawn cloud
00037		c = Spawn(class'DebrisCloud');
00038		c.SetRadius(Max(CollisionRadius,CollisionHeight));
00039	
00040		// Spawn debris
00041		numchunks = Clamp(Mass/10, 3, 15);
00042	
00043		// Find appropriate size of chunks
00044		scale = (CollisionRadius*CollisionRadius*CollisionHeight) / (numchunks*500);
00045		scale = scale ** 0.3333333;
00046		for (NumSourceGroups=1; NumSourceGroups<16; NumSourceGroups++)
00047		{
00048			if (SkelGroupSkins[NumSourceGroups] == None)
00049				break;
00050		}
00051	
00052		for (i=0; i<numchunks; i++)
00053		{
00054			loc = Location;
00055			loc.X += (FRand()*2-1)*CollisionRadius;
00056			loc.Y += (FRand()*2-1)*CollisionRadius;
00057			loc.Z += (FRand()*2-1)*CollisionHeight;
00058			d = Spawn(debristype,,,loc);
00059			if (d != None)
00060			{
00061				d.SetSize(scale);
00062				d.SetTexture(SkelGroupSkins[i%NumSourceGroups]);
00063				d.SetMomentum(Momentum);
00064				d.LifeSpan = 0.5;
00065			}
00066		}
00067	}
00068	*/
00069	
00070	function SpawnDebris()
00071	{
00072		local debriscloud c;
00073	
00074		// Spawn cloud
00075		c = Spawn(class'DebrisCloud');
00076		c.SetRadius(Max(CollisionRadius,CollisionHeight));
00077	}
00078	
00079	
00080	auto state FallingRock
00081	{
00082		function BeginState()
00083		{
00084			SetPhysics(PHYS_Falling);
00085			DesiredRotation.Yaw = Rotation.Yaw + Rand(2000) - 1000;
00086	//		RotationRate.Yaw = 50000;
00087			RotationRate.Yaw = RandRange(-50000, 50000);
00088			RotationRate.Pitch = RandRange(-50000, 50000);
00089			SetTimer(5, false);
00090		}
00091	
00092		function MakeHitSound(vector hitNormal, float speed)
00093		{
00094			local float f, m, v;
00095			local Sound snd;
00096	
00097			m = FClamp(Mass, 0, 200);
00098			if(hitNormal.Z < 0)
00099				hitNormal.Z = 0;
00100			f = FRand()*0.15 + hitNormal.Z*0.3 + m*0.00275;
00101			speed = FClamp(speed, 0, 400);
00102			v = f*0.2 + m*0.0015 + speed*0.00125;
00103			PlaySound(ImpactSound,, 0.2+v*0.8,,, 0.9+FRand()*0.2);
00104		}
00105	
00106		function Touch(actor Other)
00107		{
00108			local int damage;
00109	
00110			if(Other.IsA('ScriptPawn') && ScriptPawn(Other).bIsBoss)
00111				return; // Don't hurt bosses with falling rocks
00112	
00113			damage = (1-Velocity.Z/400)* Mass/Other.Mass;
00114	
00115			if(Owner != None && Owner.IsA('PlayerPawn') && PlayerPawn(Owner).Weapon != None)
00116			{ // Check to make sure that avalanches don't work in neutralzones/damage teammates, etc
00117				if(PlayerPawn(Owner).Weapon.CalculateDamage(Other) == 0)
00118					return;
00119			}
00120				
00121			if(Other != Owner)
00122				Other.JointDamaged(damage, Instigator, Location, 0.5*Velocity, 'crushed', 0);
00123		}
00124	
00125		function Landed(vector HitNormal, actor HitActor)
00126		{
00127			HitWall(HitNormal, HitActor);
00128		}
00129	
00130		function HitWall(vector hitNormal, actor hitWall)
00131		{
00132			local float speed;
00133	
00134			speed = VSize(Velocity);
00135	
00136			Momentum = hitNormal * speed;
00137			MakeHitSound(hitNormal, speed);
00138			Destroy();
00139		}
00140	
00141		function Timer()
00142		{	// Explode into pieces
00143			bDestroyable=false;//temp
00144			Destroy();
00145		}
00146	
00147	begin:
00148	}
00149	
00150	defaultproperties
00151	{
00152	     ImpactSound=Sound'MurmurSnd.Rocks.rock01'
00153	     bDestroyable=True
00154	     DestroyedSound=Sound'MurmurSnd.Rocks.rock08'
00155	     bStatic=False
00156	     DrawType=DT_SkeletalMesh
00157	     CollisionRadius=5.000000
00158	     CollisionHeight=5.000000
00159	     bCollideActors=True
00160	     bCollideWorld=True
00161	     bBounce=True
00162	     bFixedRotationDir=True
00163	     Mass=10.000000
00164	     Skeletal=SkelModel'objects.Rocks'
00165	}

End Source Code