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

Gameplay.Rook


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
//=====================================================================
// Rook
//=====================================================================

class Rook extends Engine.Pawn implements IEffectObserver
	native
	dependsOn(SingleplayerGameInfo);

//=====================================================================
// Constants

enum AlertnessLevels
{
	ALERTNESS_Neutral,      // gun lowered
	ALERTNESS_Alert,        // gun halfway
	ALERTNESS_Combat,       // gun aimed
};

const DAMAGE_OVERKILL = -50.0f;	// health value that justifies an "overkill" speech event 
const N_PAST_POSITIONS = 4;	// number of past positions stored in the pastPositions array (manually keep in snych with ARook.cpp version!)

//=====================================================================
// Variables

// health (default value is default.health)
var float healthMaximum;

var string hudType;

// if true, players can repair this object
var bool bCanRepair;

// the object's team
var()	protected
		editdisplay(displayActorLabel)
		editcombotype(enumTeamInfo)
		TeamInfo m_team							"The team that the object belongs to. Note: Base Devices assume the team of the BaseInfo to which they belong";

var private TeamInfo m_localTeam;

// the object's squad
var()	private
		editdisplay(displayActorLabel)
		editcombotype(enumSquadInfo)
		SquadInfo m_squad;

// Variables relating to common sensing code
var TribesVisionNotifier vision;						// Our Vision Notifier
var HearingNotifier hearing;							// Our Hearing Notifier
var ShotNotifier shotNotifier;							// Our Shot Notifier

// vision
var(AI) float PeripheralVisionZAngle "limits of peripheral vision in Z (radians)";
var(AI) float SightRadiusToPlayer "maximum distance at which player characters can be seen";

// AI Variables
var(AI) Tyrion_ResourceBase.AI_LOD_Levels AI_LOD_LevelMP "AI Level of detail for MP games";
var(AI) float AI_LOD_ActivationDistance "Distance at which AI's go into AILOD_NORMAL state";
var(AI) float AI_LOD_DeactivationDistance "Distance at which AI's leave AILOD_NORMAL state";
var(AI) bool bAIThreat "Is this a rook AI's should shoot at if it's an enemy?";
var(AI) float shotAngularDeviation "Max angular deviation from ideal line of fire in degrees";
var(AI) float shotAngularDeviationMP "Max angular deviation from ideal line of fire in degrees (MP games)";
var(AI) Range shotLeadAbility "Range from which the multiplier for the shot leading aiming component is chosen; (1,1) is totally accurate leading, numbers less than 1 undershoot, greater than 1 overshoot";
var(AI) Range shotLeadAbilityMP "Range from which the multiplier for the shot leading aiming component is chosen; (1,1) is totally accurate leading, numbers less than 1 undershoot, greater than 1 overshoot (MP games)";
var(AI) float reactionDelay "Time between spotting a new enemy and actually shooting at it"; 
var(AI) float reactionDelayMP "Time between spotting a new enemy and actually shooting at it (MP games)"; 
var(AI) float visionMemory "how long (in seconds) after losing a target does the AI still know where it is?";
var AlertnessLevels alertness;				// Alertness level
var int AI_LOD_deactivation_exemption_ticks;// when set, lets AI's stay in AILOD_NORMAL without a deactivation check
var Vector pastPositions[N_PAST_POSITIONS];	// past positions of the rook stored to compute average velocity
var int pastPositionsIndex;					// index of next position value in pastPositions
var float pastPositionsTimeAccu;			// deltaTime accumulator for pastPositions update
var Pawn attacker;							// entity who is attacking this rook
var float expectedImpactTime;				// time at which a projectile from "attacker" should have hit by
var float lastShotFiredTime;				// last time this AI fired a shot
var bool bUnobstructedLOF;					// does this rook have line of fire to its target?
var bool bDeferredAICleanup;				// true when state code is being run on AI's

var float tickTime;				// when tickTime < 0, we tick the AI
var float tickTimeOrg;			// last generated tickTime value
var Range tickTimeUpdateRange;  // min and max time that will be used to make a random tickTime

var Tyrion_ResourceBase vehicleAI;	// AI for the vehicle/turret as a whole
var Tyrion_ResourceBase mountAI;	// AI for gunner positions / drivers

// AI debug stuff
var bool bShowLOADebug;		// switch on local obstacle avoidance debugging
var bool bShowSensingDebug;	// switch on sensing debug
var Vector loaStartPoint;	// the point the lookAhead function is looking ahead from
var Vector loaEndPoint;		// and to
var Vector loaStartPoint2;	// and for the ramp/stairs segment...
var Vector loaEndPoint2;
var bool loaHit;			// true when lookAhead found an obstacle

// Boston's action/goal display
var bool bShowTyrionCharacterDebug;	// also activates vehicle/turret AI display
var bool bShowTyrionMovementDebug;
var bool bShowTyrionWeaponDebug;
var bool bShowTyrionHeadDebug;
var bool bShowNavigationDebug;

// Jetpacking/skiing debug stuff
var bool bShowJSDebug;		// switch on jetting/skiing debugging
var Vector estLocation;
var Vector movementForce;

// Squad/Formation debug stuff
var bool bShowSquadDebug;	// switch on squad/formation debugging
var Vector desiredLocation;	// where rook is trying to go

// alertness system debug
var bool logAlertnessChanges;

// shadow stuff
var (Shadow) float ShadowLightDistance;
var (Shadow) float MaxShadowTraceDistance;

// used by the sensor system
var() bool bCanBeSensed;
var() bool bIsDetectableByEnemies;
var bool sensorUpdateFlag;
var float lastDetectedTime;

