XIII
Class XIIITransientAPawn

source: C:\XIII\XIII\Classes\XIIITransientAPawn.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Pawn
         |
         +--XIII.XIIIAmbientPawn
            |
            +--XIII.XIIITransientAPawn
Direct Known Subclasses:XIIIBird

class XIIITransientAPawn
extends XIII.XIIIAmbientPawn

//----------------------------------------------------------- // //-----------------------------------------------------------
Variables
 XIIITransientAPawn NextSlave
           list of slave pawns
 float SleepTime
           list of slave pawns
 bool bDestroySoon
 bool bFlyer
 bool bPermanent
 bool bSwimmer

States
Dying, Wandering

Function Summary
 void DestroyAll()
     
//_____________________________________________________________________________
 void Destroyed()
     
//_____________________________________________________________________________
 void EncroachedBy(Actor Other)
     
//_____________________________________________________________________________
 bool EncroachingOn(Actor Other)
     
//_____________________________________________________________________________
 float GetSleepTime()
     
//_____________________________________________________________________________
 void MakePermanent()
     
//_____________________________________________________________________________
 float MoveTimeTo(vector Destination)
     
//_____________________________________________________________________________
 void PhysicsVolumeChange(PhysicsVolume NewVolume)
     
//_____________________________________________________________________________
 void Timer()
     
//_____________________________________________________________________________
// add slaves
 void VerifyLastRenderTime()
     
//_____________________________________________________________________________


State Dying Function Summary
 void BeginState()
 void Landed(vector HitNormal)


State Wandering Function Summary



Source Code


