Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

U2AI.U2NPCControllerScriptable


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
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
//=============================================================================
// U2NPCControllerScriptable.uc
// Created By: Steve Polge, Mike Fox
// Created On: 8/01/00
// $Author: Mfox $
// $Date: 12/18/02 5:22p $
// $Revision: 63 $
//=============================================================================

class U2NPCControllerScriptable extends U2NPCController
	config(User)
	abstract;

//-----------------------------------------------------------------------------

const ScriptedState					= 'Scripted';			// under script control
const ScriptedDialogState			= 'ScriptedDialog';		// engaging in dialog
const ScriptedDialogFarState		= 'ScriptedDialogFar';  // waiting for 3rd party dialog to finish
const MinMoveSpeedMultiplier		= 0.05;		// min movement speed for scripting

//-----------------------------------------------------------------------------
// properties

var class<ScriptControllerInterf>	DefaultScriptControllerClass;		// default event controller class
var class<ScriptControllerInterf>	ScriptedScriptControllerClass;		// scripted event controller class
var ScriptControllerInterf			ScriptController;					// script controller (SC) assigned on startup

var float CrouchingMoveSpeedMultiplier;
var float ProneMoveSpeedMultiplier;
var float StandingMoveSpeedMultiplier;

//-----------------------------------------------------------------------------

var Actor ScriptedFocus;
//var bool bFireAtWill;											// mdf-tbd: if scripted and has enemy/target will shoot at it if appropriate

var protected bool bDirectionalPatrol;							// whether NPC on patrol will match patrol destination rotation
var protected bool bScriptedIdleAnims;							// whether script is handling idle animations (tbd)

var bool bStayStationary;										// can be set (e.g. via script) to force NPC to stay stationary
var byte StationaryStance;
var bool bScriptLockedTarget;
var bool bScriptPendingFire;
var byte bScriptPendingFireUseAltMode;
var float ScriptedAimOdds;										// used with scripting firing
var float LastAutoEndTime;
var float MaxScriptedAutoEndDelay;								// max delay when going back to script after being autonomous
var bool bStayDormant;
var bool bDidStartup;											// hack to make sure script doesn't start executing before NPC initialized
var ETacticalMoveType ScriptedTacticalMoveType;					// type of tactical moves to use during scripted movement
var bool bScriptedHeadTrackingEnabled;
var bool bXMPHandlingEnabled;

// mdf-tbd: needed currently or get accessed Nones, animation errors
// but a better approach might be to have the script controller initiate the delay
var bool bInitializedForScripting;								// true once ScriptedState has gone through delay to make sure Pawn/Controller initialized but there has to be a better way

// set in Possess
var U2Pawn U2P;				

//-----------------------------------------------------------------------------
//@ EVENTS
//-----------------------------------------------------------------------------

/*-----------------------------------------------------------------------------
events -- these are all declared as final since this class and subclasses 
should intercept eventXXX rather than XXX directly (events are possibly 
filtered by the current event controller).

Note that some engine events are only implemented specific states (e.g. 
Scripted) so that these events aren't enabled by default in other states 
(Disable/Enable status are tracked on a per-state basis).

mdf-tbd: send initial (raw) events to an event handler component (script controller
could be derived from this instead of ScriptControllerInterf and move event handling
code from here to there (mainly to eliminate this redirection and to help keep the
amount of code in this file under control.
*/

//!!mdf-tbd: check for Pawn == None here (rather than in multiple other places) i.e.
// catch this situation and filter out event asap and all other code will assume
// that the Pawn is valid. What about checking health etc.?

function final ActorInRange()
	{ ScriptController.eventSCActorInRange( Self ); }

function final ActorOutOfRange()
	{ ScriptController.eventSCActorOutOfRange( Self ); }

event final EnemyNotVisible()											
	{ ScriptController.eventSCEnemyNotVisible( Self ); } //!!mdf-tbd:
	
event final SeeEnemy( Pawn Seen )
{ 
	if( StationaryPawn(Seen) == None || StationaryPawn(Seen).ConsiderAttacking( Seen, Self ) )
		ScriptController.eventSCSeeEnemy( Self, Seen ); 
}

function final AutoBegin( name DestinationState, name DestinationLabel )
	{ ScriptController.eventSCAutoBegin( Self, DestinationState, DestinationLabel ); }

function final AutoEnd()
	{ ScriptController.eventSCAutoEnd( Self ); }

function final BumpEnemy( Pawn Other )
	{ ScriptController.eventSCBumpEnemy( Self, Other ); }

function final BumpFriend( Pawn Other )
	{ ScriptController.eventSCBumpFriend( Self, Other ); }