// Set if this item should be always marked, even if it cannot be sensed
var() bool bAlwaysMarked;

// used to establish whether to mark this class or not:
var(Rook) class<RadarInfo> radarInfoClass;

// used for stat tracking
var array<Character> repairers;

// Damage Component system
struct native DamageComponent
{
	var() class<DynamicObject>	objectType	"Class type of the dynamic object attached at this location";
	var() name					attachmentPoint				"Bone or socket to attach object to. If None will attach to pivot";
	var DynamicObject			objectInstance;
};
var() array<DamageComponent> damageComponents;
var byte	clientDamageComponentMask;
var byte	damageComponentMask;	// this mask (and its client side dirty component) state which panels have been destroyed
var float	componentBreakThreshold;

// The PlayerCharacterController sets its state to this variable when possessing this Rook
var Name	playerControllerState;

// Ownership badge
var() bool	bUseAlternateOwnershipMaterial;
// Alternate Ownership Self-Illumination flag
var() bool	bUseAlternateSelfIllumMaterial;
var Name	teamSelfIllumSkinName;


// Fire damage
var Pawn				flameSource;
var class<DamageType>	flameDamageType;
var float				flameDamagePerSecond;
var float				flameDamageReductionPerSecond;

// Regenerating personalShields
var () class<Shield> personalShieldClass				"Class of regenerating Shield to use, or None to disable personal shields.  For Characters this should be set in the Armor class, not here.";
var Shield personalShield;

// Damage restrictions
var () float	teamDamagePercentage					"Members of this Rook's team can only reduce its health to this percentage of health.  Overrides any setting in TeamInfo.";

// effects system
var bool effectLogging;                                 // true if effect logging is enabled   
var Array<String> loopingEffects;                       // currently looping effects

// Grappler
var (Grappler) float grapplerRetentionScale                   "Scales breaking force for grapple attached to this object";

// Repair variables
var float repDepLastRateAddition;
var float repDepRepairRate;
var float repPakLastRateAddition;
var float repPakRepairRate;

// this array of useable points is replicated to the client
const MAX_USEABLE_POINTS = 10;
enum EUseablePointValid
{
	UP_Unused,
	UP_NotValid,
	UP_Valid
};
var Vector UseablePoints[MAX_USEABLE_POINTS];
var EUseablePointValid UseablePointsValid[MAX_USEABLE_POINTS];

// Havok team specific collision filtering
var  bool teamSpecificHavokCollisionFiltering;

// used to detect team changes
var private TeamInfo m_lastTeam;

replication
{
	reliable if (ROLE == ROLE_Authority)
		healthMaximum, m_team, UseablePoints, UseablePointsValid;

	reliable if ((ROLE == ROLE_Authority && !bNetOwner) || bDemoRecording)
        alertness;

	reliable if (ROLE == ROLE_Authority && personalShieldClass != None)
		personalShield;

	reliable if (ROLE == ROLE_Authority && damageComponents.Length != 0)
		damageComponentMask;
}

//=====================================================================
// Functions

function ApplyDamage(Pawn instigatedBy, float Damage, optional Name teamLabel)
{
	local Rook r;

	r = Rook(instigatedBy);
	if (r != None && r.m_team != None)
		teamLabel = r.m_team.Label;

	super.ApplyDamage(instigatedBy, Damage, teamLabel);
}

static simulated function PrecacheDamageComponents(LevelInfo Level, class<Rook> RookClass)
{
	local int i;

	// recurse through children
    for (i=0; i<RookClass.default.damageComponents.Length; i++)
	{
		if (RookClass.default.damageComponents[i].objectType != None)
			class'DynamicObject'.Static.PrecacheDynamicObjectRenderData(Level, RookClass.default.damageComponents[i].objectType);
	}
}

simulated function UpdatePrecacheRenderData()
{
	Super.UpdatePrecacheRenderData();
	PrecacheDamageComponents(Level, Class);
}


//
// Updates Havok collision data. Should be called when team changes.
//
simulated native function updateHavokCollisionFilter();

//
// Special function for returning the location of this actor
// if it is associated with an objective. This is mostly for the
// MPCarryables, because they have the problem of being attached
// to a charater & then having their location set to 0,0,0
//
simulated function Vector GetObjectiveLocation()
{
	return Location;
}

//
// For the useable points / prompts. Returns true if the
// character can use this rook. There is an array of useable
// points which is updated from server->client. Each time the
// player targets a rook, this method is called to see if the
// object is useable by them.
//
// In summary, the points are filtered on the server in case
// a particular point is unavilable (eg: someone is already using 
// an inventory station access), and the object is filtered
// on the client in case there is some character specific reason
// as to why the object cannot be accessed (eg: being on the 
// opposing team).
//
simulated function bool CanBeUsedBy(Character CharacterUser)
{
	return IsFriendly(CharacterUser);
}

function bool canBeSensed()
{
	return bCanBeSensed;
}

simulated function IFiringMotor firingMotor()
{
	return None;
}

// Returns the character (if it exists) that is controlling this rook (i.e. turret or vehicle)
simulated function Character getControllingCharacter()
{
	return None;
}

simulated function TeamInfo getControllingCharacterTeam()
{
	local Character controllingCharacter;

	controllingCharacter = getControllingCharacter();

	if ( controllingCharacter != None )
		return controllingCharacter.team();
	else
		return team();
}