00001	//-----------------------------------------------------------
00002	//
00003	//-----------------------------------------------------------
00004	class XIIITransientAPawn extends XIIIAmbientPawn
00005	     notplaceable
00006	     abstract;
00007	
00008	var bool bFlyer;
00009	var bool bSwimmer;
00010	var bool bDestroySoon;
00011	var bool bPermanent;
00012	var XIIITransientAPawn NextSlave; // list of slave pawns
00013	var float SleepTime;
00014	
00015	//_____________________________________________________________________________
00016	function MakePermanent()
00017	{
00018	    bPermanent = true;
00019	    bStasis = true;
00020	}
00021	
00022	//_____________________________________________________________________________
00023	function Destroyed()
00024	{
00025	    local XIIITransientAPawn T;
00026	
00027	    Super.Destroyed();
00028	    if ( Controller != None )
00029	    {
00030	      if ( Controller.Pawn == self )
00031	        XIIITransientACreature(Controller).SlavePawnDied(self);
00032	
00033	      // remove self from slave list
00034	      for ( T=XIIITransientAPawn(Controller.Pawn); T!=None; T=T.NextSlave )
00035	        if ( T.NextSlave == self )
00036	        {
00037	          T.NextSlave = NextSlave;
00038	          break;
00039	        }
00040	    }
00041	}
00042	
00043	//_____________________________________________________________________________
00044	// add slaves
00045	function Timer()
00046	{
00047	    local int SpawnNum, NumSlaves;
00048	    local XIIITransientAPawn Last;
00049	
00050	    NumSlaves = XIIITransientACreature(Controller).NumSlaves;
00051	    if ( (Controller.Pawn != Self) || (NumSlaves <= 0) )
00052	    {
00053	      SetTimer(0.0, false);
00054	      return;
00055	    }
00056	
00057	    if ( NumSlaves < 4 )
00058	      SpawnNum = Min(NumSlaves,2);
00059	    else
00060	      SpawnNum = NumSlaves/4;
00061	
00062	    Last = self;
00063	    While ( Last.NextSlave != None )
00064	      Last = Last.NextSlave;
00065	
00066	    XIIITransientACreature(Controller).AddSlaves(Last,SpawnNum);
00067	}
00068	
00069	//_____________________________________________________________________________
00070	function DestroyAll()
00071	{
00072	    Destroy();
00073	
00074	    if ( NextSlave != None )
00075	      NextSlave.DestroyAll();
00076	}
00077	
00078	//_____________________________________________________________________________
00079	function VerifyLastRenderTime()
00080	{
00081	    if ( bPermanent )
00082	    {
00083	      Controller.Pawn.LastRenderTime = Level.TimeSeconds;
00084	      return;
00085	    }
00086	    Controller.Pawn.LastRenderTime = Max(LastRenderTime,Controller.Pawn.LastRenderTime);
00087	    if ( NextSlave != None )
00088	      NextSlave.VerifyLastRenderTime();
00089	}
00090	
00091	//_____________________________________________________________________________
00092	event FellOutOfWorld()
00093	{
00094	    Destroy();
00095	}
00096	
00097	//_____________________________________________________________________________
00098	function bool EncroachingOn( actor Other )
00099	{
00100	    if ( (Other.Brush != None) || (Brush(Other) != None) )
00101	      return true;
00102	
00103	    return false;
00104	}
00105	
00106	//_____________________________________________________________________________
00107	function EncroachedBy( actor Other )
00108	{
00109	}
00110	
00111	//_____________________________________________________________________________
00112	singular function PhysicsVolumeChange( PhysicsVolume NewVolume )
00113	{
00114	    if ( (NewVolume.bWaterVolume && !bSwimmer) )
00115	    {
00116	      Velocity *= -1;
00117	      Acceleration *= -1;
00118	    }
00119	}
00120	
00121	//_____________________________________________________________________________
00122	function float MoveTimeTo(vector Destination)
00123	{
00124	    return 1;
00125	}
00126	
00127	//_____________________________________________________________________________
00128	function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation,
00129	                              Vector momentum, class<DamageType> damageType)
00130	{
00131	    Died(instigatedBy.Controller,damageType,hitLocation);
00132	}
00133	
00134	//_____________________________________________________________________________
00135	function Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
00136	{
00137	    if ( Controller.Pawn == self )
00138	      Controller.PawnDied();
00139	    PlayDying(DamageType, HitLocation);
00140	    GotoState('Dying');
00141	    if ( PhysicsVolume.bDestructive )
00142	    {
00143	      Destroy();
00144	      return;
00145	    }
00146	}
00147	
00148	//_____________________________________________________________________________
00149	function float GetSleepTime()
00150	{
00151	    return (SleepTime * FRand());
00152	}
00153	
00154	//_____________________________________________________________________________
00155	// Wandering state used only by Slave Pawns
00156	auto state Wandering
00157	{
00158	    ignores Trigger, Bump, HitWall, HeadVolumeChange, PhysicsVolumeChange, Falling, BreathTimer;
00159	
00160	begin:
00161	    if ( Controller == None )
00162	      Destroy();
00163	    else if ( Controller.Pawn != self )
00164	    {
00165	      if ( Controller.Pawn == None )
00166	      {
00167	        Controller.PawnDied();
00168	        Controller.GotoState('Wandering','KeepGoing');
00169	      }
00170	      else
00171	      {
00172	        // slaves pick destination to follow master pawn
00173	        XIIITransientACreature(Controller).PickSlaveDestination(self);
00174	        Sleep( GetSleepTime() );
00175	        Goto('Begin');
00176	      }
00177	    }
00178	}
00179	
00180	//_____________________________________________________________________________
00181	State Dying
00182	{
00183	    ignores Trigger, Bump, HitWall, HeadVolumeChange, PhysicsVolumeChange, Falling, BreathTimer;
00184	
00185	    function Landed(vector HitNormal)
00186	    {
00187	      SetPhysics(PHYS_None);
00188	      GotoState('Dying', 'Dead');
00189	      //fixme - destroy and leave splat mark if bug
00190	    }
00191	
00192	    function BeginState()
00193	    {
00194	      // don't call super
00195	    }
00196	
00197	Dead:
00198	    Sleep(5);
00199	    if ( Level.bDropDetail || (Level.TimeSeconds - LastRenderTime > 1) )
00200	      Destroy();
00201	    else
00202	      Goto('Dead');
00203	Begin:
00204	    AnimRate = 0;
00205	    SetPhysics(PHYS_Falling);
00206	}
00207	
00208	
00209	
00210	defaultproperties
00211	{
00212	     SleepTime=2.000000
00213	     bLOSHearing=False
00214	     bUnlit=True
00215	     bCollideActors=False
00216	     bBlockActors=False
00217	     bBlockPlayers=False
00218	     bProjTarget=False
00219	     RemoteRole=ROLE_None
00220	     CollisionRadius=0.000000
00221	     CollisionHeight=0.000000
00222	}

End Source Code