function final BumpOther( Actor Other )
	{ ScriptController.eventSCBumpOther( Self, Other ); }

function final DestinationReached()						
	{ ScriptController.eventSCDestinationReached( Self ); }

function final Died()
	{ ScriptController.eventSCDied( Self ); }

function final HearNoiseFriendly( float Loudness, Actor NoiseMaker )				
	{ ScriptController.eventSCHearNoiseFriendly( Self, Loudness, NoiseMaker ); }

function final HearNoiseOther( float Loudness, Actor NoiseMaker )				
	{ ScriptController.eventSCHearNoiseOther( Self, Loudness, NoiseMaker ); }

function final HearNoiseThreat( float Loudness, Actor NoiseMaker )				
	{ ScriptController.eventSCHearNoiseThreat( Self, Loudness, NoiseMaker ); }

function final InheritEnemy( Pawn NewEnemy )
	{ ScriptController.eventSCInheritEnemy( Self, NewEnemy ); }

function final ScriptedLanding()
	{ ScriptController.eventSCScriptedLanding( Self ); }

function final TakeDamage( int Damage, Pawn EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType )
	{ ScriptController.eventSCTakeDamage( Self, Damage, EventInstigator, HitLocation, Momentum, DamageType ); }

function final TookDamage( int Damage, Pawn Instigator, vector HitLocation, vector Momentum, class<DamageType> DamageType )
	{ ScriptController.eventSCTookDamage( Self, Damage, Instigator, HitLocation, Momentum, DamageType ); }

function Trigger( Actor Other, Pawn Instigator, optional name EventName )	// global so that autonomous NPCs with a script can be triggered
	{ ScriptController.eventSCTrigger( Self, Other, Instigator, EventName ); }

//-----------------------------------------------------------------------------

// actual event handlers -- override these to implement specific behavior
function eventAutoBegin( name DestinationState, name DestinationLabel );	// no default global handler
function eventEnemyNotVisible();											// no default global handler

function eventBumpEnemy( Pawn Other );
function eventBumpFriend( Pawn Other );
function eventBumpOther( Actor Other );
function eventDialogUnPaused();
function eventHearNoiseFriendly( float Loudness, Actor NoiseMaker );
function eventHearNoiseOther( float Loudness, Actor NoiseMaker );
function eventHearNoiseThreat( float Loudness, Actor NoiseMaker );
function eventInheritEnemy( Pawn NewEnemy );
function eventSeeAlertFriend( Pawn Seen );
function eventSeeEnemy( Pawn Seen );
function eventSeeFriend( Pawn Seen );
function eventSeeOther( Actor Seen );
function eventTakeDamage( int Damage, Pawn Instigator, vector HitLocation, vector Momentum, class<DamageType> DamageType );
function eventTookDamage( int Damage, Pawn Instigator, vector HitLocation, vector Momentum, class<DamageType> DamageType );
//tbd: not used currently function eventTrigger( Actor Other, Pawn EventInstigator ) { NILog( GetContext() ); }

//-----------------------------------------------------------------------------
//@ SCRIPTING SUPPORT
//-----------------------------------------------------------------------------

function Possess( Pawn P )
{
	// helpers
	U2P = U2Pawn(P);
	#debug DMAI( "U2P: " $ U2P );
	
	Super.Possess( P );

	AssignScriptController();
	bScriptedHeadTrackingEnabled = U2P.default.bHeadTrackingEnabled;

	#debug DMAI( "Possess: Controller=" $ Self $ " Pawn=" $ Pawn $ " ScriptController=" $ ScriptController );
}

//-----------------------------------------------------------------------------
// interface functions for scripting

function Shutdown( bool bVal );
function bool IsDialogPaused() { return false; }
function MaybeFire( byte bUseAltMode );
function bool IsRepeatFire( bool bPrimary );
function bool SetAmmoTypeStr( string AmmoString ) { return false; }
function TurnToActor( Actor A, optional bool bLock );
simulated function SetAlert( bool bNewVal )  { LPawn.SetAlert( bNewVal ); }
simulated function SetHealth( float NewVal ) { LPawn.SetHealth( NewVal ); }
#debug   function WhatToDoNext( string ContextStr );
#release function WhatToDoNext();

function SetDirectionalPatrol( bool bNewVal );
simulated function SetScriptedFocus( Actor A );
function SetScriptedIdleAnims( bool bNewVal );

function SetXMPHandlingEnabled( bool bVal )
{
	bXMPHandlingEnabled = bVal;
}

function UseActor( Actor A );
function UnuseActor( optional Actor A );

