Engine
Class Decoration

source: e:\games\UnrealTournament\Engine\Classes\Decoration.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Decoration
Direct Known Subclasses:ArenaCam, Car01, Car02, Car03, CTFFlag, IntroBoss, IntroDude, LightCone, Pylon, Shieldd, StudMetal, Stukka, TrophyDude, U, UT_Decoration, Carcass, ScaledSprite, Cannon, Chair, Cryopod, Dice, EscapePod, Flag1, Flag2, Flag3, IntroShip, Lamp1, Lamp4, Moon, Robot, SludgeBarrel, Table, Tapestry1, Barrel, Book, Boulder, BubbleGenerator, Candle, Candle2, Chest, DripGenerator, Fan2, InterpolatingObject, Knife, Lantern, Lantern2, MonkStatue, Panel, Plant1, Plant2, Plant3, Plant4, Plant5, Plant6, Plant7, Sconce, SeaWeed, Sign1, SteelBarrel, SteelBox, Tree, Urn, Vase, Wire, WoodenBox

class Decoration
extends Engine.Actor

//============================================================================= // Decoration. //=============================================================================
Variables
 class EffectWhenDestroyed
 sound EndPushSound
           Used by engine physics.
 sound PushSound
 bool bBobbing
 bool bOnlyTriggerable
 bool bPushSoundPlaying
           Used by engine physics.
 bool bPushable
 bool bSplash
 bool bWasCarried
 class content2
           Used by engine physics.
 class content3
           Used by engine physics.
 class contents
           Used by engine physics.
 int numLandings
           Used by engine physics.


Function Summary
 void BaseChange()
 void Bump(Actor Other)
 void Destroyed()
 void Drop(vector newVel)
 
simulated
FollowHolder(Actor Other)
 void Landed(vector HitNormall)
 void Timer()
 void Trigger(Actor Other, Pawn EventInstigator)
 void ZoneChange(ZoneInfo NewZone)



Source Code


