RuneI
Class Lizard

source: c:\runehov\RuneI\Classes\Lizard.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
         |
         +--Engine.Pickup
            |
            +--RuneI.Food
               |
               +--RuneI.Lizard
Direct Known Subclasses:None

class Lizard
extends RuneI.Food

//============================================================================= // Lizard. //=============================================================================
Variables
 float AmbientDelay
 Sound AmbientSound[3]
 bool bChameleon
 bool bWallLizard

States
Pickup

Function Summary
 void FallToGround(Pawn EventInstigator)
 void PostBeginPlay()
 void Trigger(Actor Other, Pawn EventInstigator)


State Pickup Function Summary
 void Landed(vector HitNormal, Actor HitActor)
 void HitWall(vector HitNormal, Actor Wall)
 void ChangeBehavior()
 bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)



Source Code


00001	//=============================================================================
00002	// Lizard.
00003	//=============================================================================
00004	class Lizard expands Food;
00005	
00006	var() bool bWallLizard;
00007	var() bool bChameleon;
00008	
00009	var() Sound AmbientSound[3];
00010	var() float AmbientDelay;
00011	
00012	function PostBeginPlay()
00013	{
00014		local Texture tex;
00015		local int Flags;
00016		local vector ScrollDir;
00017		local vector X, Y, Z;
00018	
00019		Super.PostBeginPlay();
00020	
00021		// Grab texture from surroundings
00022		if(bChameleon)
00023		{
00024			if (Level.Netmode == NM_StandAlone)
00025				Nutrition = 25; // Chameleon lizards are more nutritious
00026	
00027			GetAxes(Rotation, X, Y, Z);
00028	
00029			tex = TraceTexture(Location - Z * 100, Location, Flags, ScrollDir);
00030			if(tex != None)
00031			{
00032				SkelGroupSkins[1] = tex;
00033				SkelGroupSkins[2] = tex;
00034				SkelGroupSkins[3] = tex;
00035				SkelGroupSkins[4] = tex;
00036				SkelGroupSkins[5] = tex;
00037			}
00038		}
00039	}
00040	
00041	function Trigger(actor Other, pawn EventInstigator)
00042	{
00043		FallToGround(EventInstigator);
00044	}
00045	
00046	function FallToGround(pawn EventInstigator)
00047	{
00048		local rotator rot;
00049		local vector X, Y, Z;
00050		local Actor A;
00051	
00052		if(bWallLizard)
00053		{
00054			bWallLizard = false;
00055		
00056			// Thrust the lizard from the wall a bit
00057			GetAxes(Rotation, X, Y, Z);
00058			Velocity = Z * 60;
00059		}
00060	
00061		SetPhysics(PHYS_Falling);
00062		rot.Yaw = Rotation.Yaw;
00063		rot.Pitch = 0;
00064		rot.Roll = 0;
00065		SetRotation(rot);
00066	
00067		SetTimer(0, false);
00068		PlayAnim('base', 1.0, 0.1);
00069	
00070		// Trigger any events
00071		if( Event != '' )
00072			foreach AllActors( class 'Actor', A, Event )
00073				A.Trigger( Self, EventInstigator );
00074	}
00075	
00076	auto state Pickup
00077	{
00078		function bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)
00079		{
00080			FallToGround(EventInstigator);
00081			return true;
00082		}
00083	
00084		function ChangeBehavior()
00085		{
00086			RotationRate.Pitch = 0;
00087			RotationRate.Roll = 0;
00088	
00089			if(FRand() < 0.4)
00090			{ // Standing still
00091				LoopAnim('idle', 1.0, 0.1);
00092				DesiredRotation.Yaw = Rotation.Yaw;
00093			}
00094			else
00095			{ // Rotating
00096				LoopAnim('run', 1.0, 0.1);
00097				if(FRand() < 0.5)
00098				{
00099					DesiredRotation.Yaw = Rotation.Yaw - 8000;		
00100					RotationRate.Yaw = -4000;
00101				}
00102				else
00103				{
00104					DesiredRotation.Yaw = Rotation.Yaw + 8000;
00105					RotationRate.Yaw = 4000;
00106				}
00107			}
00108					
00109			// Make random lizard noise
00110			PlaySound(AmbientSound[Rand(3)], SLOT_Talk, 1.0, true, 700, 0.95 + FRand() * 0.1);
00111		}
00112	
00113		function HitWall(vector HitNormal, actor Wall)
00114		{
00115			SetPhysics(PHYS_Falling);
00116		}
00117	
00118		function Landed(vector HitNormal, actor HitActor)
00119		{
00120			SetPhysics(PHYS_Falling);
00121		}
00122	
00123		
00124	begin:
00125		bFixedRotationDir = true;
00126		bRotateToDesired = true;
00127	
00128		if(bWallLizard)
00129		{
00130			SetPhysics(PHYS_None);
00131		}
00132		else
00133		{
00134			SetPhysics(PHYS_Falling); // don't fall at start
00135		}
00136		
00137		LoopAnim('idle', 1.0, 0.1);
00138	
00139		Sleep(FRand()); // So that multiple lizards are offset by a bit
00140	
00141	loop:
00142		Sleep(5);
00143		ChangeBehavior();
00144		Goto('loop');
00145	}
00146	
00147	simulated function Debug(Canvas canvas, int mode)
00148	{
00149		Super.Debug(canvas, mode);
00150		
00151		Canvas.DrawText("Lizard:");
00152		Canvas.CurY -= 8;
00153		Canvas.DrawText("  bWallLizard: " $ bWallLizard);
00154		Canvas.CurY -= 8;
00155	}
00156	
00157	defaultproperties
00158	{
00159	     AmbientSound(0)=Sound'CreaturesSnd.Lizard.lizard01'
00160	     AmbientSound(1)=Sound'CreaturesSnd.Lizard.lizard02'
00161	     AmbientSound(2)=Sound'CreaturesSnd.Lizard.lizard03'
00162	     AmbientDelay=15.000000
00163	     Nutrition=15
00164	     JunkActor=Class'RuneI.EatenLizard'
00165	     UseSound=Sound'OtherSnd.Pickups.pickuplizard01'
00166	     PickupMessage="You consumed a lizard"
00167	     DrawScale=1.250000
00168	     ScaleGlow=1.250000
00169	     LODCurve=LOD_CURVE_CONSERVATIVE
00170	     CollisionRadius=25.000000
00171	     CollisionHeight=20.000000
00172	     bCollideWorld=True
00173	     Skeletal=SkelModel'creatures.Lizard'
00174	}

End Source Code