## Engine
Class Decoration

source: C:\XIII\Engine\Classes\Decoration.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Decoration

Direct Known Subclasses:HelicoRearRotor, HelicoTopRotor, Banque01DecoBombe, HarrierCockpitUndercarriage, HarrierMovingCockpit, HarrierStaticCockpit, Hual04aDecoFusible, Sanc02aDecoStatuePart, Spads02DecoBombe, Spads02DecoMicro, Usa01DecoBombe, CameraDeSurveillance, Prock03_FioleDeco, HookPoint, InteractiveCan, MitraillTop, Mitrailleuse, VehicleDeco, XIIIMPFlag

class Decoration
extends Engine.Actor

    //=============================================================================
    // Decoration.
    //=============================================================================

Variables
`class` | `EffectWhenDestroyed`
`PushSound,` | `EndPushSound`
`Texture` | `FragSkin` skin to use for fragments
`class` | `FragType` type of fragment to use
`int` | `Health` type of fragment to use
`int` | `NumFrags` number of fragments to spawn when destroyed
`ShadowProjector` | `Shadow` type of fragment to use
`float` | `SplashTime` type of fragment to use
`bool` | `bDamageable`
`bool` | `bPushSoundPlaying`
`bool` | `bPushable`
`bool` | `bSplash`
`class` | `contents` spawned when destroyed
`int` | `numLandings` Used by engine physics.

Function Summary
`void` | `BaseChange()`
`void` | `Bump(Actor Other)`
`bool` | `CanSplash()`
`simulated` | `Destroyed()`
`void` | `Drop(vector newVel)`
`void` | `HitWall(vector HitNormal, Actor Wall)`
`void` | `Landed(vector HitNormal)`
`void` | `PhysicsVolumeChange(PhysicsVolume NewVolume)`
`void` | `Timer()`
`void` | `Trigger(Actor Other, Pawn EventInstigator)`