00001	//=============================================================================
00002	// Decoration.
00003	//=============================================================================
00004	class Decoration extends Actor
00005		abstract
00006		native;
00007	
00008	// If set, the pyrotechnic or explosion when item is damaged.
00009	var() class<actor> EffectWhenDestroyed;
00010	var() bool bPushable;
00011	var() bool bOnlyTriggerable;
00012	var bool bSplash;
00013	var bool bBobbing;
00014	var bool bWasCarried;
00015	var() sound PushSound;
00016	var const int	 numLandings; // Used by engine physics.
00017	var() class<inventory> contents;
00018	var() class<inventory> content2;
00019	var() class<inventory> content3;
00020	var() sound EndPushSound;
00021	var bool bPushSoundPlaying;
00022	
00023	simulated function FollowHolder(Actor Other);
00024	
00025	function Drop(vector newVel);
00026	
00027	function Landed(vector HitNormall)
00028	{
00029		if( bWasCarried && !SetLocation(Location) )
00030		{
00031			if( Instigator!=None && (VSize(Instigator.Location - Location) < CollisionRadius + Instigator.CollisionRadius) )
00032				SetLocation(Instigator.Location);
00033			TakeDamage( 1000, Instigator, Location, Vect(0,0,1)*900,'exploded' );
00034		}
00035		bWasCarried = false;
00036		bBobbing = false;
00037	}
00038	
00039	singular function ZoneChange( ZoneInfo NewZone )
00040	{
00041		local float splashsize;
00042		local actor splash;
00043	
00044		if( NewZone.bWaterZone )
00045		{
00046			if( bSplash && !Region.Zone.bWaterZone && Mass<=Buoyancy 
00047				&& ((Abs(Velocity.Z) < 100) || (Mass == 0)) && (FRand() < 0.05) && !PlayerCanSeeMe() )
00048			{
00049				bSplash = false;
00050				SetPhysics(PHYS_None);
00051			}
00052			else if( !Region.Zone.bWaterZone && (Velocity.Z < -200) )
00053			{
00054				// Else play a splash.
00055				splashSize = FClamp(0.0001 * Mass * (250 - 0.5 * FMax(-600,Velocity.Z)), 1.0, 3.0 );
00056				if( NewZone.EntrySound != None )
00057					PlaySound(NewZone.EntrySound, SLOT_Interact, splashSize);
00058				if( NewZone.EntryActor != None )
00059				{
00060					splash = Spawn(NewZone.EntryActor); 
00061					if ( splash != None )
00062						splash.DrawScale = splashSize;
00063				}
00064			}
00065			bSplash = true;
00066		}
00067		else if( Region.Zone.bWaterZone && (Buoyancy > Mass) )
00068		{
00069			bBobbing = true;
00070			if( Buoyancy > 1.1 * Mass )
00071				Buoyancy = 0.95 * Buoyancy; // waterlog
00072			else if( Buoyancy > 1.03 * Mass )
00073				Buoyancy = 0.99 * Buoyancy;
00074		}
00075	
00076		if( NewZone.bPainZone && (NewZone.DamagePerSec > 0) )
00077			TakeDamage(100, None, location, vect(0,0,0), NewZone.DamageType);
00078	}
00079	
00080	function Trigger( actor Other, pawn EventInstigator )
00081	{
00082		Instigator = EventInstigator;
00083		TakeDamage( 1000, Instigator, Location, Vect(0,0,1)*900,'exploded' );
00084	}
00085	
00086	singular function BaseChange()
00087	{
00088		local float decorMass, decorMass2;
00089	
00090		decormass= FMax(1, Mass);
00091		bBobbing = false;
00092		if( Velocity.Z < -500 )
00093			TakeDamage( (1-Velocity.Z/30),Instigator,Location,vect(0,0,0) , 'crushed');
00094	
00095		if( (base == None) && (bPushable || IsA('Carcass')) && (Physics == PHYS_None) )
00096			SetPhysics(PHYS_Falling);
00097		else if( (Pawn(base) != None) && (Pawn(Base).CarriedDecoration != self) )
00098		{
00099			Base.TakeDamage( (1-Velocity.Z/400)* decormass/Base.Mass,Instigator,Location,0.5 * Velocity , 'crushed');
00100			Velocity.Z = 100;
00101			if (FRand() < 0.5)
00102				Velocity.X += 70;
00103			else
00104				Velocity.Y += 70;
00105			SetPhysics(PHYS_Falling);
00106		}
00107		else if( Decoration(Base)!=None && Velocity.Z<-500 )
00108		{
00109			decorMass2 = FMax(Decoration(Base).Mass, 1);
00110			Base.TakeDamage((1 - decorMass/decorMass2 * Velocity.Z/30), Instigator, Location, 0.2 * Velocity, 'stomped');
00111			Velocity.Z = 100;
00112			if (FRand() < 0.5)
00113				Velocity.X += 70;
00114			else
00115				Velocity.Y += 70;
00116			SetPhysics(PHYS_Falling);
00117		}
00118		else
00119			instigator = None;
00120	}
00121	
00122	function Destroyed()
00123	{
00124		local actor dropped, A;
00125		local class<actor> tempClass;
00126	
00127		if( (Pawn(Base) != None) && (Pawn(Base).CarriedDecoration == self) )
00128			Pawn(Base).DropDecoration();
00129		if( (Contents!=None) && !Level.bStartup )
00130		{
00131			tempClass = Contents;
00132			if (Content2!=None && FRand()<0.3) tempClass = Content2;
00133			if (Content3!=None && FRand()<0.3) tempClass = Content3;
00134			dropped = Spawn(tempClass);
00135			dropped.RemoteRole = ROLE_DumbProxy;
00136			dropped.SetPhysics(PHYS_Falling);
00137			dropped.bCollideWorld = true;
00138			if ( inventory(dropped) != None )
00139				inventory(dropped).GotoState('Pickup', 'Dropped');
00140		}	
00141	
00142		if( Event != '' )
00143			foreach AllActors( class 'Actor', A, Event )
00144				A.Trigger( Self, None );
00145	
00146		if ( bPushSoundPlaying )
00147			PlaySound(EndPushSound, SLOT_Misc,0.0);
00148				
00149		Super.Destroyed();
00150	}
00151	
00152	simulated function skinnedFrag(class<fragment> FragType, texture FragSkin, vector Momentum, float DSize, int NumFrags) 
00153	{
00154		local int i;
00155		local actor A, Toucher;
00156		local Fragment s;
00157	
00158		if ( bOnlyTriggerable )
00159			return; 
00160		if (Event!='')
00161			foreach AllActors( class 'Actor', A, Event )
00162				A.Trigger( Toucher, pawn(Toucher) );
00163		if ( Region.Zone.bDestructive )
00164		{
00165			Destroy();
00166			return;
00167		}
00168		for (i=0 ; i<NumFrags ; i++) 
00169		{
00170			s = Spawn( FragType, Owner);
00171			s.CalcVelocity(Momentum/100,0);
00172			s.Skin = FragSkin;
00173			s.DrawScale = DSize*0.5+0.7*DSize*FRand();
00174		}
00175	
00176		Destroy();
00177	}
00178	
00179	simulated function Frag(class<fragment> FragType, vector Momentum, float DSize, int NumFrags) 
00180	{
00181		local int i;
00182		local actor A, Toucher;
00183		local Fragment s;
00184	
00185		if ( bOnlyTriggerable )
00186			return; 
00187		if (Event!='')
00188			foreach AllActors( class 'Actor', A, Event )
00189				A.Trigger( Toucher, pawn(Toucher) );
00190		if ( Region.Zone.bDestructive )
00191		{
00192			Destroy();
00193			return;
00194		}
00195		for (i=0 ; i<NumFrags ; i++) 
00196		{
00197			s = Spawn( FragType, Owner);
00198			s.CalcVelocity(Momentum,0);
00199			s.DrawScale = DSize*0.5+0.7*DSize*FRand();
00200		}
00201	
00202		Destroy();
00203	}
00204	
00205	function Timer()
00206	{
00207		PlaySound(EndPushSound, SLOT_Misc,0.0);
00208		bPushSoundPlaying=False;
00209	}
00210	
00211	function Bump( actor Other )
00212	{
00213		local float speed, oldZ;
00214		if( bPushable && (Pawn(Other)!=None) && (Other.Mass > 40) )
00215		{
00216			bBobbing = false;
00217			oldZ = Velocity.Z;
00218			speed = VSize(Other.Velocity);
00219			Velocity = Other.Velocity * FMin(120.0, 20 + speed)/speed;
00220			if ( Physics == PHYS_None ) {
00221				Velocity.Z = 25;
00222				if (!bPushSoundPlaying) PlaySound(PushSound, SLOT_Misc,0.25);
00223				bPushSoundPlaying = True;			
00224			}
00225			else
00226				Velocity.Z = oldZ;
00227			SetPhysics(PHYS_Falling);
00228			SetTimer(0.3,False);
00229			Instigator = Pawn(Other);
00230		}
00231	}
00232	
00233	defaultproperties
00234	{
00235	     bStatic=True
00236	     bStasis=True
00237	     Texture=None
00238	     Mass=0.000000
00239	}

End Source Code