// Repair functions ------------------------------------------------------------------------
simulated function addRepairFromDeployable(float repairRate, float accumulationScale)
{
	if (GameInfo(Level.Game) != None)
		repairRate = GameInfo(Level.Game).modifyRepairRate(self, repairRate);

	if (repDepLastRateAddition == 0.0)
	{
		repDepRepairRate = repairRate;
		repDepLastRateAddition = repairRate;
	}
	else
	{
		repDepLastRateAddition *= accumulationScale;
		repDepRepairRate += repDepLastRateAddition;
	}
}

simulated function removeRepairFromDeployable(float accumulationScale)
{
	repDepRepairRate -= repDepLastRateAddition;
	if (accumulationScale != 0)
		repDepLastRateAddition /= accumulationScale;
}

simulated function addRepairFromPack(float repairRate, float accumulationScale, Character repairer)
{
	//log("Old = "$repairRate);
	if (GameInfo(Level.Game) != None)
		repairRate = GameInfo(Level.Game).modifyRepairRate(self, repairRate);
	//log("New = "$repairRate);

	// Remember who is repairing for stat tracking purposes
	repairers[repairers.Length] = repairer;

	if (repPakLastRateAddition == 0.0)
	{
		repPakRepairRate = repairRate;
		repPakLastRateAddition = repairRate;
	}
	else
	{
		repPakLastRateAddition *= accumulationScale;
		repPakRepairRate += repPakLastRateAddition;
	}
}

simulated function removeRepairFromPack(float accumulationScale, Character repairer)
{
	local int i;

	repPakRepairRate -= repPakLastRateAddition;
	repPakLastRateAddition /= accumulationScale;

	// Stop remembering this repairer for stat tracking purposes
	for (i=0; i<repairers.Length; i++)
	{
		if (repairers[i] == repairer)
		{
			repairers.Remove(i, 1);
			return;
		}
	}
}

simulated event ProcessRepair(float delta)
{
	if (!isAlive())
		return;

	IncreaseHealth((repPakRepairRate + repDepRepairRate) * delta);
}
// End repair functions --------------------------------------------------------------------

simulated event ProcessBurnDamage(float delta)
{
	if (flameDamagePerSecond > 0.0)
	{
		if (PhysicsVolume.bWaterVolume)
		{
			removeFlameDamage();
			TriggerEffectEvent('Extinguished');
		}
		else
		{
			if (Role == ROLE_Authority)
				TakeDamage(flameDamagePerSecond * delta, flameSource, vect(0.0, 0.0, 0.0), vect(0.0, 0.0, 0.0), flameDamageType);

			if (flameDamageReductionPerSecond > 0.0)
				flameDamagePerSecond -= flameDamageReductionPerSecond * delta;

			if (flameDamagePerSecond <= 0.0)
				removeFlameDamage();
		}
	}
}

simulated function removeFlameDamage()
{
	flameDamagePerSecond = 0.0;
	UntriggerEffectEvent('Burning');
}

function displayWorldSpaceDebug(HUD displayHUD);

simulated function Destroyed()
{
	UntriggerEffectEvent('Burning');

	if (m_squad != None)
		m_squad.memberDestroyed(self);

	if (personalShield != None)
		personalShield.Destroy();

	cleanupAI();	// (requires vision pointer to still be around)
	cleanupSensing();
	
	cleanupDamageComponents();

	super.Destroyed();
}

event PreBeginPlay()
{
	// it is assumed that healthMaximum has neither been used or set prior to this point
	healthMaximum = default.health;

	super.PreBeginPlay();
}

//---------------------------------------------------------------------
// Called at start of gameplay.

simulated event PostBeginPlay()
{
 	local int i, damageComponentCount;
	
	Super.PostBeginPlay();

	if ( (Controller == None) && ControllerClassName == "Tyrion.AI_Controller" )
	{
		// create dummy AI controller for the rook -
		// so Unreal is happy and there's a place to store replicated data
		Controller = spawn(class<Controller>( DynamicLoadObject( ControllerClassName, class'Class')));
	}

	if ( Level.NetMode != NM_Client && Level.Game.IsA( 'MultiPlayerGameInfo' ) )
	{
		AI_LOD_Level = AI_LOD_LevelMP;
		shotAngularDeviation = shotAngularDeviationMP;
		shotLeadAbility = shotLeadAbilityMP;
		reactionDelay = reactionDelayMP;
	}
	AI_LOD_LevelOrig = AI_LOD_Level;

	CreateShotNotifier();	// a shot notifier is created for all rooks because AI's are interested in players' shots

	if ( Controller != None )
		Controller.Possess( self );

	// add this rook to his squad
	if ( squad() != None )
	{
		if ( logTyrion )
			log( self @ "added to squad" @ squad() );
		setSquad( squad() );
	}

	// fill in the damage component mask
	damageComponentCount = 0;
	for (i=0; i < damageComponents.length; ++i)
	{
		if (damageComponents[i].objectType != None)
		{
			damageComponentMask = damageComponentMask | (1 << i);
			++damageComponentCount;
		}
	}
	componentBreakThreshold = GetDamageComponentThresholdRange() / (damageComponentCount + 1);

	resetPersonalShield();

/*
	if ( label == 'aitestplatformer01' || label == 'aicustomesther1' )
	{
		logTyrion = true;
		//logNavigationSystem = true;
		bShowTyrionCharacterDebug = true;
		bShowTyrionMovementDebug = true;
		bShowTyrionWeaponDebug = true;
		bShowTyrionHeadDebug = true;
		bShowSensingDebug = true;
		bShowJSDebug = true;
		//logDLM = true;
		if ( squad() != None )
			squad().logTyrion = true;
	}
*/
}

