RuneI
Class Head

source: c:\runehov\RuneI\Classes\Head.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
         |
         +--Engine.Weapon
            |
            +--RuneI.NonStow
               |
               +--RuneI.LimbWeapon
                  |
                  +--RuneI.Head
Direct Known Subclasses:AlricHead, BerserkerHead, ConrackHead, DarkVikingHead, ElderHead, GoblinBHead, GoblinCHead, GoblinDHead, GoblinEHead, GoblinHead, GuardHead, KarlHead, RagnarHead, SarkAxeHead, SarkConHead, SarkHammerHead, SarkHead, SarkRagnarHead, SarkSwordHead, SigurdHead, SvenHead, TownRagnarHead, TrialRagnarHead, UlfHead, WarDwarfAHead, WarDwarfBHead, WarDwarfCHead, WarDwarfDHead, WarDwarfEHead, WarDwarfFHead, WolfHead, WomanHead, WoodDwarfAHead, WoodDwarfBHead, WoodDwarfCHead, ZombieHead

class Head
extends RuneI.LimbWeapon

//============================================================================= // Head. //=============================================================================
Variables
 Actor Blood
 bool bBloodyHead
 int landcount

States
Throw, Active

Function Summary
 
simulated
HitWall(vector HitNormal, Actor HitWall)
 
simulated
Landed(vector HitNormal, Actor HitActor)
 
simulated
PostBeginPlay()


State Throw Function Summary


State Active Function Summary
 void EndState()
 void BeginState()



Source Code


