## Engine
Class Mover

source: C:\XIII\Engine\Classes\Mover.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.Mover

Direct Known Subclasses:MissileFakeSSH1, XIIIMover

class Mover
extends Engine.Actor

    //=============================================================================
    // The moving brush class.
    // This is a built-in Unreal class and it shouldn't be modified.
    // Note that movers by default have bNoDelete==true.  This makes movers and their default properties
    // remain on the client side.  If a mover subclass has bNoDelete=false, then its default properties must
    // be replicated
    //=============================================================================

Variables
`byte` | `BrushRaytraceKey` Raytrace the brush here.
`name` | `BumpEvent` Optional event to cause when any valid bumper bumps the mover.
`int` | `ClientUpdate` mover is in closed position, and no longer moving
`float` | `DamageThreshold` minimum damage to trigger
`float` | `DelayTime` delay before starting to open
`enum` | `EBumpType`
`enum` | `EMoverEncroachType`
`enum` | `EMoverGlideType`
`int` | `EncroachDamage` How much to damage encroached actors.
`Mover` | `Follower` for having multiple movers return together
`byte` | `KeyNum` Current or destination keyframe.
`vector` | `KeyPos[8]` delay before starting to open
`rotator` | `KeyRot[8]` delay before starting to open
`Mover` | `Leader` for having multiple movers return together
`float` | `MoveTime` Time to spend moving between keyframes.
`byte` | `NumKeys` Number of keyframes in total (0-3).
`float` | `OtherTime` TriggerPound stay-open time.
`float` | `PhysAlpha` Interpolating position, 0.0-1.0.
`float` | `PhysRate` Interpolation rate per second.
`name` | `PlayerBumpEvent` Optional event to cause when the player bumps the mover.
`byte` | `PrevKeyNum` Previous keyframe.
`vector` | `RealPosition` mover is in closed position, and no longer moving
`rotator` | `RealRotation` mover is in closed position, and no longer moving
`name` | `ReturnGroup` if none, same as tag
`OldPrePivot,` | `SavedPos` delay before starting to open
`OldRot,` | `SavedRot` delay before starting to open
`Actor` | `SavedTrigger` Who we were triggered by.
`vector` | `SimInterpolate` mover is in closed position, and no longer moving
`vector` | `SimOldPos` mover is in closed position, and no longer moving
`SimOldRotYaw,` | `SimOldRotRoll` mover is in closed position, and no longer moving
`float` | `StayOpenTime` How long to remain open before closing.
`byte` | `WorldRaytraceKey` Raytrace the world with the brush here.
`bool` | `bAlreadyClosed` delay before starting to open
`bool` | `bAlreadyClosing` delay before starting to open
`bool` | `bAlreadyOpened` delay before starting to open
`bool` | `bAlreadyOpening` delay before starting to open
`bool` | `bBreakable` Apply dynamic lighting to mover.
`bDelaying,` | `bClientPause` Interpolation rate per second.
`bool` | `bClosed` mover is in closed position, and no longer moving
`bool` | `bDamageTriggered` Triggered by taking damage
`bool` | `bDynamicLightMover` Apply dynamic lighting to mover.
`bool` | `bPlayerOnly` mover is in closed position, and no longer moving
`bool` | `bSlave` This brush is a slave.
`bool` | `bTriggerOnceOnly` Go dormant after first trigger.
`bool` | `bUseTriggered` Triggered by player grab
`NavigationPoint` | `myMarker` Interpolation rate per second.
`int` | `numTriggerEvents` number of times triggered ( count down to untrigger )

States
OpenTimedMover

Function Summary
`simulated` | `BeginPlay()`
    // When mover enters gameplay.
`void` | `Bump(Actor Other)`
    // When bumped by player.
`void` | `DoClose()`
    // Close the mover.
`void` | `DoOpen()`
    // Open the mover.
`bool` | `EncroachingOn(Actor Other)`
    // Return true to abort, false to continue.
`void` | `FinishNotify()`
    // Notify AI that mover finished movement
`void` | `FinishedClosing()`
    // Handle when the mover finishes closing.
`void` | `FinishedOpening()`
    // Handle when the mover finishes opening.
`void` | `InterpolateTo(byte NewKeyNum, float Seconds)`
    // Interpolate to keyframe KeyNum in Seconds time.
`void` | `MakeGroupReturn()`
`void` | `MakeGroupStop()`
`void` | `PostBeginPlay()`
    // Immediately after mover enters gameplay.
`void` | `SetKeyframe(byte NewKeyNum, vector NewLocation, rotator NewRotation)`
    // Set the specified keyframe.