//-----------------------------------------------------------------------------
// scripting support

exec function Use()
{
	// mdf-tbd: not used by NPCs?
	DMAssert( false, GetContext() );
}

//-----------------------------------------------------------------------------
// global version needed for U2NPCScriptables (eg. LevelMaster) wating on a dialog

function DialogUnPause()
{
	ScriptController.eventSCDialogUnPause( Self );
}

//-----------------------------------------------------------------------------

function AgentSpecialStateBegin()
{
	if( U2P != None )
	{
		U2P.bIgnoreImpactForces = true;
		U2P.bCanKnockDown = false;
		U2P.bCanPanic = false;
	}
}

//-----------------------------------------------------------------------------

function AgentSpecialStateEnd()
{
	if( U2P != None )
	{
		U2P.bIgnoreImpactForces = U2P.default.bIgnoreImpactForces;
		U2P.bCanKnockDown = U2P.default.bCanKnockDown;
		U2P.bCanPanic = U2P.default.bCanPanic;
	}
}

/*-----------------------------------------------------------------------------
If bStayDormant is true, NPC will stay dormant even if the NPC's script ends
etc.
*/

function SetDormant( bool bVal, optional bool bStayDormantVal )
{
	bStayDormant = bStayDormantVal;

	//DMTNS( "SetDormant -- bVal=" $ bVal $ " bStasis=" $ bStasis $ " Pawn=" $ Pawn );
	if( bVal )
	{
		if( !bStasis )
		{
			bStasis = true;
			#debug   StopFiring( 0.0, SFI_Behavior, GetContext() );
			#release StopFiring( 0.0, SFI_Behavior );
			if( Pawn != None )
			{
				if( !bVisibleAI )
					Pawn.bHidden = true;
				else
					U2P.SpamTextures( U2Pawn.TexDormant );
				Pawn.bStasis = true;
				Pawn.SetPhysics( PHYS_None );
				Pawn.AnimFrame = 0.0;
				Pawn.AnimRate = 0.0;
				Pawn.SetCollision( false, false, false );
				U2P.WentDormant(true);
				if( Pawn.AmbientSound != None )
					DMTNS( "Warning -- dormant Pawn " $ Pawn $ " has ambient sound " $ Pawn.AmbientSound );
			}
		}
	}
	else if( !bStayDormant )
	{
		if( bStasis )
		{
			bStasis = false;
			if( Pawn != None )
			{
				if( !bVisibleAI )
					Pawn.bHidden = false;
				else
					U2P.SpamTextures( None );
				Pawn.bStasis = false;
	    		// swimming creatures get stuck if waking up falling
				if( U2P != None && U2P.MovementPhysics == PHYS_Swimming )
					Pawn.SetPhysics( PHYS_Swimming );
				else
		    		Pawn.SetPhysics( PHYS_Falling );
				Pawn.SetCollision( true, true, true );
				U2P.WentDormant(false);
			}
		}
	}
}

//-----------------------------------------------------------------------------

function SetScriptedTacticalMoveType( ETacticalMoveType NewTacticalMoveType )
{
	ScriptedTacticalMoveType = NewTacticalMoveType;
}

//-----------------------------------------------------------------------------

function bool SetScriptedMoveSpeedMultiplier( float NewMoveSpeedMultiplier, byte Stance )
{
	local bool bResult;

	bResult = false;
	if( NewMoveSpeedMultiplier >= MinMoveSpeedMultiplier && NewMoveSpeedMultiplier <= Pawn.MaxDesiredSpeed )
	{
		switch( Stance )
		{
		case ST_Standing:
			StandingMoveSpeedMultiplier = NewMoveSpeedMultiplier * U2P.SetMoveSpeedFudge;
			#debug DMAIM( "SetScriptedMoveSpeedMultiplier  StandingMoveSpeedMultiplier: " $ StandingMoveSpeedMultiplier );
			break;
		case ST_Crouching:
			CrouchingMoveSpeedMultiplier = NewMoveSpeedMultiplier * U2P.SetMoveSpeedFudge;
			#debug DMAIM( "SetScriptedMoveSpeedMultiplier  CrouchingMoveSpeedMultiplier: " $ CrouchingMoveSpeedMultiplier );
			break;
		case ST_Prone: 
			ProneMoveSpeedMultiplier = NewMoveSpeedMultiplier * U2P.SetMoveSpeedFudge;
			#debug DMAIM( "SetScriptedMoveSpeedMultiplier  ProneMoveSpeedMultiplier: " $ ProneMoveSpeedMultiplier );
			break;
		}

		bResult = true;
	}

	return bResult;
}

