SpatialFear.SFDecoration

00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
//=============================================================================
// Spatial Fear
// Class: SFDecoration
// Description: Subclass of Decoration, allows destroying of decorations.
//              When bDestroyable is TRUE and damage is inflicted to decoration, object of type
//              EffectWhenDamaged is spawned. When Health drops to zero or less decoration is
//              destroyed, object of type EffectWhenDestroyed is spawned and chunks of type
//              ChunkType are spawned. If there's necessity for more advanced damage proccesing when decoration gets
//              hit, it is a good idea not to override TakeDamage function as it's responsible for spawning
//              effects and stuff. Override ModifyDamage function instead (it's alwayes called by TakeDamage).
//
// Effect info: EffectWhenDamaged and EffectWhenDestroyed could be any sub-class of Actor, but in most cases they
//              would probablybe some sub-class of Effects class. EffectWhenDamaged object is spawned in location where
//              decoration was hit and it's rotated into direcion of player.
//
// Chunks info: There are four types of chunks in UT: Fragment1, GlassFragments, WallFragments, WoodFragments.
//              You can change size and number of chunks with ChunkNumber and ChunkScale variables.
//              If you don't wanna your decoration to break into pieces after being destroyed, set ChunksNumber to 0,
//              (0 is default value of ChunksNumber so if you do wanna use chunks don't forget to change it).
//
//              You can also change texture used as a skin for chunks. If you don't wanna use chunk's default skin, set
//              bCustomChunkSkin to TRUE and ChunkSkin to texture you wanna use.
//
//              IMPORTANT!!! if you wanna create destroyable decoration you have to set bStatic to false,
//              if you don't your decko can't be destroyed, even with Health below zero
//
// Author: Jacek Zagrodzki (moose)
//=============================================================================
class SFDecoration expands Decoration;

// public parameters that can be adjusted in UnrealED:
var() bool			bThrowable;			// If this  item can be thrown or just dropped after having picked it up. Only effective for items with bPushable set and mass <45. Default: true (can be thrown)
var() bool			bDestroyable;		// if TRUE, decoration can be damaged and destroyed
var() travel int		Health;			// if drops to zero or less decoration is destroyed

var() class<actor>	EffectWhenDestroyed;	// 
var() class<actor>	EffectWhenDamaged;	// 

var() class<Fragment>	ChunkType;			// name of class that will be used for spawning chunks
var() int			ChunksNumber;		// number of chunks spawned when deco is destroyed (default=0)
var() float			ChunkScale;			// size of a single chunk (defalut 1.0)

var() bool			bCustomChunkSkin;		// if TRUE, chunkas will have texture from ChunkSkin insted of their default skins
var() texture		ChunkSkin;			// a texture that will be used as chunk's skin

function PostBeginPlay()
{
	Health = default.Health;
}

event TakeDamage( int Damage, Pawn EventInstigator, vector HitLocation, vector Momentum, name DamageType)
{
	local Actor DestroyEffect;
	local Actor DamageEffect;
	local float tempX;

	if(bDestroyable)
	{
		ModifyDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType);	// modify damage if necessary
		Health -= Damage;
		if(Health <= 0)	// destroy object
		{
			DestroyEffect = spawn(EffectWhenDestroyed, Self,, Location);

			if(bCustomChunkSkin)
				skinnedFrag(ChunkType, ChunkSkin, Momentum, ChunkScale, ChunksNumber);
			else
				Frag(ChunkType, Momentum, ChunkScale, ChunksNumber);

			Destroy();
		}
	}
	
	if(Health > 0)
	{
		DamageEffect = spawn(EffectWhenDamaged, Self, , HitLocation, rotator(Momentum));
	}
}

/**
Override this function if there's necessity for more advanced damage proccesing when decoration gets hit.
*/
function ModifyDamage( out int Damage, out Pawn EventInstigator, out vector HitLocation, out vector Momentum, out name DamageType)
{
	//implemented in sub-class
}

defaultproperties
{
     bThrowable=True
     ChunkScale=1.000000
     bCollideActors=True
     bCollideWorld=True
     bBlockActors=True
     bBlockPlayers=True
     bProjTarget=True
     Mass=100.000000
}

class file time: 12/7/2003 3:58:24 PM - creation time: 12/7/2003 4:03:44 PM
Created with UnCodeX