00001	//=============================================================================
00002	// Head.
00003	//=============================================================================
00004	class Head expands LimbWeapon;
00005	
00006	var Actor Blood;
00007	var(Sounds) Sound LandSound[3];
00008	var() bool bBloodyHead;
00009	var int landcount;
00010	
00011	
00012	simulated function PostBeginPlay()
00013	{
00014		DesiredRotation.Yaw = Rotation.Yaw + Rand(2000) - 1000;		
00015		DesiredRotation.Pitch = Rotation.Pitch + Rand(2000) - 1000;
00016		DesiredRotation.Yaw = Rotation.Yaw + Rand(2000) - 1000;
00017		DesiredRotation.Roll = Rotation.Roll + Rand(2000) - 1000;
00018	
00019		RotationRate.Yaw = 50000 + Rand(150000);
00020		RotationRate.Pitch = 10000 + Rand(150000);
00021	
00022	
00023	//Removed To allow LimbWeapon to handle blood on DropState.
00024	/*
00025		if(bBloodyHead)
00026		{
00027			Blood = Spawn(class'Blood');
00028			if(Blood != None)
00029			{
00030				AttachActorToJoint(Blood, JointNamed('base'));
00031				Blood.RemoteRole = ROLE_None;	// don't replicate
00032			}
00033		}
00034	
00035		SetTimer(0.25, true);
00036	*/
00037	
00038		Super.PostBeginPlay();
00039	}
00040			
00041	simulated function Landed(vector HitNormal, actor HitActor)
00042	{
00043		HitWall(HitNormal, HitActor);
00044	}
00045		
00046	simulated function HitWall(vector HitNormal, actor HitWall)
00047	{
00048		local float speed;
00049		
00050		speed = VSize(velocity);
00051	
00052		if(speed > 100 && landcount < 2)
00053		{
00054			landcount++;
00055			PlaySound(LandSound[Rand(3)]);
00056		}
00057		
00058		if(((HitNormal.Z > 0.8) && (speed < 60)) || (speed < 20))
00059		{
00060			SetPhysics(PHYS_None);
00061			bBounce = false;
00062			bFixedRotationDir = false;
00063			bCollideWorld = false;
00064			bLookFocusPlayer = false; // Player isn't interested in the head anymore
00065			SetTimer(0, false);
00066	
00067	//		GotoState('WaitingToRemove');
00068	
00069	//Removed To Allow LimbWeapon to handle Blood on DropState.
00070	/*
00071			if(bBloodyHead)
00072			{
00073				Blood = DetachActorFromJoint(JointNamed('base'));
00074				if(Blood != None)
00075				{
00076					Blood.Destroy();
00077				}
00078			}
00079	*/
00080	
00081		}
00082		else
00083		{			
00084			SetPhysics(PHYS_Falling);
00085			RotationRate.Yaw = VSize(Velocity) * 100;
00086			RotationRate.Pitch = VSize(Velocity) * 50;
00087			
00088			Velocity = 0.45 * (Velocity - 2 * HitNormal * (Velocity Dot HitNormal));
00089			if(VSize(Velocity) < 20)
00090			{
00091				self.HitWall(HitNormal, HitWall); // Force the actor to stop
00092			}
00093			DesiredRotation = rotator(HitNormal);
00094		}
00095		
00096		// Put a blood splot on the wall where the head struck it
00097		// Trace a line to determine the location to put the blood decal
00098		if(speed > 100 && HitWall.Skeletal == None && bBloodyHead)
00099		{ // Only put blood splats on walls
00100			if(FRand() < 0.5)
00101				Spawn(class'DecalBlood3',,,, rotator(HitNormal));
00102			else
00103				Spawn(class'DecalBlood4',,,, rotator(HitNormal));
00104		}
00105	
00106		if(speed < 100)
00107			GotoState('Pickup');
00108	}
00109	
00110	//-----------------------------------------------------------------------------
00111	//
00112	// State Active
00113	//
00114	// Melee Weapon is Active and in the actor's hand, waiting to be used
00115	//-----------------------------------------------------------------------------
00116	
00117	state Active
00118	{
00119		function BeginState()
00120		{
00121			if(bBloodyHead)
00122			{
00123				Blood = Spawn(class'Blood');
00124				if(Blood != None)
00125				{
00126					AttachActorToJoint(Blood, JointNamed('base'));
00127				}
00128			}
00129	
00130			SetPhysics(PHYS_None);
00131		}
00132		
00133		function EndState()
00134		{
00135			if(bBloodyHead)
00136			{
00137				Blood = DetachActorFromJoint(JointNamed('base'));
00138				if(Blood != None)
00139				{
00140					Blood.Destroy();
00141				}
00142			}
00143			landcount=0;
00144		}
00145	
00146	begin:
00147	}
00148	
00149	//-----------------------------------------------------------------------------
00150	//
00151	// State Throw
00152	//
00153	// Melee weapon was thrown
00154	//
00155	//-----------------------------------------------------------------------------
00156	
00157	state Throw
00158	{
00159		simulated function Landed(vector HitNormal, actor HitActor)
00160		{
00161			HitWall(HitNormal, HitActor);
00162		}
00163		
00164		simulated function HitWall(vector HitNormal, actor HitWall)
00165		{
00166			local int DamageAmount;
00167	
00168			Global.HitWall(HitNormal, HitWall);
00169	
00170			// Damage movers or polyobjects
00171			if((Role == ROLE_Authority) && ((Mover(HitWall) != None) || (PolyObj(HitWall) != None)))
00172			{
00173				DamageAmount = CalculateDamage(HitWall);
00174				if (DamageAmount != 0)
00175					HitWall.JointDamaged(DamageAmount, instigator, Location, Velocity*0.5, ThrownDamageType, 0);
00176			}
00177	
00178			GotoState('Drop');
00179		}
00180	}
00181	
00182	/*
00183	simulated function Timer()
00184	{
00185		bDestroyable=True;
00186		if(FRand() < 0.5)
00187			spawn(class'BloodDrips');
00188		else
00189			spawn(class'BloodDrips2');
00190	}
00191	*/
00192	
00193	defaultproperties
00194	{
00195	     LandSound(0)=Sound'OtherSnd.Gibs.gibhead01'
00196	     LandSound(1)=Sound'OtherSnd.Gibs.gibhead02'
00197	     LandSound(2)=Sound'OtherSnd.Gibs.gibhead03'
00198	     bBloodyHead=True
00199	     ThrownSoundLOOP=None
00200	     PickupMessage="You picked up a head"
00201	     Physics=PHYS_Falling
00202	     LODCurve=LOD_CURVE_ULTRA_AGGRESSIVE
00203	     CollisionRadius=6.000000
00204	     CollisionHeight=6.000000
00205	     bCollideWorld=True
00206	     bBounce=True
00207	     Skeletal=SkelModel'objects.Heads'
00208	}

End Source Code