//-----------------------------------------------------------------------------

function float GetScriptedMoveSpeed()
{
	local float ReturnedSpeed;

	switch( LPawn.GetStance() )
	{
	case ST_Standing:
		ReturnedSpeed = U2P.StandingMoveSpeed * StandingMoveSpeedMultiplier;
		break;
	case ST_Crouching:
		ReturnedSpeed = U2P.CrouchingMoveSpeed * CrouchingMoveSpeedMultiplier;
		break;
	case ST_Prone:
		ReturnedSpeed = U2P.ProneMoveSpeed * ProneMoveSpeedMultiplier;
		break;
	}

	//if( SuggestedSpeed > 0.0 )
	//	ReturnedSpeed = FMin( ReturnedSpeed, SuggestedSpeed );

	//#debug DMAIM( "GetScriptedMoveSpeed returning " $ ReturnedSpeed );
	return ReturnedSpeed;
}

//-----------------------------------------------------------------------------

function SetAutoMoveSpeed( float NewVal )
{
	DefaultMoveSpeed = NewVal * U2P.SetMoveSpeedFudge;
}

//-----------------------------------------------------------------------------

function SetHeadTrackingEnabled( bool bVal )
{
	U2P.bHeadTrackingEnabled = bVal;
	if( !bVal )
		U2P.MeshSetSatellite('Sat_HeadTrack', U2P );  // if "headtracking 0" clear old satellite and look straight ahead
		
	bScriptedHeadTrackingEnabled = bVal;
}

//-----------------------------------------------------------------------------

function SetAimOdds( float Odds )
{
	ScriptedAimOdds = Odds;
}

//-----------------------------------------------------------------------------

function ClearScriptTarget()
{
	#debug   SetControllerTarget( None, GetContext() );
	#release SetControllerTarget( None );
	bScriptLockedTarget = false;
	bScriptPendingFire = false;
}

//-----------------------------------------------------------------------------
// Changing or dropping script. Clean up stuff which might have been set while
// scripted which is no longer valid.

function ScriptReset()
{
	ClearScriptTarget();

	SetDormant( false );

	MoveTarget = None;
	if( Pawn != None )
		Destination = Pawn.Location;
	else
		Destination = Location;

	SetSpecialGoal( None );
}

/*-----------------------------------------------------------------------------
AssignScriptController

Assigns NPC's script controller (through ScriptController property).

1) if SpecifiedScriptControllerClass is set, this will be the class used
2) otherwise, if Pawn's CommandFileName is set, will use a script controller
3) otherwise, will use a ScriptControllerInterf (DefaultScriptControllerClass)

Frees old ScriptController, if any, then spawns instance of class determined
above and sets ScriptController to this.

Called on startup to setup the initial script controller and also called 
internally, e.g. when the current script is changed or set through a script or 
ScriptTrigger etc.
*/

function bool AssignScriptController( optional class<ScriptControllerInterf> SpecifiedScriptControllerClass )
{
	local class<ScriptControllerInterf> NewScriptControllerClass;

	// determine script controller class to use
	NewScriptControllerClass = DefaultScriptControllerClass;
	if( SpecifiedScriptControllerClass != None )
	{
		// use specified class
		NewScriptControllerClass = SpecifiedScriptControllerClass;
	}
	else if( U2P.CommandFileName != "" )
	{
		// if CommandFileName specified, must use a scripted script controller
		NewScriptControllerClass = ScriptedScriptControllerClass;
	}

	if( ScriptController == None || ScriptController.Class != NewScriptControllerClass )
	{
		if( ScriptController != None )
		{
			//DMTNS( "calling cleanup on " $ ScriptController );
			ScriptController.CleanupScriptController();
		}
		ScriptController = NewScriptControllerClass.static.GetInstance( Self );
	}
		
	if( HasScript() )
	{
		// under script control -- set file/label in script controller
		ScriptController.SetCommandFile( U2P.CommandFileName );
		ScriptController.SetStartLabel( U2P.CommandStartLabel );
	}
	else
	{
		// will not be under script control -- make sure doesn't try to resume any old patrol
		SetSpecialGoal( None );

		// NOTE: script might have left NPC crouched or prone at this point. If the NPC never 
		// moves (stopmovement 1 = stationary) this stance will be maintained (damage or
		// momentum xfer might change this). If the NPC moves at all the physics will restore
		// the standing stance. This all seems to make sense for an NPC that is now
		// autonomous.
	}

	if( ScriptController == None )
		NPCError( ET_Other, "WARNING: couldn't assign script controller -- NPC will be totally borked!" );

	#debug DMAI( "AssignScriptController ScriptController= " $ ScriptController $ " U2S=" $ ScriptController.GetCommandFile() );
	return ( ScriptController != None );
}

