SarkBall
Class SarkBallScriptPawn

source: c:\runehov\SarkBall\Classes\SarkBallScriptPawn.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Inventory
         |
         +--Engine.Weapon
            |
            +--RuneI.NonStow
               |
               +--SarkBall.SarkBall
                  |
                  +--SarkBall.SarkBallScriptPawn
Direct Known Subclasses:SarkBallDwarf, SarkBallGoblin

class SarkBallScriptPawn
extends SarkBall.SarkBall

//----------------------------------------------------------- // //-----------------------------------------------------------
Variables
 float Alertness
           -1 to 1 ->Used within specific states for varying reaction to stimuli
 float AmbientSoundTime
           Used to generate ambient sound events
 float AvgPhysicsTime
           Used to generate ambient sound events
 Actor Blood
 float DesiredSpeed
           set by Movement natives
 vector Destination
           set by Movement natives
 Pawn Enemy
           position where I last saw enemy (auto updated if EnemyNotVisible enabled)
 Actor FaceTarget
           set by strafefacing native
 vector Focus
           set by Movement natives
 vector LastSeeingPos
           position where I last saw enemy (auto updated if EnemyNotVisible enabled)
 vector LastSeenPos
           enemy position when I last saw enemy (auto updated if EnemyNotVisible() enabled)
 float LastSeenTime
           position where I last saw enemy (auto updated if EnemyNotVisible enabled)
 float MaxDesiredSpeed
           set by Movement natives
 float MinHitWall
           Minimum HitNormal dot Velocity.Normal to get a HitWall from the
 Actor MoveTarget
           set by movement natives
 float MoveTimer
           Used to generate ambient sound events
 float MovementSpeed
           RUNE: Current speed modifier 0..1 (Set by UpdateMovementSpeed())
 Vector NewAcceleration
 Vector NewDestination
 float PainTime
           used for getting PainTimer() messages (for Lava, no air, etc.)
 rotator R
 float SightCounter
           Used to keep track of when to check player visibility
 float SpeechTime
           used for getting PainTimer() messages (for Lava, no air, etc.)
 float Stimulus
           Strength of stimulus - Set when stimulus happens, used in Acquisition state
 byte Visibility
           How visible is the pawn? 0 = invisible.
 bool bAdvancedTactics
           used during movement between pathnodes
 bool bAutoActivate
           if bAvoidLedges and bStopAtLedges, Pawn doesn't try to walk along the edge at all
 bool bAvoidLedges
           don't get too close to ledges
 bool bBehindView
           Outside-the-player view.
 bool bCanDoSpecial
           used by movement natives
 bool bCanFly
           used by movement natives
 bool bCanJump
           used by movement natives
 bool bCanOpenDoors
           used by movement natives
 bool bCanSwim
           used by movement natives
 bool bCanWalk
           used by movement natives
 bool bCountJumps
           for games which care about whether a pawn is a human
 bool bDrowning
           used by movement natives
 bool bFromWall
           used for alternating LineOfSight traces
 bool bHitSlopedWall
           used by Physics
 bool bHunting
           tells navigation code that pawn is hunting another pawn,
 bool bHurrying
           RUNE: Whether running or walking
 bool bIsFemale
           for games which care about whether a pawn is a human
 bool bIsHuman
           for games which care about whether a pawn is a human
 bool bIsMultiSkinned
           for games which care about whether a pawn is a human
 bool bIsPlayer
           Pawn is a player or a player-bot.
 bool bIsWalking
           used by swimming
 bool bJumpOffPawn
           if bAvoidLedges and bStopAtLedges, Pawn doesn't try to walk along the edge at all
 Bool bJumping
 bool bJustLanded
           used by eyeheight adjustment
 bool bLOSflag
           used for alternating LineOfSight traces
 bool bNeverSwitchOnPickup
           if true, don't automatically switch to picked up weapon
 bool bReducedSpeed
           used by movement natives
 bool bShootSpecial
           if bAvoidLedges and bStopAtLedges, Pawn doesn't try to walk along the edge at all
 bool bStopAtLedges
           if bAvoidLedges and bStopAtLedges, Pawn doesn't try to walk along the edge at all
 bool bStopMoveIfCombatRange
           RUNE: a moveToward latent function will exit if the enemy is within CombatRange
 bool bUpAndOut
           used by swimming
 bool bUpdatingDisplay
           to avoid infinite recursion through inventory setdisplay
 bool bViewTarget
           used during movement between pathnodes
 bool bWarping
           Set when travelling through warpzone (so shouldn't telefrag)
 Int landcount

States
KnockedDown, Settling, Drop, Pickup, Loose, Carried, Throw, Awake

Function Summary
 bool CanSee(Actor Other)
     
// CanSee() similar to line of sight, but also takes into account Pawn's peripheral vision
 void ChooseMesh()
 void ClearPaths()
     
// clear all temporary path variables used in routing
 NavigationPoint CloserNavPointTo(Actor Other)
 void DoJump(int X, int Y)
 vector EAdjustJump()
 bool FindBestPathToward(Actor desired)
     
//------------------------------------------------
//
// FindBestPathToward
//
// Assumes the desired destination is not directly reachable, 
// it tries to set Destination to the location of the best
// waypoint, and returns true if successful
//------------------------------------------------
 Actor FindPathAwayFrom(Actor anActor, optional actor)
 Actor FindPathTo(vector aPoint, optional bool, optional bool)
 Actor FindPathToward(Actor anActor, optional bool, optional bool)
 NavigationPoint FindRandomDest(optional bool)
     
// returns a random pathnode which is reachable from the creature's location
 
simulated
HitWall(vector HitNormal, Actor HitWall)
 bool LineOfSightTo(Actor Other)
     
// LineOfSightTo() returns true if any of several points of Other is visible (origin, top, bottom)
 Pawn LocateClosestEnemy()
 void MoveTo(vector NewDestination, optional float)
 void MoveToward(Actor NewTarget, optional float)
 NavigationPoint NearestNavPoint()
 void PlayBackup(optional float)
 void PlayInAir(optional float)
     
// Played while jumping
 void PlayJumping(optional float)
     
// Played when not doing anything else
 void PlayMoving(optional float)
 void PlayStrafeLeft(optional float)
     
// Played while falling
 void PlayStrafeRight(optional float)
 void PlayTurning(optional float)
 void PlayWaiting(optional float)
     
// Required
 void Spawned()
 void StrafeFacing(vector NewDestination, Actor NewTarget)
 void StrafeTo(vector NewDestination, vector NewFocus)
 void TurnTo(vector NewFocus)
 void TurnToward(Actor NewTarget)
 bool actorReachable(Actor anActor)
 bool pointReachable(vector aPoint)
     
//Reachable returns what part of direct path from Actor to aPoint is traversable
//using the current locomotion method


State KnockedDown Function Summary


State Settling Function Summary
 void EndState()
 void BeginState()


State Drop Function Summary


State Pickup Function Summary


State Loose Function Summary
 void EndState()
 void BeginState()


State Carried Function Summary
 void EndState()
 void BeginState()


State Throw Function Summary


State Awake Function Summary
 void BeginState()



Source Code


00001	//-----------------------------------------------------------
00002	//
00003	//-----------------------------------------------------------
00004	class SarkBallScriptPawn expands SarkBall;
00005	
00006	var Actor Blood;
00007	var  rotator R;
00008	var Vector NewDestination;
00009	var Vector NewAcceleration;
00010	
00011	var Int landcount;
00012	
00013	Var Bool bJumping;
00014	
00015	// AI basics.
00016	var           float          MinHitWall;          // Minimum HitNormal dot Velocity.Normal to get a HitWall from the
00017	                                             // physics
00018	var()      byte            Visibility;      //How visible is the pawn? 0 = invisible. 
00019	                                             // 128 = normal.  255 = highly visible.
00020	var          float          Alertness; // -1 to 1 ->Used within specific states for varying reaction to stimuli 
00021	var          float           Stimulus; // Strength of stimulus - Set when stimulus happens, used in Acquisition state 
00022	var(AI) float          SightRadius;     //Maximum seeing distance.
00023	var(AI) float          PeripheralVision;     //Cosine of limits of peripheral vision. (-1..1)
00024	var(AI) float          HearingThreshold;  //Minimum noise loudness for hearing
00025	var          vector          LastSeenPos;           // enemy position when I last saw enemy (auto updated if EnemyNotVisible() enabled)
00026	var          vector          LastSeeingPos;          // position where I last saw enemy (auto updated if EnemyNotVisible enabled)
00027	var          float          LastSeenTime;
00028	var           Pawn         Enemy;
00029	
00030	// Ticked pawn timers
00031	var          float          SightCounter;     //Used to keep track of when to check player visibility
00032	var          float       PainTime;          //used for getting PainTimer() messages (for Lava, no air, etc.)
00033	var          float          SpeechTime;     
00034	var          float          AmbientSoundTime;     // Used to generate ambient sound events
00035	
00036	// Physics updating time monitoring (for AI monitoring reaching destinations)
00037	var const     float          AvgPhysicsTime;
00038	
00039	// Navigation AI
00040	var      float          MoveTimer;
00041	var      Actor          MoveTarget;          // set by movement natives
00042	var          Actor          FaceTarget;          // set by strafefacing native
00043	var          vector           Destination;     // set by Movement natives
00044	var           vector          Focus;               // set by Movement natives
00045	var          float          DesiredSpeed;
00046	var          float          MaxDesiredSpeed;
00047	var(Combat) float     MeleeRange; // Max range for melee attack (not including collision radii)
00048	
00049	var(Combat) float     CombatRange; // RUNE:  Range the creature tries to stay within during his fighting state
00050	                                         // CombatRange is usually further than meleerange (which is the range in which he actually can attack)
00051	var bool bStopMoveIfCombatRange; // RUNE:  a moveToward latent function will exit if the enemy is within CombatRange
00052	
00053	
00054	var(AI) enum EIntelligence //important - order in increasing intelligence
00055	{
00056	     BRAINS_NONE, //only reacts to immediate stimulus
00057	     BRAINS_REPTILE, //follows to last seen position
00058	     BRAINS_MAMMAL, //simple navigation (limited path length)
00059	     BRAINS_HUMAN   //complex navigation, team coordination, use environment stuff (triggers, etc.)
00060	}     Intelligence;
00061	
00062	var(AI) enum EAttitude  //important - order in decreasing importance
00063	{
00064	     ATTITUDE_Fear,          //will try to run away
00065	     ATTITUDE_Hate,          // will attack enemy
00066	     ATTITUDE_Frenzy,     //will attack anything, indiscriminately
00067	     ATTITUDE_Threaten,     // animations, but no attack
00068	     ATTITUDE_Ignore,
00069	     ATTITUDE_Friendly,
00070	     ATTITUDE_Follow      //accepts player as leader
00071	} AttitudeToPlayer;     //determines how creature will react on seeing player (if in human form)
00072	
00073	
00074	
00075	// Player and enemy movement.
00076	var(Movement) float          GroundSpeed;     // The maximum ground speed.
00077	var(Movement) float          WaterSpeed;          // The maximum swimming speed.
00078	var(Movement) float          AirSpeed;          // The maximum flying speed.
00079	var(Movement) float          AccelRate;          // max acceleration rate
00080	var(Movement) float          JumpZ;           // vertical acceleration w/ jump
00081	var(Movement) float          MaxStepHeight;     // Maximum size of upward/downward step.
00082	var(Movement) float          AirControl;          // amount of AirControl available to the pawn
00083	var(Movement) float          WalkingSpeed;     // RUNE:  Speed creature walks
00084	var float                    MovementSpeed;     // RUNE:  Current speed modifier 0..1 (Set by UpdateMovementSpeed())
00085	var bool                    bHurrying;          // RUNE:  Whether running or walking
00086	
00087	
00088	// General flags.
00089	var bool          bBehindView;    // Outside-the-player view.
00090	var bool        bIsPlayer;      // Pawn is a player or a player-bot.
00091	var bool          bJustLanded;     // used by eyeheight adjustment
00092	var bool          bUpAndOut;          // used by swimming
00093	var bool          bIsWalking;
00094	var const bool     bHitSlopedWall;     // used by Physics
00095	var globalconfig bool     bNeverSwitchOnPickup;     // if true, don't automatically switch to picked up weapon
00096	var bool          bWarping;          // Set when travelling through warpzone (so shouldn't telefrag)
00097	var bool          bUpdatingDisplay; // to avoid infinite recursion through inventory setdisplay
00098	
00099	
00100	// AI flags
00101	var(Combat) bool     bCanStrafe;               //can move in different directions than current rotation
00102	var(Orders) bool     bFixedStart;
00103	var const bool          bReducedSpeed;          //used by movement natives
00104	var          bool          bCanJump;
00105	var          bool           bCanWalk;
00106	var          bool          bCanSwim;
00107	var          bool          bCanFly;
00108	var          bool          bCanOpenDoors;
00109	var          bool          bCanDoSpecial;
00110	var          bool          bDrowning;
00111	var const bool          bLOSflag;               // used for alternating LineOfSight traces
00112	var      bool           bFromWall;
00113	var          bool          bHunting;               // tells navigation code that pawn is hunting another pawn,
00114	                                                  //     so fall back to finding a path to a visible pathnode if none
00115	                                                  //     are reachable
00116	var          bool          bAvoidLedges;          // don't get too close to ledges
00117	var          bool          bStopAtLedges;          // if bAvoidLedges and bStopAtLedges, Pawn doesn't try to walk along the edge at all
00118	var          bool          bJumpOffPawn;
00119	var          bool          bShootSpecial;
00120	var          bool          bAutoActivate;
00121	var          bool          bIsHuman;               // for games which care about whether a pawn is a human
00122	var          bool          bIsFemale;
00123	var          bool          bIsMultiSkinned;
00124	var          bool          bCountJumps;
00125	var          bool          bAdvancedTactics;     // used during movement between pathnodes
00126	var          bool          bViewTarget;
00127	
00128	native(500) final latent function MoveTo( vector NewDestination, optional float speed);
00129	native(502) final latent function MoveToward(actor NewTarget, optional float speed);
00130	native(504) final latent function StrafeTo(vector NewDestination, vector NewFocus);
00131	native(506) final latent function StrafeFacing(vector NewDestination, actor NewTarget);
00132	native(508) final latent function TurnTo(vector NewFocus);
00133	native(510) final latent function TurnToward(actor NewTarget);
00134	
00135	// Dwarf
00136	//#exec SKELETAL IMPORT NAME=Dwarf FILE=..\meshes\creatures\Dwarf.scm PACKAGE=creatures
00137	//#exec SKELETAL ORIGIN NAME=SarkBallDwarf X=0 Y=0 Z=-4 Pitch=0 Yaw=-64 Roll=-64
00138	//#exec SKELETAL ORIGIN NAME=Dwarf X=0 Y=0 Z=0 Pitch=90 Yaw=90 Roll=90
00139	
00140	
00141	// Required
00142	function PlayWaiting(optional float tween)               {}     // Played when not doing anything else
00143	function PlayJumping(optional float tween)               {}     // Played while jumping
00144	function PlayInAir(optional float tween)               {}     // Played while falling
00145	function PlayStrafeLeft(optional float tween)          { PlayMoving(tween); }
00146	function PlayStrafeRight(optional float tween)          { PlayMoving(tween); }
00147	function PlayBackup(optional float tween)               { PlayMoving(tween); }
00148	
00149	
00150	function PlayTurning(optional float tween)               { PlayWaiting(tween);}
00151	
00152	
00153	//=============================================================================
00154	// AI functions
00155	//=============================================================================
00156	
00157	// LineOfSightTo() returns true if any of several points of Other is visible (origin, top, bottom)
00158	native(514) final function bool LineOfSightTo(actor Other); 
00159	
00160	// CanSee() similar to line of sight, but also takes into account Pawn's peripheral vision
00161	native(533) final function bool CanSee(actor Other); 
00162	native(518) final function Actor FindPathTo(vector aPoint, optional bool bSinglePath, 
00163	                                                            optional bool bClearPaths);
00164	native(517) final function Actor FindPathToward(actor anActor, optional bool bSinglePath, 
00165	                                                            optional bool bClearPaths);
00166	
00167	// returns a random pathnode which is reachable from the creature's location
00168	native(525) final function NavigationPoint FindRandomDest(optional bool bClearPaths);
00169	
00170	// clear all temporary path variables used in routing
00171	native(522) final function ClearPaths();
00172	
00173	native(523) final function vector EAdjustJump();
00174	
00175	//Reachable returns what part of direct path from Actor to aPoint is traversable
00176	//using the current locomotion method
00177	native(521) final function bool pointReachable(vector aPoint);
00178	native(520) final function bool actorReachable(actor anActor);
00179	
00180	native(664) final function NavigationPoint NearestNavPoint();
00181	native(665) final function NavigationPoint CloserNavPointTo(actor Other);
00182	
00183	
00184	simulated function HitWall(vector HitNormal, actor HitWall){
00185	  local float speed;
00186	  local int choosesound;
00187	  choosesound=RandRange(1,5);
00188	  //BroadcastMessage("HitWall",True);
00189	  speed = VSize(velocity);
00190	
00191	  if(speed > 100 && landcount < 2){
00192	    landcount++;
00193	  }
00194	     
00195	     if(((HitNormal.Z > 0.8) && (speed < 60)) || (speed < 20)){
00196	          SetPhysics(PHYS_None);
00197	          bBounce = false;
00198	          bFixedRotationDir = false;
00199	          bCollideWorld = false;
00200	          bLookFocusPlayer = false; // Player isn't interested in the head anymore
00201	          SetTimer(0, false);
00202	
00203	//          GotoState('WaitingToRemove');
00204	
00205	//Removed To Allow LimbWeapon to handle Blood on DropState.
00206	/*
00207	          if(bBloodyHead)
00208	          {
00209	               Blood = DetachActorFromJoint(JointNamed('base'));
00210	               if(Blood != None)
00211	               {
00212	                    Blood.Destroy();
00213	               }
00214	          }
00215	*/
00216	
00217	     }
00218	     else
00219	     {               
00220	          SetPhysics(PHYS_Falling);
00221	          RotationRate.Yaw = VSize(Velocity) * 100;
00222	          RotationRate.Pitch = VSize(Velocity) * 50;
00223	          
00224	          Velocity = 0.45 * (Velocity - 2 * HitNormal * (Velocity Dot HitNormal));
00225	          if(VSize(Velocity) < 20)
00226	          {
00227	               self.HitWall(HitNormal, HitWall); // Force the actor to stop
00228	          }
00229	          DesiredRotation = rotator(HitNormal);
00230	     }
00231	     
00232	     // Put a blood splot on the wall where the head struck it
00233	     // Trace a line to determine the location to put the blood decal
00234	     if(speed > 50){
00235	     // Only put blood splats on walls
00236	      //broadcastmessage("bloodsplats",True);
00237	          if(FRand() < 0.5)
00238	               Spawn(class'DecalBlood3',,,, rotator(HitNormal));
00239	          else
00240	               Spawn(class'DecalBlood4',,,, rotator(HitNormal));
00241	     }
00242	
00243	     Super.HitWall(HitNormal,HitWall);
00244	}
00245	
00246	
00247	Function DoJump(int X,int Y){
00248	  //BroadcastMessage("DoJump:"$X$","$Y,True);
00249	  PlayAnim  ('jump',3.0, 0.05);
00250	
00251	  //BroadcastMessage("Jump",True);
00252	  SetPhysics(PHYS_Falling);
00253	  Velocity.X=Velocity.X + X;
00254	  Velocity.Y=Velocity.Y + Y;
00255	  Velocity.Z=Velocity.Z + JumpZ;
00256	
00257	
00258	
00259	}
00260	
00261	final function Actor FindPathAwayFrom(actor anActor, optional actor justvisited){
00262	     local float distsquared, furthestdistsquared;
00263	     local NavigationPoint N;
00264	     local actor A, furthestpoint;
00265	     local vector topoint;
00266	     local int i, numpaths;
00267	
00268	     N = NearestNavPoint();
00269	     if (N == None)
00270	          return N;
00271	
00272	     numpaths = N.NumPaths();
00273	     for (i=0; i<numpaths; i++)
00274	     {
00275	          A = N.PathEndPoint(i);
00276	          if (A == justvisited)
00277	               continue;
00278	          topoint = A.Location - anActor.Location;
00279	          distsquared = topoint dot topoint;
00280	          if (distsquared > furthestdistsquared)
00281	          {
00282	               furthestdistsquared = distsquared;
00283	               furthestpoint = A;
00284	          }
00285	     }
00286	     return furthestpoint;
00287	}
00288	
00289	//------------------------------------------------
00290	//
00291	// FindBestPathToward
00292	//
00293	// Assumes the desired destination is not directly reachable, 
00294	// it tries to set Destination to the location of the best
00295	// waypoint, and returns true if successful
00296	//------------------------------------------------
00297	function bool FindBestPathToward(actor desired)
00298	{
00299	     local Actor path;
00300	     local bool success;
00301	     
00302	     path = None;
00303	     if (Intelligence <= BRAINS_Reptile)
00304	          path = FindPathToward(desired, true);
00305	     else 
00306	          path = FindPathToward(desired); 
00307	          
00308	     success = (path != None);
00309	     if (success)
00310	     {
00311	          MoveTarget = path; 
00312	          Destination = path.Location;
00313	     }
00314	//slog("findbestpathtoward"@desired.name@"="$success);
00315	     return success;
00316	}
00317	
00318	
00319	Function Pawn LocateClosestEnemy(){
00320	  local Pawn P, ClosestEnemy;
00321	
00322	  foreach RadiusActors(class'Pawn', P, 1000){
00323	    if (P==self)
00324	      continue;
00325	
00326	    If (P.ISA('Spectator'))
00327	      Continue;
00328	
00329	    ClosestEnemy=P;
00330	    //BroadcastMessage("Enemy:"$ClosestEnemy.Name,True);
00331	    Return ClosestEnemy;
00332	
00333	  }
00334	
00335	
00336	}
00337	
00338	Function Spawned(){
00339	  local int choosedwarf;
00340	  //BroadcastMessage("Spawned Torch",True);
00341	  Super.Spawned();
00342	  //PlayMoving();
00343	  //GotoState('KnockedDown','Begin');
00344	  //DesiredRotation.Pitch=0;
00345	  //OrthoRotation=vector(90.00,90.00,90.00);
00346	  R.Pitch=0.0;
00347	  R.Roll=0.0;
00348	  R.Yaw=0.0;
00349	  DesiredRotation=R;
00350	  ChooseMesh();
00351	
00352	}
00353	
00354	function ChooseMesh(){
00355	  switch (int(RandRange(1,5))){
00356	
00357	    case 1: SkelMesh=1;
00358	    //log("Choosing Mesh 1");
00359	    break;
00360	    case 2: SkelMesh=2;
00361	    //log("Choosing Mesh 2");
00362	    break;
00363	    case 3: SkelMesh=3;
00364	    //log("Choosing Mesh 3");
00365	    break;
00366	    case 4: SkelMesh=4;
00367	    //log("Choosing Mesh 4");
00368	    break;
00369	    case 5: SkelMesh=5;
00370	    //log("Choosing Mesh 5");
00371	    break;
00372	    //case 5: SkelMesh=6;
00373	    //log("Choosing Mesh 6");
00374	    //break;
00375	    //case 6: SkelMesh=7;
00376	    //log("Choosing Mesh 7");
00377	    //break;
00378	    //case 7: SkelMesh=8;
00379	    //log("Choosing Mesh 8");
00380	    //break;
00381	  }
00382	
00383	}
00384	
00385	function PlayMoving(optional float tween)
00386	{
00387	     LoopAnim('RunA', 4.0, 0.1);
00388	}
00389	
00390	state Awake{
00391	
00392	  Function BeginState(){
00393	    BroadcastMessage("Awake_BeginState",True);
00394	
00395	  }
00396	
00397	begin:
00398	     PlayMoving(0.1);
00399	
00400	}
00401	
00402	State Throw{
00403	
00404	  simulated function HitWall(vector HitNormal, actor HitWall){
00405	
00406	    //BroadcastMessage( "Throw_The SarkBall has Hit The Wall! "$HitWall.Name, true );
00407	
00408	    Super.HitWall(HitNormal,HitWall);
00409	    Global.HitWall(HitNormal,HitWall);
00410	    //Log("SarkBall_HitWall_End");
00411	
00412	    }
00413	
00414	Begin:
00415	  //BroadcastMessage("Throw_Begin",True);
00416	     //PlayAnim('deatha', 1.0, 0.5);     // Fall down
00417	     //PlaySound(Sound'SarkBallSnd.cartman.kickass');
00418	
00419	
00420	
00421	     PlayAnim  ('fallingA',3.0, 0.1);
00422	     FinishAnim();
00423	     PlayAnim  ('flip',3.0, 0.1);
00424	     FinishAnim();
00425	     PlayAnim  ('fallingB',3.0, 0.1);
00426	     FinishAnim();
00427	     PlayAnim  ('fallingC',3.0, 0.1);
00428	     FinishAnim();
00429	     //Sleep(0.1);     // Stun Time
00430	     //WaitForLanding();
00431	     Goto('Begin');
00432	
00433	
00434	}
00435	
00436	
00437	State Carried{
00438	  function BeginState(){
00439	    //BroadcastMessage( "Dwarf_Carried_BeginState", true );
00440	    Super.BeginState();
00441	  }
00442	     
00443	  function EndState(){
00444	     //BroadcastMessage( "Dwarf_Carried_EndState", true );
00445	     Super.BeginState();
00446	  }
00447	
00448	  Begin:
00449	    //BroadcastMessage("Carried_Begin",True);
00450	    PlayAnim('cower',4.0, 0.1);
00451	    FinishAnim();
00452	    PlayAnim('fallingA', 4.0, 0.1);     // Fall down
00453	    FinishAnim();
00454	    //DesiredColorAdjust.X = 255;
00455	    //DesiredColorAdjust.Y = 255;
00456	    //DesiredColorAdjust.Z = 0;
00457	    Goto('Begin');
00458	
00459	
00460	}
00461	
00462	State Loose{
00463	  function BeginState(){
00464	    BroadcastMessage( "Dwarf_Loose_BeginState", true );
00465	    Super.BeginState();
00466	  }
00467	     
00468	  function EndState(){
00469	     BroadcastMessage( "Dwarf_Loose_EndState", true );
00470	     Super.BeginState();
00471	  }
00472	
00473	
00474	Begin:
00475	  //BroadcastMessage("Flee!"$Velocity.X$",Rot,Pitch:"$Rotation.Pitch$",Yaw:"$Rotation.Yaw$",Roll:"$Rotation.Roll,True);
00476	  //PlayAnim  ('getup',2.0, 0.1);
00477	     //FinishAnim();
00478	     LoopAnim('runA', 1.0, 0.1);
00479	
00480	  SetPhysics(PHYS_Walking);
00481	  bIsWalking=True;
00482	  R.Pitch=0.0;
00483	     R.Roll=0.0;
00484	     R.Yaw=0.0;
00485	     DesiredRotation=R;
00486	
00487	   //Location.x=location.x + 100;
00488	   NewDestination.x=3;
00489	   NewDestination.Y=3;
00490	   NewDestination.Z=0;
00491	   Destination=NewDestination;
00492	   //MoveSmooth( NewDestination );
00493	   //If (Velocity.X<=250){
00494	   //Velocity.X=Velocity.X + 250;
00495	   //Velocity.Y=Velocity.Y + 250;
00496	   //}
00497	   //NewAcceleration.X=100.00;
00498	   //NewAcceleration.Y=100.00;
00499	   //NewAcceleration.Z=0.00;
00500	   //Acceleration=NewAcceleration;
00501	   //SetLocation(NewDestination);
00502	   //MoveTo(Destination,300);
00503	   Enemy=LocateClosestEnemy();
00504	   //FindBestPathToward(Enemy);
00505	   //DesiredRotation.Yaw = Rotator(Enemy.Location - Location).Yaw;
00506	   //PlayTurning();
00507	   //DesiredRotation=Rotator(Enemy.Location);
00508	   SetRotation( Rotator(Enemy.Location - Location));
00509	
00510	   If (FRand() < 0.30){
00511	    AddVelocity(vect(200,0,500));
00512	  }Else If (FRand() < 0.30){
00513	    AddVelocity(vect(0,200,500));
00514	  }Else If (FRand() < 0.30){
00515	    AddVelocity(vect(0,200,500));
00516	  }else{
00517	    AddVelocity(vect(200,200,500));
00518	  }
00519	
00520	
00521	   //FinishAnim();
00522	   //BroadcastMessage("TurnToward:"$Enemy.Name$",Loc:"$self.location,True);
00523	   DesiredSpeed=300.000;
00524	   bHurrying=True;
00525	   //MoveToward(Enemy);
00526	   Sleep(0.1);
00527	   Goto('Begin');
00528	
00529	}
00530	//-----------------------------------------------------------------------------
00531	//
00532	// State Pickup
00533	//
00534	// Melee Weapon is sitting on the ground waiting to be picked up
00535	//-----------------------------------------------------------------------------
00536	auto state Pickup{
00537	
00538	
00539	Begin:
00540	  //BroadcastMessage("Pickup_Begin",True);
00541	  //GotoState('Loose','Begin');
00542	  R.Pitch=0.0;
00543	     R.Roll=0.0;
00544	     R.Yaw=0.0;
00545	     DesiredRotation=R;
00546	     PlayAnim  ('getup',3.0, 0.1);
00547	     FinishAnim();
00548	
00549	     //MoveTo(Enemy.Location - VecToEnemy * MeleeRange, MovementSpeed);
00550	     //PlayAnim('getup', 2.0, 0.1);
00551	     //FinishAnim();
00552	
00553	     //Goto('Begin');
00554	     //GotoState('KnockedDown');
00555	     //Sleep(0.1);     // Stun Time
00556	     //PlayMoving();
00557	     R.Pitch=0.0;
00558	     R.Roll=0.0;
00559	     R.Yaw=0.0;
00560	     DesiredRotation=R;
00561	
00562	     SetPhysics(PHYS_Walking);
00563	
00564	Flee:
00565	  //BroadcastMessage("Flee!"$Velocity.X$",Rot,Pitch:"$Rotation.Pitch$",Yaw:"$Rotation.Yaw$",Roll:"$Rotation.Roll,True);
00566	  If (Frand()<0.50){
00567	      PlayAnim('Cower', 2.0, 0.3);
00568	     }else{
00569	      PlayAnim('fallingA', 2.0, 0.3);
00570	     }
00571	     FinishAnim();
00572	  bIsWalking=True;
00573	  //R.Pitch=0.0;
00574	     //R.Roll=0.0;
00575	     //R.Yaw=0.0;
00576	     //SetRotation(R);
00577	   //Location.x=location.x + 100;
00578	   //NewDestination.x=self.location.x+5;
00579	   //NewDestination.Y=self.location.y+5;
00580	   //NewDestination.Z=self.location.z;
00581	   //Destination=NewDestination;
00582	
00583	   //If (Velocity.X<=250){
00584	   //Velocity.X=Velocity.X + 250;
00585	   //Velocity.Y=Velocity.Y + 250;
00586	   //}
00587	   //NewAcceleration.X=100.00;
00588	   //NewAcceleration.Y=100.00;
00589	   //NewAcceleration.Z=0.00;
00590	   //Acceleration=NewAcceleration;
00591	   //SetLocation(NewDestination);
00592	   //MoveTo(Destination,300);
00593	   Enemy=LocateClosestEnemy();
00594	   //FindBestPathToward(Enemy);
00595	   //DesiredRotation.Yaw = Rotator(Enemy.Location - Location).Yaw;
00596	   //PlayTurning();
00597	
00598	   //FinishAnim();
00599	   //BroadcastMessage("TurnToward:"$Enemy.Name,True);
00600	   DesiredSpeed=300.000;
00601	   bHurrying=True;
00602	   //MoveToward(Enemy);
00603	
00604	   SetRotation( Rotator(Enemy.Location - Location));
00605	
00606	   If (VSize(Enemy.Location-Location)<=500){
00607	
00608	   If (FRand() < 0.20){
00609	    DoJump(500,0);
00610	    Sleep(0.1);
00611	    Goto('Jumping');
00612	  }Else If (FRand() < 0.20){
00613	    DoJump(0,500);
00614	    Sleep(0.1);
00615	    Goto('Jumping');
00616	  }Else If (FRand() < 0.20){
00617	    DoJump(500,500);
00618	    Sleep(0.1);
00619	    Goto('Jumping');
00620	  }Else If (FRand() < 0.20){
00621	    DoJump(-500,0);
00622	    Sleep(0.1);
00623	    Goto('Jumping');
00624	  }Else If (FRand() < 0.20){
00625	    DoJump(0,-500);
00626	    Sleep(0.1);
00627	    Goto('Jumping');
00628	  }else{
00629	    DoJump(-500,-500);
00630	    Sleep(0.1);
00631	    Goto('Jumping');
00632	  }
00633	
00634	  }
00635	
00636	   //Sleep(0.1);
00637	   Goto('Flee');
00638	
00639	Jumping:
00640	  //BroadcastMessage("Jumping",True);
00641	  PlayAnim  ('flip',3.0, 0.1);
00642	     FinishAnim();
00643	     PlayAnim  ('fallingA',3.0, 0.1);
00644	     FinishAnim();
00645	
00646	     PlayAnim  ('fallingB',3.0, 0.1);
00647	     //FinishAnim();
00648	     //PlayAnim  ('fallingC',3.0, 0.1);
00649	     FinishAnim();
00650	     If(Velocity.X==0 && Velocity.Y==0){
00651	      GotoState('Pickup','Begin');
00652	     }else{
00653	      Goto('Jumping');
00654	     }
00655	}
00656	
00657	State Drop{
00658	
00659	  simulated function HitWall(vector HitNormal, actor HitWall){
00660	
00661	    //BroadcastMessage( "Drop_The SarkBall has Hit The Wall! "$HitWall.Name, true );
00662	
00663	    Super.HitWall(HitNormal,HitWall);
00664	    Global.HitWall(HitNormal,HitWall);
00665	    //Log("SarkBall_HitWall_End");
00666	
00667	  }
00668	
00669	Begin:
00670	  //BroadcastMessage("Drop_Begin",True);
00671	  PlayAnim  ('flip',3.0, 0.1);
00672	     FinishAnim();
00673	     PlayAnim  ('fallingA',3.0, 0.1);
00674	     FinishAnim();
00675	
00676	     PlayAnim  ('fallingB',3.0, 0.1);
00677	     FinishAnim();
00678	     PlayAnim  ('fallingC',3.0, 0.1);
00679	     FinishAnim();
00680	     Goto('Begin');
00681	     //Sleep(0.1);     // Stun Time
00682	     //WaitForLanding();
00683	
00684	     //GotoState('KnockedDown');
00685	
00686	
00687	
00688	
00689	}
00690	
00691	//-----------------------------------------------------------------------------
00692	//
00693	// State
00694	//
00695	// Weapon has hit ground, settle into rest position/orientation
00696	//-----------------------------------------------------------------------------
00697	state Settling{
00698	
00699	  function BeginState(){
00700	    //BroadcastMessage("Settling_BeginState",True);
00701	    Super.BeginState();
00702	    Blood = Spawn(class'Blood');
00703	    if(Blood != None){
00704	      AttachActorToJoint(Blood, JointNamed('base'));
00705	    }
00706	
00707	
00708	  }
00709	
00710	  Function EndState(){
00711	    //BroadcastMessage("Settling_EndState",True);
00712	    Blood.Destroy();
00713	    Super.EndState();
00714	  }
00715	
00716	Begin:
00717	  //BroadcastMessage("Settling_Begin",True);
00718	     //PlayAnim('Cower', 3.0, 0.1);     // Fall down
00719	     PlayAnim  ('flip',3.0, 0.1);
00720	     FinishAnim();
00721	     FinishAnim();
00722	     PlayAnim('FallingA', 3.0, 0.1);     // Fall down
00723	     FinishAnim();
00724	     Sleep(0.1);     // Stun Time
00725	     //WaitForLanding();
00726	     Goto('Begin');
00727	
00728	}
00729	
00730	//================================================
00731	//
00732	// KnockedDown
00733	//
00734	//================================================
00735	State KnockedDown
00736	{
00737	
00738	Begin:
00739	  BroadcastMessage("KnockedDown_Begin",True);
00740	     PlayAnim('deatha', 1.0, 0.1);     // Fall down
00741	     FinishAnim();
00742	
00743	     Sleep(0.5);     // Stun Time
00744	     //WaitForLanding();
00745	
00746	GettingUp:
00747	     PlayAnim('getup', 1.0, 0.7);
00748	     FinishAnim();
00749	     GotoState('KnockedDown');
00750	}
00751	
00752	defaultproperties
00753	{
00754	    Visibility=128
00755	    SightRadius=2500.00
00756	    AvgPhysicsTime=0.10
00757	    MaxDesiredSpeed=300.00
00758	    Intelligence=BRAINS_REPTILE
00759	    AttitudeToPlayer=ATTITUDE_Hate
00760	    GroundSpeed=300.00
00761	    AccelRate=500.00
00762	    JumpZ=800.00
00763	    MaxStepHeight=25.00
00764	    WalkingSpeed=320.00
00765	    MovementSpeed=1.00
00766	    bCanWalk=True
00767	    bIsPawn=True
00768	    RemoteRole=ROLE_SimulatedProxy
00769	    bRotateToDesired=True
00770	    RotationRate=(Pitch=4096,Yaw=50000,Roll=3072)
00771	    DesiredRotation=(Pitch=0,Yaw=20292,Roll=0)
00772	    NetPriority=2.00
00773	    SkelMesh=1
00774	    Skeletal=SkelModel'creatures.Dwarf'
00775	}

End Source Code