`simulated` | `StartInterpolation()`
    /* StartInterpolation()
    when this function is called, the actor will start moving along an interpolation path
    beginning at Dest
    */
`simulated` | `Timer()`

State OpenTimedMover Function Summary
`void` | `EndEvent()`
`void` | `BeginEvent()`
`void` | `Bump(Actor Other)`
    // Open when bumped, close when reset.
`void` | `BeginState()`
`void` | `UnTrigger(Actor Other, Pawn EventInstigator)`
`void` | `Trigger(Actor Other, Pawn EventInstigator)`
    // Start pounding when triggered.
`void` | `BeginState()`
`void` | `UnTrigger(Actor Other, Pawn EventInstigator)`
`void` | `Trigger(Actor Other, Pawn EventInstigator)`
    // Open when triggered, close when get untriggered.
`void` | `Trigger(Actor Other, Pawn EventInstigator)`
    // Toggle when triggered.
`void` | `EnableTrigger()`
`void` | `DisableTrigger()`
`void` | `Trigger(Actor Other, Pawn EventInstigator)`
    // When triggered, open, wait, then close.
`void` | `EnableTrigger()`
`void` | `DisableTrigger()`
`void` | `Bump(Actor Other)`
    // Open when bumped, wait, then close.
`void` | `EnableTrigger()`
`void` | `DisableTrigger()`
`void` | `Attach(Actor Other)`
    // Open when stood on, wait, then close.
`void` | `EnableTrigger()`
`void` | `DisableTrigger()`

