RuneI
Class TrainingUlf

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

class TrainingUlf
extends RuneI.Ulf

//============================================================================= // TrainingUlf. //=============================================================================
Variables
 int OuchCount
 int PrevHealth
 Sound UlfDeadMessage
 Sound UlfOuch[4]
 Sound UlfTaunt[4]

States
Dying, Pain

Function Summary
 void Died(Pawn Killer, name damageType, vector HitLocation)
     
//------------------------------------------------------------
//
// Died
//
// Pawn has run out of health, kill him properly
//------------------------------------------------------------
 void PlayDeath(name DamageType)
     
//===================================================================
//
// PlayDeath
//
//===================================================================
 void WeaponActivate()
     
//===================================================================
//
// WeaponActivate
//
//===================================================================
 void WeaponDeactivate()
     
//===================================================================
//
// WeaponDeactivate
//
//===================================================================


State Dying Function Summary


State Pain Function Summary
 bool CanGotoPainState()



Source Code


00001	//=============================================================================
00002	// TrainingUlf.
00003	//=============================================================================
00004	class TrainingUlf expands Ulf;
00005	
00006	var() Sound UlfTaunt[4];
00007	var() Sound UlfOuch[4];
00008	var() Sound UlfDeadMessage;
00009	
00010	var int OuchCount;
00011	var int PrevHealth;
00012	
00013	//===================================================================
00014	//
00015	// PlayDeath
00016	//
00017	//===================================================================
00018	
00019	function PlayDeath(name DamageType)           
00020	{ 
00021		PlayAnim('z_knockdown', 1.0, 0.1);
00022	}
00023	
00024	//===================================================================
00025	//
00026	// WeaponActivate
00027	//
00028	//===================================================================
00029	
00030	function WeaponActivate()
00031	{	
00032		// This is a training NPC, so he should NOT be able to kill the player
00033		// if Ragnar's health gets too low, don't do as much damage anymore
00034		if(Enemy.Health < 10)
00035			Weapon.Damage = 0; 
00036		else if(Enemy.Health < 25)
00037			Weapon.Damage = 2;	
00038		else
00039			Weapon.Damage = 5;
00040	
00041		PrevHealth = Enemy.Health;
00042	
00043		Super.WeaponActivate();
00044	}
00045	
00046	//===================================================================
00047	//
00048	// WeaponDeactivate
00049	//
00050	//===================================================================
00051	
00052	function WeaponDeactivate()
00053	{
00054		if(Enemy.Health < PrevHealth && FRand() < 0.8)
00055		{ // TrainingUlf has hurt the player in this swipe, play a taunt
00056			PlaySound(UlfTaunt[Rand(4)], SLOT_Talk);
00057		}
00058	
00059		Super.WeaponDeactivate();
00060	}
00061	
00062	//------------------------------------------------------------
00063	//
00064	// Died
00065	//
00066	// Pawn has run out of health, kill him properly
00067	//------------------------------------------------------------
00068	function Died(pawn Killer, name damageType, vector HitLocation)
00069	{
00070		local actor A;
00071	
00072		if ( bDeleteMe ) return; //already destroyed
00073		Health = Min(0, Health);
00074		
00075		if (Killer != None)
00076			Killer.Killed(Killer, self, damageType);
00077		Level.Game.Killed(Killer, self, damageType);
00078		DropWeapon();
00079		DropShield();
00080		Level.Game.DiscardInventory(self);	// Delete the rest of the inventory
00081	
00082		GotoState('Dying');
00083	}
00084	
00085	//------------------------------------------------------------
00086	//
00087	// Pain
00088	//
00089	//------------------------------------------------------------
00090	state Pain
00091	{
00092		function bool CanGotoPainState()
00093		{ // Do not allow the actor to enter the painstate when already in pain
00094			return(false);
00095		}
00096	
00097	Begin:
00098	
00099		if(PainDelay < 0)
00100		{ // If PainDelay is negative, the painstate waits until the anim has completed
00101			FinishAnim();
00102		}
00103		else
00104		{ // Otherwise, just use the PainDelay
00105			Sleep(PainDelay);
00106		}
00107	
00108		if(OuchCount < 4 && FRand() < 0.75)
00109		{
00110			PlaySound(UlfOuch[OuchCount], SLOT_Talk);
00111			OuchCount++;
00112		}
00113		
00114		GotoState(NextStateAfterPain);
00115	}
00116	
00117	//============================================================
00118	//
00119	// Dying
00120	//
00121	//============================================================
00122	state Dying
00123	{
00124	ignores SeePlayer, EnemyNotVisible, HearNoise, KilledBy, Trigger, Bump, HitWall, HeadZoneChange, FootZoneChange, ZoneChange, Falling, WarnTarget, Died, LongFall, PainTimer, Landed, JointDamaged;
00125	
00126	Begin:
00127		Acceleration = vect(0, 0, 0);
00128		Velocity = vect(0, 0, 0);
00129		bLookFocusPlayer = true;
00130		LookTarget = Enemy;
00131	
00132		Goto('PreDeath');
00133	
00134	PreDeath:
00135		Goto('Death');
00136	
00137	Death:
00138		PlayAnim('cine_vil_kneeldown', 1.0, 0.15);
00139		FinishAnim();
00140		Sleep(0.5);
00141		PlaySound(UlfDeadMessage, SLOT_Talk);
00142		Sleep(1.0);
00143		PlayAnim('cine_vil_standup', 1.0, 0.15);
00144		FinishAnim();
00145	
00146		// Talk for a bit....
00147		LoopAnim('cine_vil_talkingA', 1.0, 0.1);
00148		Sleep(1.5);
00149		LoopAnim('cine_vil_talkingB', 1.0, 0.1);
00150		Sleep(1.5);
00151		LoopAnim('cine_vil_talkingC', 1.0, 0.1);
00152		Sleep(1.5);
00153		LoopAnim('cine_vil_talkingB', 1.0, 0.1);
00154		Sleep(1.5);
00155		LoopAnim('cine_vil_talkingA', 1.0, 0.1);
00156		Sleep(1.5);
00157		LoopAnim('cine_vil_talkingC', 1.0, 0.1);
00158		Sleep(1.0);
00159	
00160		// Trigger any Events... this is overridden to happen here instead of at the moment of "death"
00161		FireEvent(Event);
00162	
00163		// Hide TrainingUlf's enemy (which would be Ragnar), as other scripting will happen after TrainingUlf
00164		Enemy.bHidden = true;
00165		Enemy.SetCollision(false, false, false);
00166		Destroy(); // Finally, destroy this training Ulf
00167	
00168		Goto('PostDeath');
00169	
00170	PostDeath:
00171	}
00172	
00173	simulated function Debug(Canvas canvas, int mode)
00174	{
00175		local vector offset;
00176		
00177		Super.Debug(canvas, mode);
00178		
00179		Canvas.DrawText("	TrainingUlf:");
00180		Canvas.CurY -= 8;
00181		Canvas.DrawText("	Enemy:" $Enemy);
00182		Canvas.CurY -= 8;
00183	}
00184	
00185	defaultproperties
00186	{
00187	     Health=300
00188	     BodyPartHealth(1)=999
00189	     BodyPartHealth(3)=999
00190	     BodyPartHealth(5)=999
00191	     StabJoint=	
00192	}

End Source Code