RuneI
Class Dangler

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

class Dangler
extends RuneI.ScriptPawn

//============================================================================= // Dangler. //=============================================================================
Variables
 float AirTime
 byte BiteDamage
 byte RipDamage
 bool bAttackBump
 string debugstring

States
Ripping, Fighting, StakeOut

Function Summary
 eAttitude AttitudeToCreature(Pawn Other)
 void Destroyed()
 void Died(Pawn Killer, name damageType, vector HitLocation)
     
//=============================================================================
//
// Died
//
//=============================================================================
 void FootStep()
     
//=============================================================================
//
// FootStep Notify
// 
//=============================================================================
 bool InAttackRange(Actor Other)
     
//------------------------------------------------
//
// InAttackRange
//
// When within attack range, state changes from
// charging to fighting
//------------------------------------------------
 bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)
 Texture PainSkin(int BodyPart)
 void PlayDeath(name DamageType)
 void PlayFrontHit(optional float)
 void PlayInAir(optional float)
 void PlayMoving(optional float)
 void PlayRipping()
 void PlayTurning(optional float)
 void PlayWaiting(optional float)
     
//============================================================
// Animation functions
//============================================================
 void PostBeginPlay()
     
// FUNCTIONS ------------------------------------------------------------------
 void PreSetMovement()
 bool SetEnemy(Actor NewEnemy)
 void SetMovementPhysics()
 void TweenToFalling()
 void TweenToMoving(float tweentime)
 void TweenToWaiting(float tweentime)
 void ZoneChange(ZoneInfo newZone)


State Ripping Function Summary
 void SoundNotify2()


State Fighting Function Summary
 void LungeAttack()
 void SoundNotify1()
 void Bump(Actor Other)
 void AmbientSoundTimer()
 void EndState()


State StakeOut Function Summary



Source Code


