Botpack
Class UTCreatureChunks

source: e:\games\UnrealTournament\Botpack\Classes\UTCreatureChunks.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Decoration
         |
         +--Engine.Carcass
            |
            +--Botpack.UTCreatureChunks
Direct Known Subclasses:UTMasterCreatureChunk, UTPlayerChunks

class UTCreatureChunks
extends Engine.Carcass

//============================================================================= // UTCreatureChunks. //=============================================================================
States
Dead, Dying

Function Summary
 
simulated
BeginPlay()
 void ChunkUp(int Damage)
 
simulated
ClientExtraChunks()
 
simulated
Destroyed()
 
simulated
HitWall(vector HitNormal, Actor Wall)
 void InitVelocity(Actor Other)
 void Initfor(Actor Other)
 
simulated
Landed(vector HitNormal)
 void TakeDamage(int Damage, Pawn instigatedBy, Vector hitlocation, Vector momentum, name damageType)
 
simulated
ZoneChange(ZoneInfo NewZone)


State Dead Function Summary
 void BeginState()
 void Timer()


State Dying Function Summary



Source Code


00001	//=============================================================================
00002	// UTCreatureChunks.
00003	//=============================================================================
00004	class UTCreatureChunks extends Carcass;
00005	
00006	var		UT_Bloodtrail		trail;
00007	var		float			TrailSize;
00008	var		bool			bGreenBlood;
00009	var		class<UTHumanCarcass>	CarcassClass;
00010	var		name			CarcassAnim;	   	
00011	var		Vector			CarcLocation;
00012	var		float			CarcHeight;
00013	var		Sound	HitSounds[4];
00014	
00015	replication
00016	{
00017		// Things the server should send to the client.
00018		unreliable if( Role==ROLE_Authority )
00019			bGreenBlood, CarcassClass, CarcassAnim, CarcLocation, CarcHeight;
00020	}
00021	
00022	simulated function BeginPlay()
00023	{
00024		if ( Region.Zone.bDestructive 
00025			|| ((Level.NetMode == NM_Standalone) && class'GameInfo'.Default.bLowGore) )
00026		{
00027			Destroy();
00028			return;
00029		}
00030	
00031		Super.BeginPlay();
00032	}
00033	
00034	simulated function ClientExtraChunks()
00035	{
00036		local UT_BloodBurst b;
00037	
00038		If ( Level.NetMode == NM_DedicatedServer )
00039			return;
00040	
00041		b = Spawn(class 'UT_BloodBurst',,,,rot(16384,0,0));
00042		if ( bGreenBlood )
00043			b.GreenBlood();
00044		b.RemoteRole = ROLE_None;
00045	}
00046	
00047	simulated function ZoneChange( ZoneInfo NewZone )
00048	{
00049		local float splashsize;
00050		local actor splash;
00051	
00052		if ( NewZone.bWaterZone )
00053		{
00054			if ( trail != None )
00055			{
00056				if ( Level.bHighDetailMode && !Level.bDropDetail )
00057					bUnlit = false;
00058				trail.Destroy();
00059			}
00060			if ( Mass <= Buoyancy )
00061				SetCollisionSize(0,0);
00062			if ( bSplash && !Region.Zone.bWaterZone && (Abs(Velocity.Z) < 80) )
00063				RotationRate *= 0.6;
00064			else if ( !Region.Zone.bWaterZone && (Velocity.Z < -200) )
00065			{
00066				// else play a splash
00067				splashSize = FClamp(0.0001 * Mass * (250 - 0.5 * FMax(-600,Velocity.Z)), 1.0, 2.0 );
00068				if ( NewZone.EntrySound != None )
00069					PlaySound(NewZone.EntrySound, SLOT_Interact, splashSize);
00070				if ( NewZone.EntryActor != None )
00071				{
00072					splash = Spawn(NewZone.EntryActor); 
00073					if ( splash != None )
00074						splash.DrawScale = splashSize;
00075				}
00076			}
00077			bSplash = true;
00078		}
00079	
00080		if ( NewZone.bDestructive || (NewZone.bPainZone  && (NewZone.DamagePerSec > 0)) )
00081			Destroy();
00082	}
00083		
00084	simulated function Destroyed()
00085	{
00086		if ( trail != None )
00087			trail.Destroy();
00088		Super.Destroyed();
00089	}
00090	
00091	function InitVelocity(Actor Other)
00092	{
00093		local vector RandDir;
00094	
00095		RandDir = 700 * FRand() * VRand();
00096		RandDir.Z = 200 * FRand() - 50;
00097		Velocity = (0.2 + FRand()) * (other.Velocity + RandDir);
00098		If (Region.Zone.bWaterZone)
00099			Velocity *= 0.5;
00100	}
00101	
00102	function Initfor(actor Other)
00103	{
00104		if ( Other.IsA('Carcass') )
00105			PlayerOwner = Carcass(Other).PlayerOwner;
00106		bDecorative = false;
00107		DrawScale = Other.DrawScale;
00108		if ( DrawScale != 1.0 )
00109			SetCollisionSize(CollisionRadius * 0.5 * (1 + DrawScale), CollisionHeight * 0.5 * (1 + DrawScale));
00110		RotationRate.Yaw = Rand(200000) - 100000;
00111		RotationRate.Pitch = Rand(200000 - Abs(RotationRate.Yaw)) - 0.5 * (200000 - Abs(RotationRate.Yaw));
00112		InitVelocity(Other);
00113		if ( TrailSize > 0 )
00114		{
00115			if ( UTHumanCarcass(Other) != None )
00116				bGreenBlood = UTHumanCarcass(Other).bGreenBlood;
00117			else if ( (UTCreatureChunks(Other) != None) )
00118				bGreenBlood = UTCreatureChunks(Other).bGreenBlood;
00119		}
00120				
00121		if ( FRand() < 0.3 )
00122			Buoyancy = 1.06 * Mass; // float corpse
00123		else
00124			Buoyancy = 0.94 * Mass;
00125	}
00126	
00127	function ChunkUp(int Damage)
00128	{
00129		local UT_BloodBurst b;
00130	
00131		if (bHidden)
00132			return;
00133		b = Spawn(class 'UT_BloodBurst',,,,rot(16384,0,0));
00134		if ( bGreenBlood )		
00135			b.GreenBlood();	
00136		if (bPlayerCarcass)
00137		{
00138			bHidden = true;
00139			SetPhysics(PHYS_None);
00140			SetCollision(false,false,false);
00141			bProjTarget = false;
00142			if ( Trail != None )
00143				Trail.Destroy();
00144		}
00145		else
00146			destroy();
00147	}
00148	
00149	simulated function Landed(vector HitNormal)
00150	{
00151		local rotator finalRot;
00152		local UT_BloodBurst b;
00153		local actor a;
00154	
00155		if ( trail != None )
00156		{
00157			if ( Level.bHighDetailMode && !Level.bDropDetail )
00158				bUnlit = false;
00159			trail.Destroy();
00160			trail = None;
00161		}
00162		finalRot = Rotation;
00163		finalRot.Roll = 0;
00164		finalRot.Pitch = 0;
00165		setRotation(finalRot);
00166		if ( (Level.NetMode != NM_DedicatedServer) && !Level.bDropDetail )
00167		{
00168			b = Spawn(class 'UT_BloodBurst',,,,rot(0,0,0));
00169			if ( bGreenBlood )
00170				b.GreenBlood();		
00171			b.RemoteRole = ROLE_None;
00172			if ( !bGreenBlood )
00173				Spawn(class'BloodSplat',,,Location,rotator(HitNormal));
00174		}
00175		SetPhysics(PHYS_None);
00176		SetCollision(true, false, false);
00177	}
00178	
00179	simulated function HitWall(vector HitNormal, actor Wall)
00180	{
00181		local float speed, decision;
00182		local UT_BloodBurst b;
00183		local actor a;
00184	
00185		Velocity = 0.8 * (Velocity - 2 * HitNormal * (Velocity Dot HitNormal));
00186		Velocity.Z = FMin(Velocity.Z * 0.8, 700);
00187		speed = VSize(Velocity);
00188		if ( speed < 350 )
00189		{
00190			if ( trail != None )
00191			{
00192				if ( Level.bHighDetailMode && !Level.bDropDetail )
00193					bUnlit = false;
00194				trail.Destroy();
00195				trail = None;
00196			}
00197			if ( speed < 120 )
00198			{
00199				bBounce = false;
00200				Disable('HitWall');
00201			}
00202		}
00203		else if ( speed > 150 )
00204		{
00205			if ( speed > 700 )
00206				velocity *= 0.8;
00207			if (  (Level.NetMode != NM_DedicatedServer) && Level.bHighDetailMode && !Level.bDropDetail
00208				&& (LifeSpan < 19.3) )
00209				PlaySound(HitSounds[Rand(4)],,12);
00210		}
00211		if ( (Level.NetMode != NM_DedicatedServer) )
00212		{
00213			if ( (trail == None) && !Level.bDropDetail )
00214			{ 
00215				b = Spawn(class 'UT_BloodBurst',,,,Rot(0,0,0));
00216				if ( bGreenBlood )
00217					b.GreenBlood();		
00218				b.RemoteRole = ROLE_None;
00219			}
00220			if ( !bGreenBlood && (!Level.bDropDetail || (FRand() < 0.65)) )
00221				Spawn(class'BloodSplat',,,Location,rotator(HitNormal));
00222		}
00223	}
00224	
00225	function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, 
00226							Vector momentum, name damageType)
00227	{
00228		SetPhysics(PHYS_Falling);
00229		bBobbing = false;
00230		Velocity += momentum/Mass;
00231		CumulativeDamage += Damage;
00232		If ( Damage > FMin(15, Mass) || (CumulativeDamage > Mass) )
00233			ChunkUp(Damage);
00234	}
00235				
00236	auto state Dying
00237	{
00238		ignores TakeDamage;
00239	
00240	Begin:
00241		if ( bDecorative )
00242			SetPhysics(PHYS_None);
00243		else if ( (TrailSize > 0) && !Region.Zone.bWaterZone && (Level.NetMode != NM_DedicatedServer) )
00244		{
00245			trail = Spawn(class'UT_BloodTrail',self);
00246			if ( bGreenBlood )
00247				trail.GreenBlood();
00248		}
00249		Sleep(0.35);
00250		SetCollision(true, false, false);
00251		GotoState('Dead');
00252	}	
00253	
00254	state Dead 
00255	{
00256		function Timer()
00257		{
00258			local bool bSeen;
00259			local Pawn aPawn;
00260			local float dist;
00261	
00262			if ( !Level.bDropDetail && (Region.Zone.NumCarcasses <= Region.Zone.MaxCarcasses) )
00263			{
00264				if ( !PlayerCanSeeMe() )
00265					Destroy();
00266				else
00267					SetTimer(2.0, false);	
00268			}
00269			else
00270				Destroy();
00271		}
00272	
00273		function BeginState()
00274		{
00275			if ( bDecorative )
00276				lifespan = 0.0;
00277			else
00278				SetTimer(5.0, false);
00279		}
00280	}
00281	
00282	defaultproperties
00283	{
00284	     TrailSize=3.000000
00285	     HitSounds(0)=Sound'UnrealShare.Gibs.gibP1'
00286	     HitSounds(1)=Sound'UnrealShare.Gibs.gibP4'
00287	     HitSounds(2)=Sound'UnrealShare.Gibs.gibP5'
00288	     HitSounds(3)=Sound'UnrealShare.Gibs.gibP6'
00289	     bNetTemporary=True
00290	     RemoteRole=ROLE_SimulatedProxy
00291	     LifeSpan=20.000000
00292	     Mesh=LodMesh'UnrealShare.CowBody1'
00293	     bUnlit=True
00294	     bCollideActors=False
00295	     bBounce=True
00296	     bFixedRotationDir=True
00297	     Mass=90.000000
00298	     Buoyancy=27.000000
00299	     RotationRate=(Pitch=30000,Roll=30000)
00300	}

End Source Code