RuneI
Class DwarfBlack

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

class DwarfBlack
extends RuneI.Dwarf

//============================================================================= // DwarfBlack. //=============================================================================
Variables
 Actor LightningTarget
           attack bolt
 float MoveRadius
           attack bolt
 int PowerLevel
 float SpringMag
           attack bolt
 DarkDwarfBolt bolt
           attack bolt
 DarkDwarfChargeup chargeup
           chargeup actor in hand
 int loop

States
Dying, Overcharged, Fighting

Function Summary
 bool CanPickup(Inventory item)
     
//================================================
//
// CanPickup
//
// Let's pawn dictate what it can pick up
//================================================
 void CheckForEnemies()
 bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)
     
//================================================
//
// JointDamaged
//
//================================================
 Texture PainSkin(int BodyPart)
     
//================================================
//
// PainSkin
//
// returns the pain skin for a given polygroup
//================================================
 void PlayDeath(name DamageType)
 void PlayMissileAttack()
 void PlayVictoryDance()
 void PlayWaiting(optional float)
     
//-----------------------------------------------------------------------------
// Animation functions
//-----------------------------------------------------------------------------
 void PostBeginPlay()
 void Trigger(Actor Other, Pawn EventInstigator)
     
//================================================
//
// Trigger
//
// Each time he is triggered raises power level
//================================================
 void TweenToWaiting(float time)
 bool ValidEnemy()
     
// Used to stop attacking when conditions are met
// Player is still valid with DarkDwarf even if player goes invisible


State Dying Function Summary


State Overcharged Function Summary
 void ResetLightning()
 void RemoveLightning()
 void Timer()
 void Spring()
 void MakeSpringy()
 void EndState()
 void BeginState()


State Fighting Function Summary
 bool PickDestination()
 bool ShouldShoot()
 void BoltOff()
 void BoltOn()
 void AmbientSoundTimer()
 void DoThrow()
     
// Notify callback to throw energy ball
 void EndState()



Source Code


