RuneI
Class DwarfMech

source: c:\runehov\RuneI\Classes\DwarfMech.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pawn
         |
         +--RuneI.ScriptPawn
            |
            +--RuneI.DwarfMech
Direct Known Subclasses:None

class DwarfMech
extends RuneI.ScriptPawn

//============================================================================= // DwarfMech. //=============================================================================
Variables
 float AttackRange
           Longest range for ranged attacks
 bool bPlanted
           Longest range for ranged attacks

States
Dying, FightingRanged, FightingHigh, FightingLow, Fighting

Function Summary
 void AfterSpawningInventory()
     
//================================================
//
// AfterSpawningInventory
//
// Used to spawn additional chained weapon
//================================================
 void ApplyPainToJoint(int joint, vector Momentum)
 bool BodyPartCritical(int BodyPart)
     
//================================================
//
// BodyPartCritical
//
//================================================
 int BodyPartForJoint(int joint)
     
//================================================
//
// BodyPartForJoint
//
// Returns the body part a joint is associated with
//================================================
 int BodyPartForPolyGroup(int polygroup)
     
//================================================
//
// BodyPartForPolyGroup
//
//================================================
 bool BodyPartSeverable(int BodyPart)
     
//================================================
//
// BodyPartSeverable
//
//================================================
 bool CanPickup(Inventory item)
     
//================================================
//
// CanPickup
//
// Let's pawn dictate what it can pick up
//================================================
 void DropLeftWeapon()
 void DropRightWeapon()
 bool InAttackRange(Actor Other)
     
//================================================
//
// InAttackRange
//
//================================================
 int LimbPassThrough(int BodyPart, out int, out int)
     
//============================================================
//
// LimbPassThrough
//
// Determines what damage is passed through to body
//============================================================
 void LimbSevered(int BodyPart, vector Momentum)
     
//================================================
//
// LimbSevered
//
//================================================
 void LongFall()
 EMatterType MatterForJoint(int joint)
     
//============================================================
//
// MatterForJoint
//
// Returns what kind of material joint is associated with
//============================================================
 Texture PainSkin(int BodyPart)
     
//================================================
//
// PainSkin
//
// returns the pain skin for a given polygroup
//================================================
 void PlayBodyHit(optional float)
 void PlayClawAttack()
 void PlayDeath(name DamageType)
 void PlayFire()
 void PlayFrontHit(float tweentime)
 void PlayHeadHit(optional float)
 void PlayHighAttack()
 void PlayHuntStop(optional float)
 void PlayInAir(optional float)
 void PlayJumping(optional float)
 void PlayLArmHit(optional float)
 void PlayLLegHit(optional float)
 void PlayLanding(optional float)
 void PlayLowAttack()
 void PlayMeleeHigh(optional float)
 void PlayMissileAttack()
 void PlayMoving(optional float)
 void PlayPlant()
 void PlayPlantIdle()
 void PlayPropAttack()
 void PlayRArmHit(optional float)
 void PlayRLegHit(optional float)
 void PlayTaunting(optional float)
 void PlayThrowing(optional float)
 void PlayTurning(optional float)
 void PlayUnPlant()
 void PlayWaiting(optional float)
     
//-----------------------------------------------------------------------------
// Animation functions
//-----------------------------------------------------------------------------
 void PostBeginPlay()
     
// SLOT_None
 void SetHeadLook()
 void SetTorsoLook()
 void TweenToHuntStop(float time)
 void TweenToJumping(float time)
 void TweenToMeleeHigh(float time)
 void TweenToMoving(float time)
 void TweenToThrowing(float time)
 void TweenToTurning(float time)
 void TweenToWaiting(float time)
     
// Tween functions


State Dying Function Summary
 void BeginState()


State FightingRanged Function Summary
 void DoThrow()
 void AmbientSoundTimer()


State FightingHigh Function Summary
 void AmbientSoundTimer()
 void EndState()
 void BeginState()


State FightingLow Function Summary
 void AmbientSoundTimer()
 void BeginState()
 void EndState()


State Fighting Function Summary
 void SoundNotify2()
 void SoundNotify1()
 void AmbientSoundTimer()
     
// Out of sight, unplant and hunt
		GotoState('Fighting', 'Done');
	}*/
 void EnemyNotVisible()
     
