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

Engine.Controller


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
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727
00728
00729
00730
00731
00732
00733
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920
00921
00922
00923
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936
00937
00938
00939
00940
00941
00942
00943
00944
00945
00946
00947
00948
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123
01124
01125
01126
01127
01128
01129
01130
01131
01132
01133
01134
01135
01136
01137
01138
01139
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195
01196
01197
01198
01199
01200
01201
01202
01203
01204
01205
01206
01207
01208
01209
01210
01211
01212
01213
01214
01215
01216
01217
01218
01219
01220
01221
01222
01223
01224
01225
01226
01227
01228
01229
01230
01231
01232
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252
01253
01254
01255
01256
01257
01258
01259
01260
01261
01262
01263
01264
01265
01266
01267
01268
01269
01270
01271
01272
01273
01274
01275
01276
01277
01278
01279
01280
01281
01282
01283
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319
01320
01321
01322
01323
01324
01325
01326
01327
01328
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350
01351
01352
01353
01354
01355
01356
01357
01358
01359
01360
01361
01362
01363
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378
01379
01380
01381
01382
01383
01384
01385
01386
01387
01388
01389
01390
01391
01392
01393
01394
01395
01396
01397
01398
01399
01400
01401
01402
01403
01404
01405
01406
01407
01408
01409
01410
01411
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447
01448
01449
01450
01451
01452
01453
01454
01455
01456
01457
01458
01459
01460
01461
01462
01463
01464
01465
01466
01467
01468
01469
01470
01471
01472
01473
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484
01485
01486
01487
01488
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515
01516
01517
01518
01519
01520
01521
01522
01523
01524
01525
01526
01527
01528
01529
01530
01531
01532
01533
01534
01535
01536
01537
01538
01539
01540
01541
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554
01555
01556
01557
01558
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622
01623
01624
01625
01626
01627
01628
01629
01630
01631
01632
01633
01634
01635
01636
01637
01638
01639
01640
01641
01642
01643
01644
01645
01646
01647
01648
01649
01650
01651
01652
01653
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692
01693
01694
01695
01696
01697
01698
01699
01700
01701
01702
01703
01704
01705
01706
01707
01708
01709
01710
01711
01712
01713
01714
01715
01716
01717
01718
01719
01720
01721
01722
01723
01724
01725
01726
01727
01728
01729
01730
01731
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770
01771
01772
01773
01774
01775
01776
01777
01778
01779
01780
01781
01782
01783
01784
01785
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
// Controller, the base class of players or AI.
//
// Controllers are non-physical actors that can be attached to a pawn to control 
// its actions.  PlayerControllers are used by human players to control pawns, while 
// AIControFllers implement the artificial intelligence for the pawns they control.  
// Controllers take control of a pawn using their Possess() method, and relinquish 
// control of the pawn by calling UnPossess().
//
// Controllers receive notifications for many of the events occuring for the Pawn they 
// are controlling.  This gives the controller the opportunity to implement the behavior 
// in response to this event, intercepting the event and superceding the Pawn's default 
// behavior.  
//
// This is a built-in Unreal class and it shouldn't be modified.
//=============================================================================
class Controller extends Actor
	native
	nativereplication
	abstract;

//NEW
const DeadState			= 'Dead';
const GameEndedState	= 'GameEnded';
const FearTimerName		= 'FearTimer';
//OLD

//NEW (mdf)
enum EAttitude						// NOTE: UT/UW EAttitude etc. was renamed to EReaction etc.
{
	ATTITUDE_Enemy,					// considered an enemy
	ATTITUDE_Neutral,				// not considered a friend or enemy (but could go either way)
	ATTITUDE_Friend,				// considered a friend
	ATTITUDE_None,					// used for invalid situations (attitude to self, Pawn not set etc.)
};

struct native TFearLocationInfo
{
	var vector Location;
	var float ExpireTime;
};

enum EStopFiringInfo				// StopFiring "hints"
{
	SFI_None,						// no reason given
	SFI_Behavior,					// called for behavior reasons (e.g. firing burst over)
	SFI_NoLOS,						// NPC has no LOS to target/last seen position
	SFI_NoShot,						// NPC doesn't have a shot from current location (e.g. no grenade trajectory, blocked)
	SFI_Orientation,				// NPC facing away from target
	SFI_OutOfRange,					// target is out of range
	SFI_TargetInvalid,				// target is no longer valid (e.g. dead)
	SFI_Timeout,					// too long since target was last seen (e.g. stop firing at last seen position)
	SFI_WeaponRating,				// rating for weapon is ineffective / dangerous
	SFI_WeaponReload,				// reloading weapon
	SFI_WeaponSwitch,				// changing weapon
};
//OLD

var Pawn Pawn;

// Ticked pawn timers
var		float		ActorRangeCounter;	//NEW (mib) counter for checking for ActorRangeTransition events
var		float		LeapCounter;		//NEW (mdf) counter for checking for Enemy[Not]InMeleeRange events
var		float		MeleeCounter;		//NEW (mdf) counter for checking for Enemy[Not]InMeleeRange events
var		float		RangeCounter;		//NEW (mdf) counter for checking for EnemyInRange events
var		float		SightCounter;		// Used to keep track of when to check player visibility
var		float		FallWaitTime;		// used to countdown MaxWaitTime (if non-zero when WaitForLanding called)
var		int			LastRange;			// last range (1..Ranges.Num, 0 means not set
var		Pawn		LastRangeEnemy;		// last enemy used for range check
var		CoverSpot	CurrentCoverSpot;	//NEW (mdf) NPC's current cover spot (if set).
var		array<TFearLocationInfo> FearLocations;	//NEW (mdf) locations an NPC is afraid of
var		float		FovAngle;			// X field of view angle in degrees, usually 90.
var		globalconfig float Handedness;
var		bool        bIsPlayer;			// Pawn is a player or a player-bot.
var		bool        bIsBot;				//NEW (mdf) Pawn is a player-bot.
var		bool		bGodMode;			// cheat - when true, can't be killed or hurt

//AI flags
var const bool		bLOSflag;			// used for alternating LineOfSight traces
//NEW (mdf) serpentine support
var	private const ETacticalMoveType TacticalMoveType;	// used during movement towards destination (MoveToPoint not supported currently)
/*OLD
//var		bool		bAdvancedTactics;	// used during movement between pathnodes
*/
//NEW (mdf) moved to Pawn
/*OLD
var		bool		bCanOpenDoors;
var		bool		bCanDoSpecial;		//NEW (mdf) //Com: must be true for NPCs to be able to teleport...
*/
var		float		DefaultMoveSpeed;	//NEW (mdf)
var const bool		bAdjusting;
var		bool		bNoTact;
var     bool		bTacticalDir;		// used during movement between pathnodes
var		bool		bPreparingMove;		// set true while pawn sets up for a latent move
var		bool		bControlAnimations;	// take control of animations from pawn (don't let pawn play animations based on notifications)
var		bool		bEnemyAcquired;		//NEW (mdf) serpentine support
//NEW (mdf) Fix -- see PostBeginPlay
var		bool		bShouldPossess;		// set for NPCs so they're possessed on startup
//OLD

var const float FinishRotationThreshold; //NEW (mdf) support threshold with FinishRotation
var float CosMinFacingTargetAngle;		//NEW (mdf) min angle between NPC's rotation and line to enemy for firing
var	array<float> Ranges;				//NEW (mdf) optional list of important ranges to check in engine (calls EnemyRangeTransition if threshold crossed)
var vector AdjustLoc;
var rotator	AimRotation;				//NEW (mdf) used to squirrel away the rotation to use for aiming

//NEW (mdf) replaced Pawn.bJumpOffPawn which is gone from UW777 
/* !!mdf-tbd: figure out how Steve is handling this now -- afaict this was
   mainly used to prevent AdjustJump from being called when NPCs go
   into PHYS_Falling after using a kicker/jumppad (maybe these aren't
   used in UW which would be potentially bad...*/
var bool bSpecialJump;					
//OLD

// Input buttons.
//NEW
var input byte bFire, bAltFire, bJump;
var private input byte bRun, bDuck; //!!mdf-tbd: make public/protected again?
var input byte bLeanForward, bLeanLeft, bLeanRight, bLeanUp;
/*OLD
 	bRun, bDuck, bFire, bAltFire;
*/

var const	Controller		nextController; // chained Controller list

