Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

U2.GibSet


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
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
//-----------------------------------------------------------------------------
// GibSet.uc
// $Author: Mbaldwin $
// $Date: 11/12/02 7:12p $
// $Revision: 17 $
//-----------------------------------------------------------------------------
// A collection of gibby bits.
//-----------------------------------------------------------------------------
class GibSet extends Object
	abstract;

struct GibDesc
{
	var() string			MeshName; 					// mesh to use
	var() string			SkinName;					// skin to use
	var() int				SkinSlot;					// slot
	var() string			BounceSoundStr;				// special bounce sound, usually none
	var() bool				bNoBlood;					// whether to spawn blood when bouncing (e.g. false for bones)
	var() float 			Odds;						// odds of using this part
	var() float				PctParentMass;				// percent mass of gib part (affects how far it's tossed)
	var() bool				bNoDamage;					// if true, chunk doesn't take damage
	var() float				DrawScale;
	var() float				CollisionHeight;			// gibs collision cylinder dimensions
	var() float				CollisionRadius;
	var() vector			PrePivot;					// offset to make gib lay flat
	var() int				ExtraCount;					// number of additional times to spawn that gib
};

var int GoreLevel;
var array<GibDesc> Gibs;
var array<sound> GibbedSounds;
var array<sound> BounceSounds;
var ParticleRadiator GibbedEffectType;
var ParticleGenerator BloodTrailType;
var float GibbedEffectVolumeMultiplier;
var float BloodTrailVolumeMultiplier;
var float GibbedEffectLifeSpanMultiplier;
var float BloodTrailLifeSpanMultiplier;

//-----------------------------------------------------------------------------

static function CreateChunks( U2Pawn U2P )
{
	local int i, j;
	local sound GibSound;

	if( U2P == None || U2P.bDeleteMe )
		return;

	for( i=0; i < default.Gibs.Length; i++ )
		if( default.Gibs[i].MeshName != "" && FRand() < default.Gibs[i].Odds )
		{
			for( j=0; j<default.Gibs[i].ExtraCount+1; j++ )
				CreateChunk( U2P, i );
		}
		
	GibSound = default.GibbedSounds[ Rand( default.GibbedSounds.Length ) ];
	U2P.PlaySound( GibSound );
}

//-----------------------------------------------------------------------------

static function Gib CreateChunk( U2Pawn U2P, int GibIndex )
{
	local vector NewLocation, GibDir;
	local float Spread;
	local rotator BaseRotation;
	local GibDesc GibInfo;
	local Gib Chunk;

	GibInfo = default.Gibs[GibIndex];

	// location
	NewLocation = U2P.Location;
	NewLocation.X += RandRange( -U2P.CollisionRadius, U2P.CollisionRadius );
	NewLocation.Y += RandRange( -U2P.CollisionRadius, U2P.CollisionRadius );
	NewLocation.Z += RandRange( -U2P.CollisionHeight, U2P.CollisionHeight );

	Chunk = U2P.Spawn( class'Gib',,, NewLocation );
	if( Chunk != None && !Chunk.bDeleteMe )
	{
		Chunk.StaticMesh = StaticMesh( DynamicLoadObject( GibInfo.MeshName, class'StaticMesh' ) );
		if( GibInfo.SkinName != "" )
			Chunk.Skins[GibInfo.SkinSlot] = Texture( DynamicLoadObject( GibInfo.SkinName, class'Texture' ) );

		// dimensions
		Chunk.SetCollisionSize( GibInfo.CollisionRadius, GibInfo.CollisionHeight );
		Chunk.SetDrawScale( GibInfo.DrawScale );
		Chunk.PrePivot=GibInfo.PrePivot;

		// mass / buoyancy
		if( GibInfo.PctParentMass > 0 )
			Chunk.Mass = U2P.Mass * GibInfo.PctParentMass;
		else
			Chunk.Mass = U2P.Mass / U2P.GibSetClass.default.Gibs.Length;

		if( FRand() < 0.3 )
			Chunk.Buoyancy = 1.06 * Chunk.Mass; // float chunk
		else
			Chunk.Buoyancy = 0.94 * Chunk.Mass;

		// rotation
		if( VSize( U2P.Velocity ) < 10 )
			BaseRotation = rotator(vect(0,0,1));
		else
			BaseRotation = U2P.Rotation;

		// default spread in case ground speed is zero
		Spread = 360.0;
		// the slower the victim's velocity, the more the spread
		if( U2P.GroundSpeed > 0 )
			Spread = (1.0 - (VSize(U2P.Velocity) / U2P.GroundSpeed)) * 360;
		GibDir = class'Util'.static.CalcSprayDirection( BaseRotation, RandRange(0, Spread) );
		Chunk.SetRotation( rotator( GibDir ));

		// spin
		Chunk.RotationRate.Yaw = 128000 * FRand() - 64000;
		Chunk.RotationRate.Pitch = 128000 * FRand() - 64000;
		Chunk.RotationRate.Roll = 128000 * FRand() - 64000;	
		Chunk.DesiredRotation = RotRand();
		Chunk.bRotateToDesired = false;

		// velocity
		if( VSize( U2P.Velocity ) < 100 )
			Chunk.Velocity = GibDir * RandRange( 250, 400 );		// stationary, randomize speed
		else
			Chunk.Velocity = U2P.Velocity * RandRange(0.5,1.5);		// randomize along velocity vector

		// don't sink player gibs
		if( U2P.bIsRealPlayer )
			Chunk.bShouldSink = false;

		Chunk.SetupEffects( U2P );

		Chunk.BounceSound = default.BounceSounds[ Rand( default.BounceSounds.Length ) ];
	}
	
	return Chunk;
}

//-----------------------------------------------------------------------------

defaultproperties
{
	GoreLevel=3
     GibbedSounds(0)=Sound'U2A.Effects.Gibbed1'
     GibbedSounds(1)=Sound'U2A.Effects.Gibbed2'
     GibbedSounds(2)=Sound'U2A.Effects.Gibbed3'
     BounceSounds(0)=Sound'U2A.Effects.GibBounce01'
     BounceSounds(1)=Sound'U2A.Effects.GibBounce02'
     BounceSounds(2)=Sound'U2A.Effects.GibBounce03'
     BounceSounds(3)=Sound'U2A.Effects.GibBounce04'
	GibbedEffectVolumeMultiplier=1.000000
	BloodTrailVolumeMultiplier=1.000000
	GibbedEffectLifeSpanMultiplier=1.000000
	BloodTrailLifeSpanMultiplier=1.000000
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: sk 3-1-2016 10:38:42.000 - Creation time: sk 3-1-2016 10:48:39.142 - Created with UnCodeX