Source Code

    00001	//=============================================================================
    00002	// The moving brush class.
    00003	// This is a built-in Unreal class and it shouldn't be modified.
    00004	// Note that movers by default have bNoDelete==true.  This makes movers and their default properties
    00005	// remain on the client side.  If a mover subclass has bNoDelete=false, then its default properties must
    00006	// be replicated
    00007	//=============================================================================
    00008	class Mover extends Actor
    00009	     native
    00010	     nativereplication
    00011	     placeable;
    00012
    00013	// How the mover should react when it encroaches an actor.
    00014	var() enum EMoverEncroachType
    00015	{
    00016	     ME_StopWhenEncroach,     // Stop when we hit an actor.
    00017	     ME_ReturnWhenEncroach,     // Return to previous position when we hit an actor.
    00018	        ME_CrushWhenEncroach,   // Crush the poor helpless actor.
    00019	        ME_IgnoreWhenEncroach,  // Ignore encroached actors.
    00020	} MoverEncroachType;
    00021
    00022	// How the mover moves from one position to another.
    00023	var() enum EMoverGlideType
    00024	{
    00025	     MV_MoveByTime,               // Move linearly.
    00026	     MV_GlideByTime,               // Move with smooth acceleration.
    00027	} MoverGlideType;
    00028
    00029	// What classes can bump trigger this mover
    00030	var() enum EBumpType
    00031	{
    00032	     BT_PlayerBump,          // Can only be bumped by player.
    00033	     BT_PawnBump,          // Can be bumped by any pawn
    00034	     BT_AnyBump,               // Can be bumped by any solid actor
    00035	} BumpType;
    00036
    00037	//-----------------------------------------------------------------------------
    00038	// Keyframe numbers.
    00039	var() byte       KeyNum;           // Current or destination keyframe.
    00040	var byte         PrevKeyNum;       // Previous keyframe.
    00041	var() const byte NumKeys;          // Number of keyframes in total (0-3).
    00042	var() const byte WorldRaytraceKey; // Raytrace the world with the brush here.
    00043	var() const byte BrushRaytraceKey; // Raytrace the brush here.
    00044
    00045	//-----------------------------------------------------------------------------
    00046	// Movement parameters.
    00047	var() float      MoveTime;         // Time to spend moving between keyframes.
    00048	var() float      StayOpenTime;     // How long to remain open before closing.
    00049	var() float      OtherTime;        // TriggerPound stay-open time.
    00050	var() int        EncroachDamage;   // How much to damage encroached actors.
    00051
    00052	//-----------------------------------------------------------------------------
    00053	// Mover state.
    00054	var() bool       bTriggerOnceOnly; // Go dormant after first trigger.
    00055	var() bool       bSlave;           // This brush is a slave.
    00056	var() bool           bUseTriggered;          // Triggered by player grab
    00057	var() bool           bDamageTriggered;     // Triggered by taking damage
    00058	var() bool       bDynamicLightMover; // Apply dynamic lighting to mover.
    00059	var   bool bBreakable;
    00060	var() name       PlayerBumpEvent;  // Optional event to cause when the player bumps the mover.
    00061	var() name       BumpEvent;               // Optional event to cause when any valid bumper bumps the mover.
    00062	var   actor      SavedTrigger;      // Who we were triggered by.
    00063	var() float           DamageThreshold;     // minimum damage to trigger
    00064	var       int           numTriggerEvents;     // number of times triggered ( count down to untrigger )
    00065	var       Mover           Leader;               // for having multiple movers return together
    00066	var       Mover           Follower;
    00067	var() name           ReturnGroup;          // if none, same as tag
    00068	var() float           DelayTime;               // delay before starting to open
    00069	//-----------------------------------------------------------------------------
    00070	// Audio.
    00071	var(MoverSounds) sound      OpeningSound;     // When start opening.
    00072	var(MoverSounds) sound          OpeningMusic;
    00073	var(MoverSounds) sound      OpenedSound;      // When finished opening.
    00074	var(MoverSounds) sound      OpenedMusic;
    00075	var(MoverSounds) sound      ClosingSound;       // When start closing.
    00076	var(MoverSounds) sound      ClosingMusic;
    00077	var(MoverSounds) sound      ClosedSound;      // When finish closing.
    00078	var(MoverSounds) sound      ClosedMusic;
    00079	var(MoverSounds) sound      MoveAmbientSound; // Optional ambient sound when moving.
    00080	var(MoverSounds) vector          SoundLocationOffset;     // Offset for CheckHearSound
    00081	var(MoverSounds) bool          bMusicOnlyOnce;       // to launch music only once...
    00082	var                     bool          bAlreadyOpening;
    00083	var                     bool          bAlreadyOpened;
    00084	var                     bool          bAlreadyClosing;
    00085	var                     bool          bAlreadyClosed;
    00086	//-----------------------------------------------------------------------------
    00087	// Internal.
    00088	var vector       KeyPos[8];
    00089	var rotator      KeyRot[8];
    00090	var vector       BasePos, OldPos, OldPrePivot, SavedPos;
    00091	var rotator      BaseRot, OldRot, SavedRot;
    00092	var           float       PhysAlpha;       // Interpolating position, 0.0-1.0.
    00093	var           float       PhysRate;        // Interpolation rate per second.
    00094
    00095	// AI related
    00096	var       NavigationPoint  myMarker;
    00097	var            bool               bOpening, bDelaying, bClientPause;
    00098	var            bool               bClosed;     // mover is in closed position, and no longer moving
    00099	var            bool               bPlayerOnly;
    00100
    00101	// for client side replication
    00102	var          vector               SimOldPos;
    00103	var          int                    SimOldRotPitch, SimOldRotYaw, SimOldRotRoll;
    00104	var          vector               SimInterpolate;
    00105	var          vector               RealPosition;
    00106	var     rotator               RealRotation;
    00107	var          int                    ClientUpdate;
    00108
    00109	replication
    00110	{
    00111	     // Things the server should send to the client.
    00112	     reliable if( Role==ROLE_Authority )
    00113	          SimOldPos, SimOldRotPitch, SimOldRotYaw, SimOldRotRoll, SimInterpolate, RealPosition, RealRotation;
    00114	}
    00115
    00116	/* StartInterpolation()
    00117	when this function is called, the actor will start moving along an interpolation path
    00118	beginning at Dest
    00119	*/
    00120	simulated function StartInterpolation()
    00121	{
    00122	     GotoState('');
    00123	     bInterpolating = true;
    00124	     SetPhysics(PHYS_None);
    00125	}
    00126
    00127	simulated function Timer()
    00128	{
    00129	     if ( Velocity != vect(0,0,0) )
    00130	     {
    00131	          bClientPause = false;
    00132	          return;
    00133	     }
    00134	     if ( Level.NetMode == NM_Client )
    00135	     {
    00136	          if ( ClientUpdate == 0 ) // not doing a move
    00137	          {
    00138	               if ( bClientPause )
    00139	               {
    00140	                    if ( VSize(RealPosition - Location) > 3 )
    00141	                         SetLocation(RealPosition);
    00142	                    else
    00143	                         RealPosition = Location;
    00144	                    SetRotation(RealRotation);
    00145	                    bClientPause = false;
    00146	               }
    00147	               else if ( RealPosition != Location )
    00148	                    bClientPause = true;
    00149	          }
    00150	          else
    00151	               bClientPause = false;
    00152	     }
    00153	     else
    00154	     {
    00155	          RealPosition = Location;
    00156	          RealRotation = Rotation;
    00157	     }
    00158	}
    00159
    00160	//-----------------------------------------------------------------------------
    00161	// Movement functions.
    00162
    00163	// Interpolate to keyframe KeyNum in Seconds time.
    00164	function InterpolateTo( byte NewKeyNum, float Seconds )
    00165	{
    00166	     NewKeyNum = Clamp( NewKeyNum, 0, ArrayCount(KeyPos)-1 );
    00167	     if( NewKeyNum==PrevKeyNum && KeyNum!=PrevKeyNum )
    00168	     {
    00169	          // Reverse the movement smoothly.
    00170	          PhysAlpha = 1.0 - PhysAlpha;
    00171	          OldPos    = BasePos + KeyPos[KeyNum];
    00172	          OldRot    = BaseRot + KeyRot[KeyNum];
    00173	     }
    00174	     else
    00175	     {
    00176	          // Start a new movement.
    00177	          OldPos    = Location;
    00178	          OldRot    = Rotation;
    00179	          PhysAlpha = 0.0;
    00180	     }
    00181
    00182	     // Setup physics.
    00183	     SetPhysics(PHYS_MovingBrush);
    00184	     bInterpolating   = true;
    00185	     PrevKeyNum       = KeyNum;
    00186	     KeyNum                = NewKeyNum;
    00187	     PhysRate         = 1.0 / FMax(Seconds, 0.005);
    00188
    00189	     ClientUpdate++;
    00190	     SimOldPos = OldPos;
    00191	     SimOldRotYaw = OldRot.Yaw;
    00192	     SimOldRotPitch = OldRot.Pitch;
    00193	     SimOldRotRoll = OldRot.Roll;
    00194	     SimInterpolate.X = 100 * PhysAlpha;
    00195	     SimInterpolate.Y = 100 * FMax(0.01, PhysRate);
    00196	     SimInterpolate.Z = 256 * PrevKeyNum + KeyNum;
    00197	}
    00198
    00199	// Set the specified keyframe.
    00200	final function SetKeyframe( byte NewKeyNum, vector NewLocation, rotator NewRotation )
    00201	{
    00202	     KeyNum         = Clamp( NewKeyNum, 0, ArrayCount(KeyPos)-1 );
    00203	     KeyPos[KeyNum] = NewLocation;
    00204	     KeyRot[KeyNum] = NewRotation;
    00205	}
    00206
    00207	// Interpolation ended.
    00208	event KeyFrameReached()
    00209	{
    00210	     local byte OldKeyNum;
    00211
    00212	     OldKeyNum  = PrevKeyNum;
    00213	     PrevKeyNum = KeyNum;
    00214	     PhysAlpha  = 0;
    00215	     ClientUpdate--;
    00216
    00217	     // If more than two keyframes, chain them.
    00218	     if( KeyNum>0 && KeyNum<OldKeyNum )
    00219	     {
    00220	          // Chain to previous.
    00221	          InterpolateTo(KeyNum-1,MoveTime);
    00222	     }
    00223	     else if( KeyNum<NumKeys-1 && KeyNum>OldKeyNum )
    00224	     {
    00225	          // Chain to next.
    00226	          InterpolateTo(KeyNum+1,MoveTime);
    00227	     }
    00228	     else
    00229	     {
    00230	          // Finished interpolating.
    00231	          StopSound(MoveAmbientSound);
    00232	          if ( (ClientUpdate == 0) && (Level.NetMode != NM_Client) )
    00233	          {
    00234	               RealPosition = Location;
    00235	               RealRotation = Rotation;
    00236	          }
    00237	     }
    00238	}
    00239
    00240	//-----------------------------------------------------------------------------
    00241