//NEW (mdf) legacy -- only set in SeePawn, never used elsewhere
/*
var		float 		Stimulus;			// Strength of stimulus - Set when stimulus happens
*/
//NEW (mdf) cleanup, Skill moved to AIController
var		float		StrafeTimer;		// C++ timer used if using ST_Basic strafing while moving towards destination (call UpdateTactics)
/*OLD
var     float		Skill;				// skill, scaled by game difficulty (add difficulty to this value)	
var		float		TacticalOffset;		// C++ timer used if using advanced tactics (to call UpdateTactics)
*/


// Navigation AI
var 	float		MoveTimer;
var 	Actor		MoveTarget;		// set by movement natives
var		vector	 	Destination;	// set by Movement natives
var	 	vector		FocalPoint;		// set by Movement natives
var		Actor		Focus;

//NEW (mdf) changed behavior somewhat
// these are updated every 0.1 secs as long as the NPC has LOS to his enemy
var	private	vector	LastEnemySeenLocation; 		// enemy position when I last saw enemy
var	private	vector	LastEnemySeeingLocation;	// position where I last saw enemy
var	private	float	LastEnemySeenTime;			// last time enemy was seen

// these are identical to the above when the NPC has LOS to his enemy but when
// there is no LOS, these might be set based on where the NPC thinks the enemy
// might be (e.g. if NPC heard enemy).
var	private	vector	LastEnemyDetectedLocation;
var	private	vector	LastEnemyDetectionLocation;
var	private	float	LastEnemyDetectedTime;
/*OLD
var		vector		LastSeenPos; 	// enemy position when I last saw enemy (auto updated if EnemyNotVisible() enabled)
var		vector		LastSeeingPos;	// position where I last saw enemy (auto updated if EnemyNotVisible enabled)
var		float		LastSeenTime;
*/

//NEW (mdf) // const to force script through native "set" functions to modify
var	const Pawn		ControllerEnemy;
var	const Actor		ControllerTarget;
/*OLD
var		Pawn    	Enemy;
var		Actor		Target;
*/
var		Mover		PendingMover;	// mover pawn is waiting for to complete its move
var		Actor		GoalList[4];	// used by navigation AI - list of intermediate goals

var NavigationPoint home;			// set when begin play, used for retreating and attitude checks
var	 	float		MinHitWall;		// Minimum HitNormal dot Velocity.Normal to get a HitWall from the physics
 
var byte VoicePitch; //for speech
var string VoiceType; //for speech
var float OldMessageTime; //to limit frequency of voice messages

// Route Cache for Navigation
var Actor RouteCache[16];
var ReachSpec	CurrentPath;
var vector		CurrentPathDir;	//NEW (mdf) serpentine support
var Actor	RouteGoal; //final destination for current route
var float	RouteDist;	// total distance for current route

// Replication Info
var() class<PlayerReplicationInfo> PlayerReplicationInfoClass;
var PlayerReplicationInfo PlayerReplicationInfo;

//NEW (mdf): renamed to EReaction and moved to AIController
/*OLD
var(AI) enum EAttitude  //order in decreasing importance
{
	ATTITUDE_Fear,		//will try to run away
	ATTITUDE_Hate,		// will attack enemy
	ATTITUDE_Frenzy,	//will attack anything, indiscriminately
	ATTITUDE_Threaten,	// animations, but no attack
	ATTITUDE_Ignore,
	ATTITUDE_Friendly,
	ATTITUDE_Follow 	//accepts player as leader
} AttitudeToPlayer;	//determines how creature will react on seeing player (if in human form)
*/

var class<Pawn> PawnClass;	// class of pawn to spawn (for players)

var float GroundPitchTime;
var vector ViewX, ViewY, ViewZ;	// Viewrotation encoding for PHYS_Spider

var NavigationPoint StartSpot;  // where player started the match

// Audio stuff
var bool	bSlowAudioOcclusion;	// whether to use slow or fast audio occlusion.
var float	AudioRadiusModifier;	// gets used if obstructed with slow occlusion.
var float	AudioVolumeModifier;	// gets used if obstructed with slow occlusion.

//NEW (mdf) U2 navigation
enum EMoveResult
{
	MR_Continue,						//0 used internally when still moving (hasn't timed out & hasn't reached destination & move still valid)
	MR_TimeOut,							//1 MoveTimer ran out before reaching destination
	MR_Error,							//2 invalid call to MoveToXXX or invalid situation (tbd)
	MR_NoPawn,							//3 controller no longer has a pawn (tbd)
	MR_DestinationInvalid,				//4 situation changed, e.g. fell past destination
	MR_DestinationLost, 				//5 MoveTarget destroyed/cleared (tbd)
	MR_DestinationReached,   			//6 reached given destination
	MR_DestinationReachedFinal,			//7 reached given (final) destination
	MR_DestinationReachedPending,		//8 used internally
	MR_DestinationReachedFinalPending,	//9 used internally
};

var const EMoveResult MoveResult;					// set by Movement natives during call to MoveToXXX
var const Actor MoveFinalDestinationActor;			// set by Movement natives during call to MoveToActor
var const float MoveAtFinalDestinationDistance;		// set by Movement natives during call to MoveToActor

enum EPathResult						// returned by calls to FindPathToActor/Point
{
	PR_None,							//0 no path found 
	PR_Visible,							//1 goal is visible from end anchor (last actor in RouteCache)
	PR_Reachable,						//2 goal is reachable from end anchor (last actor in RouteCache)
	PR_Direct,							//3 goal is directly reachable from NPC's current location
};
//OLD

//NEW MJL
var bool bPlayerCanFire; //can be used to force playercontrollers not to be able to fire, even if they have a weapon
//OLD

//NEW (mib) tracking when an actor gets comes in / goes out of a certain range
var actor InRangeActor;							// actor whose distance we're checking
var float InRangeDistance;						// distance at which actor goes in / out of range
var bool  InRangebSendInitialEvent;				// send an event the first time the range is tested
var int   LastInRangeResult;					// cache last result so we track range transitions
//OLD

replication
{
	// Functions the server calls on the client side.
	reliable if( RemoteRole==ROLE_AutonomousProxy ) 
		ClientGameEnded, ClientDying, ClientSetRotation, ClientSetLocation;
	reliable if ( (!bDemoRecording || (bClientDemoRecording && bClientDemoNetFunc)) && Role == ROLE_Authority )
		ClientVoiceMessage;

	// Functions the client calls on the server.
	unreliable if( Role<ROLE_Authority )
		SendVoiceMessage;
	reliable if ( Role < ROLE_Authority )
		ServerRestartPlayer;
}

event Replication()
{
	Super.Replication();

	if( bNetDirty )
	{
		DOREP('PlayerReplicationInfo');
		DOREP('Pawn');
		if ( bNetOwner )
		{
//NEW
			DOREP('bPlayerCanFire');
/*OLD
			DOREP('PawnClass');
*/
		}
	}
}

// Latent Movement.
//NEW (mdf) U2 approach
/*
Use MoveToPoint to move towards a specific location (vector). Note that if this 
location isn't directly reachable, MoveToPoint will eventually time-out.

Use MoveToActor to move toward a specific Actor's location. If the intended 
destination actor (e.g. an enemy Pawn, a PathNode) isn't reachable, use 
FindPathToXXX to determine intermediate destinations which can be used to get 
closer to the final destination until this becomes directly reachable.

Both MoveToPoint and MoveToActor are "latent" functions. This means that when script
state code calls these (and latent functions can only be called from state 
code), the call won't return immediately. MoveToXXX will return for various
reasons including: the destination was reached, the move timed out (destination
not reached after X seconds), the destination became invalid, etc. The calling
code needs to handle these situations correctly, e.g. by looping the 
MoveToXXX code until the destination is reached or until some attempt limit
(see NumMoveAttempts) is reached.

NOTE: the following are set in the Controller for MoveToXXX:

	MoveToPoint:						  
	
		Parameter:						  Default:
		Destination						= DestinationLocation
		MoveTarget						= NULL
		MoveFinalDestinationActor		= NULL;	
		MoveAtFinalDestinationDistance	= AtFinalDestinationDistance2D (-1.0)

	MoveToActor:
	
		Parameter:						  Default:
		Destination						= DestinationActor.Location
		MoveTarget						= DestinationActor
		MoveFinalDestinationActor		= FinalDestinationActor
		MoveAtFinalDestinationDistance	= AtFinalDestinationDistance2D (-1.0)


Actor will rotate towards Destination unless the optional ViewFocus is specified.

When MoveToXXX return (latently), the Controller's MoveResult property 
will be set according to the result (see above MT_XXX consts for possible values). 
These can be used by the caller to determine what action to take (generally try 
again N times until a result of MR_DestinationReachedFinal is obtained). In most 
cases it should not be necessary to call AtDestinationPoint/Actor after a call to
MoveToActor since this information will be in MoveResult.

The Destination and FinalDestination Actors can be the same (this will happen when 
an intermediate goal is the same as the final goal and when the final goal is 
directly reachable).

With MoveToActor, it is possible to modify the "reached destination" test somewhat
so that NPCs can be made to stop short of a final destination. e.g. if a script
wants to send an NPC into "the general vicinity" of a target pathnode. Do this
by filling in the FinalDestinationActor and AtFinalDestinationDistance2D parameters
when calling MoveToActor. NOTE: if an AtFinalDestinationDistance2D is supplied, this
represents the 2D location-to-location distance between the moving NPC and the
given FinalDestinationActor and won't include any collision radii. The height test
is simply that the center of the pawn is vertically inside the Z range of the 
target actor.

By default, MoveToPoint considers the destination to have been reached when the 
destination location is inside the moving Pawn's collision radius (+various
height checks). To override this check, specify a AtFinalDestinationDistance2D, 
e.g. a value of 5.0 should force the Pawn to continue moving towards the 
destination location until it is within this distance. As with MoveToActor, the
distance represents the 2D point-to-point distance between the center of the 
Pawn and the given destination location. The height test is simply that the
given destination location is vertically inside the range of the Pawn.

Note: with a large enough AtFinalDestinationDistance2D, it may be possible for the 
final destination to be reached while moving towards an intermediate destination
(one which is different from the FinalDestinationActor). The calling code needs
to handle this situation if it can/does arise.
*/