/*	



Source Code


00001	//=============================================================================
00002	// DwarfMech.
00003	//=============================================================================
00004	class DwarfMech expands ScriptPawn;
00005	
00006	/*
00007		Description: Once in range, he plants himself and does blade attacks when you
00008		are in range, and rocket attacks when you are further away.
00009	
00010		Combat strategy:
00011			use blunt damage to disarm blades
00012			use sever damage to take off arms
00013			then kill with anything
00014	*/
00015	
00016	var float AttackRange;		// Longest range for ranged attacks
00017	var bool bPlanted;
00018	
00019	var(Sounds) Sound	PlantSound;				// SLOT_Interact
00020	var(Sounds) Sound	UnplantSound;			// SLOT_Interact
00021	var(Sounds) Sound	UpDownSound;			// SLOT_Talk
00022	var(Sounds) Sound	FireSound;				// SLOT_Misc
00023	var(Sounds) Sound	ExplodeSound;			// SLOT_None
00024	var(Sounds) Sound	GrindSoundLOOP;			// SLOT_Ambient
00025	var(Sounds) Sound	AliveSoundLOOP;			// SLOT_Ambient
00026	var(Sounds) Sound	DyingSpinSound;			// SLOT_None
00027	
00028	function PostBeginPlay()
00029	{
00030		Super.PostBeginPlay();
00031	
00032		// Make upper body wobble when hit
00033	//	JointFlags[5] = JointFlags[5] | JOINT_FLAG_ACCELERATIVE;	// moved to SCM file
00034	}
00035	
00036	simulated event GetAccelJointParms(int joint, out float DampFactor, out float RotThreshold)
00037	{
00038		DampFactor = 0.035;
00039		RotThreshold = 8192;
00040	}
00041	
00042	simulated event float GetAccelJointMagnitude(int joint)
00043	{
00044		return 9000;
00045	}
00046	
00047	function ApplyPainToJoint(int joint, vector Momentum)
00048	{
00049		ApplyJointForce(5, Momentum*0.5);
00050	}
00051	
00052	//================================================
00053	//
00054	// AfterSpawningInventory
00055	//
00056	// Used to spawn additional chained weapon
00057	//================================================
00058	function AfterSpawningInventory()
00059	{
00060		local Weapon W;
00061		W = Spawn(class'mechblade');
00062		W.SetOwner(self);
00063		AttachActorToJoint(W, 23);	// Attach to left wrist
00064		InvisibleWeapon(Weapon).ChainOnWeapon(W);
00065		W.GotoState('Active');
00066	}
00067	
00068	function DropLeftWeapon()
00069	{
00070		if (Weapon != None && InvisibleWeapon(Weapon) != None)
00071		{
00072			if (InvisibleWeapon(Weapon).ChainedWeapon == None)
00073			{
00074				DetachActorFromJoint(23);
00075				Weapon.Destroy();
00076				Weapon = None;
00077			}
00078			else
00079			{
00080				DetachActorFromJoint(23);
00081				InvisibleWeapon(Weapon).ChainedWeapon.Destroy();
00082				InvisibleWeapon(Weapon).ChainedWeapon = None;
00083			}
00084		}
00085	}
00086	
00087	function DropRightWeapon()
00088	{
00089		local InvisibleWeapon removing;
00090	
00091		if (Weapon != None && InvisibleWeapon(Weapon) != None)
00092		{
00093			removing = InvisibleWeapon(Weapon);
00094			DetachActorFromJoint(JointNamed(WeaponJoint));
00095			Weapon = removing.ChainedWeapon;
00096			removing.ChainedWeapon = None;
00097			removing.Destroy();
00098		}
00099	}
00100	
00101	function SetHeadLook()
00102	{
00103		bRotateHead=true;
00104		bRotateTorso=false;
00105		MaxBodyAngle.Yaw=0;
00106		MaxBodyAngle.Pitch=0;
00107		MaxHeadAngle.Yaw=32768;
00108		MaxHeadAngle.Pitch=0;
00109	}
00110	
00111	function SetTorsoLook()
00112	{
00113		bRotateHead=false;
00114		bRotateTorso=true;
00115		MaxBodyAngle.Yaw=32768;
00116		MaxBodyAngle.Pitch=0;
00117		MaxHeadAngle.Yaw=0;
00118		MaxHeadAngle.Pitch=0;
00119	}
00120	
00121	//================================================
00122	//
00123	// CanPickup
00124	//
00125	// Let's pawn dictate what it can pick up
00126	//================================================
00127	function bool CanPickup(Inventory item)
00128	{
00129		return item.IsA('MechBlade');
00130	}
00131	
00132	
00133	//================================================
00134	//
00135	// InAttackRange
00136	//
00137	//================================================
00138	function bool InAttackRange(actor Other)
00139	{
00140		local float range;
00141	
00142		range = VSize(Location-Other.Location);
00143	
00144		if (range < CollisionRadius + Other.CollisionRadius + AttackRange)
00145			return true;
00146	
00147		return false;
00148	}
00149	
00150	//================================================
00151	//
00152	// PainSkin
00153	//
00154	// returns the pain skin for a given polygroup
00155	//================================================
00156	function Texture PainSkin(int BodyPart)
00157	{
00158		switch(BodyPart)
00159		{
00160			case BODYPART_TORSO:
00161				SkelGroupSkins[3] = Texture'creatures.mechadwarfbodypain';
00162				break;
00163			case BODYPART_HEAD:
00164				SkelGroupSkins[2] = Texture'creatures.mechadwarfheadpain';
00165				break;
00166			case BODYPART_MISC1:
00167				SkelGroupSkins[14] = Texture'creatures.mechadwarfarmlegpain';
00168				break;
00169			case BODYPART_MISC2:
00170				SkelGroupSkins[13] = Texture'creatures.mechadwarfarmlegpain';
00171				break;
00172		}
00173		return None;
00174	}
00175	
00176	//============================================================
00177	//
00178	// MatterForJoint
00179	//
00180	// Returns what kind of material joint is associated with
00181	//============================================================
00182	function EMatterType MatterForJoint(int joint)
00183	{
00184		switch(joint)
00185		{
00186			case 33:			return MATTER_METAL;	// leg
00187			case 29:			return MATTER_METAL;	// leg
00188			case 7:				return MATTER_FLESH;	// head
00189			case 20:			return MATTER_FLESH;	// Left Arm (flesh)
00190			case 10:			return MATTER_FLESH;	// Right Arm (flesh)
00191			case 12:			return MATTER_METAL;	// Right Arm (metal)
00192			case 22:			return MATTER_METAL;	// Left Arm (metal)
00193			case 25:			return MATTER_METAL;	// Left top blade
00194			case 27:			return MATTER_METAL;	// Left bottom Blade
00195			case 15:			return MATTER_METAL;	// Right top blade
00196			case 17:			return MATTER_METAL;	// Right Bottom Blade
00197			case 5:				return MATTER_METAL;	// torso
00198			default:			return MATTER_METAL;
00199		}
00200	}
00201	
00202	//================================================
00203	//
00204	// BodyPartForJoint
00205	//
00206	// Returns the body part a joint is associated with
00207	//================================================
00208	function int BodyPartForJoint(int joint)
00209	{
00210		switch(joint)
00211		{
00212			case 33:			return BODYPART_LLEG1;
00213			case 29:			return BODYPART_RLEG1;
00214			case 7:				return BODYPART_HEAD;
00215			case 20: case 22:	return BODYPART_MISC1;	// Left Arm (flesh/metal)
00216			case 10: case 12:	return BODYPART_MISC2;	// Right Arm (flesh/metal)
00217			case 25:			return BODYPART_LARM1;	// Left top blade
00218			case 27:			return BODYPART_LARM2;	// Left bottom Blade
00219			case 15:			return BODYPART_RARM1;	// Right top blade
00220			case 17:			return BODYPART_RARM2;	// Right Bottom Blade
00221			case 5:				return BODYPART_TORSO;
00222			default:			return BODYPART_BODY;
00223		}
00224	}
00225	
00226	//================================================
00227	//
00228	// BodyPartForPolyGroup
00229	//
00230	//================================================
00231	function int BodyPartForPolyGroup(int polygroup)
00232	{
00233		switch(polygroup)
00234		{
00235			case 2:				return BODYPART_HEAD;
00236			case 14:			return BODYPART_MISC1;	// left arm
00237			case 13:			return BODYPART_MISC2;	// right arm
00238			case 9:				return BODYPART_LARM2;	// left bottom blade
00239			case 10:			return BODYPART_LARM1;	// left top blade
00240			case 7:			 	return BODYPART_RARM2;	// right bottom blade
00241			case 8:				return BODYPART_RARM1;	// right top blade
00242			case 5:	case 12:	return BODYPART_LLEG1;
00243			case 4:	case 11:	return BODYPART_RLEG1;
00244			case 3: case 6:
00245			case 15: case 0:	return BODYPART_TORSO;
00246			default:			return BODYPART_BODY;
00247		}
00248	}
00249	
00250	
00251	//============================================================
00252	//
00253	// LimbPassThrough
00254	//
00255	// Determines what damage is passed through to body
00256	//============================================================
00257	function int LimbPassThrough(int BodyPart, out int Blunt, out int Sever)
00258	{
00259		if (BodyPart == BODYPART_BODY)	// Falling damage, etc.
00260			return Blunt+Sever;
00261	
00262		if (BodyPart == BODYPART_TORSO)
00263			return Blunt+Sever;
00264	
00265		if (BodyPart == BODYPART_HEAD)
00266			return Blunt+Sever;
00267	
00268		if (BodyPart == BODYPART_LARM1 ||
00269			BodyPart == BODYPART_LARM2 ||
00270			BodyPart == BODYPART_RARM1 ||
00271			BodyPart == BODYPART_RARM2)
00272		{	// Blades
00273			Sever = Blunt;
00274			return 0;
00275		}
00276	
00277		if (BodyPart == BODYPART_MISC1 ||
00278			BodyPart == BODYPART_MISC2)
00279		{	// Arms
00280			return 0;
00281		}
00282	
00283		return 0;
00284	}
00285	
00286	
00287	//================================================
00288	//
00289	// BodyPartSeverable
00290	//
00291	//================================================
00292	function bool BodyPartSeverable(int BodyPart)
00293	{
00294		//TODO:  do this only if blades gone?
00295		return (BodyPart==BODYPART_MISC1 ||
00296				BodyPart==BODYPART_MISC2 ||
00297				BodyPart==BODYPART_LARM1 ||
00298				BodyPart==BODYPART_LARM2 ||
00299				BodyPart==BODYPART_RARM1 ||
00300				BodyPart==BODYPART_RARM2);
00301	}
00302	
00303	
00304	//================================================
00305	//
00306	// BodyPartCritical
00307	//
00308	//================================================
00309	function bool BodyPartCritical(int BodyPart)
00310	{
00311		return false;
00312	}
00313	
00314	
00315	//================================================
00316	//
00317	// LimbSevered
00318	//
00319	//================================================
00320	function LimbSevered(int BodyPart, vector Momentum)
00321	{
00322		local int joint;
00323		local vector X,Y,Z;
00324		local class<actor> partclass;
00325		local actor part;
00326		
00327		Super.LimbSevered(BODYPART_BODY, Momentum);		// Disallow fleeing by passing None
00328	
00329		if (BodyPart == BODYPART_LARM1 || BodyPart == BODYPART_lARM2)
00330		{
00331			if (BodyPartMissing(BODYPART_LARM1) && BodyPartMissing(BODYPART_LARM2))
00332			{	// left blades gone, drop invisible weapon
00333				DropLeftWeapon();
00334			}
00335		}
00336		else if (BodyPart == BODYPART_RARM1 || BodyPart == BODYPART_RARM2)
00337		{
00338			if (BodyPartMissing(BODYPART_RARM1) && BodyPartMissing(BODYPART_RARM2))
00339			{	// right blades gone, drop invisible weapon
00340				DropRightWeapon();
00341			}
00342		}
00343		else if (BodyPart == BODYPART_MISC1 || BodyPart == BODYPART_MISC2)
00344		{
00345			if (BodyPart == BODYPART_MISC1)
00346			{	// left arm gone, drop weapon and hide blades
00347				DropLeftWeapon();
00348				BodyPartVisibility(BODYPART_LARM1, false);
00349				BodyPartVisibility(BODYPART_LARM2, false);
00350			}
00351			else if (BodyPart == BODYPART_MISC2)
00352			{	// right arm gone, drop weapon and hide blades
00353				DropRightWeapon();
00354				BodyPartVisibility(BODYPART_RARM1, false);
00355				BodyPartVisibility(BODYPART_RARM2, false);
00356			}
00357	
00358			if (BodyPartMissing(BODYPART_MISC1) && BodyPartMissing(BODYPART_MISC2))
00359			{	// both arms gone, flee
00360				if (Health > 0)
00361					GotoState('Fleeing');
00362			}
00363		}
00364	
00365		partclass = SeveredLimbClass(BodyPart);
00366		switch(BodyPart)
00367		{
00368			case BODYPART_LARM1:
00369			case BODYPART_LARM2:
00370				joint = JointNamed('lwrist');
00371				GetAxes(Rotation, X, Y, Z);
00372				part = Spawn(partclass,,, GetJointPos(joint), Rotation);
00373				if(part != None)
00374				{
00375					part.Velocity = -Y * 100 + vect(0, 0, 175);
00376					part.GotoState('Drop');
00377				}
00378				break;
00379	
00380			case BODYPART_RARM1:
00381			case BODYPART_RARM2:
00382				joint = JointNamed('rwrist');
00383				GetAxes(Rotation, X, Y, Z);
00384				part = Spawn(partclass,,, GetJointPos(joint), Rotation);
00385				if(part != None)
00386				{
00387					part.Velocity = -Y * 100 + vect(0, 0, 175);
00388					part.GotoState('Drop');
00389				}
00390				break;
00391	
00392			case BODYPART_MISC1:
00393				joint = JointNamed('lshouldb');
00394				GetAxes(Rotation, X, Y, Z);
00395				part = Spawn(partclass,,, GetJointPos(joint), Rotation);
00396				if(part != None)
00397				{
00398					part.Velocity = -Y * 100 + vect(0, 0, 175);
00399					part.GotoState('Drop');
00400				}
00401				break;
00402			case BODYPART_MISC2:
00403				joint = JointNamed('rshouldb');
00404				GetAxes(Rotation, X, Y, Z);
00405				part = Spawn(partclass,,, GetJointPos(joint), Rotation);
00406				if(part != None)
00407				{
00408					part.Velocity = -Y * 100 + vect(0, 0, 175);
00409					part.GotoState('Drop');
00410				}
00411				break;
00412		}
00413	}
00414	
00415	
00416	//================================================
00417	//
00418	// SeveredLimbClass
00419	//
00420	//================================================
00421	function class<Actor> SeveredLimbClass(int BodyPart)
00422	{
00423		switch(BodyPart)
00424		{
00425			case BODYPART_LARM1:
00426			case BODYPART_LARM2:
00427			case BODYPART_RARM1:
00428			case BODYPART_RARM2:
00429				return class'MechBladeArm';
00430			case BODYPART_MISC1:
00431			case BODYPART_MISC2:
00432				return class'MechArm';
00433		}
00434		return None;
00435	}
00436	
00437	//-----------------------------------------------------------------------------
00438	// Animation functions
00439	//-----------------------------------------------------------------------------
00440	function PlayWaiting(optional float tween)
00441	{
00442		if (bPlanted)
00443			LoopAnim  ('plant_idle',    1.0, tween);
00444		else
00445			LoopAnim  ('idle',    1.0, tween);
00446	}
00447	function PlayMoving(optional float tween)
00448	{
00449		if (bHurrying)
00450		{
00451			LoopAnim  ('run',     1.0, tween);
00452		}
00453		else
00454		{
00455			if (Weapon==None)						LoopAnim  ('walk',     1.0, tween);
00456			else if (Weapon.IsA('Torch'))			LoopAnim  ('walk',     1.0, tween);
00457			else									LoopAnim  ('walk',     1.0, tween);
00458		}
00459	}
00460	function PlayJumping(optional float tween)		{ PlayAnim  ('jump',	1.0, tween);	}
00461	function PlayHuntStop(optional float tween)		{ LoopAnim  ('idle',	1.0, tween);	}
00462	function PlayMeleeHigh(optional float tween)	{ PlayAnim  ('attackB', 1.0, tween);	}
00463	function PlayTurning(optional float tween)		{ PlayAnim  ('run',		1.0, tween);	}
00464	function PlayThrowing(optional float tween)		{}
00465	function PlayTaunting(optional float tween)		{ PlayAnim  ('pain',	1.0, tween);	}
00466	function PlayInAir(optional float tween)		{}
00467	function LongFall()								{}
00468	function PlayLanding(optional float tween)		{}
00469	
00470	function PlayHeadHit(optional float tween)		{}
00471	function PlayBodyHit(optional float tween)		{}
00472	function PlayLArmHit(optional float tween)		{}
00473	function PlayRArmHit(optional float tween)		{}
00474	function PlayLLegHit(optional float tween)		{}
00475	function PlayRLegHit(optional float tween)		{}
00476	function PlayDeath(name DamageType)				{ PlayAnim  ('startblowup',	1.0, 0.2);		}
00477	function PlayFrontHit(float tweentime)			{}
00478	
00479	// Tween functions
00480	function TweenToWaiting(float time)
00481	{
00482		if (bPlanted)
00483			TweenAnim ('plant_idle',	time);
00484		else
00485			TweenAnim ('idleA',			time);
00486	}
00487	function TweenToMoving(float time)
00488	{
00489		if (bHurrying)
00490		{
00491			TweenAnim ('run',   time);
00492		}
00493		else
00494		{
00495			if (Weapon==None)						TweenAnim ('walk',     time);
00496			else if (Weapon.IsA('Torch'))			TweenAnim ('walktorch',time);
00497			else									TweenAnim ('walk',     time);
00498		}
00499	}
00500	function TweenToTurning(float time)				{	TweenAnim ('run',    time);			}
00501	function TweenToJumping(float time)				{	TweenAnim ('jump',   time);			}
00502	function TweenToHuntStop(float time)			{	TweenAnim ('idle',   time);			}
00503	function TweenToMeleeHigh(float time)			{	TweenAnim ('attackB', time);			}
00504	function TweenToThrowing(float time)			{	TweenAnim ('throwA',  time);			}
00505	
00506	function PlayPlant()							{	PlayAnim('plant',		1.0, 0.2);	}
00507	function PlayUnPlant()							{	PlayAnim('unplant',		1.0, 0.2);	}
00508	function PlayPlantIdle()						{	LoopAnim('fire_idle',	1.0, 0.1);	}
00509	function PlayPropAttack()						{	LoopAnim('prop_cycle',	1.0, 0.1);	}
00510	function PlayClawAttack()						{	PlayAnim('attackB',		1.0, 0.1);	}
00511	function PlayMissileAttack()					{	PlayAnim('fire_windup',	1.0, 0.2);	}
00512	function PlayFire()								{	LoopAnim('fire_cycle',	1.0, 0.1);	}
00513	
00514	function PlayLowAttack()						{	LoopAnim('saw_cycle',	1.0, 0.5);	}
00515	function PlayHighAttack()						{	LoopAnim('spin_cycle',	1.0, 0.5);	}
00516	
00517	
00518	//================================================
00519	//
00520	// Fighting
00521	//
00522	//================================================
00523	State Fighting
00524	{
00525	ignores EnemyAcquired, BeginState, EndState;
00526	
00527	/*	function EnemyNotVisible()
00528		{	// Out of sight, unplant and hunt
00529			GotoState('Fighting', 'Done');
00530		}*/
00531	
00532		function AmbientSoundTimer()
00533		{
00534			PlayAmbientFightSound();
00535		}
00536	
00537		function SoundNotify1()
00538		{
00539			PlaySound(PlantSound, SLOT_Interact,,,, 1.0 + FRand()*0.2-0.1);
00540		}
00541	
00542		function SoundNotify2()
00543		{
00544			PlaySound(UnplantSound, SLOT_Interact,,,, 1.0 + FRand()*0.2-0.1);
00545		}
00546	
00547	Begin:
00548		if(debugstates) SLog(name@"Fighting");
00549		Acceleration = vect(0,0,0);
00550	
00551		// Turn towards enemy during attack
00552		DesiredRotation = rotator(Enemy.Location-Location);
00553	
00554	Plant:
00555		PlayPlant();
00556		FinishAnim();
00557		bPlanted=true;
00558		LookAt(Enemy);
00559	
00560	Planted:
00561		// Evaluate and goto substates
00562	
00563	Evaluate:
00564		if ( !ValidEnemy() )
00565		{
00566			NextState = 'GoingHome';
00567			NextLabel = '';
00568			Goto('Done');
00569		}
00570	
00571	Fight:
00572		//TODO: Check for existence of blades
00573	
00574		if (InRange(Enemy, MeleeRange))
00575		{	// Melee Range
00576			if ( PlayerPawn(Enemy)!=None )
00577			{	// Players
00578				if ( PlayerPawn(Enemy).bIsCrouching )
00579				{
00580					GotoState('FightingLow');
00581				}
00582				else
00583				{
00584					GotoState('FightingHigh');
00585				}
00586			}
00587			else
00588			{	// Creatures
00589				if (Enemy.Location.Z + Enemy.CollisionHeight < Location.Z + 15)
00590				{
00591					GotoState('FightingLow');
00592				}
00593				else
00594				{
00595					GotoState('FightingHigh');
00596				}
00597			}
00598		}
00599		else if (InRange(Enemy, AttackRange))
00600		{	// Missile Range
00601			GotoState('FightingRanged');
00602		}
00603	
00604		NextState = 'Charging';
00605		NextLabel = 'ResumeFromFighting';
00606	
00607	Done:
00608		bSwingingHigh = false;
00609		SwipeEffectEnd();
00610		WeaponDeactivate();
00611		SetTorsoLook();
00612		LookAt(None);
00613		PlayUnplant();
00614		FinishAnim();
00615		bPlanted=false;
00616		GotoState(NextState, NextLabel);
00617	}
00618	
00619	
00620	//================================================
00621	//
00622	// FightingLow
00623	//
00624	//================================================
00625	State FightingLow
00626	{
00627		function EndState()
00628		{
00629			//TODO: Use timer to use an attack for a limited time before switching (unless damage has been inflicted)
00630			//LastAttack=LA_LOW1;
00631			AmbientSound = AliveSoundLOOP;
00632		}
00633	
00634		function BeginState()
00635		{
00636			local InvisibleWeapon W;
00637	
00638			W = InvisibleWeapon(Weapon);
00639			if (W!=None)
00640				W.ExtendedLength = 10;
00641			if (W.ChainedWeapon!=None)
00642				W.ChainedWeapon.ExtendedLength = 10;
00643		}
00644	
00645		function AmbientSoundTimer()
00646		{
00647			PlayAmbientFightSound();
00648		}
00649	
00650	Begin:
00651	//	SetHeadLook();
00652		LookAt(None);
00653	
00654		// Tween into Low
00655		if (AnimSequence == 'high_tran')
00656		{
00657			PlaySound(UpdownSound, SLOT_Talk,,,, 1.0 + FRand()*0.2-0.1);
00658			TweenAnim('low_tran', 0.5);
00659			FinishAnim();
00660			Sleep(0.5);
00661	
00662			// Cycle up
00663		}
00664	
00665		PlayLowAttack();
00666		AmbientSound = GrindSoundLOOP;
00667		SwipeEffectStart();
00668	
00669	ContinueAttack:
00670		WeaponDeactivate();
00671		WeaponActivate();
00672		Sleep(0.5);
00673	
00674		// Evaluate exit conditions
00675		if (InRange(Enemy, MeleeRange))
00676		{
00677			Goto('ContinueAttack');
00678		}
00679	
00680	Done:
00681		// Cycle down for transition to next move
00682		FinishAnim();
00683		AmbientSound = AliveSoundLOOP;
00684		SwipeEffectEnd();
00685		WeaponDeactivate();
00686	
00687		// Tween to idle low
00688		TweenAnim('low_tran', 0.5);
00689		FinishAnim();
00690		Sleep(0.5);
00691	
00692		GotoState('Fighting', 'Planted');
00693	
00694	AlternateLow:	//(unused)
00695		// Claw attack
00696		SetTorsoLook();
00697		PlayClawAttack();
00698		FinishAnim();
00699	}
00700	
00701	
00702	//================================================
00703	//
00704	// FightingHigh
00705	//
00706	//================================================
00707	State FightingHigh
00708	{
00709		function BeginState()
00710		{
00711			local InvisibleWeapon W;
00712	
00713			W = InvisibleWeapon(Weapon);
00714			if (W!=None)
00715				W.ExtendedLength = 40;
00716			if (W.ChainedWeapon!=None)
00717				W.ChainedWeapon.ExtendedLength = 40;
00718		}
00719	
00720		function EndState()
00721		{
00722			AmbientSound = AliveSoundLOOP;
00723		}
00724	
00725		function AmbientSoundTimer()
00726		{
00727			PlayAmbientFightSound();
00728		}
00729	
00730	Begin:
00731	//	SetHeadLook();
00732		LookAt(None);
00733	
00734		// Tween into high
00735		if (AnimSequence == 'low_tran')
00736		{
00737			PlaySound(UpdownSound, SLOT_Talk,,,, 1.0 + FRand()*0.2-0.1);
00738	
00739			TweenAnim('high_tran', 0.5);
00740			FinishAnim();
00741			Sleep(0.5);
00742	
00743			// Cycle up
00744		}
00745	
00746		PlayHighAttack();
00747		AmbientSound = GrindSoundLOOP;
00748		SwipeEffectStart();
00749	
00750	ContinueAttack:
00751		WeaponDeactivate();
00752		WeaponActivate();
00753		Sleep(0.5);
00754	
00755		// Evaluate exit conditions
00756		if ((InRange(Enemy, MeleeRange)) &&
00757			!(PlayerPawn(Enemy)!=None && PlayerPawn(Enemy).bIsCrouching) )
00758		{
00759			Goto('ContinueAttack');
00760		}
00761	
00762	Done:
00763		// Cycle down for transition to next move
00764		FinishAnim();
00765		AmbientSound = AliveSoundLOOP;
00766		SwipeEffectEnd();
00767		WeaponDeactivate();
00768	
00769		// Tween to idle high
00770		TweenAnim('high_tran', 0.5);
00771		FinishAnim();
00772		Sleep(0.5);
00773	
00774		GotoState('Fighting', 'Planted');
00775	
00776	AlternateHigh: //(unused)
00777		// Propeller attack
00778		SetHeadLook();
00779	
00780		PlayHighAttack();
00781		//PlayPropAttack();
00782		Sleep(0.5);
00783		FinishAnim();
00784	
00785		if (InRange(Enemy, MeleeRange))
00786			Goto('Melee');
00787		else
00788		{
00789			PlayWaiting(0.1);
00790			FinishAnim();
00791		}
00792	}
00793	
00794	
00795	//================================================
00796	//
00797	// FightingRanged
00798	//
00799	//================================================
00800	State FightingRanged
00801	{
00802		
00803		function AmbientSoundTimer()
00804		{
00805			PlayAmbientFightSound();
00806		}
00807	
00808		function DoThrow()
00809		{
00810			local Projectile ball;
00811			local vector FireLocation;
00812			local bool bfired;
00813	
00814			//TODO: Fire out in actual direction dictated by look
00815			
00816			if (BodyPartHealth[BODYPART_MISC2] > 0)
00817			{	// Throw out right missile
00818				FireLocation = GetJointPos(JointNamed('rwrist'));
00819				ball = Spawn(class'MechRocket', self,,FireLocation,rotator(Normal(Enemy.Location - FireLocation)));
00820				ball.SetPhysics(PHYS_Projectile);
00821				ball.Velocity = Normal(Enemy.Location - FireLocation) * ball.Speed;
00822				bfired=true;
00823			}
00824	
00825			if (BodyPartHealth[BODYPART_MISC1] > 0)
00826			{	// Throw out left missile
00827				FireLocation = GetJointPos(JointNamed('lwrist'));
00828				ball = Spawn(class'MechRocket', self,,FireLocation,rotator(Normal(Enemy.Location - FireLocation)));
00829				ball.SetPhysics(PHYS_Projectile);
00830				ball.Velocity = Normal(Enemy.Location - FireLocation) * ball.Speed;
00831				bfired=true;
00832			}
00833	
00834			if (bfired)
00835				PlaySound(FireSound, SLOT_Misc,,,, 1.0 + FRand()*0.4-0.2);
00836		}
00837	
00838	Begin:
00839		SetTorsoLook();
00840		LookAt(Enemy);
00841	
00842		// Tween into Low
00843		if (AnimSequence == 'high_tran')
00844		{
00845			TweenAnim('low_tran', 0.5);
00846			FinishAnim();
00847			Sleep(0.5);
00848		}
00849	
00850		
00851		PlayMissileAttack();
00852		FinishAnim();
00853	
00854	ContinueAttack:
00855		
00856		if(abs(GetJointRot(JointNamed('torso')).Yaw - (rotator(Enemy.Location - Location)).Yaw) < 1000)
00857		{
00858			PlayFire();
00859		}
00860		
00861		FinishAnim();
00862		PlayPlantIdle();
00863	
00864		if (InRange(Enemy, AttackRange) && !InRange(Enemy, MeleeRange))
00865		{
00866			Goto('ContinueAttack');
00867		}
00868	
00869	Done:
00870		// Cycle down for transition to next move
00871	
00872		// Tween to idle high
00873		TweenAnim('high_tran', 0.5);
00874		FinishAnim();
00875		Sleep(0.5);
00876	
00877		GotoState('Fighting', 'Planted');
00878	}
00879	
00880	
00881	//============================================================
00882	//
00883	// Dying
00884	//
00885	//============================================================
00886	state Dying
00887	{
00888	ignores SeePlayer, EnemyNotVisible, HearNoise, KilledBy, Trigger, Bump, HitWall, HeadZoneChange, FootZoneChange, ZoneChange, Falling, WarnTarget, Died, LongFall, PainTimer, Landed, EnemyAcquired;
00889	
00890		function BeginState()
00891		{
00892			AmbientSound = None;
00893			Super.BeginState();
00894		}
00895	
00896	PreDeath:
00897		Acceleration=vect(0,0,0);
00898		PlaySound(DyingSpinSound,SLOT_None,,,, 1.0 + FRand()*0.2-0.1);
00899		FinishAnim();
00900		LoopAnim('blowupcycle', 1.0, 0.1);
00901	
00902		// Explode
00903		spawn(class'Explosion',,,GetJointPos(JointNamed('spinea')));
00904		PlaySound(ExplodeSound,,,,, 1.0 + FRand()*0.2-0.1);
00905		AttachActorToJoint(spawn(class'blacksmoke'), JointNamed('spinea'));
00906	
00907		BodyPartCollision(BODYPART_TORSO, false);
00908		BodyPartCollision(BODYPART_HEAD, false);
00909		BodyPartCollision(BODYPART_MISC1, false);
00910		BodyPartCollision(BODYPART_MISC2, false);
00911		BodyPartCollision(BODYPART_LARM2, false);
00912		BodyPartCollision(BODYPART_LARM1, false);
00913		BodyPartCollision(BODYPART_RARM2, false);
00914		BodyPartCollision(BODYPART_RARM1, false);
00915	
00916		BodyPartVisibility(BODYPART_TORSO, false);
00917		BodyPartVisibility(BODYPART_HEAD, false);
00918		BodyPartVisibility(BODYPART_MISC1, false);
00919		BodyPartVisibility(BODYPART_MISC2, false);
00920		BodyPartVisibility(BODYPART_LARM2, false);
00921		BodyPartVisibility(BODYPART_LARM1, false);
00922		BodyPartVisibility(BODYPART_RARM2, false);
00923		BodyPartVisibility(BODYPART_RARM1, false);
00924		Goto('Death');
00925	}
00926	
00927	
00928	simulated function Debug(Canvas canvas, int mode)
00929	{
00930		Super.Debug(canvas, mode);
00931		
00932		Canvas.DrawText("DwarfMech:");
00933		Canvas.CurY -= 8;
00934		Canvas.DrawText("  MaxBodyAngle="$MaxBodyAngle);
00935		Canvas.CurY -= 8;
00936		
00937	}
00938	
00939	defaultproperties
00940	{
00941	     AttackRange=500.000000
00942	     PlantSound=Sound'CreaturesSnd.Mech.mechfoot02'
00943	     UnplantSound=Sound'CreaturesSnd.Mech.mechfoot01'
00944	     UpDownSound=Sound'CreaturesSnd.Mech.mechservo04'
00945	     FireSound=Sound'CreaturesSnd.Mech.mechfire01'
00946	     ExplodeSound=Sound'OtherSnd.Explosions.explosion06'
00947	     GrindSoundLOOP=Sound'CreaturesSnd.Mech.mechspin02L'
00948	     AliveSoundLOOP=Sound'CreaturesSnd.Mech.mechalive01L'
00949	     DyingSpinSound=Sound'CreaturesSnd.Mech.mechspin'
00950	     FightOrFlight=1.000000
00951	     FightOrDefend=1.000000
00952	     AcquireSound=Sound'CreaturesSnd.Mech.mechsee01'
00953	     AmbientWaitSounds(0)=Sound'CreaturesSnd.Mech.mechmove09'
00954	     AmbientWaitSounds(1)=Sound'CreaturesSnd.Mech.mechcock04'
00955	     AmbientWaitSounds(2)=Sound'CreaturesSnd.Mech.mechservo06'
00956	     AmbientFightSounds(0)=Sound'CreaturesSnd.Mech.mechmove02'
00957	     AmbientFightSounds(1)=Sound'CreaturesSnd.Mech.mechcock02'
00958	     AmbientFightSounds(2)=Sound'CreaturesSnd.Mech.mechmove08'
00959	     AmbientWaitSoundDelay=3.000000
00960	     AmbientFightSoundDelay=3.000000
00961	     StartWeapon=Class'RuneI.MechBlade'
00962	     bWaitLook=False
00963	     bBurnable=False
00964	     A_StepUp=pullup
00965	     CarcassType=Class'RuneI.CarcassMechDwarf'
00966	     bAlignToFloor=True
00967	     MeleeRange=175.000000
00968	     GroundSpeed=150.000000
00969	     AccelRate=1000.000000
00970	     WalkingSpeed=122.000000
00971	     ClassID=2
00972	     PeripheralVision=-1.000000
00973	     Health=150
00974	     BodyPartHealth(1)=50
00975	     BodyPartHealth(2)=50
00976	     BodyPartHealth(3)=50
00977	     BodyPartHealth(4)=50
00978	     BodyPartHealth(5)=50
00979	     BodyPartHealth(11)=75
00980	     BodyPartHealth(12)=75
00981	     UnderWaterTime=2.000000
00982	     Intelligence=BRAINS_HUMAN
00983	     HitSound1=Sound'CreaturesSnd.Mech.mechhit02'
00984	     HitSound2=Sound'CreaturesSnd.Mech.mechhit01'
00985	     HitSound3=Sound'CreaturesSnd.Mech.mechhit02'
00986	     Die=Sound'OtherSnd.Explosions.explosion08'
00987	     Die2=Sound'OtherSnd.Explosions.explosion08'
00988	     Die3=Sound'OtherSnd.Explosions.explosion08'
00989	     FootstepVolume=1.400000
00990	     FootStepWood(0)=Sound'CreaturesSnd.Mech.mechfoot07'
00991	     FootStepWood(1)=Sound'CreaturesSnd.Mech.mechfoot07'
00992	     FootStepWood(2)=Sound'CreaturesSnd.Mech.mechfoot07'
00993	     FootStepMetal(0)=Sound'CreaturesSnd.Mech.mechfoot07'
00994	     FootStepMetal(1)=Sound'CreaturesSnd.Mech.mechfoot07'
00995	     FootStepMetal(2)=Sound'CreaturesSnd.Mech.mechfoot07'
00996	     FootStepStone(0)=Sound'CreaturesSnd.Mech.mechfoot07'
00997	     FootStepStone(1)=Sound'CreaturesSnd.Mech.mechfoot07'
00998	     FootStepStone(2)=Sound'CreaturesSnd.Mech.mechfoot07'
00999	     FootStepFlesh(0)=Sound'CreaturesSnd.Mech.mechfoot07'
01000	     FootStepFlesh(1)=Sound'CreaturesSnd.Mech.mechfoot07'
01001	     FootStepFlesh(2)=Sound'CreaturesSnd.Mech.mechfoot07'
01002	     FootStepIce(0)=Sound'CreaturesSnd.Mech.mechfoot07'
01003	     FootStepIce(1)=Sound'CreaturesSnd.Mech.mechfoot07'
01004	     FootStepIce(2)=Sound'CreaturesSnd.Mech.mechfoot07'
01005	     FootStepEarth(0)=Sound'CreaturesSnd.Mech.mechfoot07'
01006	     FootStepEarth(1)=Sound'CreaturesSnd.Mech.mechfoot07'
01007	     FootStepEarth(2)=Sound'CreaturesSnd.Mech.mechfoot07'
01008	     FootStepSnow(0)=Sound'CreaturesSnd.Mech.mechfoot07'
01009	     FootStepSnow(1)=Sound'CreaturesSnd.Mech.mechfoot07'
01010	     FootStepSnow(2)=Sound'CreaturesSnd.Mech.mechfoot07'
01011	     FootStepWater(0)=Sound'CreaturesSnd.Mech.mechfoot07'
01012	     FootStepWater(1)=Sound'CreaturesSnd.Mech.mechfoot07'
01013	     FootStepWater(2)=Sound'CreaturesSnd.Mech.mechfoot07'
01014	     FootStepMud(0)=Sound'CreaturesSnd.Mech.mechfoot07'
01015	     FootStepMud(1)=Sound'CreaturesSnd.Mech.mechfoot07'
01016	     FootStepMud(2)=Sound'CreaturesSnd.Mech.mechfoot07'
01017	     FootStepLava(0)=Sound'CreaturesSnd.Mech.mechfoot07'
01018	     FootStepLava(1)=Sound'CreaturesSnd.Mech.mechfoot07'
01019	     FootStepLava(2)=Sound'CreaturesSnd.Mech.mechfoot07'
01020	     LandSoundWood=Sound'CreaturesSnd.Mech.mechland01'
01021	     LandSoundMetal=Sound'CreaturesSnd.Mech.mechland01'
01022	     LandSoundStone=Sound'CreaturesSnd.Mech.mechland01'
01023	     LandSoundFlesh=Sound'CreaturesSnd.Mech.mechland01'
01024	     LandSoundIce=Sound'CreaturesSnd.Mech.mechland01'
01025	     LandSoundSnow=Sound'CreaturesSnd.Mech.mechland01'
01026	     LandSoundEarth=Sound'CreaturesSnd.Mech.mechland01'
01027	     LandSoundWater=Sound'CreaturesSnd.Mech.mechland01'
01028	     LandSoundMud=Sound'CreaturesSnd.Mech.mechland01'
01029	     LandSoundLava=Sound'CreaturesSnd.Mech.mechland01'
01030	     WeaponJoint=rwrist
01031	     bCanLook=True
01032	     MaxBodyAngle=(Yaw=32768)
01033	     MaxHeadAngle=(Pitch=0,Yaw=0)
01034	     bRotateHead=False
01035	     DeathRadius=40.000000
01036	     DeathHeight=33.000000
01037	     AnimSequence=Idle
01038	     LODCurve=LOD_CURVE_NONE
01039	     SoundRadius=64
01040	     CollisionRadius=50.000000
01041	     CollisionHeight=47.000000
01042	     Mass=250.000000
01043	     Buoyancy=200.000000
01044	     RotationRate=(Pitch=0,Roll=0)
01045	     Skeletal=SkelModel'creatures.MechaDwarf'
01046	}

End Source Code