simulated function float GetDamageComponentThresholdRange()
{
	return healthMaximum;
}

simulated event PostNetBeginPlay()
{
	Super.PostNetBeginPlay();

	if (bActorShadows && Level.NetMode != NM_DedicatedServer)
	{
		Shadow = Spawn(class'ShadowProjector',self,'',Location);
		Shadow.ShadowActor = self;
        Shadow.bBlobShadow = false;
		Shadow.LightDirection = Normal(vect(1,1,5));
		Shadow.LightDistance = ShadowLightDistance;
		Shadow.MaxTraceDistance = MaxShadowTraceDistance;
		Shadow.RootMotion = true;
		Shadow.CullDistance = 8000;
		Shadow.Resolution = 256;
		Shadow.InitShadow();
	}

	if (damageComponents.length != 0)
	{
		clientDamageComponentMask = damageComponentMask;
		clientUpdateDamageComponents();

		// we need to snooop on net receive if we are using damage components
		bNetNotify = true;
	}

	// if we have a radar info which displays icons ina  viewport, then turn on 
	// the post render callback. Make sure that we dont turn it off, though
	if (GetRadarInfoClass() != None)
		bNeedPostRenderCallback = bNeedPostRenderCallback || class<RadarInfo>(GetRadarInfoClass()).default.bDisplayViewport;
}

simulated function bool ShouldBeMarked(PlayerCharacterController pcc)
{
	// if the radar info says no, then don't.
	if (! (GetRadarInfoClass() != None && class<RadarInfo>(GetRadarInfoClass()).default.bDisplayViewport))
		return false;

	// always marked, so return true
	if(bAlwaysMarked)
		return true;

	// add the rook to the list of markers to be marked on the HUD
	if(bCanBeSensed && IsAlive() && (IsA('MPCarryable') || pcc.IsFriendly(self) || // friendlies and carryables are always rendered
		(! pcc.IsFriendly(self) && pcc.GetControllerTeam() != None && pcc.GetControllerTeam().bSensorGridFunctional)))	// enemy players are rendered only if the sensor grid is up
			return true;

	return false;
}

//---------------------------------------------------------------------
// Damage Component functions
simulated function clientUpdateDamageComponents()
{
	local int i;
	//local DynamicObject component;

	for (i=0; i < damageComponents.length && i < 8; ++i)
	{
		if (damageComponents[i].objectType != None)
		{
			// unspawned components that need to be spawned
			if (damageComponents[i].objectInstance == None && (damageComponentMask & (1<<i))!=0 )
				createDamageComponent(i, false);

			// removed components need to be broken
			if (damageComponents[i].objectInstance != None && (damageComponentMask & (1<<i))==0 )
				breakDamageComponent(i, 0, vect(0,0,0));
		}
	}
}

simulated function cleanupDamageComponents()
{
	local int i;

	for (i=0; i < damageComponents.length && i < 8; ++i)
	{
		if (damageComponents[i].objectInstance != None)
			damageComponents[i].objectInstance.Destroy();
	}
}

// client/server side functions
simulated native final function breakDamageComponent(int index, float damage, vector momentum);
simulated native final function createDamageComponent(int index, bool fadeIn);

// server side only functions
function damageComponentsPostTakeDamage(float damage, vector hitLocation, vector momentum, class<DamageType> damageType, optional float projectileFactor)
{
	// we may not neccesarily process this call
	if (Level.NetMode != NM_Client && damageComponentMask != 0 && damage > 0)
		damageComponentsOnDamage(damage, HitLocation, Momentum, DamageType);
}

native final function damageComponentsOnDamage(float damage, vector hitLocation, vector momentum, class<DamageType> damageType);
native final function damageComponentsOnIncreaseHealth(float quantity);

simulated event onTeamChange()
{
	updateHavokCollisionFilter();
}

// need to snoop on damage so that we can drop damage components
function PostTakeDamage(float Damage, Pawn EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional float projectileFactor)
{
	local float actualDamage, maxPercentageHealth;
	local Rook attackerRook;
	local VehicleMountedTurret attackerVehicleTurret;
	local Rook originalAttackerRook;
	
	actualDamage = Damage;

	// If personalShields are active, take damage from them instead
	if (personalShieldActive())
		actualDamage = personalShield.applyDamage(Damage, health);

	attackerRook = Rook(EventInstigator);
	originalAttackerRook = attackerRook;

	// handle vehicle case
	if (attackerRook != None && attackerRook.isA('Vehicle'))
		attackerRook = Vehicle(attackerRook).positions[Vehicle(attackerRook).driverIndex].occupant;

	// handle vehicle mounted turret case
	if (attackerRook != None && attackerRook.isA('VehicleMountedTurret'))
	{
		attackerVehicleTurret = VehicleMountedTurret(attackerRook);
		if (attackerVehicleTurret.positionIndex >= 0 && attackerVehicleTurret.ownerVehicle != None)
			attackerRook = attackerVehicleTurret.ownerVehicle.positions[attackerVehicleTurret.positionIndex].occupant;
	}
		
	// Restrict team damage if applicable
	if(attackerRook != None && attackerRook.team() != None && attackerRook.team().isFriendlyRook(self))
	{
		maxPercentageHealth = getTeamDamagePercentage();

		if (maxPercentageHealth > 0.0)
		{
			// Modify actual damage taken to only apply enough damage to bring the Rook's health down to maxPercentageHealth
			if ((health - actualDamage) / healthMaximum < maxPercentageHealth)
			{
				actualDamage = health - healthMaximum * maxPercentageHealth;
				if (actualDamage < 0)
					actualDamage = 0;
			}
		}		
	}

	Super.PostTakeDamage(actualDamage, EventInstigator, HitLocation, Momentum, DamageType, projectileFactor);

	// Hit feedback for character objects
	if(EventInstigator != None && Health > 0 && bCanBeDamaged)
	{
		if(Character(EventInstigator) != None)
			Character(EventInstigator).OnHitObject(self);
		else if(VehicleMountedTurret(EventInstigator) != None && VehicleMountedTurret(EventInstigator).GetDriver() != None)
			VehicleMountedTurret(EventInstigator).GetDriver().OnHitObject(self);
		else if(Turret(EventInstigator) != None && Turret(EventInstigator).driver != None)
			Turret(EventInstigator).driver.OnHitObject(self);
		else if(Vehicle(EventInstigator) != None && Vehicle(EventInstigator).GetDriver() != None)
			Vehicle(EventInstigator).GetDriver().OnHitObject(self);
	}

	damageComponentsPostTakeDamage(actualDamage, HitLocation, Momentum, DamageType, projectileFactor);

	generateAISpeechEvents(originalAttackerRook);
}