native(500) final latent function MoveToPoint( 
	vector DestinationLocation,
	optional float AtFinalDestinationDistance2D,
	optional Actor ViewFocus,
	optional float Speed );
	
native(502) final latent function MoveToActor( 
	Actor DestinationActor,
	ETacticalMoveType DesiredTacticalMoveType,
	optional Actor FinalDestinationActor,
	optional float AtFinalDestinationDistance2D,
	optional Actor ViewFocus,
	optional float Speed );

// functions for testing whether destination reached using the same tests as MoveToXXX
native final function bool AtDestinationPoint( vector Destination, optional float AtDestinationDistance );
native final function bool AtDestinationActor( Actor DestinationActor, optional float AtDestinationDistance );

// returns true if NPC is currently handling a MoveToActor or MoveToPoint latent move
native final function bool IsHandlingLatentMove();

/*OLD
//Note that MoveTo sets the actor's Destination, and MoveToward sets the
//actor's MoveTarget.  Actor will rotate towards destination unless the optional ViewFocus is specified.

native(500) final latent function MoveTo( vector NewDestination, optional Actor ViewFocus, optional float speed);
native(502) final latent function MoveToward(actor NewTarget, optional Actor ViewFocus, optional float speed);
*/
//NEW (mdf) support threshold with FinishRotation
native(508) final latent function FinishRotation( optional int Threshold );
/*OLD
native(508) final latent function FinishRotation( DefaultRotationThreshold );
*/

// native AI functions
//NEW (mdf)
/*
LineOfSightTo: returns true if any of several points of Other is visible 
(origin, top, bottom).

+if Other is Pawn's enemy -- LOS checks are only done to Other's center and 
 Other's eyes unless bRobustLOSChecks is true
+if Other not enemy:
	+only checks to Other's center if more than 8000 units away
	+if source Pawn isn't a player or other isn't a Pawn won't look more than 2000 units

CanSee: similar to LineOfSightTo, but also takes into account Pawn's peripheral 
vision.

+if Other is Pawn's enemy, simply calls LineOfSightTo (i.e. does *NOT* use source Pawn's FOV)
	+this seems to be an optimization which assumes that Pawn will turn to see enemy
+if not enemy, toggles searching Pawn's bLOSflag with each call
	+this controls whether LineOfSightTo (when bUseLOSFlag is true) checks for LOS to head
	+i.e. consecutive calls to CanSee will/won't use the same checks!!!
		+this behavior needs to be eliminated for script calls to CanSee
	+has various distance checks depending on whether Other is a Pawn or player
	+Uses Pawn's PeripheralVision and SightRadius properites.
*/

native(514) final function bool LineOfSightTo( Actor Other, optional bool bRobustLOSChecks, optional int TraceFlags ); 
native(533) final function bool CanSee( Actor Other, optional bool bRobustLOSChecks, optional int TraceFlags ); 

/*OLD
//LineOfSightTo() returns true if any of several points of Other is visible 
//(origin, top, bottom)
native(514) final function bool LineOfSightTo(actor Other); 

//CanSee() similar to line of sight, but also takes into account Pawn's peripheral vision
native(533) final function bool CanSee(Pawn Other); 
*/

//Navigation functions - return the next path toward the goal
//NEW (mdf)
/* 
FindPathToPoint and FindPathToActor can return the given target (vector /
Actor) if this is directly reachable and bIncludeDirect=true (default). If
bIncludeDirect=false, the first navigation point on a path to the target (if
one is found) will be returned. 

Most code will probably want to use bIncludeDirect=true unless the target is 
known to not be directly reachable already (e.g. because of an earlier test).
This makes it unnecessary to continue to have script code that checks for 
reachability then calls FindPathToXXX if the  target is not reachable -- 
FindPathToXXX now take care of this internally.

With bIncludeDirect=true, the current code considers the target to *not* be
directly reachable if jumping is required. This is likely a temporary approach
and will eventually be replaced by code which considers jump-reachable targets
but *prefers* using pathing if this does not result in a substantially more
expensive path.

With bClearSpecialColliders=true, the collision for actors in the level's special
colliders list is cleared/restored in the call to FindPathToPoint/Actor. This
is currently used with XMP items which are colliding but which shouldn't
interfere with path *building* (they will interfere with path *using*).
*/
 
native(517) final function EPathResult FindPathToPoint( vector TargetVector, optional out vector ReturnedVector, optional bool bIncludeDirect/*true*/, optional bool bClearPaths/*true*/, optional bool bClearSpecialColliders/*true*/ );
native(518) final function EPathResult FindPathToActor( Actor TargetActor, optional out Actor ReturnedActor, optional bool bIncludeDirect/*true*/, optional bool bClearPaths/*true*/, optional bool bClearSpecialColliders/*true*/ );
native final function EPathResult FindPathTowardNearest( class<NavigationPoint> GoalClass, optional out Actor ReturnedActor, optional bool bClearSpecialColliders/*true*/ );
native(525) final function NavigationPoint FindRandomDest( optional bool bClearPaths, optional bool bClearSpecialColliders/*true*/ );
/*OLD
//native(518) final function Actor FindPathTo(vector aPoint, optional bool bClearPaths);
//native(517) final function Actor FindPathToward(actor anActor, optional bool bClearPaths);
//native final function Actor FindPathTowardNearest(class<NavigationPoint> GoalClass);
//native(525) final function NavigationPoint FindRandomDest(optional bool bClearPaths);
*/
native(522) final function ClearPaths();

//NEW (mdf) - parameterize destination to use
/* !!mdf-tbd: collapse with projectile aiming code?
*/
native(523) final function vector EAdjustJump( vector TargetLocation, float BaseZ, float XYSpeed );
/*OLD
native(523) final function vector EAdjustJump(float BaseZ, float XYSpeed);
*/

//Reachable returns whether direct path from Actor to aPoint is traversable
//using the current locomotion method
//NEW (mdf)
native(521) final function bool PointReachable( vector point, optional float MaxDistSquared/*=PathsMaxDistSquared*/ );
native(520) final function bool ActorReachable( Actor TargetActor, optional float MaxDistSquared/*=PathsMaxDistSquared*/ );
/*OLD
native(521) final function bool pointReachable(vector aPoint);
native(520) final function bool actorReachable(actor anActor);
*/

//NEW (mdf) cover support

/*-----------------------------------------------------------------------------
Returns true if the given CoverActor is valid. The NPC must be able to hide 
from the PawnToAvoid at the given CoverActor's location (with the NPC's feet at
the bottom of the CoverActor's collision). If bTestReach is true, then the 
CoverActor is also tested for reachability (directly or via pathing).

!!mdf-tbd: if valid and bTestReach given, sets MoveTarget to CoverActor if 
reachable or to next NavigationPoint to move towards if pathable).
*/

native final function bool ValidCoverActor(
	Actor		CoverActor,				// cover actor (usually current CoverSpot)
	Pawn		PawnToAvoid,			// pawn to avoid (usually enemy)
	bool		bTestReach );			// if true CoverActor reachability is tested