//-----------------------------------------------------------------------------
// Used e.g. when NPC is killed to make sure it is no longer under script 
// control.

function ResetScriptController()
{
	ScriptReset();
	AssignScriptController( DefaultScriptControllerClass );
}

//-----------------------------------------------------------------------------

function DetachScriptController()
{
	if( HasScript() )
	{
		ScriptReset();
		AssignScriptController( DefaultScriptControllerClass );
		#debug   WhatToDoNext( GetContext() );
		#release WhatToDoNext();
	}
}

//-----------------------------------------------------------------------------
// Called externally (e.g. through an exec function) to reload the scripts for
// all scripted NPCs. Mainly used for testing/modifying scripts without having
// to restart the game.

function ReloadScriptController()
{
	#debug DMAI( "ReloadScriptController" );
	ScriptReset();
	if( ScriptController != None )
	{
		//DMTNS( "calling InitializeScriptController #2" );
		ScriptController.InitializeScriptController( Self );
	}
}

//-----------------------------------------------------------------------------
// Used for specifying the script that an NPC should be using. This can be
// done within a previous script (setscript command), or externally through a
// ScriptTrigger (trigger which, when activated by an appropriate NPC, gives a
// script, possibly from a list, to that NPC), or through the SetScript exec
// (used for testing).

function SetScript( string NewCommandFileName, optional string NewStartLabel )
{
	#debug DMAI( "SetScript: " $ NewCommandFileName $ " " $ NewStartLabel );
	ScriptReset();
	U2P.CommandFileName = NewCommandFileName;
	U2P.CommandStartLabel = NewStartLabel;

	// note: NPC might not have a script controller at this point
	if( AssignScriptController() )
	{
		if( HasScript() )
		{
			bDidStartup = true;
			bInitializedForScripting = true;

			if( GetStateName() != ScriptedState )
			{
				//EnableSenses( true );
				GotoState( ScriptedState, BeginLabel );
			}

			// NOTE: unlike situation on game startup (script was in NPC's properties) the NPC
			// is already initialized at this point (Possess has been called etc.) so we can
			// initialize the script controller immediately
			//DMTNS( "calling InitializeScriptController #3" );
			ScriptController.InitializeScriptController( Self );
		}
		else
		{
			#debug   WhatToDoNext( GetContext() );
			#release WhatToDoNext();
		}
	}
}

//-----------------------------------------------------------------------------

function bool HasScript()
{
	return ( ScriptController.bHasScript );
}

//-----------------------------------------------------------------------------

function bool UnderScriptControl()
{
	return IsInState( ScriptedState );
}

//-----------------------------------------------------------------------------

function PawnDied()
{
	if( ScriptController != None ) //mdf: this check appears to be needed currently
		Died(); // sends event to script controller
	ResetScriptController();
	Super.PawnDied();
}

//-----------------------------------------------------------------------------

function CleanupScriptController()
{
	//DMTNS( "CleanupScriptController: " $ ScriptController );
	if( ScriptController != None )
	{
		// this is absolutely needed or script FTimerManagers can cause a crash
		ScriptController.CleanupScriptController();
		ScriptController.Delete();
		ScriptController = None;
	}
}

//-----------------------------------------------------------------------------

event Destroyed()
{
	//DMTNS( "Destroyed calling CleanupScriptController for " $ ScriptController );
	CleanupScriptController();
	Super.Destroyed();
}

//-----------------------------------------------------------------------------
//@ DEBUGGING
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// Used with the "trace debug" facility to get additional debugging information
// from the NPC and/or its script controller.

function GetExtendedInformation( out array<string> ReturnedStrings )
{ 
	if( ScriptController == None )
		ReturnedStrings[ 0 ] = "ScriptController not set!";
	else
		ScriptController.GetDebugInformation( Self, ReturnedStrings );
}

//-----------------------------------------------------------------------------

defaultproperties
{
	ScriptedAimOdds=1.000000
     UseReticleOnEvents(0)="UseReticleText"
     UseReticleOnEvents(1)="UseReticleCorners"
     UseReticleOnEvents(2)="UseReticleTopBars"
     ProximityReticleOnEvents(0)="ProximityReticleCorners"
     ProximityReticleOnEvents(1)="ProximityReticleTopBars"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: sk 3-1-2016 10:38:44.000 - Creation time: sk 3-1-2016 10:48:43.201 - Created with UnCodeX