// Mover functions. 00242 00243 // Notify AI that mover finished movement 00244 function FinishNotify() 00245 { 00246 local Controller C; 00247 00248 for ( C=Level.ControllerList; C!=None; C=C.nextController ) 00249 if ( (C.Pawn != None) && (C.PendingMover == self) ) 00250 C.MoverFinished(); 00251 } 00252 00253 // Handle when the mover finishes closing. 00254 function FinishedClosing() 00255 { 00256 // Update sound effects. 00257 PlaySound( ClosedSound ); 00258 if ( !bMusicOnlyOnce || !bAlreadyClosed ) 00259 { 00260 bAlreadyClosed = true; 00261 PlayMusic( ClosedMusic ); 00262 } 00263 00264 // Notify our triggering actor that we have completed. 00265 if( SavedTrigger != None ) 00266 SavedTrigger.EndEvent(); 00267 SavedTrigger = None; 00268 Instigator = None; 00269 If ( MyMarker != None ) 00270 MyMarker.MoverClosed(); 00271 bClosed = true; 00272 FinishNotify(); 00273 } 00274 00275 // Handle when the mover finishes opening. 00276 function FinishedOpening() 00277 { 00278 // Update sound effects. 00279 PlaySound( OpenedSound ); 00280 if ( !bMusicOnlyOnce || !bAlreadyOpened ) 00281 { 00282 bAlreadyOpened = true; 00283 PlayMusic( OpenedMusic ); 00284 } 00285 00286 // Trigger any chained movers. 00287 TriggerEvent(Event, Self, Instigator); 00288 00289 If ( MyMarker != None ) 00290 MyMarker.MoverOpened(); 00291 FinishNotify(); 00292 } 00293 00294 // Open the mover. 00295 function DoOpen() 00296 { 00297 bOpening = true; 00298 bDelaying = false; 00299 InterpolateTo( 1, MoveTime ); 00300 PlaySound( OpeningSound ); 00301 if ( !bMusicOnlyOnce || !bAlreadyOpening ) 00302 { 00303 bAlreadyOpening = true; 00304 PlayMusic( OpeningMusic ); 00305 } 00306 PlaySound(MoveAmbientSound); 00307 } 00308 00309 // Close the mover. 00310 function DoClose() 00311 { 00312 bOpening = false; 00313 bDelaying = false; 00314 InterpolateTo( Max(0,KeyNum-1), MoveTime ); 00315 PlaySound( ClosingSound ); 00316 if ( !bMusicOnlyOnce || !bAlreadyClosing ) 00317 { 00318 bAlreadyClosing = true; 00319 PlayMusic( ClosingMusic ); 00320 } 00321 UntriggerEvent(Event, self, Instigator); 00322 PlaySound(MoveAmbientSound); 00323 } 00324 00325 //----------------------------------------------------------------------------- 00326 // Engine notifications. 00327 00328 // When mover enters gameplay. 00329 simulated function BeginPlay() 00330 { 00331 local rotator R; 00332 00333 // timer updates real position every second in network play 00334 if ( Level.NetMode != NM_Standalone ) 00335 { 00336 if ( Level.NetMode == NM_Client ) 00337 settimer(4.0, true); 00338 else 00339 settimer(1.0, true); 00340 if ( Role < ROLE_Authority ) 00341 return; 00342 } 00343 00344 if ( Level.NetMode != NM_Client ) 00345 { 00346 RealPosition = Location; 00347 RealRotation = Rotation; 00348 } 00349 00350 // Init key info. 00351 Super.BeginPlay(); 00352 KeyNum = Clamp( KeyNum, 0, ArrayCount(KeyPos)-1 ); 00353 PhysAlpha = 0.0; 00354 00355 // Set initial location. 00356 Move( BasePos + KeyPos[KeyNum] - Location ); 00357 00358 // Initial rotation. 00359 SetRotation( BaseRot + KeyRot[KeyNum] ); 00360 00361 // find movers in same group 00362 if ( ReturnGroup == '' ) 00363 ReturnGroup = tag; 00364 } 00365 00366 // Immediately after mover enters gameplay. 00367 function PostBeginPlay() 00368 { 00369 local mover M; 00370 00371 // Initialize all slaves. 00372 if( !bSlave ) 00373 { 00374 foreach DynamicActors( class 'Mover', M, Tag ) 00375 { 00376 if( M.bSlave ) 00377 { 00378 M.GotoState(''); 00379 M.SetBase( Self ); 00380 } 00381 } 00382 } 00383 if ( Leader == None ) 00384 { 00385 Leader = self; 00386 ForEach DynamicActors( class'Mover', M ) 00387 if ( (M != self) && (M.ReturnGroup == ReturnGroup) ) 00388 { 00389 M.Leader = self; 00390 M.Follower = Follower; 00391 Follower = M; 00392 } 00393 } 00394 } 00395 00396 function MakeGroupStop() 00397 { 00398 // Stop moving immediately. 00399 bInterpolating = false; 00400 StopSound(MoveAmbientSound); 00401 GotoState( , '' ); 00402 00403 if ( Follower != None ) 00404 Follower.MakeGroupStop(); 00405 } 00406 00407 function MakeGroupReturn() 00408 { 00409 // Abort move and reverse course. 00410 bInterpolating = false; 00411 StopSound(MoveAmbientSound); 00412 if( KeyNum<PrevKeyNum ) 00413 GotoState( , 'Open' ); 00414 else 00415 GotoState( , 'Close' ); 00416 00417 if ( Follower != None ) 00418 Follower.MakeGroupReturn(); 00419 } 00420 00421 // Return true to abort, false to continue. 00422 function bool EncroachingOn( actor Other ) 00423 { 00424 local Pawn P; 00425 if ( ((Pawn(Other) != None) && (Pawn(Other).Controller == None)) || Other.IsA('Decoration') ) 00426 { 00427 Other.TakeDamage(10000, None, Other.Location, vect(0,0,0), class'Crushed'); 00428 return false; 00429 } 00430 if ( Other.IsA('Pickup') ) 00431 { 00432 if ( !Other.bAlwaysRelevant && (Other.Owner == None) ) 00433 Other.Destroy(); 00434 return false; 00435 } 00436 if ( Other.IsA('Fragment') ) 00437 { 00438 Other.Destroy(); 00439 return false; 00440 } 00441 00442 // Damage the encroached actor. 00443 if( EncroachDamage != 0 ) 00444 Other.TakeDamage( EncroachDamage, Instigator, Other.Location, vect(0,0,0), class'Crushed' ); 00445 00446 // If we have a bump-player event, and Other is a pawn, do the bump thing. 00447 P = Pawn(Other); 00448 if( P!=None && (P.Controller != None) && P.IsPlayerPawn() ) 00449 { 00450 if ( PlayerBumpEvent!='' ) 00451 Bump( Other ); 00452 if ( (P.Base != self) && (P.Controller.PendingMover == self) ) 00453 P.Controller.UnderLift(self); // pawn is under lift - tell him to move 00454 } 00455 00456 // Stop, return, or whatever. 00457 if( MoverEncroachType == ME_StopWhenEncroach ) 00458 { 00459 Leader.MakeGroupStop(); 00460 return true; 00461 } 00462 else if( MoverEncroachType == ME_ReturnWhenEncroach ) 00463 { 00464 Leader.MakeGroupReturn(); 00465 return true; 00466 } 00467 else if( MoverEncroachType == ME_CrushWhenEncroach ) 00468 { 00469 // Kill it. 00470 Other.KilledBy( Instigator ); 00471 return false; 00472 } 00473 else if( MoverEncroachType == ME_IgnoreWhenEncroach ) 00474 { 00475 // Ignore it. 00476 return false; 00477 } 00478 } 00479 00480 // When bumped by player. 00481 function Bump( actor Other ) 00482 { 00483 local pawn P; 00484 00485 P = Pawn(Other); 00486 if ( bUseTriggered && (P != None) && !P.IsHumanControlled() && P.IsPlayerPawn() ) 00487 { 00488 Trigger(P,P); 00489 P.Controller.WaitForMover(self); 00490 } 00491 if ( (BumpType != BT_AnyBump) && (P == None) ) 00492 return; 00493 if ( (BumpType == BT_PlayerBump) && !P.IsPlayerPawn() ) 00494 return; 00495 if ( (BumpType == BT_PawnBump) && P.bAmbientCreature ) 00496 return; 00497 TriggerEvent(BumpEvent, self, P); 00498 00499 if ( (P != None) && P.IsPlayerPawn() ) 00500 TriggerEvent(PlayerBumpEvent, self, P); 00501 } 00502 00503 // When damaged 00504 function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation, 00505 Vector momentum, class<DamageType> damageType) 00506 { 00507 if ( bDamageTriggered && (Damage >= DamageThreshold) ) 00508 self.Trigger(self, instigatedBy); 00509 } 00510 00511 //======================================================================== 00512 // Master State for OpenTimed mover states (for movers that open and close) 00513 00514 state OpenTimedMover 00515 { 00516 function DisableTrigger(); 00517 function EnableTrigger(); 00518 00519 Open: 00520 bClosed = false; 00521 DisableTrigger(); 00522 if ( DelayTime > 0 ) 00523 { 00524 bDelaying = true; 00525 Sleep(DelayTime); 00526 } 00527 DoOpen(); 00528 FinishInterpolation(); 00529 FinishedOpening(); 00530 Sleep( StayOpenTime ); 00531 if( bTriggerOnceOnly ) 00532 GotoState(''); 00533 Close: 00534 DoClose(); 00535 FinishInterpolation(); 00536 FinishedClosing(); 00537 EnableTrigger(); 00538 } 00539 00540 // Open when stood on, wait, then close. 00541 state() StandOpenTimed extends OpenTimedMover 00542 { 00543 function Attach( actor Other ) 00544 { 00545 local pawn P; 00546 00547 P = Pawn(Other); 00548 if ( (BumpType != BT_AnyBump) && (P == None) ) 00549 return; 00550 if ( (BumpType == BT_PlayerBump) && !P.IsPlayerPawn() ) 00551 return; 00552 if ( (BumpType == BT_PawnBump) && (Other.Mass < 10) ) 00553 return; 00554 SavedTrigger = None; 00555 GotoState( 'StandOpenTimed', 'Open' ); 00556 } 00557 00558 function DisableTrigger() 00559 { 00560 Disable( 'Attach' ); 00561 } 00562 00563 function EnableTrigger() 00564 { 00565 Enable('Attach'); 00566 } 00567 } 00568 00569 // Open when bumped, wait, then close. 00570 state() BumpOpenTimed extends OpenTimedMover 00571 { 00572 function Bump( actor Other ) 00573 { 00574 if ( (BumpType != BT_AnyBump) && (Pawn(Other) == None) ) 00575 return; 00576 if ( (BumpType == BT_PlayerBump) && !Pawn(Other).IsPlayerPawn() ) 00577 return; 00578 if ( (BumpType == BT_PawnBump) && (Other.Mass < 10) ) 00579 return; 00580 Global.Bump( Other ); 00581 SavedTrigger = None; 00582 Instigator = Pawn(Other); 00583 Instigator.Controller.WaitForMover(self); 00584 GotoState( 'BumpOpenTimed', 'Open' ); 00585 } 00586 00587 function DisableTrigger() 00588 { 00589 Disable( 'Bump' ); 00590 } 00591 00592 function EnableTrigger() 00593 { 00594 Enable('Bump'); 00595 } 00596 } 00597 00598 // When triggered, open, wait, then close. 00599 state() TriggerOpenTimed extends OpenTimedMover 00600 { 00601 function Trigger( actor Other, pawn EventInstigator ) 00602 { 00603 SavedTrigger = Other; 00604 Instigator = EventInstigator; 00605 if ( SavedTrigger != None ) 00606 SavedTrigger.BeginEvent(); 00607 GotoState( 'TriggerOpenTimed', 'Open' ); 00608 } 00609 00610 function DisableTrigger() 00611 { 00612 Disable( 'Trigger' ); 00613 } 00614 00615 function EnableTrigger() 00616 { 00617 Enable('Trigger'); 00618 } 00619 } 00620 00621 //================================================================= 00622 // Other Mover States 00623 00624 // Toggle when triggered. 00625 state() TriggerToggle 00626 { 00627 function Trigger( actor Other, pawn EventInstigator ) 00628 { 00629 SavedTrigger = Other; 00630 Instigator = EventInstigator; 00631 if ( SavedTrigger != None ) 00632 SavedTrigger.BeginEvent(); 00633 if( KeyNum==0 || KeyNum<PrevKeyNum ) 00634 GotoState( 'TriggerToggle', 'Open' ); 00635 else 00636 GotoState( 'TriggerToggle', 'Close' ); 00637 } 00638 Open: 00639 bClosed = false; 00640 if ( DelayTime > 0 ) 00641 { 00642 bDelaying = true; 00643 Sleep(DelayTime); 00644 } 00645 DoOpen(); 00646 FinishInterpolation(); 00647 FinishedOpening(); 00648 if ( SavedTrigger != None ) 00649 SavedTrigger.EndEvent(); 00650 Stop; 00651 Close: 00652 DoClose(); 00653 FinishInterpolation(); 00654 FinishedClosing(); 00655 } 00656 00657 // Open when triggered, close when get untriggered. 00658 state() TriggerControl 00659 { 00660 function Trigger( actor Other, pawn EventInstigator ) 00661 { 00662 numTriggerEvents++; 00663 SavedTrigger = Other; 00664 Instigator = EventInstigator; 00665 if ( SavedTrigger != None ) 00666 SavedTrigger.BeginEvent(); 00667 GotoState( 'TriggerControl', 'Open' ); 00668 } 00669 function UnTrigger( actor Other, pawn EventInstigator ) 00670 { 00671 numTriggerEvents--; 00672 if ( numTriggerEvents <=0 ) 00673 { 00674 numTriggerEvents = 0; 00675 SavedTrigger = Other; 00676 Instigator = EventInstigator; 00677 SavedTrigger.BeginEvent(); 00678 GotoState( 'TriggerControl', 'Close' ); 00679 } 00680 } 00681 00682 function BeginState() 00683 { 00684 numTriggerEvents = 0; 00685 } 00686 00687 Open: 00688 bClosed = false; 00689 if ( DelayTime > 0 ) 00690 { 00691 bDelaying = true; 00692 Sleep(DelayTime); 00693 } 00694 DoOpen(); 00695 FinishInterpolation(); 00696 FinishedOpening(); 00697 SavedTrigger.EndEvent(); 00698 if( bTriggerOnceOnly ) 00699 GotoState(''); 00700 Stop; 00701 Close: 00702 DoClose(); 00703 FinishInterpolation(); 00704 FinishedClosing(); 00705 } 00706 00707 // Start pounding when triggered. 00708 state() TriggerPound 00709 { 00710 function Trigger( actor Other, pawn EventInstigator ) 00711 { 00712 numTriggerEvents++; 00713 SavedTrigger = Other; 00714 Instigator = EventInstigator; 00715 GotoState( 'TriggerPound', 'Open' ); 00716 } 00717 function UnTrigger( actor Other, pawn EventInstigator ) 00718 { 00719 numTriggerEvents--; 00720 if ( numTriggerEvents <= 0 ) 00721 { 00722 numTriggerEvents = 0; 00723 SavedTrigger = None; 00724 Instigator = None; 00725 GotoState( 'TriggerPound', 'Close' ); 00726 } 00727 } 00728 function BeginState() 00729 { 00730 numTriggerEvents = 0; 00731 } 00732 00733 Open: 00734 bClosed = false; 00735 if ( DelayTime > 0 ) 00736 { 00737 bDelaying = true; 00738 Sleep(DelayTime); 00739 } 00740 DoOpen(); 00741 FinishInterpolation(); 00742 Sleep(OtherTime); 00743 Close: 00744 DoClose(); 00745 FinishInterpolation(); 00746 Sleep(StayOpenTime); 00747 if( bTriggerOnceOnly ) 00748 GotoState(''); 00749 if( SavedTrigger != None ) 00750 goto 'Open'; 00751 } 00752 00753 //----------------------------------------------------------------------------- 00754 // Bump states. 00755 00756 00757 // Open when bumped, close when reset. 00758 state() BumpButton 00759 { 00760 function Bump( actor Other ) 00761 { 00762 if ( (BumpType != BT_AnyBump) && (Pawn(Other) == None) ) 00763 return; 00764 if ( (BumpType == BT_PlayerBump) && !Pawn(Other).IsPlayerPawn() ) 00765 return; 00766 if ( (BumpType == BT_PawnBump) && (Other.Mass < 10) ) 00767 return; 00768 Global.Bump( Other ); 00769 SavedTrigger = Other; 00770 Instigator = Pawn( Other ); 00771 Instigator.Controller.WaitForMover(self); 00772 GotoState( 'BumpButton', 'Open' ); 00773 } 00774 function BeginEvent() 00775 { 00776 bSlave=true; 00777 } 00778 function EndEvent() 00779 { 00780 bSlave = false; 00781 Instigator = None; 00782 GotoState( 'BumpButton', 'Close' ); 00783 } 00784 Open: 00785 bClosed = false; 00786 Disable( 'Bump' ); 00787 if ( DelayTime > 0 ) 00788 { 00789 bDelaying = true; 00790 Sleep(DelayTime); 00791 } 00792 DoOpen(); 00793 FinishInterpolation(); 00794 FinishedOpening(); 00795 if( bTriggerOnceOnly ) 00796 GotoState(''); 00797 if( bSlave ) 00798 Stop; 00799 Close: 00800 DoClose(); 00801 FinishInterpolation(); 00802 FinishedClosing(); 00803 Enable( 'Bump' ); 00804 } 00805 00806 defaultproperties 00807 { 00808 MoverEncroachType=ME_ReturnWhenEncroach 00809 MoverGlideType=MV_GlideByTime 00810 NumKeys=2 00811 MoveTime=1.000000 00812 StayOpenTime=4.000000 00813 bClosed=True 00814 bNoDelete=True 00815 bAlwaysRelevant=True 00816 bShadowCast=True 00817 bIgnoreDynLight=False 00818 bCollideActors=True 00819 bBlockActors=True 00820 bBlockPlayers=True 00821 Physics=PHYS_MovingBrush 00822 RemoteRole=ROLE_SimulatedProxy 00823 DrawType=DT_StaticMesh 00824 InitialState="BumpOpenTimed" 00825 PanCoeff=0.350000 00826 CollisionRadius=160.000000 00827 CollisionHeight=160.000000 00828 NetPriority=2.700000 00829 bEdShouldSnap=True 00830 bPathColliding=True 00831 }

End Source Code