00001	//=============================================================================
00002	// DwarfBlack.
00003	//=============================================================================
00004	class DwarfBlack expands Dwarf;
00005	
00006	/*
00007		Description:
00008			Boss.  Accumulates electricity through his back and releases it as energy balls
00009			5 spigots of electricity
00010			twitch and smoke when 5th switch turned on...
00011			stays in a radius
00012			each switch makes more and more powerful, but closer to overload
00013	
00014		Anims:
00015			Muttering
00016			Laughing
00017	
00018		TODO:
00019			Lead Target when shooting
00020			Death Explosion
00021			twitch and smoke at higher power levels
00022			attack beam support for tracing to target
00023	*/
00024	
00025	var private int PowerLevel;
00026	var private int loop;
00027	var private DarkDwarfChargeup chargeup;		// chargeup actor in hand
00028	var private DarkDwarfBolt bolt;				// attack bolt
00029	var private actor LightningTarget;
00030	var float MoveRadius;
00031	var float SpringMag;
00032	
00033	var(Sounds) sound	ChargeupSoundLOOP;
00034	var(Sounds) sound	ReleaseSoundLOOP;
00035	var(Sounds) sound	OverchargedSoundLOOP;
00036	
00037	
00038	//================================================
00039	//
00040	// PainSkin
00041	//
00042	// returns the pain skin for a given polygroup
00043	//================================================
00044	function Texture PainSkin(int BodyPart)
00045	{
00046		switch(BodyPart)
00047		{
00048			case BODYPART_BODY:
00049			case BODYPART_HEAD:
00050			case BODYPART_LARM1:
00051			case BODYPART_RARM1:
00052			case BODYPART_LLEG1:
00053			case BODYPART_RLEG1:
00054			case BODYPART_LLEG2:
00055			case BODYPART_LARM2:
00056			case BODYPART_RARM2:
00057			case BODYPART_RLEG2:
00058				break;
00059		}
00060		return None;
00061	}
00062	
00063	
00064	function PostBeginPlay()
00065	{
00066		Super.PostBeginPlay();
00067	
00068		chargeup = spawn(class'DarkDwarfChargeup',,,,);
00069		AttachActorToJoint(chargeup, 28);
00070	
00071		// Spawn charge up electricity
00072		bolt = Spawn(class'darkdwarfbolt',self,'bolt',,);
00073		AttachActorToJoint(bolt, 29);
00074		bolt.bHidden = true;
00075		bolt.Target = None;
00076	}
00077	
00078	//================================================
00079	//
00080	// CanPickup
00081	//
00082	// Let's pawn dictate what it can pick up
00083	//================================================
00084	function bool CanPickup(Inventory item)
00085	{
00086		return false;
00087	}
00088	
00089	function CheckForEnemies()	{}
00090	
00091	
00092	//================================================
00093	//
00094	// Trigger
00095	//
00096	// Each time he is triggered raises power level
00097	//================================================
00098	function Trigger(actor Other, pawn EventInstigator)
00099	{
00100		PowerLevel++;
00101	
00102		if (PowerLevel >= 5)
00103		{
00104			GotoState('OverCharged');
00105		}
00106		else
00107		{
00108			chargeup.SetPowerLevel(PowerLevel);
00109			bolt.SetPowerLevel(PowerLevel);
00110		}
00111	}
00112	
00113	
00114	//================================================
00115	//
00116	// JointDamaged
00117	//
00118	//================================================
00119	function bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)
00120	{
00121		return false;
00122	}
00123	
00124	//-----------------------------------------------------------------------------
00125	// Animation functions
00126	//-----------------------------------------------------------------------------
00127	function PlayWaiting(optional float tween)
00128	{
00129		LoopAnim('dd_idlea', 1.0, 0.1);
00130	}
00131	function TweenToWaiting(float time)
00132	{
00133		TweenAnim ('dd_idlea',          time);
00134	}
00135	
00136	function PlayVictoryDance()
00137	{
00138		LoopAnim('dd_idleb', 1.0, 0.1);
00139	}
00140	
00141	function PlayMissileAttack()
00142	{
00143		PlayAnim('dd_attacka', 1.0, 0.1);
00144	}
00145	
00146	function PlayDeath(name DamageType)
00147	{
00148		LoopAnim('dd_death', 1.0, 0.1);
00149	}
00150	
00151	
00152	
00153	//-----------------------------------------------------------------------------
00154	// States
00155	//-----------------------------------------------------------------------------
00156	
00157	// Used to stop attacking when conditions are met
00158	// Player is still valid with DarkDwarf even if player goes invisible
00159	function bool ValidEnemy()
00160	{
00161		if (AttitudeToPlayer==ATTITUDE_Follow && ScriptPawn(Enemy)!=None && ScriptPawn(Enemy).Ally==Ally)
00162			return false;
00163	
00164		return (Enemy!=None && Enemy.Health > 0);
00165	}
00166	
00167	State Fighting
00168	{
00169		function EndState()
00170		{
00171			BoltOff();
00172			AmbientSound=None;
00173			chargeup.StopExpanding();
00174			chargeup.Hide();
00175		}
00176	
00177		// Notify callback to throw energy ball
00178		function DoThrow()
00179		{
00180			if (bolt!=None)
00181				bolt.DoDamage();
00182		}
00183	
00184		function AmbientSoundTimer()
00185		{
00186			PlayAmbientFightSound();
00187		}
00188	
00189		function BoltOn()
00190		{
00191			bolt.bHidden = false;
00192			bolt.ResetTargetting();
00193		}
00194	
00195		function BoltOff()
00196		{
00197			bolt.bHidden = true;
00198		}
00199	
00200		function bool ShouldShoot()
00201		{
00202			local Actor HitActor;
00203			local vector HitLocation, HitNormal;
00204			local vector FireLocation;
00205	
00206			FireLocation = GetJointPos(JointNamed('attach_hand'));
00207	
00208			// Make sure have LOS to enemy or blocked by destroyable
00209			HitActor = Trace(HitLocation, HitNormal, Enemy.Location+(vect(0,0,1)*Enemy.EyeHeight), FireLocation, true, vect(5,5,5));
00210			if (HitActor != None)
00211			{
00212				bolt.SetTarget(HitActor);
00213				if (HitActor.IsA('LevelInfo'))
00214					return false;
00215				else if (HitActor.IsA('PolyObj'))
00216					return (powerlevel > 1);
00217				else if (HitActor == Enemy)
00218					return true;
00219				else
00220					return false;
00221			}
00222			return true;
00223		}
00224	
00225		function bool PickDestination()
00226		{
00227			local int i;
00228			local actor HitActor;
00229			local vector HitLocation, HitNormal, newloc;
00230	
00231			bHurrying = false; //Rand(2) == 0;
00232			UpdateMovementSpeed();
00233	
00234			// Try to find a position within MoveRadius that gives LOS
00235			Destination = Location;
00236			for (i=0; i<10; i++)
00237			{
00238				newloc = HomeBase + VRand()*MoveRadius;
00239				newloc.Z = HomeBase.Z;
00240				HitActor = Trace(HitLocation, HitNormal, newloc, Enemy.Location, false, vect(5,5,5));
00241				if (HitActor == None)
00242				{
00243					Destination = newloc;
00244					return true;
00245				}
00246			}
00247	
00248			return false;
00249		}
00250	
00251	Begin:
00252	
00253	Think:
00254		if ( !ValidEnemy() )
00255		{
00256			PlayVictoryDance();
00257			Sleep(5);
00258			FinishAnim();
00259			GotoState('GoingHome');
00260		}
00261	
00262		if (NeedToTurn(Enemy.Location))
00263		{
00264			PlayTurning(0.1);
00265			TurnToward(Enemy);
00266		}
00267	
00268		if (ShouldShoot())
00269		{	// Throw
00270			PlayAnim('dd_windupa', 1.0, 0.1);
00271			Sleep(0.2);
00272			AmbientSound=ChargeupSoundLOOP;
00273			chargeup.StartExpanding();
00274			FinishAnim();
00275			PlayAnim('dd_attacka', 1.0, 0.1);
00276			FinishAnim();
00277	
00278			// Looping fire
00279			loop = PowerLevel;
00280			LoopAnim('dd_fireA', 1.0, 0.1);
00281			chargeup.StopExpanding();
00282			AmbientSound=ReleaseSoundLOOP;
00283			BoltOn();
00284			Sleep(1*PowerLevel);
00285			BoltOff();
00286			AmbientSound=None;
00287	
00288	donelooping:
00289			chargeup.Hide();
00290			FinishAnim();
00291			PlayWaiting(0.5);	// Refire rate
00292			Sleep(0.5);
00293			FinishAnim();
00294	
00295			// Play Laugh anim
00296		}
00297	
00298		if (PickDestination())
00299		{
00300			// Maneuver for better vantage point
00301			PlayMoving(0.1);
00302			MoveTo(Destination, MovementSpeed);
00303			Acceleration=vect(0,0,0);
00304			TurnToward(Enemy);
00305	//		FinishAnim();
00306		}
00307		else
00308		{
00309			PlayWaiting(0.1);
00310			FinishAnim();
00311		}
00312	
00313		Goto('think');
00314	}
00315	
00316	
00317	State Overcharged
00318	{
00319	ignores SeePlayer, EnemyNotVisible, HearNoise, KilledBy, Trigger, Bump, HitWall, HeadZoneChange, FootZoneChange, ZoneChange, Falling, WarnTarget, LongFall, PainTimer, Landed, EnemyAcquired, JointDamaged;
00320	
00321		function BeginState()
00322		{
00323			MakeSpringy();
00324			Timer();
00325		}
00326	
00327		function EndState()
00328		{
00329			SetTimer(0, false);
00330		}
00331	
00332		function MakeSpringy()
00333		{
00334			local int i;
00335			for (i=1; i<NumJoints(); i++)
00336			{
00337				JointFlags[i] = JointFlags[i] | JOINT_FLAG_SPRINGPOINT;
00338			}
00339		}
00340	
00341		function Spring()
00342		{
00343			local int i;
00344			for (i=1; i<NumJoints(); i++)
00345				ApplyJointForce(i, VRand()*Rand(SpringMag));
00346		}
00347	
00348		function Timer()
00349		{
00350			DesiredFatness=Rand(255);
00351			if (FRand() < 0.4)
00352				PlaySound(Sound'OtherSnd.Explosions.explosion10', SLOT_None);
00353			else
00354				PlaySound(Sound'OtherSnd.Explosions.explosion11', SLOT_None);
00355	
00356			SetTimer(FRand()*0.5, false);
00357	
00358			Spring();
00359		}
00360	
00361		function RemoveLightning()
00362		{
00363			local actor A;
00364			local DarkDwarfLightning B;
00365			local SparkSystem C;
00366			
00367			foreach AllActors( class 'DarkDwarfLightning', B,)
00368				B.Target = LightningTarget;
00369	
00370			foreach AllActors( class 'actor', A, 'Concentrator' )
00371			{
00372				A.Target = None;
00373				A.bHidden = true;
00374			}	
00375		}
00376	
00377		function ResetLightning()
00378		{
00379			local DarkDwarfLightning A;
00380				
00381			foreach AllActors(class 'DarkDwarfLightning', A,)
00382			{
00383				if(LightningTarget == None)
00384					LightningTarget = A.Target;
00385				A.Target = self;
00386				A.TargetJointIndex = Rand(NumJoints() - 1); 
00387			}
00388		}
00389	Begin:
00390		Acceleration=vect(0,0,0);
00391		ResetLightning();
00392		PlayDeath('overcharged');
00393		AmbientSound=OverchargedSoundLoop;
00394		Sleep(5);
00395	
00396		AmbientSound=None;
00397		SetTimer(0, false);
00398		RemoveLightning();
00399		spawn(class'DarkDwarfExplosion',,,,);
00400		spawn(class'DarkDwarfBlast',,,Location + vect(0,0,-50),);
00401		Died(self, 'overcharged', Location);
00402	}
00403	
00404	
00405	State Dying
00406	{
00407	ignores SeePlayer, EnemyNotVisible, HearNoise, KilledBy, Trigger, Bump, HitWall, HeadZoneChange, FootZoneChange, ZoneChange, Falling, WarnTarget, Died, LongFall, PainTimer, Landed, EnemyAcquired, JointDamaged;
00408	
00409	Begin:
00410		Destroy();
00411	}
00412	
00413	defaultproperties
00414	{
00415	     PowerLevel=1
00416	     MoveRadius=375.000000
00417	     SpringMag=100.000000
00418	     ChargeupSoundLOOP=Sound'EnvironmentalSnd.Scifi.scifi14L'
00419	     ReleaseSoundLOOP=Sound'EnvironmentalSnd.Scifi.scifi11L'
00420	     OverchargedSoundLOOP=Sound'EnvironmentalSnd.Scifi.scifi12L'
00421	     bThrowWeapon=False
00422	     BashSound=None
00423	     AlertOrders=Fighting
00424	     bLungeAttack=False
00425	     BlockChance=0.000000
00426	     BreathSound=None
00427	     AcquireSound=Sound'CreaturesSnd.Dwarves.bosssee01'
00428	     AmbientWaitSounds(0)=None
00429	     AmbientWaitSounds(1)=None
00430	     AmbientWaitSounds(2)=None
00431	     AmbientFightSounds(0)=Sound'CreaturesSnd.Dwarves.boss08'
00432	     AmbientFightSounds(1)=Sound'CreaturesSnd.Dwarves.boss10'
00433	     AmbientFightSounds(2)=Sound'CreaturesSnd.Dwarves.boss09'
00434	     AmbientFightSoundDelay=8.000000
00435	     bIsBoss=True
00436	     StartWeapon=None
00437	     StartShield=None
00438	     MeleeRange=100.000000
00439	     GroundSpeed=642.000000
00440	     AccelRate=5000.000000
00441	     WalkingSpeed=399.000000
00442	     Health=1000
00443	     Die=Sound'CreaturesSnd.Dwarves.bossdeath01'
00444	     Die2=Sound'CreaturesSnd.Dwarves.bossdeath01'
00445	     Die3=Sound'CreaturesSnd.Dwarves.bossdeath01'
00446	     FootstepVolume=1.000000
00447	     FootStepWood(0)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00448	     FootStepWood(1)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00449	     FootStepWood(2)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00450	     FootStepMetal(0)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00451	     FootStepMetal(1)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00452	     FootStepMetal(2)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00453	     FootStepStone(0)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00454	     FootStepStone(1)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00455	     FootStepStone(2)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00456	     FootStepFlesh(0)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00457	     FootStepFlesh(1)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00458	     FootStepFlesh(2)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00459	     FootStepIce(0)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00460	     FootStepIce(1)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00461	     FootStepIce(2)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00462	     FootStepEarth(0)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00463	     FootStepEarth(1)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00464	     FootStepEarth(2)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00465	     FootStepSnow(0)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00466	     FootStepSnow(1)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00467	     FootStepSnow(2)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00468	     FootStepWater(0)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00469	     FootStepWater(1)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00470	     FootStepWater(2)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00471	     FootStepMud(0)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00472	     FootStepMud(1)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00473	     FootStepMud(2)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00474	     FootStepLava(0)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00475	     FootStepLava(1)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00476	     FootStepLava(2)=Sound'CreaturesSnd.Dwarves.bossfoot01'
00477	     MaxBodyAngle=(Yaw=22768)
00478	     MaxHeadAngle=(Pitch=2048,Yaw=2048)
00479	     DrawScale=3.000000
00480	     SoundRadius=64
00481	     SoundVolume=200
00482	     TransientSoundRadius=2500.000000
00483	     CollisionRadius=105.000000
00484	     CollisionHeight=99.000000
00485	     SkelMesh=9
00486	}

End Source Code