function generateAISpeechEvents( Rook attackerRook )
{
	local BaseAICharacter controllingCharacter;

	//log( "@@@" @ attackerRook.name @ "hit" @ name );

	// Speech events when an AI hits something
	if ( static.checkAlive(attackerRook) && attackerRook != self && !isFriendly( attackerRook ) )
	{
		controllingCharacter = BaseAICharacter(attackerRook.getControllingCharacter());

		if ( controllingCharacter != None && controllingCharacter.bTaunt )
		{
			if ( health > 0 )
			{
				if ( controllingCharacter.scaleByWeaponRefireRate() )
					level.speechManager.PlayDynamicSpeech( controllingCharacter, 'Hit', controllingCharacter );
			}
			else
			{
				if ( health > DAMAGE_OVERKILL )
					level.speechManager.PlayDynamicSpeech( controllingCharacter, 'Kill', None, self );
				else
					level.speechManager.PlayDynamicSpeech( controllingCharacter, 'Kill', None, self, "OverKill" );
				if ( FRand() < controllingCharacter.tauntAnimFrequency )
					controllingCharacter.playTauntAnim();
			}
		}

		// if hit, cancel pending miss speech event
		if ( attackerRook == attacker )
			attacker = None;
	}
}

simulated function PostNetReceive()
{
	super.PostNetReceive();

	// check mask to see if any damage components have been added or removed
	if (Level.NetMode == NM_Client && damageComponents.length != 0 && clientDamageComponentMask != damageComponentMask)
	{
		clientUpdateDamageComponents();
		clientDamageComponentMask = damageComponentMask;
	}

	// check if team has changed
	if (m_localTeam != m_team)
	{
		onTeamChange();
		m_localTeam = m_team;
	}
}

simulated event Material GetOverlayMaterial(int Index)
{
	// our shield can put an overlay on us
	if (personalShield != None && personalShield.bActive)
		return personalShield.GetEffectMaterial();
}


//---------------------------------------------------------------------
// Health functions
final function IncreaseHealth(float quantity)
{
	health += quantity;

	if (health > healthMaximum)
		health = healthMaximum;

	// update damage components
	if (Level.NetMode != NM_Client && damageComponents.length != 0)
		damageComponentsOnIncreaseHealth(quantity);
}

// Overridden in subclasses
function float getTeamDamagePercentage()
{
	return teamDamagePercentage;
}

//---------------------------------------------------------------------
// personalShield functions
function bool personalShieldActive()
{
	if (personalShield == None)
		return false;

	return personalShield.bActive && personalShield.health > 0;
}

function activatePersonalShield()
{
	if (personalShield != None)
		personalShield.activate();
}

function deactivatePersonalShield()
{
	if (personalShield != None)
		personalShield.deactivate();
}

function resetPersonalShield()
{
	if (personalShield != None)
		personalShield.destroy();

	if (personalShieldClass != None)
		personalShield = spawn(personalShieldClass);
}
//---------------------------------------------------------------------

protected function CreateVisionNotifier()
{
    vision = new class'TribesVisionNotifier';
    assert(vision != None);

	vision.addRef();
    vision.InitializeVisionNotifier(self);

	//log( "VISION NOTIFIER CREATED FOR" @ name );
}

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

protected function CreateHearingNotifier()
{
	hearing = new class'HearingNotifier';
	assert(hearing != None);
	
	hearing.addRef();
	hearing.InitializeHearingNotifier(self);
}

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

protected function CreateShotNotifier()
{
    shotNotifier = new class'ShotNotifier';
    assert(shotNotifier != None);

    shotNotifier.InitializeShotNotifier(self);
}

//---------------------------------------------------------------------
// Low-Level Vision Implementation

// Register to be notified when we see / no longer see a Pawn
function RegisterVisionNotification(IVisionNotification Registrant)
{
    vision.RegisterVisionNotification(Registrant);
}

function UnregisterVisionNotification(IVisionNotification Registrant)
{
	if ( vision != None )
		vision.UnregisterVisionNotification(Registrant);
}

//---------------------------------------------------------------------
// Low-Level Hearing Implementation

// Register to be notified when we see / no longer see a Pawn
function RegisterHearingNotification(IHearingNotification Registrant)
{
    hearing.RegisterHearingNotification(Registrant);
}

