RuneI
Class SarkConrack

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

class SarkConrack
extends RuneI.Sark

//============================================================================= // SarkConrack. //=============================================================================
States
Dying, Scripting, Fighting

Function Summary
 void ApplyGoreCap(int BodyPart)
     
//============================================================
//
// ApplyGoreCap
//
//============================================================
 int BodyPartForPolyGroup(int polygroup)
     
//============================================================
//
// BodyPartForPolyGroup
//
//============================================================
 bool CanGotoPainState()
     
//------------------------------------------------------------
//
// CanGotoPainState
//
//------------------------------------------------------------
 Texture PainSkin(int BodyPart)
     
//============================================================
//
// PainSkin
//
// returns the pain skin for a given polygroup
//============================================================
 void PlayDeath(name DamageType)
 void PlaySkewerDeath(name DamageType)
     
//===================================================================
//
// PlayDeath
//
// SarkConrack is a special character who is fought only once in the game
// and he should NOT play a death animation, instead he plays a pain anim
//===================================================================
 void PostBeginPlay()
     
//============================================================
//
// PostBeginPlay
//
//============================================================


State Dying Function Summary
 void BeginState()


State Scripting Function Summary
 void Died(Pawn Killer, name damagetype, vector HitLocation)
 void AmbientSoundTimer()


State Fighting Function Summary
 bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)
     
//------------------------------------------------
//
// JointDamaged
//
//------------------------------------------------
 void Timer()
     
// Determine AttackAction based upon enemy movement and position



Source Code


