SpatialFear.SFMover

00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
//=============================================================================
// Spatial Fear
// Class: SFMover
// Descripton: Subclasses of Mover, adds SF specific behaviour, like triggered
//             by UseKey.
//             When using the mover with the default setting: IgnoreBumping=True,
//             the mover ignores the Bump event for the states:
//			   BumpOpenTimed and  BumpButton.
//			   Instead the bump action is fired, when within a range of a UseKey
//			   action.
//			   When using the mover with the default setting: IgnoreTrigger=True,
//			   the mover ignores any Trigger events for the state:
//			   TriggerToggle.
//			   Instead the trigger action is executed, when within a range of a
//			   UseKey action.
//
// Author: Markus Nuebel
//=============================================================================

class SFMover extends Mover;

var (SpatialFear) bool IgnoreBumping; //Ignore bump and instead fire when within a range of a UseKey trace. Defaults to true.
var (SpatialFear) bool IgnoreTrigger; //Ignore Normal trigger event and instead fire when within a range of a UseKey trace. Defaults to true.
var (SpatialFear) vector CenterOffset; // Offset from brush origin to brush center, used for rotation brushes to work right with UseKey.
var (SpatialFear) bool bShowHUDHint; // This flags determines, if a HUD hint (Icon) is displayed, when the player get close to the trigger. Defaults to true.
var bool	m_bFreeze; // Private: Keeps track of multiple trigger events.
var float	m_fCurrentDamageThreshold;	// Private: Keeps track of current damage threshold


//-----------------------------------------------------------------------------
// Engine notifications.

// Some custom initialization
function PostBeginPlay()
{
	// Call to base class
	Super.PostBeginPlay();
}

// Just initializes the current threshold with the configured one.
function resetThreshold()
{
	m_fCurrentDamageThreshold = DamageThreshold;
}

// Base class override, to keep track of taken damage
// and fire event, when the taken damage exeeds a treshold after
// multiple damage events
function TakeDamage( int Damage, Pawn instigatedBy, Vector hitlocation,
						Vector momentum, name damageType)
{
	m_fCurrentDamageThreshold	-= Damage;
	if ( bDamageTriggered && (0 >= m_fCurrentDamageThreshold) )
	{
		self.Trigger(self, instigatedBy);
		resetThreshold();
	}
}


// Dummy state to cope with movers not configured for bumping
function Bump( actor Other )
{
}

// Called from an SFPlayer when in state: TriggerToggle
// Ths function is overridden in the TriggerToggle state
function ManualTrigger( actor Other)
{

}

// When bumped by player.
function ManualBump( actor Other )
{
	local actor A;
	local pawn  P;

	class'SFUtils'.Static.sfLogEx(15,"SFMover - ManualBump: Caused by: " $ Other.name);

	P = Pawn(Other);
	if ( (BumpType != BT_AnyBump) && (P == None) )
		return;
	if ( (BumpType == BT_PlayerBump) && !P.bIsPlayer )
		return;
	if ( (BumpType == BT_PawnBump) && (Other.Mass < 10) )
		return;
	if( BumpEvent!='' )
		foreach AllActors( class 'Actor', A, BumpEvent )
			A.Trigger( Self, P );

	if ( P != None )
	{
		if( P.bIsPlayer && (PlayerBumpEvent!='') )
				foreach AllActors( class 'Actor', A, PlayerBumpEvent )
						A.Trigger( Self, P );

		if ( P.SpecialGoal == self )
			P.SpecialGoal = None;
	}

}

//-----------------------------------------------------------------------------
// Bump states.