/*-----------------------------------------------------------------------------
Attempts to find the best location matching the given constraints at which the
NPC can hide from the given PawnToAvoid. If a valid location is found, creates
a CoverSpot at that location (on the ground) and returns it, otherwise returns
None.
*/

native final function CoverSpot FindCoverSpot(
	Pawn		PawnToAvoid,			// actor to avoid (usually current enemy)
	float		MinDistance,			// min distance to consider
	float		MaxDistance,			// max distance to consider
	float		MinDeltaZ,				// min delta Z to consider
	float		MaxDeltaZ,				// max delta Z to consider
	float		CosMinAngle,			// cosine of min acceptable angle between PawnToAvoid and cover
	float		CosMaxAngle,			// cosine of min acceptable angle between PawnToAvoid and cover
	bool		bIncludePathable );		// include destinations which aren't directly reachable
//OLD

/* PickWallAdjust()
Check if could jump up over obstruction (only if there is a knee height obstruction)
If so, start jump, and return current destination
Else, try to step around - return a destination 90 degrees right or left depending on traces
out and floor checks
*/
native(526) final function bool PickWallAdjust(vector HitNormal);

/* WaitForLanding()
latent function returns when pawn is on ground (no longer falling)
//NEW (mdf) comment: FindPathToPoint/Actor will fail if the NPC is falling.
*/
//NEW (mdf) optional max wait time
native(527) final latent function WaitForLanding( optional float MaxWaitTime );
/*OLD
native(527) final latent function WaitForLanding( );
*/

//NEW (mdf) cleanup 
/* 
Given BestPath Actor refers best target actor if successful, None otherwise. Returns Weight 
for best path found (>0) or -1.0 if no path found. Script code should no longer need dummy 
MinWeight parameters and makes in vs out values clearer.

NOTE: bPredictRespawns not implemented currently.
*/
native(540) final function float FindBestInventoryPath( out Actor BestPath, float MinWeight, bool bPredictRespawns, optional bool bClearSpecialColliders/*true*/ );
/*OLD
native(540) final function actor FindBestInventoryPath(out float MinWeight, bool bPredictRespawns);
*/

native(529) final function AddController();
native(530) final function RemoveController();

// Pick best pawn target
native(531) final function pawn PickTarget(out float bestAim, out float bestDist, vector FireDir, vector projStart);
native(534) final function actor PickAnyTarget(out float bestAim, out float bestDist, vector FireDir, vector projStart);

// Force end to sleep
native function StopWaiting();
native function EndClimbLadder();

//NEW (mdf) corrected comment
/*-------------------------------------------------------------------------
Called by engine physics if walking and bCanJump, and is about to go off a 
ledge. Pawn has opportunity (by setting bCanJump to false) to avoid fall.
*/
//OLD
event /*probe*/ MayFall();

//NEW (mdf) called from script code when NPC is starting to fall
function StartFalling();
//OLD

/* DisplayDebug()
list important controller attributes on canvas
*/
function DisplayDebug(Canvas Canvas, out float YL, out float YPos)
{
	Canvas.DrawText("PAWN "$Pawn);
	YPos += YL;
	Canvas.SetPos(4,YPos);
	if ( Pawn == None )
	{
		Super.DisplayDebug(Canvas,YL,YPos);
		return;
	}
	Canvas.DrawText("CONTROLLER "$GetItemName(string(self)));
	YPos += YL;
	Canvas.SetPos(4,YPos);

	//NEW (mdf)
	Canvas.DrawText("     STATE: "$GetStateName()$" Timer: "$TimerCounter$" Enemy "$ControllerEnemy, false);
	/*OLD
	Canvas.DrawText("     STATE: "$GetStateName()$" Timer: "$TimerCounter$" Enemy "$Enemy, false);
	*/
	YPos += YL;
	Canvas.SetPos(4,YPos);

	if ( PlayerReplicationInfo == None )
		Canvas.DrawText("     NO PLAYERREPLICATIONINFO", false);
	else
		PlayerReplicationInfo.DisplayDebug(Canvas,YL,YPos);

	YPos += YL;
	Canvas.SetPos(4,YPos);
}

/* Reset() 
reset actor to initial state
*/
function Reset()
{
	Super.Reset();
//NEW (mdf)	
	#debug   SetControllerEnemy( None, GetContext() );
	#release SetControllerEnemy( None );
	ClearLastSeenTimes();
/*OLD
	Enemy = None;
	LastSeenTime = 0;
*/	
	StartSpot = None;
}

/* ClientSetLocation()
replicated function to set location and rotation.  Allows server to force new location for
teleports, etc.
*/
function ClientSetLocation( vector NewLocation, rotator NewRotation )
{
	SetRotation(NewRotation);
	If ( (Rotation.Pitch > RotationRate.Pitch) 
		&& (Rotation.Pitch < 65536 - RotationRate.Pitch) )
	{
		If (Rotation.Pitch < 32768) 
			NewRotation.Pitch = RotationRate.Pitch;
		else
			NewRotation.Pitch = 65536 - RotationRate.Pitch;
	}
	if ( Pawn != None )
	{
		NewRotation.Roll  = 0;
		Pawn.SetRotation( NewRotation );
		Pawn.SetLocation( NewLocation );
	}
}

/* ClientSetRotation()
replicated function to set rotation.  Allows server to force new rotation.
*/
function ClientSetRotation( rotator NewRotation )
{
	SetRotation(NewRotation);
	if ( Pawn != None )
	{
		NewRotation.Pitch = 0;
		NewRotation.Roll  = 0;
		Pawn.SetRotation( NewRotation );
	}
}

function ClientDying(class<DamageType> DamageType, vector HitLocation, Pawn InstigatedBy, vector Momentum)
{
	if ( Pawn != None )
	{
		Pawn.PlayDying(DamageType, HitLocation, InstigatedBy, Momentum);
//NEW
		Pawn.GotoState( Pawn.DyingState );
/*OLD
		Pawn.GotoState('Dying');
*/
	}
}

/* AIHearSound()
Called when AI controlled pawn would hear a sound.  Default AI implementation uses MakeNoise() 
interface for hearing appropriate sounds instead. //NEW (mdf): i.e. currently NPCs only hear
sounds through MakeNoise (which causes a HearNoise event). It seems like the intent with
AIHearSound is/was to replace/complement this approach with having calls to DemoPlaySound,
PlaySound and PlayOwnedSound call CheckHearSound (see UnScript.cpp) which would then call
AIHearSound for NPCs which should hear the sound. Currently even UW isn't using this approach
at all and I'm guessing U2 will stick with the MakeNoise approach for now as switching over
to AIHearSound would a) possibly require a lot of cleaning up, b) possibly create a lot of
situations where things would need to be tweaked, c) possibly break existing code.. In theory,
having the engine automatically determine whether NPCs should hear a sound seems to be a good
approach, in practice, I'm skeptical that the volume needed for players to hear sounds will /
should be directly correlated with whether NPCs hear the sound and there are many cases where
sounds are only meant to be heard by real player(s).

*/
event /*probe*/ AIHearSound ( 
	actor Actor, 
	int Id, 
	sound S, 
	vector SoundLocation, 
	vector Parameters,
	bool Attenuate 
);

function Possess(Pawn aPawn)
{
//NEW (mdf) -- PossessedBy in U2Pawn hands out default inventory which assumes Pawn already set
	Pawn = aPawn;
	aPawn.PossessedBy(self);
/*OLD
	aPawn.PossessedBy(self);
	Pawn = aPawn;
*/
	if ( PlayerReplicationInfo != None )
		PlayerReplicationInfo.bIsFemale = Pawn.bIsFemale;
	// preserve Pawn's rotation initially for placed Pawns
	//!!mdf-tbd: the code in U2NPCControllerBase can go away now
	FocalPoint = Pawn.Location + 512*vector(Pawn.Rotation);
	Restart();
}

/* PawnDied()
 unpossess a pawn (because pawn was killed)
 */
function PawnDied()
{
	Unuse(); //NEW: Just in case.
	if ( Pawn != None )
	{
		SetLocation(Pawn.Location);
		Pawn.UnPossessed();
	}
	Pawn = None;
	PendingMover = None;
//NEW
	if( CanRespawn() )
	{
		GotoState( DeadState ); // can respawn
	}
/*OLD
	if ( bIsPlayer )
		GotoState('Dead'); // can respawn
*/
	else
		Destroy();
}

function Restart()
{
	//NEW (mdf)
	#debug   SetControllerEnemy( None, GetContext() );
	#release SetControllerEnemy( None );
	/*OLD
	Enemy = None;
	*/
}