function UnregisterHearingNotification(IHearingNotification Registrant)
{
	if ( hearing != None )
	    hearing.UnregisterHearingNotification(Registrant);
}

//---------------------------------------------------------------------
// Low-Level Shot Notification Implementation

// Register to be notified when we fire a shot
function RegisterShotNotification(IShotNotification Registrant)
{
	shotNotifier.RegisterShotNotification(Registrant);
}

function UnregisterShotNotification(IShotNotification Registrant)
{
	shotNotifier.UnregisterShotNotification(Registrant);
}

event OnShotFired( Projectile projectile )
{
    shotNotifier.OnShotFired( projectile );
}

function Died(Controller Killer, class<DamageType> damageType, vector HitLocation)
{
	Super.Died( Killer, damageType, HitLocation );

	cleanupAI();
	
	if (Killer!=None)
	    squadCleanupOnDeath( Killer.Pawn, damageType, HitLocation );
	else
	    squadCleanupOnDeath( None, damageType, HitLocation );
}

// returns true if cleanup should be deferred
event bool cleanupAI()
{
	local int i;

	if ( bDeferredAICleanup )
		return true;

	level.AI_Setup.shutDownVision( self );	// (handles updating enemy lists of squad mates)

	// make sure the outer of any classes is no longer pointing to this (soon to be destroyed) actor
	for ( i = 0; i < abilities.length; ++i )
	{
		level.AI_Setup.makeSafeOuter( self, abilities[i] );
	}

	// make sure the outer of any classes is no longer pointing to this (soon to be destroyed) actor
	for ( i = 0; i < goals.length; ++i )
	{
		level.AI_Setup.makeSafeOuter( self, goals[i] );
	}

	return false;
}

function squadCleanupOnDeath( Pawn InstigatedBy, class<DamageType> damageType, vector HitLocation )
{
	if ( m_squad != None )
	{
		m_squad.memberDied( self, InstigatedBy, damageType, HitLocation );	// let squad know a member died
	}
}

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

private function CleanupSensing()
{
    if (Vision != None)
    {
        Vision.CleanupVisionNotifier();
        Vision.Release();
        Vision = None;
    }
 
    if (Hearing != None)
    {
        Hearing.Release();
        Hearing = None;
    }

	if (shotNotifier != None)
	{
		shotNotifier.Delete();
		shotNotifier = None;
	}
}

//---------------------------------------------------------------------
// enumTeamInfo
// List all team info objects in the editor
function enumTeamInfo(Engine.LevelInfo l, out Array<TeamInfo> s)
{
	local TeamInfo t;

	ForEach l.AllActors(class'TeamInfo', t)
	{
		s[s.Length] = t;
	}
}

//---------------------------------------------------------------------
// List all SquadInfo objects in the editor

function enumSquadInfo(Engine.LevelInfo l, out Array<SquadInfo> s)
{
	local SquadInfo t;

	ForEach l.AllActors(class'SquadInfo', t)
	{
		s[s.Length] = t;
	}
}

//---------------------------------------------------------------------
// displayActorLabel
// Display an actor reference's label in the editor
function string displayActorLabel(Actor t)
{
	return string(t.label);
}

//---------------------------------------------------------------------
// team
// Get the Rook's team object
simulated function TeamInfo team()
{
	return m_team;
}

simulated function Name getTeamLabel()
{
	if (team() != None)
		return team().label;

	return '';
}

//---------------------------------------------------------------------
// setTeam
// Sets the Rook's team object
function setTeam(TeamInfo info)
{
	local TeamInfo oldTeam;

	oldTeam = m_team;

	m_team = info;

	if (oldTeam != info)
	{
		onTeamChange();
		level.notifyListenersTeamChanged( self );
	}
}

//---------------------------------------------------------------------
// isFriendly
// returns true if this rook is friendly to the given rook
// team values of "None" are defined to be friendly to everyone else
// if rook is a vehicle, takes team of occupant into account (use team version of isFriendly if you don't want this)
simulated event bool isFriendly(Rook otherGuy)
{
	local TeamInfo tiThisGuy;
	local TeamInfo tiOtherGuy;

	if (otherGuy == None)
		return true;

	tiThisGuy = getControllingCharacterTeam();
	tiOtherGuy = otherGuy.getControllingCharacterTeam();

	if (tiThisGuy == None || tiOtherGuy == None)
		return true;

	return tiThisGuy.isFriendly( tiOtherGuy );
}

//---------------------------------------------------------------------
// isRepairFriendly
// returns true if this rook is friendly to the given rook with respect to repairing
// team values of "None" are defined to be friendly to everyone else

simulated function bool canBeRepairedBy(Rook otherGuy)
{
	return isFriendly(otherGuy);
}

//---------------------------------------------------------------------
// Get the Rook's squad object

function SquadInfo squad()
{
	return m_squad;
}

//---------------------------------------------------------------------
// Sets the Rook's squad object

function setSquad(SquadInfo squad)
{
	// TODO: remove from squad if already in one

	m_squad = squad;

	if (squad != None)
		squad.addToSquad( self );
}

//---------------------------------------------------------------------
// getAlertnessLevel

function AlertnessLevels getAlertnessLevel()
{
	return alertness;
}

//---------------------------------------------------------------------
// setAlertnessLevel
// Sets the Rook's alertness level
// note: you should always set the alertness through this function
// because child classes (character) override this method and perform
// additional functionality to keep animations in sync with the alert level!
function setAlertnessLevel(AlertnessLevels alertness)
{
	self.alertness = alertness;
}

//---------------------------------------------------------------------
// sets AI to AILOD_NORMAL - deactivation checks suspended for specified number of ticks