00001	//=============================================================================
00002	// Dangler.
00003	//=============================================================================
00004	class Dangler expands ScriptPawn;
00005	
00006	/* Description: Tough, possibly unbeatable large fish that dangles a phosphous light emiting
00007		dealie in order to see in his domain which is deep dark water areas. Moves better horizontally
00008		than vertically.  Avoidance should be used against them as weapons are of no use against him.
00009	
00010	   TODO:
00011	*/
00012	
00013	
00014	// EDITABLE INSTANCE VARIABLES ------------------------------------------------
00015	
00016	var() byte			BiteDamage;
00017	var() byte			RipDamage;
00018	var(Sounds) sound	BiteMissSound;
00019	var(Sounds) sound	BiteEatSound;
00020	var(Sounds) sound	RipSound;
00021	var(Sounds) sound	SwimSound;
00022	
00023	// INSTANCE VARIABLES ---------------------------------------------------------
00024	
00025	var float		AirTime;
00026	var bool		bAttackBump;
00027	
00028	var string 		debugstring;
00029	
00030	// FUNCTIONS ------------------------------------------------------------------
00031	
00032	function PostBeginPlay()
00033	{
00034		local int j;
00035		local actor a;
00036	
00037		Super.PostBeginPlay();
00038		
00039		// Spawn his dealie light
00040		a = spawn(class'DanglerLight', self,, Location);
00041		if (a != None)
00042			AttachActorToJoint(a, JointNamed('danglerb'));
00043	}
00044	
00045	function Destroyed()
00046	{
00047		local actor a;
00048		
00049		// Remove his dealie light
00050		a = DetachActorFromJoint(JointNamed('danglerb'));
00051		if (a!=None)
00052			a.Destroy();
00053		Super.Destroyed();
00054	}
00055	
00056	function bool JointDamaged(int Damage, Pawn EventInstigator, vector HitLoc, vector Momentum, name DamageType, int joint)
00057	{
00058		return false;
00059	}
00060	
00061	function PreSetMovement()
00062	{
00063		bCanJump = false;
00064		bCanWalk = false;
00065		bCanSwim = true;
00066		bCanFly = false;
00067		MinHitWall = -0.6;
00068		bCanOpenDoors = false;
00069		bCanDoSpecial = false;
00070	}
00071	
00072	function Texture PainSkin(int BodyPart)
00073	{
00074	}
00075	
00076	
00077	//------------------------------------------------
00078	//
00079	// InAttackRange
00080	//
00081	// When within attack range, state changes from
00082	// charging to fighting
00083	//------------------------------------------------
00084	function bool InAttackRange(Actor Other)
00085	{
00086		local float range;
00087		range = VSize(Location-Other.Location);
00088		return (range <= CollisionRadius + Other.CollisionRadius + LungeRange) &&
00089			(Abs(Other.Location.Z - Location.Z) < CollisionHeight) &&
00090			ActorInSector(Other, ANGLE_1*20);
00091	}
00092	
00093	
00094	function ZoneChange(ZoneInfo newZone)
00095	{
00096		if(newZone.bWaterZone)
00097		{
00098			AirTime = 0;
00099			setPhysics(PHYS_Swimming);
00100			PlayMoving();
00101		}
00102		else
00103		{
00104			SetPhysics(PHYS_Falling);
00105		}
00106	}
00107	
00108	function SetMovementPhysics()
00109	{
00110		if(Region.Zone.bWaterZone)
00111			SetPhysics(PHYS_Swimming);
00112		else
00113		{
00114			SetPhysics(PHYS_Falling);
00115			MoveTimer = -1.0;
00116		}
00117	}
00118	
00119	function eAttitude AttitudeToCreature(Pawn Other)
00120	{
00121		if ( Other.IsA('Dangler') )
00122			return ATTITUDE_Friendly;
00123		else
00124			return ATTITUDE_Ignore;
00125	}
00126	
00127	function bool SetEnemy( Actor NewEnemy )
00128	{
00129		local EAttitude attitude;
00130	
00131		if (bTaskLocked)
00132			return false;
00133		if (NewEnemy == IgnoreEnemy)
00134			return false;
00135		if (Pawn(NewEnemy)!=None && Pawn(NewEnemy).Health<=0)
00136			return false;
00137	
00138		// Attitude logic for choosing enemy
00139		if (Pawn(NewEnemy) != None)
00140			attitude = AttitudeTo(Pawn(NewEnemy));
00141		else
00142			attitude = ATTITUDE_IGNORE;	// ATTITUDE_CURIOUS
00143		if (attitude >= ATTITUDE_IGNORE)
00144			return false;
00145	
00146		if (Enemy==None || attitude < AttitudeTo(Enemy))
00147		{
00148			// Only set enemy if reachable
00149			if (!actorReachable(NewEnemy) && !FindBestPathToward(NewEnemy) )
00150				return false;
00151	
00152			Enemy = Pawn(NewEnemy);
00153			EnemyAcquired();
00154		}
00155		return true;
00156	
00157	}
00158	
00159	
00160	//=============================================================================
00161	//
00162	// Died
00163	//
00164	//=============================================================================
00165	
00166	function Died(pawn Killer, name damageType, vector HitLocation)
00167	{
00168		local actor A;
00169	
00170		// Destroy the light when the Dangler is killed
00171		A = DetachActorFromJoint(JointNamed('danglerb'));
00172		if(A != None)
00173			A.Destroy();
00174		A = DetachActorFromJoint(JointNamed('head'));
00175	
00176		Super.Died(Killer, damagetype, HitLocation);
00177	}
00178	
00179	//=============================================================================
00180	//
00181	// FootStep Notify
00182	// 
00183	//=============================================================================
00184	function FootStep()
00185	{
00186		local EMatterType matter;
00187		local vector end;
00188		local sound snd;
00189		local int i;
00190	
00191		if(bFootsteps && Region.Zone.bWaterZone)
00192		{
00193			PlaySound(SwimSound, SLOT_Interact,,,, 1.0 + FRand()*0.2-0.1);
00194		}
00195	}
00196	
00197	//============================================================
00198	// Animation functions
00199	//============================================================
00200	
00201	function PlayWaiting(optional float tween)
00202	{
00203		LoopAnim('idle', 0.5 + 0.3 * FRand());
00204	}
00205	
00206	function PlayMoving(optional float tween)
00207	{
00208		if (bHurrying)
00209			LoopAnim('Swimfast', -0.8/WaterSpeed,, 0.4);
00210		else
00211			LoopAnim('Swimfast', 0.5, 0.4);
00212	}
00213	
00214	function PlayTurning(optional float tween)
00215	{
00216		LoopAnim('Swimfast', -0.8/WaterSpeed,, 0.4);
00217	//	LoopAnim('Swimfast', 1.0, 0.1);
00218	}
00219	
00220	function PlayInAir(optional float tween)
00221	{
00222		LoopAnim('Bite', 2.0, 0.1);
00223	}
00224	function PlayFrontHit(optional float tween)
00225	{
00226		PlayAnim('Pain', 1.0, 0.1);
00227	}
00228	
00229	function PlayDeath(name DamageType)	          { PlayAnim  ('death', 1.0, 0.1);     }
00230	
00231	function TweenToWaiting(float tweentime)
00232	{
00233		TweenAnim('idle', tweentime);
00234	}
00235	
00236	function TweenToMoving(float tweentime)
00237	{
00238		TweenAnim('Swimfast', tweentime);
00239	}
00240	
00241	function TweenToFalling()
00242	{
00243		TweenAnim('Bite', 0.5);
00244	}
00245	
00246	function PlayRipping()		{	LoopAnim('thrash', 1.0, 0.1);	}	// Thrashing with creature in mouth
00247	
00248	
00249	
00250	// STATES ---------------------------------------------------------------------
00251	
00252	state StakeOut
00253	{	// Overridden to roam
00254		ignores SeePlayer, HearNoise, EnemyAcquired;
00255	
00256	Begin:
00257		Enemy = None;
00258		GotoState('Roaming');
00259	}
00260	
00261	
00262	state Fighting
00263	{
00264	ignores SeePlayer, HearNoise;
00265	
00266		function EndState()
00267		{
00268			bAttackBump = false;
00269			MaxDesiredSpeed = 1.0;
00270		}
00271	
00272		function AmbientSoundTimer()
00273		{
00274			PlayAmbientFightSound();
00275		}
00276	
00277		singular function Bump(actor Other)
00278		{
00279			if ( bAttackBump && Pawn(Other) != None)
00280			{
00281				if (Pawn(Other).ReducedDamageType == 'All' )
00282					return;
00283	
00284				Other.JointDamaged(Pawn(Other).Health*2, self, Other.Location, vect(0,0,0), 'gibbed', 0);
00285				PlaySound(BiteEatSound, SLOT_Interact,,,, 1.0 + FRand()*0.2-0.1);
00286				Velocity *= 0.5;
00287				Other.DrawType = DT_None;
00288	
00289	/*
00290				if (Other.IsA('PlayerPawn'))
00291				{			
00292					AttachActorToJoint(Other, JointNamed('head'));
00293					//Other.LoopAnim('inmouth', 1.0, 0.1);
00294	
00295					// Drop the camera
00296					RunePlayer(Other).bCameraLock = true;
00297				}
00298	*/
00299	
00300				GotoState('Ripping');
00301			}
00302		}
00303	
00304		function SoundNotify1()
00305		{
00306			PlaySound(BiteMissSound, SLOT_Interact,,,, 1.0 + FRand()*0.2-0.1);
00307			bAttackBump = false;	// missed
00308		}
00309	
00310		function LungeAttack()
00311		{
00312			local vector X,Y,Z;
00313			local vector ToEnemy;
00314	
00315			GetAxes(Rotation, X,Y,Z);
00316	
00317			// Lunge at enemy
00318			Acceleration = X*8000*WaterSpeed;
00319			Velocity += X*800*WaterSpeed;
00320		}
00321	
00322	Begin:
00323		// Keep moving forward
00324	
00325		// Turn to enemy
00326		DesiredRotation = rotator(Enemy.Location - Location);
00327	
00328		if (ActorInSector(Enemy, ANGLE_1*20) && (Abs(Enemy.Location.Z - Location.Z) < CollisionHeight))
00329		{
00330			PlayAnim('Bite', 1.0, 0.1);
00331			bAttackBump = true;
00332			MaxDesiredSpeed = 8.0;
00333	
00334			LungeAttack();
00335	
00336			FinishAnim();
00337			MaxDesiredSpeed = 1.0;
00338			bAttackBump = false;
00339		}
00340	/*	else
00341		{
00342			PlayAnim('SwimmingB', 1.0, 0.1);
00343			FinishAnim();
00344		}
00345	*/
00346	
00347		GotoState('Charging', 'ResumeFromFighting');
00348	
00349	}
00350	
00351	
00352	State Ripping
00353	{
00354	ignores SeePlayer, HearNoise, Bump;
00355	
00356		function SoundNotify2()
00357		{
00358			PlaySound(RipSound, SLOT_Interact,,,, 1.0 + FRand()*0.2-0.1);
00359		}
00360	
00361	Begin:
00362		PlayRipping();
00363		Sleep(1.0);
00364		GotoState('Roaming');
00365	}
00366	
00367	
00368	simulated function Debug(canvas Canvas, int mode)
00369	{
00370		Super.Debug(canvas, mode);
00371		
00372		Canvas.DrawText("Dangler:");
00373		Canvas.CurY -= 8;
00374		Canvas.DrawText(" RotationRate: "$RotationRate);
00375		Canvas.CurY -= 8;
00376		Canvas.DrawText(" Buoyancy: "$Buoyancy);
00377		Canvas.CurY -= 8;
00378		Canvas.DrawText(" bCanStrafe: "$bCanStrafe);
00379		Canvas.CurY -= 8;
00380		Canvas.DrawText(" MoveTimer: "$MoveTimer);
00381		Canvas.CurY -= 8;
00382		Canvas.DrawText(" MoveTarget: "$MoveTarget);
00383		Canvas.CurY -= 8;
00384		Canvas.DrawText(" Destination: "$Destination);
00385		Canvas.CurY -= 8;
00386		Canvas.DrawText(" debugstring: "$debugstring);
00387		Canvas.CurY -= 8;
00388	}
00389	
00390	defaultproperties
00391	{
00392	     BiteMissSound=Sound'CreaturesSnd.Dangler.danglerbite01'
00393	     BiteEatSound=Sound'CreaturesSnd.Dangler.danglereats01'
00394	     RipSound=Sound'CreaturesSnd.Dangler.danglerbite01'
00395	     bLungeAttack=True
00396	     FightOrFlight=1.000000
00397	     FightOrDefend=1.000000
00398	     HighOrLow=1.000000
00399	     LungeRange=200.000000
00400	     AcquireSound=Sound'CreaturesSnd.Dangler.danglerbite01'
00401	     bRoamHome=True
00402	     bGlider=True
00403	     bWaitLook=False
00404	     bBurnable=False
00405	     WanderDistance=0.000000
00406	     MeleeRange=200.000000
00407	     GroundSpeed=0.000000
00408	     WaterSpeed=300.000000
00409	     AccelRate=1000.000000
00410	     WalkingSpeed=200.000000
00411	     ClassID=3
00412	     HitSound1=Sound'CreaturesSnd.Dangler.danglerhit01'
00413	     HitSound2=Sound'CreaturesSnd.Dangler.danglerhit01'
00414	     HitSound3=Sound'CreaturesSnd.Dangler.danglerhit01'
00415	     Die=Sound'CreaturesSnd.Dangler.danglerdeath01'
00416	     Die2=Sound'CreaturesSnd.Dangler.danglerdeath01'
00417	     Die3=Sound'CreaturesSnd.Dangler.danglerdeath01'
00418	     bCanLook=True
00419	     MaxHeadAngle=(Yaw=6917)
00420	     bRotateTorso=False
00421	     SoundRadius=34
00422	     SoundVolume=119
00423	     SoundPitch=50
00424	     AmbientSound=Sound'CreaturesSnd.Dangler.danglerswim04L'
00425	     TransientSoundRadius=800.000000
00426	     CollisionRadius=80.000000
00427	     CollisionHeight=66.000000
00428	     bJointsTouch=True
00429	     Mass=400.000000
00430	     Buoyancy=400.000000
00431	     RotationRate=(Pitch=1000,Yaw=16000)
00432	     Skeletal=SkelModel'creatures.Dangler'
00433	}

End Source Code