00001	//=============================================================================
00002	// SarkConrack.
00003	//=============================================================================
00004	class SarkConrack expands Sark;
00005	
00006	
00007	//============================================================
00008	//
00009	// PostBeginPlay
00010	//
00011	//============================================================
00012	
00013	function PostBeginPlay()
00014	{
00015		local actor f;
00016	
00017		Super.PostBeginPlay();
00018	
00019		f = Spawn(Class'SarkEyeConrack');
00020		AttachActorToJoint(f, JointNamed('head'));
00021	}
00022	
00023	//============================================================
00024	//
00025	// PainSkin
00026	//
00027	// returns the pain skin for a given polygroup
00028	//============================================================
00029	function Texture PainSkin(int BodyPart)
00030	{
00031		switch(BodyPart)
00032		{
00033			case BODYPART_TORSO:
00034				SkelGroupSkins[3] = Texture'players.Ragnarsc_torsopain';
00035				break;
00036			case BODYPART_HEAD:
00037				SkelGroupSkins[2] = Texture'players.Ragnarsc_head';
00038				break;
00039			case BODYPART_LARM1:
00040				SkelGroupSkins[6] = Texture'players.ragnarsc_armlegpain';
00041				break;
00042			case BODYPART_RARM1:
00043				SkelGroupSkins[7] = Texture'players.ragnarsc_armlegpain';
00044				break;
00045			case BODYPART_LLEG1:
00046				SkelGroupSkins[1] = Texture'players.ragnarsc_armlegpain';
00047				break;
00048			case BODYPART_RLEG1:
00049				SkelGroupSkins[1] = Texture'players.ragnarsc_armlegpain';
00050				break;
00051		}
00052		return None;
00053	}
00054	
00055	//============================================================
00056	//
00057	// BodyPartForPolyGroup
00058	//
00059	//============================================================
00060	function int BodyPartForPolyGroup(int polygroup)
00061	{
00062		switch(polygroup)
00063		{
00064			case 2:						return BODYPART_HEAD;
00065			case 8:						return BODYPART_LARM1;
00066			case 9:						return BODYPART_RARM1;
00067			case 1:						return BODYPART_LLEG1;
00068			case 1:						return BODYPART_RLEG1;
00069			case 4: case 5: case 10:	// Gore caps
00070			case 8: case 9:			// Arm stubs
00071			case 3:						return BODYPART_TORSO;
00072		}
00073		return BODYPART_BODY;
00074	}
00075	
00076	//============================================================
00077	//
00078	// ApplyGoreCap
00079	//
00080	//============================================================
00081	function ApplyGoreCap(int BodyPart)
00082	{
00083		switch(BodyPart)
00084		{	// no gore caps exist
00085			case BODYPART_LARM1:
00086				SkelGroupSkins[4] = Texture'runefx.gore_bone';
00087				SkelGroupFlags[4] = SkelGroupFlags[8] & ~POLYFLAG_INVISIBLE;
00088				break;
00089			case BODYPART_RARM1:
00090				SkelGroupSkins[5] = Texture'runefx.gore_bone';
00091				SkelGroupFlags[5] = SkelGroupFlags[7] & ~POLYFLAG_INVISIBLE;
00092				break;
00093			case BODYPART_HEAD:
00094				SkelGroupSkins[10] = Texture'runefx.gore_bone';
00095				SkelGroupFlags[10] = SkelGroupFlags[4] & ~POLYFLAG_INVISIBLE;
00096				break;
00097		}
00098	}
00099	
00100	//================================================
00101	//
00102	// SeveredLimbClass
00103	//
00104	//================================================
00105	function class<Actor> SeveredLimbClass(int BodyPart)
00106	{
00107		switch(BodyPart)
00108		{
00109			case BODYPART_LARM1:
00110			case BODYPART_RARM1:
00111				return class'SarkConArm';
00112			case BODYPART_HEAD:
00113				return class'SarkConHead';
00114		}
00115	
00116		return None;
00117	}
00118	
00119	//===================================================================
00120	//
00121	// PlayDeath
00122	//
00123	// SarkConrack is a special character who is fought only once in the game
00124	// and he should NOT play a death animation, instead he plays a pain anim
00125	//===================================================================
00126	function PlaySkewerDeath(name DamageType) { PlayDeath(DamageType); }
00127	
00128	function PlayDeath(name DamageType)           
00129	{ 
00130		PlayAnim('cine_Loki_kneelonhands', 1.0, 0.1);
00131	}
00132	
00133	//------------------------------------------------------------
00134	//
00135	// CanGotoPainState
00136	//
00137	//------------------------------------------------------------
00138	
00139	function bool CanGotoPainState()
00140	{
00141		return(false);
00142	}
00143	
00144	//================================================
00145	//
00146	// Fighting
00147	//
00148	//================================================
00149	State Fighting
00150	{
00151	ignores EnemyAcquired;
00152	
00153		// Determine AttackAction based upon enemy movement and position
00154		function Timer()
00155		{
00156			GetEnemyProximity();
00157	
00158			LastAction = AttackAction;
00159					
00160			if(EnemyMovement == MOVE_STRAFE_LEFT && FRand() < 0.65 && CheckStrafeLeft())
00161			{
00162				AttackAction = AA_STRAFE_LEFT;
00163			}
00164			else if(EnemyMovement == MOVE_STRAFE_RIGHT && FRand() < 0.65 && CheckStrafeRight())
00165			{
00166				AttackAction = AA_STRAFE_RIGHT;
00167			}
00168			else if(FRand() < 0.08 && Physics == PHYS_Walking && CheckJumpLocation())
00169			{ // Sark jump
00170				AttackAction = AA_JUMP;
00171			}
00172			else if(EnemyMovement == MOVE_STANDING && FRand() < 0.9 || FRand() < 0.35)
00173			{
00174				AttackAction = AA_LUNGE;
00175			}		
00176		 	else if(FRand() < 0.9)
00177		 	{
00178		 		if(FRand() < 0.5 && LastAction != AA_STRAFE_RIGHT || LastAction == AA_STRAFE_LEFT
00179					&& CheckStrafeLeft())
00180		 		{
00181		 			AttackAction = AA_STRAFE_LEFT;
00182		 		}
00183		 		else if(LastAction != AA_STRAFE_LEFT || LastAction == AA_STRAFE_RIGHT && CheckStrafeRight())
00184		 		{
00185		 			AttackAction = AA_STRAFE_RIGHT;
00186		 		}
00187				else
00188				{
00189					AttackAction = AA_WAIT;
00190				}
00191		 	}
00192			else
00193			{
00194				AttackAction = AA_WAIT;
00195			}
00196			
00197	/*	
00198			if (ShouldDefend())
00199			{
00200				GotoState('Fighting', 'Defend');
00201			}
00202	*/		
00203		}
00204			
00205	Fight:
00206		if(!ValidEnemy())
00207			Goto('BackFromSubState');
00208	
00209		GetEnemyProximity();
00210		
00211		// Attack if close enough
00212		if(Weapon != None && InMeleeRange(Enemy) || (EnemyMovement == MOVE_CLOSER && EnemyDist < MeleeRange * 2.5))
00213		{
00214			PlayAnim(Weapon.A_AttackA, 1.5, 0.1);
00215			Sleep(0.1);
00216			WeaponActivate();
00217			Weapon.EnableSwipeTrail();
00218			FinishAnim();
00219	
00220			if(Weapon.A_AttackB != 'None' && FRand() < 0.7)
00221			{
00222				PlayAnim(Weapon.A_AttackB, 1.5, 0.01);
00223				if(Enemy != None)
00224					TurnToward(Enemy);
00225				FinishAnim();
00226	
00227				// B-Return
00228				WeaponDeactivate();
00229	
00230				if(Weapon.A_AttackBReturn != 'None')
00231				{
00232					PlayAnim(Weapon.A_AttackBReturn, 1.5, 0.1);
00233					FinishAnim();
00234				}
00235			}
00236			else
00237			{ // A-Return
00238				WeaponDeactivate();
00239	
00240				if(Weapon.A_AttackAReturn != 'None')
00241				{
00242					PlayAnim(Weapon.A_AttackAReturn, 1.5, 0.1);
00243					FinishAnim();
00244				}
00245			}
00246	
00247			Weapon.DisableSwipeTrail();
00248	
00249			Sleep(TimeBetweenAttacks);
00250		}
00251		else if(AttackAction == AA_LUNGE)
00252		{ // Random lunge
00253			PlayMoving();
00254			bStopMoveIfCombatRange = false;
00255			MoveTo(Enemy.Location - VecToEnemy * MeleeRange, MovementSpeed);
00256			bStopMoveIfCombatRange = true;
00257		}
00258		else if(AttackAction == AA_STRAFE_LEFT)
00259		{ // Strafe - Position is calculated in Timer, when the strafe is chosen
00260			PlayStrafeLeft();
00261			bStopMoveIfCombatRange = false;
00262			StrafeFacing(Destination, Enemy);
00263			bStopMoveIfCombatRange = true;
00264		}
00265		else if(AttackAction == AA_STRAFE_RIGHT)
00266		{ // Strafe - Position is calculated in Timer, when the strafe is chosen
00267			PlayStrafeRight();
00268			bStopMoveIfCombatRange = false;
00269			StrafeFacing(Destination, Enemy);
00270			bStopMoveIfCombatRange = true;
00271		}
00272		else if(AttackAction == AA_JUMP)
00273		{
00274			PlayFlip(0.1);
00275			Sleep(0.4); // Sleep for a bit before making the leap
00276			PlaySound(JumpSound);
00277			CalcJumpVelocity();
00278			WaitForLanding();
00279	
00280			RotateSark();
00281			PlayAnim('sark_land', 1.0, 0.0);
00282			if(Enemy != None)
00283				TurnToward(Enemy);
00284			FinishAnim();
00285		}
00286		else
00287		{
00288			PlayWaiting();
00289		}
00290	
00291		if(InCombatRange(Enemy))
00292		{
00293			Sleep(0.05);
00294			Goto('Begin');
00295		}
00296		
00297	BackFromSubState:
00298		GotoState('Charging', 'ResumeFromFighting');
00299	}
00300	
00301	//------------------------------------------------
00302	//
00303	// JointDamaged
00304	//
00305	//------------------------------------------------
00306	function bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)
00307	{
00308		local bool rtn;
00309		local int healthBefore, healthAfter;
00310		local ParticleSystem S;
00311	
00312		healthBefore = Health;
00313		rtn = Super.JointDamaged(Damage, EventInstigator, HitLoc, Momentum, DamageType, joint);
00314		healthAfter = Health;
00315	
00316		if(healthBefore >= 500 && healthAfter < 500 && Weapon != None)
00317		{ // Change his sword and up the damage it does
00318			Weapon.Damage = Weapon.Damage * 2;
00319	
00320			for(i = 2; i < 6; i++)
00321			{
00322				S = Spawn(class'RespawnFire');
00323				if(S != None)
00324				{
00325					S.bSystemOneShot = false;
00326					S.bOneShot = false;
00327					S.ScaleMax = 0.8;
00328					S.ScaleMin = 0.6;
00329					S.LifeSpanMax = 0.5;
00330					S.LifeSpanMin = 0.3;
00331					S.ShapeVector = vect(6, 6, 6);
00332	
00333					Weapon.AttachActorToJoint(S, i);			
00334				}
00335			}
00336		}
00337	
00338		return(rtn);
00339	}
00340	
00341	//===================================================================
00342	//
00343	// Scripting
00344	//
00345	//===================================================================
00346	
00347	state Scripting
00348	{
00349		function AmbientSoundTimer()
00350		{ // Don't play any ambient sounds while scripting
00351		}
00352	}
00353	
00354	function Died(pawn Killer, name damagetype, vector HitLocation)
00355	{
00356		local int joint;
00357		local actor S;
00358	
00359		if(Weapon != None)
00360		{
00361			for(joint = 2; joint < 6; joint++)
00362			{
00363				S = Weapon.DetachActorFromJoint(joint);
00364				if(S != None)
00365					S.Destroy();
00366			}				
00367		}
00368	
00369		Super.Died(Killer, damageType, HitLocation);
00370	}
00371	
00372	//================================================
00373	//
00374	// Dying
00375	//
00376	//================================================
00377	
00378	state Dying
00379	{
00380		function BeginState()
00381		{
00382			local int joint;
00383			local vector X, Y, Z;
00384	
00385			// Drop any stowed weapons
00386			if(StowWeapon != None)
00387			{		
00388				switch(StowWeapon.MeleeType)
00389				{
00390				case MELEE_SWORD:
00391					joint = JointNamed('attatch_sword');
00392					break;
00393				case MELEE_AXE:
00394					joint = JointNamed('attach_axe');
00395					break;
00396				case MELEE_AXE:
00397					joint = JointNamed('attach_hammer');
00398					break;
00399				default:
00400					// Unknown or non-stow item
00401					return;
00402				}
00403	
00404				DetachActorFromJoint(joint);
00405					
00406				GetAxes(Rotation, X, Y, Z);
00407				StowWeapon.DropFrom(GetJointPos(joint));
00408			
00409				StowWeapon.SetPhysics(PHYS_Falling);
00410				StowWeapon.Velocity = Y * 100 + X * 75;
00411				StowWeapon.Velocity.Z = 50;
00412				
00413				StowWeapon.GotoState('Drop');
00414				StowWeapon.DisableSwipeTrail();
00415	
00416				StowWeapon = None; // Remove the StowWeapon from the actor
00417			}		
00418		}
00419			
00420	begin:
00421		PlayDeath('');
00422	}
00423	
00424	defaultproperties
00425	{
00426	     JumpSound=Sound'CreaturesSnd.Sark.sark3jump01'
00427	     AcquireSound=Sound'CreaturesSnd.Sark.sark1see'
00428	     AmbientWaitSounds(0)=Sound'CreaturesSnd.Vikings.conrak2ambient01'
00429	     AmbientWaitSounds(1)=Sound'CreaturesSnd.Vikings.conrak2ambient02'
00430	     AmbientWaitSounds(2)=Sound'CreaturesSnd.Vikings.conrak2ambient03'
00431	     AmbientFightSounds(0)=Sound'CreaturesSnd.Vikings.conrak2attack01'
00432	     AmbientFightSounds(1)=Sound'CreaturesSnd.Vikings.conrak2attack02'
00433	     AmbientFightSounds(2)=Sound'CreaturesSnd.Vikings.conrak2attack03'
00434	     AmbientWaitSoundDelay=8.000000
00435	     AmbientFightSoundDelay=5.000000
00436	     bIsBoss=True
00437	     StartWeapon=Class'RuneI.DwarfWorkSword'
00438	     StartShield=Class'RuneI.DwarfBattleShield'
00439	     MeleeRange=70.000000
00440	     GroundSpeed=400.000000
00441	     HitSound1=Sound'CreaturesSnd.Vikings.conrak2hit01'
00442	     HitSound2=Sound'CreaturesSnd.Vikings.conrak2hit02'
00443	     HitSound3=Sound'CreaturesSnd.Vikings.conrak2hit03'
00444	     Die=Sound'CreaturesSnd.Vikings.conrak2death01'
00445	     Die2=Sound'CreaturesSnd.Vikings.conrak2death02'
00446	     Die3=Sound'CreaturesSnd.Vikings.conrak2death03'
00447	     LandSoundWood=Sound'CreaturesSnd.Sark.sarkland02'
00448	     LandSoundMetal=Sound'CreaturesSnd.Sark.sarkland02'
00449	     LandSoundStone=Sound'CreaturesSnd.Sark.sarkland02'
00450	     LandSoundFlesh=Sound'CreaturesSnd.Sark.sarkland02'
00451	     LandSoundIce=Sound'CreaturesSnd.Sark.sarkland02'
00452	     LandSoundSnow=Sound'CreaturesSnd.Sark.sarkland02'
00453	     LandSoundEarth=Sound'CreaturesSnd.Sark.sarkland02'
00454	     LandSoundWater=Sound'CreaturesSnd.Sark.sarkland02'
00455	     LandSoundMud=Sound'CreaturesSnd.Sark.sarkland02'
00456	     LandSoundLava=Sound'CreaturesSnd.Sark.sarkland02'
00457	     MaxMouthRot=7000
00458	     MaxMouthRotRate=65535
00459	     DrawScale=1.750000
00460	     CollisionRadius=36.000000
00461	     CollisionHeight=69.000000
00462	     SkelMesh=16
00463	     SkelGroupSkins(0)=Texture'Players.Ragnarragd_arms'
00464	     SkelGroupSkins(1)=Texture'Players.Ragnarsc_armleg'
00465	     SkelGroupSkins(2)=Texture'Players.Ragnarsc_head'
00466	     SkelGroupSkins(3)=Texture'Players.Ragnarsc_torso'
00467	     SkelGroupSkins(4)=Texture'Players.Ragnarsc_armleg'
00468	     SkelGroupSkins(5)=Texture'Players.Ragnarsc_armleg'
00469	     SkelGroupSkins(6)=Texture'Players.Ragnarsc_armleg'
00470	     SkelGroupSkins(7)=Texture'Players.Ragnarsc_armleg'
00471	     SkelGroupSkins(8)=Texture'Players.Ragnarsc_armleg'
00472	     SkelGroupSkins(9)=Texture'Players.Ragnarsc_armleg'
00473	     SkelGroupSkins(10)=Texture'Players.Ragnarsc_torso'
00474	}

End Source Code