event LongFall(); // called when latent function WaitForLanding() doesn't return after 4 seconds

// notifications of pawn events (from C++)
// if return true, then pawn won't get notified 
event /*probe*/ bool NotifyPhysicsVolumeChange(PhysicsVolume NewVolume); //NEW (mdf) //COM: has nothing to do with whether Pawn notified (PhysicsVolumeChange always called on Pawn...)
event /*probe*/ bool NotifyHeadVolumeChange(PhysicsVolume NewVolume); //NEW (mdf) //COM: not implemented currently?
event /*probe*/ bool NotifyLanded(vector HitNormal);
event /*probe*/ bool NotifyHitWall(vector HitNormal, actor Wall);
event /*probe*/ bool NotifyBump(Actor Other);
event NotifyHitMover(vector HitNormal, mover Wall);

function NotifyInvalidLanding( CheckResult Hit ); //NEW (mdf): sent by Pawn to Controller after invalid landing (e.g. Hit.Actor has bBlockNavigation)
function NotifyValidLanding( CheckResult Hit ); //NEW (mdf): sent by Pawn to Controller after valid landing (e.g. Hit.Actor has !bBlockNavigation)

// notifications called by pawn in script
function NotifyAddInventory(inventory NewItem);
function NotifyRemoveInventory(inventory RemovedItem); //NEW
//NEW (mdf) cleanup -- interface implementation should really be empty (real players' attitudes don't change...)
function NotifyTakeHit( Pawn InstigatedBy, vector HitLocation, int Damage, class<DamageType> DamageType, vector Momentum );
/*OLD
function NotifyTakeHit(pawn InstigatedBy, vector HitLocation, int Damage, class<DamageType> damageType, vector Momentum)
{
	if ( (instigatedBy != None) && (instigatedBy != pawn) )
		damageAttitudeTo(instigatedBy, Damage);
} 
*/

function SetFall();	//about to fall
function PawnIsInPain(PhysicsVolume PainVolume);	// called when pawn is taking pain volume damage

//NEW
simulated event PreBeginPlay()
{
	Super.PreBeginPlay();

	AddController();

	if( Role==ROLE_Authority )
	{
		if ( bDeleteMe )
			return;

		SightCounter = 0.2 * FRand();  //offset randomly 
	}
}
/*OLD
event PreBeginPlay()
{
	AddController();
	Super.PreBeginPlay();
	if ( bDeleteMe )
		return;

	SightCounter = 0.2 * FRand();  //offset randomly 
}
*/

event PostBeginPlay()
{
	Super.PostBeginPlay();
//NEW MJL: don't want to spawn these on the client
	if (bIsPlayer && Level.Netmode != NM_Client )
/*OLD
	if (bIsPlayer)
*/
	{
		PlayerReplicationInfo = Spawn(PlayerReplicationInfoClass, Self,,vect(0,0,0),rot(0,0,0));
		InitPlayerReplicationInfo();
	}
}

function InitPlayerReplicationInfo()
{
//NEW (mdf) Fix -- UW asssumes all NPCs have controllers	
	if( PlayerReplicationInfo != None && PlayerReplicationInfo.PlayerName == "" )
/*OLD
	if (PlayerReplicationInfo.PlayerName == "")
*/
		PlayerReplicationInfo.SetPlayerName(class'GameInfo'.Default.DefaultPlayerName);
}

function vector WeaponBob(float BobDamping)
{
	return vect(0,0,0);
}

function HandlePickup(Pickup pick)
{
	if ( MoveTarget == pick )
		MoveTimer = -1.0;
}

simulated event Destroyed()
{
	//DMTNS( "Destroyed:" );

//NEW
	RemoveController();
	RemoveAllTimers();
//OLD

	if ( Role < ROLE_Authority )
		return;

//NEW
/*OLD
	RemoveController();
*/

	if ( bIsPlayer && (Level.Game != None) )
		Level.Game.logout(self);
	if ( PlayerReplicationInfo != None )
		PlayerReplicationInfo.Destroy();
	Super.Destroyed();
}

/* AdjustView() 
by default, check and see if pawn still needs to update eye height
(only if some playercontroller still has pawn as its viewtarget)
Overridden in playercontroller
*/
function AdjustView( float DeltaTime )
{
	local Controller C;

	for ( C=Level.ControllerList; C!=None; C=C.NextController )
		if ( C.IsA('PlayerController') && (PlayerController(C).ViewTarget == Pawn) )
			return;

	Pawn.bUpdateEyeHeight = false;
	Pawn.Eyeheight = Pawn.BaseEyeheight;
}
			
function bool WantsSmoothedView()
{
	return ( ((Pawn.Physics==PHYS_Walking) || (Pawn.Physics==PHYS_Spider)) && !Pawn.bJustLanded );
}

function ClientGameEnded()
{
//NEW
	GotoState( GameEndedState );
/*OLD
	GotoState('GameEnded');
*/
}

simulated event RenderOverlays( canvas Canvas )
{
//NEW (mdf) major spam fix
	if ( Pawn != None && Pawn.Weapon != None )
/*OLD
	if ( Pawn.Weapon != None )
*/
		Pawn.Weapon.RenderOverlays(Canvas);

}

/* GetFacingDirection()
returns direction faced relative to movement dir

0 = forward
16384 = right
32768 = back
49152 = left
*/
function int GetFacingDirection()
{
	return 0;
}

//------------------------------------------------------------------------------
// Speech related

function SendMessage(PlayerReplicationInfo Recipient, name MessageType, byte MessageID, float Wait, name BroadcastType)
{
	SendVoiceMessage(PlayerReplicationInfo, Recipient, MessageType, MessageID, BroadcastType);
}

function SendVoiceMessage(PlayerReplicationInfo Sender, PlayerReplicationInfo Recipient, name messagetype, byte messageID, name broadcasttype)
{
	local Controller P;
	local bool bNoSpeak;

	if ( Level.TimeSeconds - OldMessageTime < 2.5 )
		bNoSpeak = true;
	else
		OldMessageTime = Level.TimeSeconds;

	for ( P=Level.ControllerList; P!=None; P=P.NextController )
	{
		if ( PlayerController(P) != None )
		{  
			if ( !bNoSpeak )
			{
				if ( (broadcasttype == 'GLOBAL') || !Level.Game.bTeamGame )
					P.ClientVoiceMessage(Sender, Recipient, messagetype, messageID);
				else if ( Sender.Team == P.PlayerReplicationInfo.Team )
					P.ClientVoiceMessage(Sender, Recipient, messagetype, messageID);
			}
		}
		else if ( (P.PlayerReplicationInfo == Recipient) || ((messagetype == 'ORDER') && (Recipient == None)) )
			P.BotVoiceMessage(messagetype, messageID, self);
	}
}

function ClientVoiceMessage(PlayerReplicationInfo Sender, PlayerReplicationInfo Recipient, name messagetype, byte messageID);
function BotVoiceMessage(name messagetype, byte MessageID, Controller Sender);

//***************************************************************
// interface used by ScriptedControllers to query pending controllers

function bool WouldReactToNoise( float Loudness, Actor NoiseMaker)
{
	return false;
}

function bool WouldReactToSeeing(Pawn Seen)
{
	return false;
}

//***************************************************************
// AI related

//NEW (mdf) moved in 829 build from here into SquadAI -- putting back here for now
function bool CanHelp() { return false; }
function HandleHelpMessageFrom(Controller Other);
//OLD
function FearThisSpot(Actor ASpot);
event PrepareForMove(NavigationPoint Goal, ReachSpec Path);
function WaitForMover(Mover M);
function MoverFinished();
function UnderLift(Mover M);

//NEW (mdf) 
/* 

!!mdf-tbd: called by pathing code when evaluating a reachspec with
bSpecialPath=true. Returns true if the path should be used, false if it should
be ignored and/or sets ExtraCost to the additional cost to associate with the
path, if any. The intent is to use this with the force fields to disable 
paths through shield walls for NPCs which aren't going to attack them (i.e.
NPCs which are on the same team as the force field). NPCs which will attack
the force field are encouraged to find a path around the force field since
the cost of reachspecs through the force field are increased as long as the
force field is present but they aren't completely prohibited from trying to
use a path through the force field since they will be able to destroy it
if/when they run into it.
*/
event bool SpecialPathing( ReachSpec Path, out int ExtraCost )
{
	return true;
}
//OLD

event float Desireability(Pickup P)
{
	return P.BotDesireability(Pawn);
}