event setLimitedTimeLODActivation( int ticksToKeepActivated )
{
	if ( AI_LOD_Level > AILOD_NONE && AI_LOD_Level < AILOD_NORMAL )
	{
		level.AI_Setup.setAILOD( self, AILOD_NORMAL );
		AI_LOD_deactivation_exemption_ticks = ticksToKeepActivated;
	}
}

//---------------------------------------------------------------------
// check whether to put a new position value into pastPositions array

native function updatePastPositions( float deltaSeconds );

//---------------------------------------------------------------------
// Returns the rook's average velocity over the last
// N_PAST_POSITIONS * PAST_POSITION_UPDATE_INTERVAL seconds

native function Vector averageVelocity();

//---------------------------------------------------------------------
// Estimate where character will be in t seconds

native function Vector predictedLocation( float t );

//---------------------------------------------------------------------
// Estimate where character will be in t seconds (while on the ground)

native function Vector groundPredictedLocation( float t );

//---------------------------------------------------------------------
// Vision debug

function DrawVisionCone(HUD DrawTarget)
{
	local float fDistance, fConeRadius, fRadians, fI, fPeripheralVisionAngle;
	local array<vector> VisionConePoints;
	local int i;
	local Vector ViewLocation, ViewDirection, X, Y, Z;
	local Coords ViewCoords;
	local color CurrentColor;

	fPeripheralVisionAngle = Acos(PeripheralVision);

	fDistance = Square(SightRadius) * cos(fPeripheralVisionAngle * 0.5);
	fConeRadius = tan(fPeripheralVisionAngle * 0.5) * fDistance;

	ViewDirection   = GetViewDirection();
	ViewDirection.Z = 0.0;

	GetAxes(rotator(ViewDirection), X, Y, Z);

	ViewLocation    = GetViewPoint();

	ViewCoords.Origin = ViewLocation;
	ViewCoords.XAxis  = X;
	ViewCoords.YAxis  = Y;
	ViewCoords.ZAxis  = Z;

    // @TODO:  Add in Color based on something
    CurrentColor = class'Canvas'.Static.MakeColor(200,155,0);

	for(i=0; i<8; ++i)
	{
		fI       = i;
		fRadians = (fI * Pi * 2.0) / 8;

		VisionConePoints[i]   = vect(0,0,0);
		VisionConePoints[i].X = fDistance;
		VisionConePoints[i].Y = cos(fRadians) * fConeRadius;
		VisionConePoints[i].Z = sin(fRadians) * fConeRadius;

//		log(self@"fRadians: "@fRadians@" i: "@i@" fI: "@fI@" VisionConePoints: "@VisionConePoints[i].X@" "@VisionConePoints[i].Y@" "@VisionConePoints[i].Z);

		VisionConePoints[i] = VisionConePoints[i] >> rotator(GetViewDirection());
//		log("VisionConePoints: "@VisionConePoints[i].X@" "@VisionConePoints[i].Y@" "@VisionConePoints[i].Z);

		DrawTarget.Draw3DLine(ViewLocation, VisionConePoints[i], CurrentColor);
	}
}

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

function displayTyrionDebugHeader()
{
	AddDebugMessage( Label @ "(LOD:" $ AI_LOD_Level $ ")", class'Canvas'.static.MakeColor(0,200,0) );
}

function displayEnemiesList()
{
	local int i;
	local string displayString;
	local array<Pawn> enemyList;

	if ( vision == None )
		return;

	// enemies in seenlist
	enemyList = vision.getEnemyList();

	for ( i = 0; i < enemyList.length; ++i )
	{
		displayString $= enemyList[i].label $ " ";
	}

	AddDebugMessage( displayString, class'Canvas'.static.MakeColor(255,0,0) );

	// todo: enemies in squadSeenList

	// enemy sensor list
	displayString = "";

	enemyList = level.AI_Setup.getEnemyListFromSensor( self );

	for ( i = 0; i < enemyList.length; ++i )
	{
		displayString $= enemyList[i].label $ " ";
	}

	AddDebugMessage( displayString, class'Canvas'.static.MakeColor(200,0,0) );
}

//---------------------------------------------------------------------
// script version of native function
// (used in AI debugging)

native function bool IsInVisionCone( Actor Other, float SightRadius );

//---------------------------------------------------------------------
// wrapper function for playing effects

simulated function bool PlayEffect(String effect, optional String tag, optional Actor other, optional Material material, optional Vector location, optional Rotator rotator)
{
    if (effectLogging)
    {
        if (tag=="")
            log("play effect: "$effect);
        else
            log("play effect: "$effect$" ("$tag$")");
    }
    
	return TriggerEffectEvent(Name(effect), other, material, location, rotator, false, false, none, Name(tag)); //self, Name(tag));
}

simulated function bool StopEffect(String effect)
{
    if (effectLogging)
        log("stop effect: "$effect);
    
	UnTriggerEffectEvent(Name(effect));
	
	return true;            // how to detect if effect was actually stopped?
}

simulated function bool StartLoopingEffect(String effect, optional String tag, optional Actor other, optional Material material, optional Vector location, optional Rotator rotator)
{
	if (PlayEffect(effect$"Loop", tag, other, material, location, rotator))
    {
    	PlayEffect(effect$"Start", tag, other, material, location, rotator);

        loopingEffects[loopingEffects.length] = effect;
        
        if (effectLogging)
            log("started looping effect: "$effect$"["$loopingEffects.length-1$"]");

    	return true;
    }
    
    return false;
}