// Open when bumped, wait, then close.
state() BumpOpenTimed
{
	function bool HandleDoor(pawn Other)
	{
		if ( (BumpType == BT_PlayerBump) && !Other.bIsPlayer )
			return false;

		Bump(Other);
		WaitingPawn = Other;
		Other.SpecialPause = 2.5;
		return true;
	}

	function Bump( actor Other )
	{
		if(!IgnoreBumping)
			ManualBump(Other);
	}

	function ManualBump( actor Other )
	{
		class'SFUtils'.Static.sfLogEx(15,"SFMover - ManualBump(BumpOpenTimed): Caused by: " $ Other.name);

		if ( (BumpType != BT_AnyBump) && (Pawn(Other) == None) )
			return;
		if ( (BumpType == BT_PlayerBump) && !Pawn(Other).bIsPlayer )
			return;
		if ( (BumpType == BT_PawnBump) && (Other.Mass < 10) )
			return;
		Global.ManualBump( Other );
		SavedTrigger = None;
		Instigator = Pawn(Other);
		GotoState( 'BumpOpenTimed', 'Open' );
	}

Open:
	Disable( 'Bump' );
	if ( DelayTime > 0 )
	{
		bDelaying = true;
		Sleep(DelayTime);
	}
	DoOpen();
	FinishInterpolation();
	FinishedOpening();
	Sleep( StayOpenTime );
	if( bTriggerOnceOnly )
		GotoState('');
Close:
	DoClose();
	FinishInterpolation();
	FinishedClosing();
	Enable( 'Bump' );
}

// Open when bumped, close when reset.
state() BumpButton
{
	function bool HandleDoor(pawn Other)
	{
		if ( (BumpType == BT_PlayerBump) && !Other.bIsPlayer )
			return false;

		Bump(Other);
		return false; //let pawn try to move around this button
	}

	function Bump( actor Other )
	{
		if(!IgnoreBumping)
			ManualBump(Other);
	}

	function ManualBump( actor Other )
	{
		class'SFUtils'.Static.sfLogEx(15,"SFMover - ManualBump(BumpButton): Caused by: " $ Other.name);

		if ( (BumpType != BT_AnyBump) && (Pawn(Other) == None) )
			return;
		if ( (BumpType == BT_PlayerBump) && !Pawn(Other).bIsPlayer )
			return;
		if ( (BumpType == BT_PawnBump) && (Other.Mass < 10) )
			return;
		Global.ManualBump( Other );
		SavedTrigger = Other;
		Instigator = Pawn( Other );
		GotoState( 'BumpButton', 'Open' );
	}
	function BeginEvent()
	{
		bSlave=true;
	}
	function EndEvent()
	{
		bSlave     = false;
		Instigator = None;
		GotoState( 'BumpButton', 'Close' );
	}
Open:
	Disable( 'Bump' );
	if ( DelayTime > 0 )
	{
		bDelaying = true;
		Sleep(DelayTime);
	}
	DoOpen();
	FinishInterpolation();
	FinishedOpening();
	if( bTriggerOnceOnly )
		GotoState('');
	if( bSlave )
		Stop;
Close:
	DoClose();
	FinishInterpolation();
	FinishedClosing();
	Enable( 'Bump' );
}

// Toggle when triggered.
state() TriggerToggle
{
	function Trigger( actor Other, pawn EventInstigator )
	{
		if(!IgnoreTrigger)
		{
			// Set the event instigator, here, because it isn't handled in
			// the ManualTrigger action: UseKey: Other and EventInstigator
			// will always be an SFPlayer
			Instigator = EventInstigator;

			ManualTrigger(Other);
		}
	}

	function ManualTrigger(actor Other)
	{
		if(m_bFreeze)
			return;
		m_bFreeze = true;

		SavedTrigger = Other;
		if ( SavedTrigger != None )
			SavedTrigger.BeginEvent();
		if( KeyNum==0 || KeyNum<PrevKeyNum )
			GotoState( 'TriggerToggle', 'Open' );
		else
			GotoState( 'TriggerToggle', 'Close' );
	}
Open:
	if ( DelayTime > 0 )
	{
		bDelaying = true;
		Sleep(DelayTime);
	}
	DoOpen();
	FinishInterpolation();
	FinishedOpening();
	if ( SavedTrigger != None )
		SavedTrigger.EndEvent();
	m_bFreeze = false;
	Stop;
Close:
	DoClose();
	FinishInterpolation();
	FinishedClosing();
	m_bFreeze = false;
}

defaultproperties
{
     IgnoreBumping=True
     IgnoreTrigger=True
     bShowHUDHint=True
     CollisionRadius=20.000000
     CollisionHeight=20.000000
}

class file time: 12/7/2003 3:58:24 PM - creation time: 12/7/2003 4:03:45 PM
Created with UnCodeX