Source Code

    00001	//=============================================================================
    00002	// Decoration.
    00003	//=============================================================================
    00004	class Decoration extends Actor
    00005		abstract
    00006		placeable
    00007		native;
    00008
    00009	// If set, the pyrotechnic or explosion when item is damaged.
    00010	var()  class<actor> EffectWhenDestroyed;
    00011	var() bool bPushable;
    00012	var() bool bDamageable;
    00013	var bool bPushSoundPlaying;
    00014	var bool bSplash;
    00015
    00016	var() sound PushSound, EndPushSound;
    00017	var const int	 numLandings;		// Used by engine physics.
    00018	var() class<inventory> contents;	// spawned when destroyed
    00019
    00020	var()	int		NumFrags;		// number of fragments to spawn when destroyed
    00021	var()	texture	FragSkin;		// skin to use for fragments
    00022	var()	class<Fragment> FragType;	// type of fragment to use
    00023	var		vector FragMomentum;		// momentum to be imparted to frags when destroyed
    00024	var()	int		Health;
    00025	var()	float  SplashTime;
    00026
    00027	// shadow decal
    00028	var ShadowProjector	Shadow;
    00029
    00030	event PostBeginPlay()
    00031	{
    00032		if(bActorShadows && (Shadow==None) )
    00033		{
    00034			Shadow = Spawn(class'ShadowProjector',Self,'',Location);
    00035			Shadow.ShadowScale = 4.0;
    00036		}
    00037	}
    00038
    00039	function bool CanSplash()
    00040	{
    00041		if ( (Level.TimeSeconds - SplashTime > 0.25)
    00042			&& (Physics == PHYS_Falling)
    00043			&& (Abs(Velocity.Z) > 100) )
    00044		{
    00045			SplashTime = Level.TimeSeconds;
    00046			return true;
    00047		}
    00048		return false;
    00049	}
    00050
    00051	function Drop(vector newVel);
    00052
    00053	function Landed(vector HitNormal)
    00054	{
    00055		local rotator NewRot;
    00056
    00057		if (Velocity.Z<-500)
    00058			TakeDamage(100,Pawn(Owner),HitNormal,HitNormal*10000,class'Crushed');
    00059		Velocity = vect(0,0,0);
    00060		NewRot = Rotation;
    00061		NewRot.Pitch = 0;
    00062		NewRot.Roll = 0;
    00063		SetRotation(NewRot);
    00064	}
    00065
    00066	function HitWall (vector HitNormal, actor Wall)
    00067	{
    00068		Landed(HitNormal);
    00069	}
    00070
    00071	function TakeDamage( int NDamage, Pawn instigatedBy, Vector hitlocation,
    00072						Vector momentum, class<DamageType> damageType)
    00073	{
    00074		Instigator = InstigatedBy;
    00075		if (!bDamageable || (Health<0) )
    00076			Return;
    00077		if ( Instigator != None )
    00078			MakeNoise(1.0);
    00079		Health -= NDamage;
    00080		FragMomentum = Momentum;
    00081		if (Health <0)
    00082			Destroy();
    00083		else
    00084		{
    00085			SetPhysics(PHYS_Falling);
    00086			Momentum.Z = 1000;
    00087			Velocity=Momentum/Mass;
    00088		}
    00089	}
    00090
    00091	singular function PhysicsVolumeChange( PhysicsVolume NewVolume )
    00092	{
    00093		if( NewVolume.bWaterVolume )
    00094		{
    00095			if( bSplash && !PhysicsVolume.bWaterVolume && Mass<=Buoyancy
    00096				&& ((Abs(Velocity.Z) < 100) || (Mass == 0)) && (FRand() < 0.05) && !PlayerCanSeeMe() )
    00097			{
    00098				bSplash = false;
    00099				SetPhysics(PHYS_None);
    00100			}
    00101		}
    00102		if( PhysicsVolume.bWaterVolume && (Buoyancy > Mass) )
    00103		{
    00104			if( Buoyancy > 1.1 * Mass )
    00105				Buoyancy = 0.95 * Buoyancy; // waterlog
    00106			else if( Buoyancy > 1.03 * Mass )
    00107				Buoyancy = 0.99 * Buoyancy;
    00108		}
    00109	}
    00110
    00111	function Trigger( actor Other, pawn EventInstigator )
    00112	{
    00113		Instigator = EventInstigator;
    00114		TakeDamage( 1000, Instigator, Location, Vect(0,0,1)*900, class'Crushed');
    00115	}
    00116
    00117	singular function BaseChange()
    00118	{
    00119		if( Velocity.Z < -500 )
    00120			TakeDamage( (1-Velocity.Z/30),Instigator,Location,vect(0,0,0) , class'Crushed');
    00121
    00122		if( base == None )
    00123		{
    00124			if ( !bInterpolating && bPushable && (Physics == PHYS_None) )
    00125				SetPhysics(PHYS_Falling);
    00126		}
    00127		else if( Pawn(Base) != None )
    00128		{
    00129			Base.TakeDamage( (1-Velocity.Z/400)* mass/Base.Mass,Instigator,Location,0.5 * Velocity , class'Crushed');
    00130			Velocity.Z = 100;
    00131			if (FRand() < 0.5)
    00132				Velocity.X += 70;
    00133			else
    00134				Velocity.Y += 70;
    00135			SetPhysics(PHYS_Falling);
    00136		}
    00137		else if( Decoration(Base)!=None && Velocity.Z<-500 )
    00138		{
    00139			Base.TakeDamage((1 - Mass/Base.Mass * Velocity.Z/30), Instigator, Location, 0.2 * Velocity, class'Crushed');
    00140			Velocity.Z = 100;
    00141			if (FRand() < 0.5)
    00142				Velocity.X += 70;
    00143			else
    00144				Velocity.Y += 70;
    00145			SetPhysics(PHYS_Falling);
    00146		}
    00147		else
    00148			instigator = None;
    00149	}
    00150
    00151	simulated function Destroyed()
    00152	{
    00153		local inventory dropped;
    00154		local int i;
    00155		local Fragment s;
    00156		local float BaseSize;
    00157
    00158		if ( Role == ROLE_Authority )
    00159		{
    00160			if( (Contents!=None) && !Level.bStartup )
    00161			{
    00162				dropped = Spawn(Contents);
    00163				dropped.DropFrom(Location);
    00164			}
    00165
    00166			TriggerEvent( Event, Self, None);
    00167
    00168			if ( bPushSoundPlaying )
    00169				PlaySound(EndPushSound);
    00170		}
    00171
    00172		if ( (Level.NetMode != NM_DedicatedServer )
    00173			&& !PhysicsVolume.bDestructive
    00174			&& (NumFrags > 0) && (FragType != None) )
    00175		{
    00176			// spawn fragments
    00177			BaseSize = 0.8 * sqrt(CollisionRadius*CollisionHeight)/NumFrags;
    00178			for ( i=0; i<numfrags; i++ )
    00179			{
    00180				s = Spawn( FragType, Owner,,Location + CollisionRadius * VRand());
    00181				s.CalcVelocity(FragMomentum);
    00182				if ( FragSkin != None )
    00183					s.Skins[0] = FragSkin;
    00184				s.SetDrawScale(BaseSize * (0.5+0.7*FRand()));
    00185			}
    00186		}
    00187
    00188		if ( Shadow != None )
    00189			Shadow.Destroy();
    00190
    00191		Super.Destroyed();
    00192	}
    00193
    00194	function Timer()
    00195	{
    00196		PlaySound(EndPushSound);
    00197		bPushSoundPlaying=False;
    00198	}
    00199
    00200	function Bump( actor Other )
    00201	{
    00202		local float speed, oldZ;
    00203		if( bPushable && (Pawn(Other)!=None) && (Other.Mass > 40) )
    00204		{
    00205			oldZ = Velocity.Z;
    00206			speed = VSize(Other.Velocity);
    00207			Velocity = Other.Velocity * FMin(120.0, 20 + speed)/speed;
    00208			if ( Physics == PHYS_None )
    00209			{
    00210				Velocity.Z = 25;
    00211				if (!bPushSoundPlaying)
    00212				{
    00213					PlaySound(PushSound);
    00214					bPushSoundPlaying = True;
    00215				}
    00216			}
    00217			else
    00218				Velocity.Z = oldZ;
    00219			SetPhysics(PHYS_Falling);
    00220			SetTimer(0.3,False);
    00221			Instigator = Pawn(Other);
    00222		}
    00223	}
    00224
    00225	defaultproperties
    00226	{
    00227	     bStatic=True
    00228	     bStasis=True
    00229	     bOrientOnSlope=True
    00230	     DrawType=DT_Mesh
    00231	     NetUpdateFrequency=10.000000
    00232	}

End Source Code