event /*probe*/ HearNoise( float Loudness, Actor NoiseMaker);
//NEW (mdf)
event /*probe*/ SeeEnemy( Pawn Seen );			// called when an enemy is seen
event /*probe*/ SeeFriend( Pawn Seen );			// called when a friend is seen
event /*probe*/ SeeOther( Actor Seen );			// called when "other" is seen (carcasses & such - tbd)
event /*probe*/ SeeAlertFriend( Pawn Seen );	// called when an alert friend is seen (e.g. has enemy) (SeeFriend won't be called if SeeAlertFriend called)

/*OLD
//event SeePlayer( Pawn Seen );	// called when a player (bIsPlayer==true) pawn is seen
//event SeeMonster( Pawn Seen );	// called when a non-player (bIsPlayer==false) pawn is seen
*/

event UpdateTactics(); // for advanced tactics
event /*probe*/ EnemyNotVisible();
event /*probe*/ EnemyInvalid(); //NEW (mdf) called in first tick where current enemy set but invalid (Health < 0, bDeleteMe or bHidden)

//NEW (mdf) 
// EnemyInLeapRange:
// If enabled and NPC has an enemy and Pawn.LeapOdds > 0.0, checks for this 
// event every 0.25 secs (search for LeapCounter in the cpp code to verify the
// current value). The event is called if distance between NPC and enemy 
// locations is >= LeapMinRange and <= LeapMaxRange).
//
// EnemyInMeleeRange:
// If enabled and NPC has an enemy and Pawn.MeleeOdds > 0.0, checks for this 
// event every 0.25 secs (search for MeleeCounter in the cpp code to verify the
// current value). The event is called if distance between NPC and enemy 
// collision cylinders is <= MeleeRange).
//
// EnemyNotInMeleeRange:
// Same as EnemyInMeleeRange except checks for enemy outside of MeleeRange.
//
// EnemyRangeTransition:
// Called if between checks, enemy crosses into a different threshold in the
// Ranges array (if not empty).

event /*probe*/ EnemyInLeapRange( float Distance );
event /*probe*/ EnemyInMeleeRange();
event /*probe*/ EnemyNotInMeleeRange();
event /*probe*/ EnemyRangeTransition( float Distance );

// Returns true if MeleeTarget is in MeleeRange (depending on Pawn's physics).
// Used by Enemy[Not]InRange().
native final function bool CheckMeleeAttackRange( Actor MeleeTarget, optional float Range );
//OLD

//NEW (mib)
// If enabled and a InRangeActor and InRangeDistance has been set up,
// check for these every 0.25 secs (search for ActorInRangeCounter in the cpp code ).

// ActorRangeTransition gets called the when the InRangeActor's collision cyllinder
// crosses the InRangeDistance.  bInRange is set to true if the actor is entering the
// range, and false when the actor is leaving.

event ActorRangeTransition( bool bInRange );

// Returns true if Target is within Range.
native final function bool CheckActorInRange( Actor Target, float Range );

function SetActorRangeTest( actor Target, float Range, bool bSendInitialEvent )
{
	InRangeActor = Target;
	InRangeDistance = Range;
	InRangebSendInitialEvent = bSendInitialEvent;
	LastInRangeResult = -1;
}
//OLD

//NEW (arl)
function ShakeView(float Magnitude,optional float Duration);
/*OLD
function ShakeView( float shaketime, float RollMag, vector OffsetMag, float RollRate, vector OffsetRate, float OffsetTime);
*/

//NEW (mdf)
function NotifyKilled( Controller Killer, Controller Killed, Pawn KilledPawn, class<DamageType> DamageType )
{
	if( ControllerEnemy == KilledPawn )
	{
		#debug   SetControllerEnemy( None, GetContext() );
		#release SetControllerEnemy( None );
	}
}

/*OLD
function NotifyKilled(Controller Killer, Controller Killed, pawn Other)
{
	if ( Enemy == Other )
		Enemy = None;
}
*/

//NEW (mdf)
native final private function _SetControllerEnemy( Pawn Enemy );		// script code should call SetControllerEnemy
native final private function _SetControllerTarget( Actor Target );		// script code should call SetControllerTarget

#debug   function SetControllerEnemy( Pawn Enemy, coerce string ContextString )
#release function SetControllerEnemy( Pawn Enemy )
{
	if( ControllerEnemy != Enemy )
	{
		//DMTNS( "SetControllerEnemy: " $ ControllerEnemy $ " --> " $ Enemy $ " from " $ ContextString );
		bEnemyAcquired = false;
		_SetControllerEnemy( Enemy );
	}
}

#debug   function SetControllerTarget( Actor Target, coerce string ContextString )
#release function SetControllerTarget( Actor Target )
{
	if( ControllerTarget != Target )
	{
		//DMTNS( "SetControllerTarget: " $ ControllerTarget $ " --> " $ Target $ " from " $ ContextString );
		_SetControllerTarget( Target );
	}
}

function ETacticalMoveType GetTacticalMoveType()
{
	return TacticalMoveType;
}

//OLD

//NEW (mdf) GetAttitudeTo
/* 
Rules of Engagement (also see the engine code):

NPCs with bAmbientCreature = true won't attack other NPCs so other NPCs ignore
them and they ignore other NPCs in general. This is an important optimization
as it eliminates overhead caused by NPCs checking whether they can see/hear
each other when at least one of them is ambient. That said, there could
certainly be special cases in which NPCs are told to attack ambients, e.g. via
scripting. The bAmbientCreature flag can be changed in-game to make them 
become aggressive, e.g. upon taking more than a certain amount of damage.

NPCs with bAmbientCreature = false will attack NPCs which aren't on their team.
In general, an NPC that becomes aggressive (bAmbientCreature becomes false)
will still be on Team_Ambient so it won't attack other ambient NPCs. But there are
several special teams that NPCs can be placed on (usually in-game) to make them
the target of a) any aggressive NPCs b) NPCs which are on their team or c) NPCs
of the same class. e.g an injured fish might become the target for any other
fish in the area by being placed on Team_TeamOutcast;

TBD: maintain a list of NPCs that each NPC is "annoyed at" and also have them
attack these even if they are on the same team.

For botmatches, teams are only checked for player vs player if it is a team 
game, otherwise the above rules apply.

NPCs can also react to a friendly NPC that comes into view. A friendly NPC is
one that is on the same team and (in the case of ambients) of the same class.

a) if the friendly NPC isn't alert -- wave or other gesture
b) if the friendly NPC is alert, inherit its alertness and possibly its enemy if within some range
*/

native final function EAttitude GetAttitudeTo( Pawn Other );
//OLD

//NEW (mdf)
function DamageAttitudeTo( Pawn Other, float Damage, class<DamageType> DamageType );
/*OLD
function damageAttitudeTo(pawn Other, float Damage);

function eAttitude AttitudeTo(Pawn Other)
{
	if ( Other.IsPlayerPawn() )
		return AttitudeToPlayer;
	else
		return ATTITUDE_Ignore;
}
*/

function float AdjustDesireFor(Pickup P);
//NEW (mdf) renamed to emphasize that weapon not necessarily involved
function FireAt( Actor A ); //OLD function FireWeaponAt(Actor A);
 
//NEW (mdf)
// Makes sure the current weapon is no longer firing, AI subclasses also set timers 
// etc. based on the suggested SuggestedFireAgainDelay. If bBlocked=true, NPC can't
// fire because it is blocked by something (e.g. geometry, friendly NPC).
#debug   function StopFiring( float SuggestedFireAgainDelay, EStopFiringInfo SFInfo, string ContextStr )
#release function StopFiring( float SuggestedFireAgainDelay, EStopFiringInfo SFInfo )
{
	bFire = 0;
	bAltFire = 0;
}
/*OLD
function StopFiring()
{
	bFire = 0;
	bAltFire = 0;
}
*/
//NEW (mdf)
function float WeaponPreference( Weapon W ) { return 0; }
/*OLD
function float WeaponPreference(Weapon W);
*/

/* 
AdjustAim:
AIController version does adjustment for non-controlled pawns. 
PlayerController version does the adjustment for player aiming help.
Only adjusts aiming at pawns
allows more error in Z direction (full as defined by AutoAim - only half that difference for XY)
CHANGENOTE: This function change is related to the Weapon code updates
*/

//NEW (mdf) NOTE (mdf): AdjustAim is also used by NPCs as a hook for knowing that the weapon was fired (e.g. to stop firing)
function bool AdjustAim( class<Projectile> ProjectileClass, float ProjSpeed, vector ProjStart, float WeaponFireSpread, bool bLeadTarget, bool bWarnTarget, bool bTossed, bool bTrySplash )
{
	return true;
}

