XIII
Class XIIIMover

source: C:\XIII\XIII\Classes\XIIIMover.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Mover
         |
         +--XIII.XIIIMover
Direct Known Subclasses:BreakableMover, LiftButton, LiftCage, LiftDoor, Telepherique, PorteDecors, UnBreakable, XIIIMovable, XIIIMoverVarTime, XIIIPorte

class XIIIMover
extends Engine.Mover

//----------------------------------------------------------- // //-----------------------------------------------------------
Variables
 AlertPathNodeKey1, AlertPathNodeKey2
           the possible points to target when seen
 PathNode PointArrivee
           Location to target when detected opened by a enemy pawn (he will get this by himself)
 bool bAlertIfSeenOpen
           Set true to warn enemies if seen opened
 bool bOpened
           do we warn soldier if we are opened
 bool bTraversable
 bool bTraversableBySmallWeapons
 bool bWarnSoldiers
           do we warn soldier if we are opened


Function Summary
 void DoClose()
     
//____________________________________________________________________
// Close the mover.
 void DoOpen()
     
/*
 bool EncroachingOn(Actor Other)
 void FinishedOpening()
     
//____________________________________________________________________
// Handle when the mover finishes opening.
 bool IsBreakableByPlayer()
     
//____________________________________________________________________
 void PlayerTrigger(Actor Other, Pawn EventInstigator)
     
//____________________________________________________________________
// Add PlayerTrigger
 void PlayerTrigger(Actor Other, Pawn EventInstigator)
     
//____________________________________________________________________
// Add PlayerTrigger
 void PostBeginPlay()
     
//____________________________________________________________________
 
simulated
Timer()
     
//____________________________________________________________________



Source Code


00001	//-----------------------------------------------------------
00002	//
00003	//-----------------------------------------------------------
00004	class XIIIMover extends Mover;
00005	
00006	var() bool bTraversable;
00007	var() bool bTraversableBySmallWeapons;
00008	var bool bWarnSoldiers;                               // do we warn soldier if we are opened
00009	var(Display) bool bNoInteractionIcon;
00010	var bool bOpened;
00011	var() bool bAlertIfSeenOpen;                          // Set true to warn enemies if seen opened
00012	
00013	enum eBloquagePorte
00014	{
00015	    Aucun,
00016	    SensPositif,
00017	    SensNegatif,
00018	    Les2Sens
00019	};
00020	var(Porte) eBloquagePorte BloqueePourLeJoueur;
00021	var() PathNode AlertPathNodeKey1, AlertPathNodeKey2;  // the possible points to target when seen
00022	
00023	var PathNode PointArrivee;                            // Location to target when detected opened by a enemy pawn (he will get this by himself)
00024	VAR(Message) localized string LockedMessage;
00025	VAR(BreakableMover) int Health; // Damage to take before exploding
00026	
00027	//____________________________________________________________________
00028	function PostBeginPlay()
00029	{
00030	    Super.PostBeginPlay();
00031	    if (DrawType==DT_Mesh)
00032	      LoopAnim(AnimSequence);
00033	    // In solo mode, timer is used for doors that can alert enemies if being seen opened
00034	//    if ( ( bAlertIfSeenOpen ) && (Level.NetMode == NM_Standalone) )
00035	    if ( (AlertPathNodeKey1 == none) || (AlertPathNodeKey2 == none) )
00036	    {
00037	      bAlertIfSeenOpen = false;
00038	      bWarnSoldiers = false;
00039	    }
00040	
00041	    if ( ( bAlertIfSeenOpen ) && (Level.bLonePlayer) )
00042	    {
00043	      bWarnSoldiers = true;
00044	      SetTimer(2.0,true);
00045	    }
00046	}
00047	
00048	//____________________________________________________________________
00049	function bool IsBreakableByPlayer()
00050	{
00051	    return false;
00052	}
00053	
00054	//____________________________________________________________________
00055	simulated function Timer()
00056	{
00057	    local XIIIPawn P;
00058	    local float DotP;
00059	
00060	    if ( !bOpened || !bWarnSoldiers )
00061	      return;
00062	
00063	    foreach CollidingActors( class'XIIIPawn', P,2000)
00064	    {
00065	      if ( !P.bIsDead && P.IsA('BaseSoldier')
00066	//        && !P.bWarnedByDoor
00067	        && (P.controller.IsInState('Patrouille') || P.controller.IsInState('Errance') || P.controller.IsInState('Tenir')) )
00068	      {
00069	        PointArrivee = none;
00070	        DotP = (P.Location - Location) dot (AlertPathNodeKey1.Location - AlertPathNodeKey2.Location);
00071	        if ( (DotP>0)
00072	        && vsize(p.location-self.Location)<p.sightradius
00073	        && FastTrace(AlertPathNodeKey1.Location, P.Location)
00074	        && (vector(P.Rotation) dot normal(AlertPathNodeKey1.location - P.Location) > P.PeripheralVision) )
00075	          PointArrivee = AlertPathNodeKey2;
00076	        else if (vsize(p.location-self.Location)<p.sightradius
00077	        && FastTrace(AlertPathNodeKey2.Location, P.Location)
00078	        && (vector(P.Rotation) dot normal(AlertPathNodeKey2.location - P.Location) > P.PeripheralVision) )
00079	          PointArrivee = AlertPathNodeKey1;
00080	        if ( PointArrivee != none )
00081	        {
00082	          P.Trigger(self, none);
00083	//          P.bWarnedByDoor = true;
00084	          bWarnSoldiers = false;
00085	        }
00086	      }
00087	    }
00088	}
00089	
00090	//____________________________________________________________________
00091	function PlayerTrigger( actor Other, pawn EventInstigator );
00092	
00093	//____________________________________________________________________
00094	// Handle when the mover finishes opening.
00095	function FinishedOpening()
00096	{
00097	    // Update sound effects.
00098	    PlaySound( OpenedSound );
00099	    if ( !bMusicOnlyOnce || !bAlreadyOpened )
00100	    {
00101	      bAlreadyOpened = true;
00102	      PlayMusic( OpenedMusic );
00103	    }
00104	    // Trigger any chained movers.
00105	    TriggerEvent(Event, Self, Instigator);
00106	
00107	    bOpened=true;
00108	    If ( MyMarker != None )
00109	      MyMarker.MoverOpened();
00110	    FinishNotify();
00111	}
00112	
00113	//____________________________________________________________________
00114	// Open the mover.
00115	/*function DoOpen()
00116	{
00117	    bOpening = true;
00118	    bDelaying = false;
00119	    InterpolateTo( 1, MoveTime );
00120	    PlaySound( OpeningSound );
00121	    if ( !bMusicOnlyOnce || !bAlreadyOpening )
00122	    {
00123	      bAlreadyOpening = true;
00124	      PlayMusic( OpeningMusic );
00125	    }
00126	    TriggerEvent(Event, self, Instigator);
00127	    PlaySound(MoveAmbientSound);
00128	}*/
00129	
00130	//____________________________________________________________________
00131	// Close the mover.
00132	function DoClose()
00133	{
00134	    bOpening = false;
00135	    bOpened = false;
00136	    bDelaying = false;
00137	    InterpolateTo( Max(0,KeyNum-1), MoveTime );
00138	    PlaySound( ClosingSound );
00139	    if ( !bMusicOnlyOnce || !bAlreadyClosing )
00140	    {
00141	      bAlreadyClosing = true;
00142	      PlayMusic( ClosingMusic );
00143	    }
00144	    UntriggerEvent(Event, self, Instigator);
00145	    PlaySound(MoveAmbientSound);
00146	}
00147	
00148	//____________________________________________________________________
00149	// Add PlayerTrigger
00150	state() PlayerTriggerToggle extends TriggerToggle
00151	{
00152	    ignores bump;
00153	
00154	    function PlayerTrigger( actor Other, pawn EventInstigator )
00155	    {
00156	      if (bOpened || bClosed)
00157	      {
00158	        SavedTrigger = Other;
00159	        Instigator = EventInstigator;
00160	        if ( SavedTrigger != None )
00161	          SavedTrigger.BeginEvent();
00162	        if( KeyNum==0 || KeyNum<PrevKeyNum )
00163	        {
00164	          if ( bAlertIfSeenOpen && EventInstigator.IsPlayerPawn())
00165	            bWarnSoldiers = true;
00166	          GotoState( 'PlayerTriggerToggle', 'Open' );
00167	        }
00168	        else
00169	        {
00170	          if ( bAlertIfSeenOpen && EventInstigator.IsPlayerPawn() )
00171	            bWarnSoldiers = true;
00172	          GotoState( 'PlayerTriggerToggle', 'Close' );
00173	        }
00174	      }
00175	    }
00176	Open:
00177	  bClosed = false;
00178	  if ( DelayTime > 0 )
00179	  {
00180	    bDelaying = true;
00181	    Sleep(DelayTime);
00182	  }
00183	  DoOpen();
00184	  FinishInterpolation();
00185	  FinishedOpening();
00186	  if ( SavedTrigger != None )
00187	    SavedTrigger.EndEvent();
00188	  if( bTriggerOnceOnly )
00189	  {
00190	    bInteractive = false;
00191	    GotoState('');
00192	  }
00193	  Stop;
00194	Close:
00195	  DoClose();
00196	  FinishInterpolation();
00197	  FinishedClosing();
00198	  if( bTriggerOnceOnly )
00199	  {
00200	    bInteractive = false;
00201	    GotoState('');
00202	  }
00203	}
00204	
00205	//____________________________________________________________________
00206	state() CyclingMover
00207	{
00208	    event KeyFrameReached()
00209	    {
00210	      local int NextKey;
00211	
00212	      if (KeyNum==NumKeys-1)
00213	        NextKey=0;
00214	      else
00215	        NextKey=KeyNum+1;
00216	      KeyRot[NextKey]-=KeyRot[KeyNum];
00217	      KeyRot[NextKey].Yaw=((KeyRot[NextKey].Yaw+32768)&65535)-32768;
00218	      KeyRot[NextKey].Roll=((KeyRot[NextKey].Roll+32768)&65535)-32768;
00219	      KeyRot[NextKey].Pitch=((KeyRot[NextKey].Pitch+32768)&65535)-32768;
00220	      KeyRot[NextKey]+=KeyRot[KeyNum];
00221	      InterpolateTo(NextKey,MoveTime);
00222	    }
00223	Begin:
00224	     DoOpen();
00225	     FinishInterpolation();
00226	Open:
00227	Close:
00228	     Stop;
00229	}
00230	
00231	state() TriggerToggleCyclingMover extends CyclingMover
00232	{
00233	    EVENT Trigger( actor Other, pawn EventInstigator )
00234	    {
00235			if (!bOpening)
00236			{
00237				/*Debug*/Log("Declenchement CyclingMover"@name);
00238				GotoState( ,'Go' );
00239			}
00240			else
00241			{
00242	//			/*Debug*/Log("Arret CyclingMover"@name);
00243				if ( bInterpolating )
00244				{
00245					bInterpolating = false;
00246					StopSound(MoveAmbientSound);
00247				}
00248			}
00249		}
00250		FUNCTION bool EncroachingOn( actor Other )
00251		{
00252			MakeGroupStop();
00253			if ( TimerRate==0 )
00254				SetTimer(2.0, false);
00255			return true;
00256		}
00257		EVENT Timer( )
00258		{
00259	//		if ( bOpening )
00260	//		{
00261			bInterpolating=true;
00262	//			SetTimer( 0.0, false );
00263	//			GotoState( ,'Go' );
00264	//		}
00265	//		else
00266	//		{
00267	//			if ( bInterpolating )
00268	//			{
00269	//				bInterpolating = false;
00270	//				StopSound(MoveAmbientSound);
00271	//			}
00272	//		}
00273		}
00274	Begin:
00275		Stop;
00276	Go:
00277		DoOpen();
00278		FinishInterpolation();
00279	Open:
00280	Close:
00281	     Stop;
00282	}
00283	
00284	state() TriggerControlCyclingMover extends CyclingMover
00285	{
00286	    EVENT Trigger( actor Other, pawn EventInstigator )
00287	    {
00288			if (!bOpening)
00289			{
00290	//			/*DebugLog("Declenchement CyclingMover"@name);*/
00291				GotoState( ,'Go' );
00292			}
00293			else
00294			{
00295	//			/*Debug*/Log("Arret CyclingMover"@name);
00296	//			if ( bInterpolating )
00297	//			{
00298				bInterpolating = true;
00299				PlaySound( OpeningSound );
00300	//			StopSound(MoveAmbientSound);
00301	//			}
00302			}
00303		}
00304	
00305	    EVENT Untrigger( actor Other, pawn EventInstigator )
00306	    {
00307			/*Debug*/Log("Arret CyclingMover"@name);
00308			if ( bInterpolating )
00309			{
00310				bInterpolating = false;
00311				StopSound(MoveAmbientSound);
00312			}
00313		}
00314	Begin:
00315		Stop;
00316	Go:
00317		DoOpen();
00318	     FinishInterpolation();
00319	Open:
00320	Close:
00321	     Stop;
00322	}
00323	
00324	
00325	
00326	
00327	defaultproperties
00328	{
00329	     LockedMessage="This door is locked."
00330	     bPathColliding=False
00331	}

End Source Code