simulated function bool EffectIsLooping(String effect)
{
    local int i;

    for (i=0; i<loopingEffects.length; i++)
    {
        if (loopingEffects[i]~=effect)
            return true;
    }
    
    return false;
}

simulated function bool StopLoopingEffect(String effect)
{
    // exit if effect is not in looping sounds array

    local int i, index;
    
    if (EffectIsLooping(effect))
    {
	    StopEffect(effect$"Loop");
	    PlayEffect(effect$"Stop");
	    
	    if (effectLogging)
	        log("stopping loop: "$effect);
	    
	    // remove from looping effects array
	    
        index = -1;

        for (i=0; i<loopingEffects.length; i++)
        {
            if (loopingEffects[i]~=effect)
            {
                index = i;
                break; 
            }
        }
        
        if (index>=0)
            loopingEffects.remove(index, 1);
        
	    return true;
	}
	else
	{   
	    if (effectLogging)
	        log(effect$" was not looping. no need to stop it");
	
    	return false;
    }
}

// callbacks

function OnEffectInitialized(Actor effect)
{
    //log("effect initialized: "$effect);
}

function OnEffectStarted(Actor effect)
{
    /*
    local int i, index;
    local IGSoundEffectsSubsystem.SoundInstance sound;
    
    sound = IGSoundEffectsSubsystem.SoundInstance(effect);
    
    if (sound==None || sound.isEndPredictable)
        return;
        
    index = loopingSounds.length;

    loopingSounds[index] = sound.SchemaName;

    log("looping sound started: "$sound.SchemaName$" ["$index$"]");
    
    log("************************");
    for (i=0; i<loopingSounds.length; i++)
        log(i$": "$loopingSounds[i]);
    log("************************");
    */
}

function OnEffectStopped(Actor effect, bool completed)
{
    /*
    local int i, index;
    local IGSoundEffectsSubsystem.SoundInstance sound;
    
    sound = IGSoundEffectsSubsystem.SoundInstance(effect);
                       
    if (sound==None || sound.isEndPredictable)
        return;
        
    index = -1;

    for (i=0; i<loopingSounds.length; i++)
    {
        if (loopingSounds[i]==sound.SchemaName)
        {
            index = i;
            break; 
        }
    }
    
    if (index>=0)
    {
        log("looping sound stopped: "$sound.SchemaName$" ["$index$"]");
        loopingSounds.remove(index, 1);
    }
    else
        log("stopped sound not in looping sounds array: "$sound.SchemaName);
    
    log("************************");
    for (i=0; i<loopingSounds.length; i++)
        log(i$": "$loopingSounds[i]);
    log("************************");
    */
}

//---------------------------------------------------------------------
// ChunkUp
simulated function ChunkUp( Rotator HitRotation, class<DamageType> D ) 
{
}

//
// This is the main version of GetRadarInfoClass, because most items to be 
// displayed on the radar will be of type rook
//
simulated function class GetRadarInfoClass()
{
	return radarInfoClass;
}

//
// Returns the label of the killer corrsponding to this Rook.
//
simulated function Name getKillerLabel()
{
	return label;
}

//=====================================================================

defaultproperties
{
	bNetInitialRotation			= true
	bCanBeBaseForPawns			= true
	bIgnoreForces				= true
	
	bBlockHavok					= true

	// No longer any need for LandMovementState
	LandMovementState			= ""

	bCanBeSensed				= true
	bIsDetectableByEnemies		= true

	bCanRepair					= false
	DrawType					= DT_Mesh
//	hudType						= "legacy_Gameplay.LegacyHUD"
//	hudType						= "TribesGUI.TribesHUD"

	bShowTyrionCharacterDebug	= false
	bShowTyrionMovementDebug	= false
	bShowTyrionWeaponDebug		= false
	bShowNavigationDebug		= false
	logNavigationSystem			= false
	logTyrion					= false
	logDLM						= false
	logAlertnessChanges			= false
	bShowLOADebug				= false
	bShowJSDebug				= false
	bAcceptsProjectors			= false

	AI_LOD_Level				= AILOD_NONE
	AI_LOD_LevelMP				= AILOD_NONE
	AI_LOD_ActivationDistance	= 6000
	AI_LOD_DeactivationDistance = 8000
	bAIThreat					= true
	shotAngularDeviation		= 0
	shotAngularDeviationMP		= 0
	shotLeadAbility				= (Min=1,Max=1)
	shotLeadAbilityMP			= (Min=1,Max=1)
	reactionDelay				= 0
	reactionDelayMP				= 0
	tickTimeUpdateRange			= (Min=0.095,Max=0.105)
	bUnobstructedLOF			= true

	// default vision values for vehicles and vehicleMountedTurrets
	peripheralVision			= 0.1				// nearly 180 degrees
	peripheralVisionZAngle		= 0.7854			// 45 degrees up/down
	SightRadius					= 10000.0
	SightRadiusToPlayer			= 12000.0
	VisionUpdateRange			= (Min=0.4,Max=0.6)
	visionMemory				= 15.0

	alertness					= ALERTNESS_Neutral

	radarInfoClass				= class'Gameplay.RadarInfo'

	ShadowLightDistance			= 1200
	MaxShadowTraceDistance		= 600

	teamDamagePercentage		= 0.0
	teamSelfIllumSkinName		= "BaseLumNeutralPanner"

	grapplerRetentionScale      = 1.0
	bAlwaysMarked				= false
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: �t 9.9.2004 16:25:32.000 - Creation time: st 23.5.2018 00:10:46.801 - Created with UnCodeX