function rotator GetAimRotation()
{
	return AimRotation;
}
/*OLD
function rotator AdjustAim(Ammunition FiredAmmunition, vector projStart, int aimerror)
{
	return Rotation;
}
*/

//NEW (mdf)
function ShotFiredNotification( Pawn Shooter, vector FireDir, class<Projectile> ProjectileClass, float ProjSpeed );
//OLD

/* ReceiveWarning()  *** CHANGENOTE: RENAMED (WAS WARNTARGET())***
 AI controlled creatures may duck
 if not falling, and projectile time is long enough
 often pick opposite to current direction (relative to shooter axis)
*/
//NEW (mdf) not used
/*
function ReceiveWarning(Pawn shooter, float projSpeed, vector FireDir)
{
}
*/

/* CHANGENOTE: Changes in this function related to the Weapon code updates
*/

//NEW (mdf) weapon interface cleanup and keep old weapon approach
exec function bool SwitchToBestWeapon( optional out float Rating, optional out byte bUseAltMode )
{
	local bool bSuccess;

	Rating = -999999.999;
	
	//2002.12.19 (mdf) warning fix
	if( Pawn == None )
		return false;
	
	if( Pawn.Inventory != None )
	{
		#debug   StopFiring( 0.5, SFI_WeaponSwitch, GetContext() );
		#release StopFiring( 0.5, SFI_WeaponSwitch );
	
		Pawn.PendingWeapon = Pawn.Inventory.RecommendWeapon( ControllerEnemy, Rating, bUseAltMode );
	
		if ( Pawn.PendingWeapon == Pawn.Weapon )
			Pawn.PendingWeapon = None;
		if ( Pawn.PendingWeapon != None )
		{
			if ( Pawn.Weapon == None )
				Pawn.ChangedWeapon();
		
			//MJL: fix so that we only play putdown if we are switching to a real weapon.
			// changedweapon() up above sets pendingweapon to none,
			// which would cause it to put down the weapon before pulling it up.
			if ( Pawn.Weapon != Pawn.PendingWeapon && Pawn.PendingWeapon != None )
				Pawn.Weapon.PutDown();
	
			bSuccess = true;
		}
	}

	return bSuccess;
}
/*OLD
exec function SwitchToBestWeapon()
{
	local float rating;

	if ( Pawn.Inventory == None )
		return;

	StopFiring();
	Pawn.PendingWeapon = Pawn.Inventory.RecommendWeapon(rating);
	if ( Pawn.PendingWeapon == Pawn.Weapon )
		Pawn.PendingWeapon = None;
	if ( Pawn.PendingWeapon == None )
		return;

	if ( Pawn.Weapon == None )
		Pawn.ChangedWeapon();

	if ( Pawn.Weapon != Pawn.PendingWeapon )
		Pawn.Weapon.PutDown();
}
*/

//NEW (mdf) not used anywhere and moved to UtilGame as a static function
/*OLD
function bool CheckFutureSight(float DeltaTime)
{
	return true;
}
*/

function ChangedWeapon();
function ServerReStartPlayer()
{
}

// **********************************************
// Controller States

//NEW MJL
function bool PressingFire()
{
	return bFire != 0 && bPlayerCanFire;
}

function bool PressingAltFire()
{
	return bAltFire != 0 && bPlayerCanFire;
}
//OLD

//NEW
state @ DeadState
/*OLD
State Dead
*/
{
//NEW (mdf) Fix
ignores SeeEnemy, SeeFriend, SeeOther, SeeAlertFriend, HearNoise, KilledBy;
/*OLD
//ignores SeePlayer, HearNoise, KilledBy;
*/
	function PawnDied() {}

	function ServerReStartPlayer()
	{
		//log("calling restartplayer in dying with netmode "$Level.NetMode);
		if ( Level.NetMode == NM_Client )
			return;
		Level.Game.RestartPlayer(self);
	}
}

//NEW
state @ GameEndedState
/*OLD
state GameEnded
*/
{
//NEW (mdf) Fix, falling cleanup
ignores SeeEnemy, SeeFriend, SeeOther, SeeAlertFriend, HearNoise, KilledBy, NotifyBump, NotifyHitWall, NotifyPhysicsVolumeChange, NotifyHeadVolumeChange, BeginFalling, TakeDamage, ShotFiredNotification;
/*OLD
//ignores SeePlayer, HearNoise, KilledBy, NotifyBump, HitWall, NotifyPhysicsVolumeChange, NotifyHeadVolumeChange, Falling, TakeDamage, ReceiveWarning;
*/
	event BeginState()
	{
		if ( Pawn != None )
		{
			Pawn.bPhysicsAnimUpdate = false;
			Pawn.StopAnimating();
			Pawn.SimAnim.AnimRate = 0;
			Pawn.SetCollision(false,false,false);
			Pawn.Velocity = vect(0,0,0);
			Pawn.SetPhysics(PHYS_None);
			Pawn.UnPossessed();
		}
		if ( !bIsPlayer )
			Destroy();
	}
}

//NEW (mdf)
//-----------------------------------------------------------------------------
// ADDITIONAL INTERFACE FUNCTIONS 
//-----------------------------------------------------------------------------

function NotifyStanceChange( byte NewStance, float HeightAdjust );

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

function float GetSkill()
{
	return 1.0;
}

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

function bool IsRealPlayer()
{ 
	return ( Pawn != None && Pawn.IsRealPlayer() );
}

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

function bool ValidPawn( Pawn P )
{
	return class'Pawn'.static.ValidPawn( P );
}

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

function bool ValidEnemy( Pawn P )
{
	return ( P != Pawn && ValidPawn( P ) && GetAttitudeTo( P ) == ATTITUDE_Enemy );
}

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

function float GetTimeSinceEnemyLastSeen()		
{ 
	return Level.TimeSeconds - LastEnemySeenTime; 
}

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

function float GetTimeSinceEnemyLastDetected()	
{ 
	return Level.TimeSeconds - LastEnemyDetectedTime; 
}

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

function vector GetLastEnemySeenLocation()
{ 
	return LastEnemySeenLocation; 
}

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

function vector GetLastEnemySeeingLocation()	
{ 
	return LastEnemySeeingLocation; 
}

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

function float GetLastEnemySeenTime()			
{ 
	return LastEnemySeenTime; 
}

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

function vector GetLastEnemyDetectedLocation()	
{ 
	return LastEnemyDetectedLocation; 
}

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

function vector GetLastEnemyDetectionLocation()	
{ 
	return LastEnemyDetectionLocation; 
}

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

function float  GetLastEnemyDetectedTime()		
{ 
	return LastEnemyDetectedTime; 
}

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

// NOTE: LastEnemySeenLocation, LastEnemySeeingLocation, LastEnemySeenTime are
// always set by the engine (every 0.1 secs as long as the enemy is visible).

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

function EnemyDetected( vector DetectedLocation )
{
	LastEnemyDetectedLocation =  DetectedLocation;
	LastEnemyDetectionLocation = Pawn.Location;
	LastEnemyDetectedTime = Level.TimeSeconds;
}

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

function SetLastEnemyDetectedLocation( vector DetectedLocation )	
{ 
	LastEnemyDetectedLocation = DetectedLocation; 
}

//-----------------------------------------------------------------------------
	
function ClearLastSeenTimes()
{
	LastEnemySeenTime = 0.0;
	LastEnemyDetectedTime = 0.0;
}

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

function StopMovement( bool bKillAcceleration, bool bKillVelocity )
{
	if( Pawn != None )
		Pawn.StopMovement( bKillAcceleration, bKillVelocity );
}

/*-----------------------------------------------------------------------------
Returns true if PC/NPC is prepared to carry out a ranged attack (fire weapon,
lob projectile etc.). This function is used by NPCs in 2 situations 1) when the
AI code needs to determine whether the NPC is prepared to fire 2) when the AI 
code wants to check whether it appears that another PC/NPC, usually an enemy is
prepared to fire. In the first case bOwner will be set and the internal state
of the NPC's weapon (amount of ammo etc.) can be inspected, in the 2nd case, 
bOwner is not set and the internal weapon information won't be used (otherwise
this would be cheating as the NPC shouldn't normally be aware of the state of
a weapon which belongs to another PC/NPC).

If bCheckWeaponRating is true then the weapon rating is checked to make sure
that it will be effective against the current enemy (e.g. so that an NPC 
won't try to use a weapon outside of its effective distance or at a range 
which is going to cause self-damage). This isn't being done currently, but
in theory, the weapon rating checks could be used when evaluating an enemy's
attack capabilities and this wouldn't be "cheating" (weapon characteristics are 
"known" to all.
*/

