RuneI
Class DecorationRune

source: c:\runehov\RuneI\Classes\DecorationRune.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Decoration
         |
         +--RuneI.DecorationRune
Direct Known Subclasses:AnimalTrough, Bench, Bone, BoneBridgeBig, BoneBridgeSmall, Bucket, BurlapSack, Chandelier, Crucifix2, Crusifix, DeadBaracuda, DecorationWeapon, DestroyRock, EmptyTubestriker, FireObject, FireRing, Floater, FootBridge, Gib, GoblinMask, GrainSack, HangingChain, HelChandelier, HelSpikeBig, HelSpikeSmall, Instrument, Keg, Kettle, Limb, Oar, Pelvis, Plants, Plate, RibInDirt1, RibInDirt2, RibInDirt3, Ribs, RockAvalanche, Rocks, Skin, SkinRack, Skull, Statue, Stool, Table, Tarp, TarpFrame, TorchHolder, Trees, Wagon, WagonLarge, WaterPlants, SarkBallGong

class DecorationRune
extends Engine.Decoration

//============================================================================= // DecorationRune. //=============================================================================
Variables
 vector Momentum
 bool bDestroyable


Function Summary
 void AddVelocity(vector NewVelocity)
     
/*
 void Destroyed()
 bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Mom, name DamageType, int joint)
     
{
	if (Physics != PHYS_Falling)
		SetPhysics(PHYS_Falling);
	Velocity += NewVelocity;
}
*/
 EMatterType MatterForJoint(int joint)
 void PlayDestroyedSound()
 void SetOnFire(Pawn EventInstigator, int joint)
     
// RUNE: Can be set on fire
 void SpawnDebris()



Source Code