function bool IsPreparedToFire( bool bOwner, optional bool bCheckWeaponRating, optional int MinWeaponRating )
{
	return false;
}

/*-----------------------------------------------------------------------------
Returns true if PC/NPC is prepared to carry out a melee attack, whether this
is weapon or animation based). If bOwner is set, caller owns the weapon so 
weapon state and ammo can be examined w.out cheating (see also IsPreparedToFire
comments).

The distance to the enemy isn't currently checked -- the caller is generally 
responsible for determining when the NPC is within melee range.
*/

function bool IsPreparedToMelee( bool bOwner, optional bool bCheckWeaponRating, optional int MinWeaponRating )
{
	return false;
}

/*-----------------------------------------------------------------------------
Return true if has the means to carry out some attack.  If bOwner is set,
caller owns the weapon so weapon state and ammo can be examined w.out cheating.
*/

function bool IsPreparedToAttack( bool bOwner ) 
{ 
	return IsPreparedToFire( bOwner ) || IsPreparedToMelee( bOwner );
}

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

function float GetAttackStyle( Actor TargetActor );
function float GetDefenseStyle( Actor TargetActor );
function float GetAttackRating( Pawn Other );
function float GetFireRating();

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

function bool DeferTo( Controller Other )
{
	return false;
}

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

function bool CanRespawn()
{
	return bIsPlayer;
}

//-----------------------------------------------------------------------------
// NOTE: ControllerTarget should only be set temporarily for having an NPC shoot
// at something other than enemy, e.g. when scripted or when doing a combination
// move (shooting at a projectile) or shooting at a decoration or carcass etc.
// Once the attack is over (or if it is interrupted) the ControllerTarget should
// be cleared by the code that set it.

function Actor GetTarget()
{
	// enemy normally takes priority
	if( ControllerEnemy != None )
		return ControllerEnemy;
	else	
		return ControllerTarget;
}

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

function bool GetAimingLocation( out vector TargetLocation )
{
	return false;
}

//-----------------------------------------------------------------------------
// NOTE: instead of setting/clearing a property as NPC is moved while or while
// not facing his enemy, check the actual vectors (more accurate and robust).

function bool IsFacingTarget( Actor Target, float CosMinFacingAngle )
{
	local vector TargetVector, PawnRotationVector;
	local float CosAngle;
		
	if( Target == None )
		return false;

	// 2D test
	TargetVector = Target.Location - Pawn.Location;
	TargetVector.Z = 0;
	PawnRotationVector = vector(Pawn.Rotation);
	PawnRotationVector.Z = 0;
	CosAngle = Normal( TargetVector ) dot PawnRotationVector;
#debugbegin
	/*
	DMTNS( "IsFacingTarget  CosAngle: " $ CosAngle $ " CosMinAngle: " $ CosMinFacingAngle $ " result: " $ CosAngle >= CosMinFacingAngle );
	if( CosAngle < CosMinFacingAngle )
	{
		AddArrow( Pawn.Location, Target.Location, ColorRed() );
		AddArrow( Pawn.Location, Pawn.Location + 1024.0*vector(Pawn.Rotation), ColorBlue() );
	}
	*/
#debugend

	return ( CosAngle >= CosMinFacingAngle );
}

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

function float TimeSinceTargetLastSeen( Actor TargetActor )
{
	if( TargetActor != ControllerEnemy )
	{
		// time when last seen is only maintained for current enemy
		if( LineOfSightTo( TargetActor ) ) 
			return 0.0;
		else
			return 99999.0;
	}
	
	return( Level.TimeSeconds - LastEnemySeenTime );
}

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

function ClearControllerTarget()
{
	#debug   SetControllerTarget( None, GetContext() );
	#release SetControllerTarget( None );
}

//-----------------------------------------------------------------------------
// Pawn became invisible or Controller should otherwise forget about the Pawn.

function ClearReferencesTo( Pawn P )
{
	if( ControllerEnemy == P )
	{
		#debug   SetControllerEnemy( None, GetContext() );
		#release SetControllerEnemy( None );
	}
	if( ControllerTarget == P )
	{
		#debug   SetControllerTarget( None, GetContext() );
		#release SetControllerTarget( None );
	}
	if( Focus == P )
		Focus = None;
}

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

function FearTimer()
{
	local int ii;
	local float TimeRemaining, MinTimeRemaining;

	//DMTNS( "FearTimer" );
	MinTimeRemaining = 999999.999;
	
	for( ii=0; ii<FearLocations.Length; ii++ )
	{
		TimeRemaining = FearLocations[ ii ].ExpireTime - Level.TimeSeconds;
		if( TimeRemaining <= 0.0 )
		{
			//DMTNS( "removing entry " $ ii );
			FearLocations.Remove( ii, 1 );
		}
		else
		{
			//DMTNS( "keeping entry " $ ii $ " " $ TimeRemaining );
			MinTimeRemaining = FMin( MinTimeRemaining, TimeRemaining );
		}
	}
	
	if( FearLocations.Length > 0 )
		AddTimer( FearTimerName, MinTimeRemaining, false );
		
	//for( ii=0; ii<FearLocations.Length; ii++ )
	//	DMTNS( ii $ ": " $ FearLocations[ ii ].Location $ " " $ FearLocations[ ii ].ExpireTime );
}

//-----------------------------------------------------------------------------
// Probably only used when NPC is using cover and taking damage for now? 

function AddFearLocation( vector FearLocation, float FearDuration )
{
	local float FearTimerWait;
	local TFearLocationInfo FLI;
	//local int ii;
	
	FLI.Location = FearLocation;
	FLI.ExpireTime = Level.TimeSeconds + FearDuration;
	
	FearLocations[ FearLocations.Length ] = FLI;
	//DMTNS( "AddFearLocation: " $ FearLocations.Length );
	
	FearTimerWait = TimeRemaining( FearTimerName );
	if( FearTimerWait < 0.0 || FearTimerWait > FearDuration )
		AddTimer( FearTimerName, FearDuration, false );
	
	//for( ii=0; ii<FearLocations.Length; ii++ )
	//	DMTNS( ii $ ": " $ FearLocations[ ii ].Location $ " " $ FearLocations[ ii ].ExpireTime );
}

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

function SetFrozen( bool bVal );
function SetStationary( bool bVal, optional bool bStayStationaryVal  );

function bool IsFrozen()		{ return false; }	// true if can't move and can't shoot etc.
function bool IsStationary()	{ return false; }	// true if stationary (moving disabled)
function bool IsMobile()		{ return true; }	// true if can't move (e.g. turrets, frozen/stationary NPCs)
function HandleKnockDown();
function HandlePanic();

function LevelChange();

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

function rotator GetViewRotation()			{ return Rotation; }

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

function EnableRotation( bool bVal )
{
	if( Pawn != None )
		Pawn.EnableRotation( bVal );
}

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

function bool AllowHitAnimations()			{ return true; }
function bool AllowHitSounds()				{ return true; }

// note that bRun != 0 means run key held down which means player is walking...

// made bRun/bDuck private for now -- use these accessors to read those values
function byte GetbRun()
{
	return bRun;
}

function byte GetbDuck()
{
	return bDuck;
}

// override these as needed to implement toggle support for example
function byte GetRunFlag()
{
	return bRun;
}

function byte GetDuckFlag()
{
	return bDuck;
}

function SetRunFlag( byte Val )
{
	bRun = Val;
}

function SetDuckFlag( byte Val )
{
	bDuck = Val;
}

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

function string GetStateInfoString()
{
	return "*" $ string(GetStateName());
}

//-----------------------------------------------------------------------------
// execs

exec function RestartLevel();
exec function Use();
exec function Unuse();
//OLD

defaultproperties
{
	FovAngle=90.000000
	DefaultMoveSpeed=1.000000
	CosMinFacingTargetAngle=0.984000
	MinHitWall=-1.000000
	PlayerReplicationInfoClass=Class'Engine.PlayerReplicationInfo'
	bSlowAudioOcclusion=true
	AudioRadiusModifier=0.500000
	AudioVolumeModifier=0.350000
	bPlayerCanFire=true
	bHidden=true
	RotationRate=(Pitch=3072,Yaw=30000,Roll=2048)
	bHiddenEd=true
     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:40.000 - Creation time: sk 3-1-2016 10:48:37.814 - Created with UnCodeX