00001	//=============================================================================
00002	// DecorationRune.
00003	//=============================================================================
00004	class DecorationRune extends Decoration
00005		abstract;
00006	
00007	var() bool bDestroyable;
00008	var vector Momentum;
00009	var(Sounds) sound DestroyedSound;
00010	var(Advanced) bool        bBurnable;			// RUNE: Can be set on fire
00011	
00012	
00013	function SetOnFire(Pawn EventInstigator, int joint)
00014	{
00015		local PawnFire F;
00016	
00017		if (bBurnable)
00018		{
00019			if (ActorAttachedTo(joint) == None)
00020			{
00021				F = Spawn(class'PawnFire',EventInstigator);
00022				AttachActorToJoint(F, joint);
00023			}
00024		}
00025	}
00026	
00027	function EMatterType MatterForJoint(int joint)
00028	{
00029		return MATTER_WOOD;
00030	}
00031	
00032	/*
00033	function AddVelocity(vector NewVelocity)
00034	{
00035		if (Physics != PHYS_Falling)
00036			SetPhysics(PHYS_Falling);
00037		Velocity += NewVelocity;
00038	}
00039	*/
00040	
00041	function bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Mom, name DamageType, int joint)
00042	{
00043		local EMatterType matter;
00044		local bool bDamage;
00045	
00046		if (DamageType == 'fire')
00047		{
00048			return Super.JointDamaged(Damage, EventInstigator, HitLoc, Mom, DamageType, joint);
00049		}
00050	
00051		if (bDestroyable)
00052		{
00053			Momentum = Mom;
00054			Destroy();
00055	
00056	/* CJR - changed this so all weapons can destroy all decorations, so that creatures can smash objects at will
00057			matter = MatterForJoint(joint);
00058			switch(DamageType)
00059			{
00060				case 'sever':		// Sword
00061				case 'thrownweaponsever':
00062					bDamage = (matter==MATTER_FLESH || matter==MATTER_EARTH);
00063					break;
00064				case 'bluntsever':	// Axe
00065				case 'thrownweaponbluntsever':
00066					bDamage = (matter==MATTER_FLESH || matter==MATTER_WOOD || matter==MATTER_EARTH);
00067					break;
00068				case 'blunt':		// Hammer
00069				case 'thrownweaponblunt':
00070					bDamage = (matter==MATTER_FLESH || matter==MATTER_WOOD || matter==MATTER_STONE || matter==MATTER_EARTH);
00071					break;
00072				default:
00073					bDamage = false;
00074					break;
00075			}
00076	
00077			if (bDamage)
00078			{
00079				Momentum = Mom;
00080				Destroy();
00081			}
00082	*/
00083		}
00084	
00085		return false;
00086	}
00087	
00088	function PlayDestroyedSound()
00089	{
00090		local EMatterType matter;
00091	
00092		if (DestroyedSound != None)
00093		{	// Default behavior is to play matter based crash sounds unless a specific DestroyedSound is specified
00094			PlaySound(DestroyedSound, SLOT_Pain);
00095		}
00096		else
00097		{
00098			matter = MatterForJoint(0);
00099			switch(matter)
00100			{
00101				case MATTER_FLESH:
00102					PlaySound(Sound'WeaponsSnd.impflesh.impactflesh02', SLOT_Pain);
00103					break;
00104				case MATTER_WOOD:
00105					PlaySound(Sound'WeaponsSnd.impcrashes.crashwood01', SLOT_Pain);
00106					break;
00107				case MATTER_STONE:
00108					PlaySound(Sound'WeaponsSnd.impcrashes.crashxstone01', SLOT_Pain);
00109					break;
00110				case MATTER_EARTH:
00111					PlaySound(Sound'WeaponsSnd.impcrashes.crashwood03', SLOT_Pain);
00112					break;
00113				case MATTER_ICE:
00114					PlaySound(Sound'WeaponsSnd.impcrashes.crashglass02', SLOT_Pain);
00115					break;
00116			}
00117		}
00118	}
00119	
00120	function SpawnDebris()
00121	{
00122		local EMatterType matter;
00123		local class<debris> debristype;
00124		local int i, numchunks, NumSourceGroups;
00125		local debris d;
00126		local debriscloud c;
00127		local vector loc;
00128		local float scale;
00129	
00130		// Determine type of debris
00131		matter = MatterForJoint(0);
00132		switch(matter)
00133		{
00134			case MATTER_FLESH:
00135				debristype = class'debrisflesh';
00136				break;
00137			case MATTER_WOOD:
00138				debristype = class'debriswood';
00139				break;
00140			case MATTER_STONE:
00141			case MATTER_EARTH:
00142				debristype = class'debrisstone';
00143				break;
00144			case MATTER_ICE:
00145				debristype = class'debrisice';
00146				break;
00147		}
00148	
00149		// Spawn cloud
00150		c = Spawn(class'DebrisCloud');
00151		c.SetRadius(Max(CollisionRadius,CollisionHeight));
00152	
00153		// Spawn debris
00154		if (debristype != None)
00155		{
00156			numchunks = Clamp(Mass/10, 2, 10)*Level.Game.DebrisPercentage;
00157	
00158			// Find appropriate size of chunks
00159			scale = (CollisionRadius*CollisionRadius*CollisionHeight) / (numchunks*500);
00160			scale = scale ** 0.3333333;
00161			for (NumSourceGroups=1; NumSourceGroups<16; NumSourceGroups++)
00162			{
00163				if (SkelGroupSkins[NumSourceGroups] == None)
00164					break;
00165			}
00166	
00167			for (i=0; i<numchunks; i++)
00168			{
00169				loc = Location;
00170				loc.X += (FRand()*2-1)*CollisionRadius;
00171				loc.Y += (FRand()*2-1)*CollisionRadius;
00172				loc.Z += (FRand()*2-1)*CollisionHeight;
00173				d = Spawn(debristype,,,loc);
00174				if (d != None)
00175				{
00176					d.SetSize(scale);
00177					d.SetTexture(SkelGroupSkins[i%NumSourceGroups]);
00178					d.SetMomentum(Momentum);
00179				}
00180			}
00181		}
00182	}
00183	
00184	
00185	function Destroyed()
00186	{
00187		if (bDestroyable)
00188		{
00189			SpawnDebris();
00190			PlayDestroyedSound();
00191		}
00192		Super.Destroyed();
00193	}
00194	
00195	defaultproperties
00196	{
00197	     bSweepable=True
00198	     Mass=100.000000
00199	}

End Source Code