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

UTGame.UTOnslaughtGame


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
/**
 * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
 */
class UTOnslaughtGame extends UTTeamGame
	abstract;

var array<UTOnslaughtObjective> PowerNodes;
var UTOnslaughtPowerCore PowerCore[2];

var float OvertimeCoreDrainPerSec;
var config bool bSwapSidesAfterReset;
var bool bSidesAreSwitched;

var bool	bSpawnNodeSelected;		/** temporarily set true if player had chosen his start position, to prevent him from being teleported to a super vehicle */

/** Holds refs to the two orbs */
var UTOnslaughtFlag Orbs[2];

var UTGameObjective SelectedStartNode;

function InitGameReplicationInfo()
{
	local UTOnslaughtMapInfo OnslaughtInfo;

	Super.InitGameReplicationInfo();

	// tell GRI what link setup we're using to replicate to clients
	OnslaughtInfo = UTOnslaughtMapInfo(WorldInfo.GetMapInfo());
	if (OnslaughtInfo != None)
	{
		UTOnslaughtGRI(WorldInfo.GRI).LinkSetupName = OnslaughtInfo.GetActiveSetupName();
	}
}

event PostLogin(PlayerController PC)
{
	Super.PostLogin(PC);

	UpdateNodePlayerCountRequirements(false);
}

event Logout(Controller Exiting)
{
	Super.Logout(Exiting);

	UpdateNodePlayerCountRequirements(false);
}

function UTBot AddBot(optional string BotName, optional bool bUseTeamIndex, optional int TeamIndex)
{
	local UTBot B;

	B = Super.AddBot(BotName, bUseTeamIndex, TeamIndex);
	UpdateNodePlayerCountRequirements(false);
	return B;
}

function PostSeamlessTravel()
{
	Super.PostSeamlessTravel();
	UpdateNodePlayerCountRequirements(false);
}

function ViewObjective(PlayerController PC)
{
	local UTOnslaughtFlag Orb;

	if ( Orbs[0] == None )
	{
		ForEach DynamicActors(class'UTOnslaughtFlag', Orb)
		{
			if ( Orb.Team != None )
			{
				Orbs[Orb.Team.TeamIndex] = Orb;
			}
		}
	}	
	if ( (Orbs[0] == None) || (Orbs[1] == None) )
	{
		return;
	}
	if (PC.ViewTarget != none &&
	      (PC.ViewTarget == Orbs[0] || (PC.ViewTarget == Orbs[0].Holder) || PC.ViewTarget == Orbs[0].HomeBase) )
	{
		PC.SetViewTarget( Orbs[1].HomeBase.GetBestViewTarget() );
		if ( UTPlayerController(PC) != None )
		{
			UTPlayerController(PC).ClientSetBehindView(true);
		}
	}
	else
	{
		PC.SetViewTarget( Orbs[0].HomeBase.GetBestViewTarget() );
		if ( UTPlayerController(PC) != None )
		{
			UTPlayerController(PC).ClientSetBehindView(true);
		}
	}
}

/** update the state of nodes with player count requirements because the number of players in the game has changed */
function UpdateNodePlayerCountRequirements(bool bAllowDuringGame)
{
	local int i;
	local UTOnslaughtNodeObjective Node;

	if (!GameReplicationInfo.bMatchHasBegun || bAllowDuringGame || WorldInfo.IsPlayInEditor())
	{
		for (i = 0; i < PowerNodes.length; i++)
		{
			Node = UTOnslaughtNodeObjective(PowerNodes[i]);
			if (Node != None && !Node.IsA('UTOnslaughtPowerCore') && Node.MinPlayerCount > 0 && (Node.bStandalone || Node.NumLinks > 0))
			{
				if (NumPlayers + NumBots >= Node.MinPlayerCount)
				{
					if (Node.bIsDisabled)
					{
						Node.SetInitialState();
					}
				}
				else if (!Node.bIsDisabled)
				{
					Node.GotoState('DisabledNode');
				}
			}
		}
	}
}

// Returns whether a mutator should be allowed with this gametype
static function bool AllowMutator( string MutatorClassName )
{
	if (MutatorClassName ~= "UTGame.UTMutator_NoOrbs")
	{
		// No Orbs mutator only for Warfare
		return true;
	}
	if ( (MutatorClassName ~= "UTGame.UTMutator_Instagib") || (MutatorClassName ~= "UTGame.UTMutator_WeaponsRespawn")
		|| (MutatorClassName ~= "UTGame.UTMutator_LowGrav") )
	{
		return false;
	}
	return Super.AllowMutator(MutatorClassName);
}

function bool DominatingVictory()
{
	if ( Teams[0].Score == 0 )
	{
		return (PowerCore[1].Health >= PowerCore[1].default.DamageCapacity);
	}
	else if ( Teams[1].Score == 0 )
	{
		return (PowerCore[0].Health >= PowerCore[0].default.DamageCapacity);
	}
	return false;
}

/** return a value based on how much this pawn needs help */
function int GetHandicapNeed(Pawn Other)
{
	local int HealthDifference;

	if ( (Other.PlayerReplicationInfo == None) || (Other.PlayerReplicationInfo.Team == None) )
	{
		return 0;
	}

	// base handicap on how far team is behind in powercore health
	HealthDifference = PowerCore[1 - Other.PlayerReplicationInfo.Team.TeamIndex].Health - PowerCore[Other.PlayerReplicationInfo.Team.TeamIndex].Health;
	if (  HealthDifference < 10 )
	{
		// team is ahead, or close
		return 0;
	}
	return HealthDifference/10;
}

/**
In Onslaught, vehicle factories are activated by active powernodes
*/
function ActivateVehicleFactory(UTVehicleFactory VF)
{
	VF.bStartNeutral = false;
}

event InitGame(string Options, out string ErrorMessage)
{
	local UTOnslaughtObjective O;
	local string LinkSetupName;
	local UTOnslaughtMapInfo OnslaughtInfo;

	Super.InitGame(Options, ErrorMessage);

	foreach AllActors(class'UTOnslaughtObjective', O)
	{
		// Register all the PowerNodes
		PowerNodes[PowerNodes.length] = O;
	}

	// set up startup link setup, if any
	OnslaughtInfo = UTOnslaughtMapInfo(WorldInfo.GetMapInfo());
	if (OnslaughtInfo != None)
	{
		// if we are in the editor, use the LD specified preview setup
		if (OnslaughtInfo.EditorPreviewSetup != 'None')
		{
			OnslaughtInfo.ApplyLinkSetup(OnslaughtInfo.EditorPreviewSetup);
		}
		else
		{
			LinkSetupName = ParseOption(Options, "LinkSetup");
			OnslaughtInfo.ApplyLinkSetup((LinkSetupName != "") ? name(LinkSetupName) : 'Default');
		}
	}

	SetPowerCores();
	FindCloseActors();

	if (PowerNodes.Length == 0)
	{
		LogInternal("Onslaught: Level doesn't have any PowerNodes!",'Error');
	}
}

function CreateTeam(int TeamIndex)
{
	Super.CreateTeam(TeamIndex);

	if (TeamIndex < ArrayCount(Teams) && TeamIndex < ArrayCount(PowerCore))
	{
		Teams[TeamIndex].HomeBase = PowerCore[TeamIndex];
	}
}

/* FindCloseActors()
Associate certain actor classes with neares Onslaught Objective
*/
function FindCloseActors()
{
	local Actor A;
	local UTOnslaughtObjective O;
	local UTOnslaughtPowerCore ReverseCore;
	local UTOnslaughtNodeObjective Node;
	local int i;

	for (i = 0; i < PowerNodes.Length; i++)
	{
		PowerNodes[i].InitCloseActors();
	}

	if ( PowerCore[0].bReverseForThisCore )
		ReverseCore = PowerCore[0];
	else if ( PowerCore[1].bReverseForThisCore )
		ReverseCore = PowerCore[1];

	ForEach AllActors(class 'Actor', A)
	{
		if ( PlayerStart(A) != None )
		{
			O = ClosestObjectiveTo(A);
			O.PlayerStarts[O.PlayerStarts.Length] = PlayerStart(A);
			if ( UTOnslaughtNodeObjective(O) != None )
				UTOnslaughtNodeObjective(O).bIsTeleportDestination = true;
		}
		else if ( UTVehicleFactory(A) != None )
		{
			UTVehicleFactory(A).AddToClosestObjective();
			UTVehicleFactory(A).ReverseObjective = ReverseCore;
		}
		else if (UTOnslaughtNodeEnhancement(A) != None)
		{
			if (UTOnslaughtNodeEnhancement(A).ControllingNode == None)
			{
				UTOnslaughtNodeEnhancement(A).SetControllingNode(ClosestNodeTo(A));
			}
		}
		else if(UTDeployableNodeLocker(A) != none)
		{
			UTDeployableNodeLocker(A).AddToClosestObjective();
		}
		else if (UTOnslaughtNodeTeleporter(A) != None)
		{
			Node = ClosestNodeTo(A);
			Node.NodeTeleporters[Node.NodeTeleporters.length] = UTOnslaughtNodeTeleporter(A);
		}
	}
}

/* SetPowerCores()
Find the Red and Blue team PowerCores
Set the distance in hops from every PowerNode to each powercore
*/
function SetPowerCores()
{
	local int i;
	local int CoreCnt, PrefTeam;
	local UTOnslaughtPowerCore PC;
	local UTOnslaughtNodeObjective Node;
	local bool bTooManyCores;
	local byte MaxDistance, DesiredDistance;

	for (i = 0; i < ArrayCount(PowerCore); i++)
	{
		PowerCore[i] = None;
	}

	CoreCnt = 0;

	// Find the two powercores
	for (i=0; i<PowerNodes.Length; i++)
	{
		PC = UTOnslaughtPowerCore(PowerNodes[i]);
		if ( PC != None  )
		{
			if (CoreCnt < 2)
			{
				// figure out the team
				PrefTeam = bSidesAreSwitched ? 1 - CoreCnt : CoreCnt;

				// If this core's slot is taken, move the person there
				if ( PowerCore[PrefTeam] != None )
				{
					PowerCore[1-PrefTeam] = PowerCore[PrefTeam];
					PowerCore[1-PrefTeam].DefenderTeamIndex = 1-PrefTeam;
				}

				PowerCore[PrefTeam] = PC;
				PowerCore[PrefTeam].DefenderTeamIndex = PrefTeam;
				if (Teams[PrefTeam] != None)
				{
					Teams[PrefTeam].HomeBase = PC;
				}
			}
			else
			{

				// If we have more than 2 cores, flag it for a warning, but
				// also reset the core just in case :)

				bTooManyCores = true;
				PC.Reset();
			}

			CoreCnt++;
		}

		// clear core distance - will be reinitialized in the PowerCores' InitializeForThisRound()
		PowerNodes[i].FinalCoreDistance[0] = 255;
		PowerNodes[i].FinalCoreDistance[1] = 255;
		// initialize links - make sure they are all two way
		Node = UTOnslaughtNodeObjective(PowerNodes[i]);
		if (Node != None)
		{
			Node.InitLinks();
		}

	}

	PowerCore[0].Reset();
	PowerCore[0].InitializeForThisRound(0);
	PowerCore[1].Reset();
	PowerCore[1].InitializeForThisRound(1);

	// init core distance for standalone nodes using StandaloneSpawnPriority, since the cores won't be linked to us so it won't get set normally
	MaxDistance = Max(PowerCore[0].FinalCoreDistance[1], PowerCore[1].FinalCoreDistance[0]) - 1;
	for (i = 0; i < PowerNodes.length; i++)
	{
		Node = UTOnslaughtNodeObjective(PowerNodes[i]);
		if (Node != None && Node.bStandalone)
		{
			DesiredDistance = (Node.StandaloneSpawnPriority != 255) ? Node.StandaloneSpawnPriority : MaxDistance;
			Node.SetCoreDistance(0, DesiredDistance);
			Node.SetCoreDistance(1, DesiredDistance);
		}
	}

	if (bTooManyCores)
	{
		LogInternal("!! TOO MANY CORES FOUND IN MAP (found "$CoreCnt$" expect no more than 2) !!");
	}

}

/* UpdateLinks()
determine which powernodes are severed
*/
function UpdateLinks()
{
	local int i;
	local UTOnslaughtNodeObjective N;

	for (i = 0; i < PowerNodes.Length; i++)
	{
		N = UTOnslaughtNodeObjective(PowerNodes[i]);
		if ( N != None )
		{
			N.bWasSevered = N.bSevered;
			N.bSevered = !N.bStandalone;
		}
	}

	CheckSevering(PowerCore[0], 0);
	CheckSevering(PowerCore[1], 1);

	for (i = 0; i < PowerNodes.Length; i++)
	{
 		N = UTOnslaughtNodeObjective(PowerNodes[i]);
		if ( N != None  && N.bSevered && !N.bWasSevered )
			N.Sever();
	}
}

function CheckSevering(UTOnslaughtNodeObjective PC, int TeamIndex)
{
	local int i;

	PC.bSevered = False;
	if ( !PC.IsActive() )
	{
		return;
	}
	for (i = 0; i < PC.NumLinks; i++)
	{
		if (PC.LinkedNodes[i] != None && PC.LinkedNodes[i].bSevered && PC.LinkedNodes[i].DefenderTeamIndex == TeamIndex)
		{
			CheckSevering(PC.LinkedNodes[i], TeamIndex);
		}
	}
}


function UTOnslaughtNodeObjective ClosestNodeTo(Actor A)
{
	local float Distance, BestDistance;
	local UTOnslaughtNodeObjective Node, Best;
	local int i;

	for (i = 0; i < PowerNodes.Length; i++)
	{
		Node = UTOnslaughtNodeObjective(PowerNodes[i]);
		if (Node != None)
		{
			Distance = VSize(A.Location - PowerNodes[i].Location);
			if (Best == None || Distance < BestDistance)
			{
				BestDistance = Distance;
				Best = Node;
			}
		}
	}
	return Best;
}

function UTOnslaughtObjective ClosestObjectiveTo(Actor A)
{
	local float Distance, BestDistance;
	local UTOnslaughtObjective Best;
	local int i;

	for ( i=0; i<PowerNodes.Length; i++ )
	{
		if ( PowerNodes[i].bAssociatePlayerStarts )
		{
			Distance = VSize(A.Location - PowerNodes[i].Location);
			if ( (Best == None) || (Distance < BestDistance) )
			{
				BestDistance = Distance;
				Best = PowerNodes[i];
			}
		}
	}
	return Best;
}

function bool ShouldReset(Actor ActorToReset)
{
	return ( Super.ShouldReset(ActorToReset) && !ActorToReset.IsA('UTOnslaughtObjective') && !ActorToReset.IsA('TeamInfo') &&
		!ActorToReset.IsA('PlayerReplicationInfo') );
}

function Reset()
{
	local int i;
	local UTPlayerReplicationInfo PRI;

	// we reset PowerNodes and PowerCores after everything else because their reset might cause
	// vehiclefactories, etc to activate and spawn new actors that we don't want to affect
	if (bSwapSidesAfterReset && !PowerCore[0].bNoCoreSwitch && !PowerCore[1].bNoCoreSwitch)
	{
		bSidesAreSwitched = !bSidesAreSwitched;
	}

	SetPowerCores();

	for (i = 0; i < PowerNodes.length; i++)
	{
		// powercores are reset in SetPowerCores()
		if (UTOnslaughtPowerCore(PowerNodes[i]) == None)
		{
			PowerNodes[i].Reset();
		}
	}

	FindCloseActors();

	UpdateNodePlayerCountRequirements(true);

	Super.Reset();

	// reset per-life PRI properties
	for (i = 0; i < GameReplicationInfo.PRIArray.length; i++)
	{
		PRI = UTPlayerReplicationInfo(GameReplicationInfo.PRIArray[i]);
		if (PRI != None)
		{
			PRI.Spree = 0;
			PRI.ResetHero();
			PRI.bHasBeenHero = false;
		}
	}

	for (i = 0; i < ArrayCount(Teams); i++)
	{
		Teams[i].AI.SetObjectiveLists();
	}
}

State MatchInProgress
{
	event Timer()
	{
		local int i, TeamNodes[2], TotalNodes;
		local float OvertimeDrain;

		if (bOverTime)
		{
			for (i = 0; i < PowerNodes.Length; i++)
			{
				if (UTOnslaughtPowerNode(PowerNodes[i]) != None && !PowerNodes[i].bIsDisabled)
				{
					if (PowerNodes[i].IsActive() && PowerNodes[i].DefenderTeamIndex < 2)
					{
				    		TeamNodes[PowerNodes[i].DefenderTeamIndex]++;
				    	}
					TotalNodes++;
				}
			}


			for (i = 0; i < ArrayCount(PowerCore); i++)
			{
				OvertimeDrain = OvertimeCoreDrainPerSec - (OvertimeCoreDrainPerSec * float(TeamNodes[i]) / float(TotalNodes));
				PowerCore[i].Health -= OvertimeDrain;
				PowerCore[i].DamagePanels(OvertimeDrain, PowerCore[i].Location);
				PowerCore[i].UpdateDamageEffects(false);
				PowerCore[i].bForceNetUpdate = TRUE;
			}

			if ( (PowerCore[0].Health <= 0) && (PowerCore[1].Health <= 0) )
			{
				// DRAW
				ScoreDraw();
			}
			else
			{
				if (PowerCore[0].Health <= 0)
				{
					PowerCore[0].DisableObjective(None);
				}
				if (PowerCore[1].Health <= 0)
				{
					PowerCore[1].DisableObjective(None);
				}
			}
		}

		Super.Timer();
	}
}

function ScoreDraw()
{
	Teams[0].Score += 1;
	Teams[1].Score += 1;
	BroadcastLocalizedMessage( MessageClass, 4);
	CheckScore(PowerCore[0].LastDamagedBy);
	if ( !bGameEnded )
	{
		EndRound(PowerCore[0]);
	}
}

function MainCoreDestroyed(byte T)
{
	local int Score;

	Score = bOverTime ? 1 : 2;

	if (T == 1)
	{
		BroadcastLocalizedMessage( MessageClass, 0);
		Teams[0].Score += Score;
		Teams[0].bForceNetUpdate = TRUE;
		CheckScore(PowerCore[1].LastDamagedBy);
	}
	else
	{
		BroadcastLocalizedMessage( MessageClass, 1);
		Teams[1].Score += Score;
		Teams[1].bForceNetUpdate = TRUE;
		CheckScore(PowerCore[0].LastDamagedBy);
	}
	BroadcastLocalizedMessage( MessageClass, bOverTime ? 12 : 11);

	if ( !bGameEnded )
	{
		EndRound(PowerCore[T]);
	}
}

state MatchOver
{
	function FindNewObjectives(UTGameObjective DisabledObjective) {}

	function MainCoreDestroyed(byte T) {}
}

function bool CheckScore(PlayerReplicationInfo Scorer)
{
	if (CheckMaxLives(Scorer))
	{
		return false;
	}
	else if (GoalScore != 0 && (Teams[0].Score >= GoalScore || Teams[1].Score >= GoalScore))
	{
		EndGame(Scorer,"teamscorelimit");
		return true;
	}
	else
	{
		return false;
	}
}

function bool CheckEndGame(PlayerReplicationInfo Winner, string Reason)
{
	local Controller P;

	if (Reason ~= "TimeLimit")
	{
		// if we are doing automated perf testing then we have reached the end of the match and watch to exit so the perf logs are saved out
		if( bAutomatedPerfTesting )
		{
			if( bAutoContinueToNextRound == FALSE )
			{
				ConsoleCommand("EXIT");
			}
			foreach WorldInfo.AllControllers(class'Controller', P)
			{
				P.GameHasEnded();
			}
			return TRUE;
		}

		if ( !bOverTimeBroadcast )
		{
			StartupStage = 7;
			PlayStartupMessage();
			bOverTimeBroadcast = true;
		}

		return false;
	}

	return Super.CheckEndGame(Winner, Reason);
}

function SetEndGameFocus(PlayerReplicationInfo Winner)
{
	local Controller P;

	if ( Winner != None )
	{
		if (Winner.Team.TeamIndex == 0)
			EndGameFocus = PowerCore[1];
		else
			EndGameFocus = PowerCore[0];
	}
	if ( EndGameFocus != None )
		EndGameFocus.bAlwaysRelevant = true;

	foreach WorldInfo.AllControllers(class'Controller', P)
	{
		P.GameHasEnded(EndGameFocus, (P.PlayerReplicationInfo != None) && (P.PlayerReplicationInfo.Team == GameReplicationInfo.Winner) );
	}
}

/** returns whether a node with a flag at it should be prioritized for spawning members of Team */
function bool ShouldPrioritizeNodeWithFlag(byte Team, byte EnemyTeam, bool bEnemyCanAttackCore, controller Player)
{
	local UTPlayerController PC;

	PC = UTPlayerController(Player);
	if ( PC != None )
	{
		if ( PC.bNotUsingOrb )
		{
			return false;
		}
		if ( PC.AutoObjectivePreference == AOP_OrbRunner )
		{
			return true;
		}
		if ( PC.AutoObjectivePreference == AOP_Defend )
		{
			return PowerCore[EnemyTeam].PoweredBy(Team);
		}
	}
	return !PowerCore[EnemyTeam].PoweredBy(Team) && (UTBot(Player) != None || !TeamHasOrbRunner(Player));
}

function bool TeamHasOrbRunner(Controller Player)
{
	local Controller C;
	local UTPlayerReplicationInfo PRI;

	ForEach WorldInfo.AllControllers(class'Controller', C)
	{
		if ( WorldInfo.GRI.OnSameTeam(C, Player) )
		{
		  	PRI = UTPlayerReplicationInfo(C.PlayerReplicationInfo);
		  	if ( (PRI != None) && PRI.bHasFlag )
		  	{
				  return true;
		  	}
		  	if ( UTBot(C) != None )
		  	{
				  if ( UTBot(C).GetOrders() == 'Attack' )
				  return true;
		  	}
		  	else if ( (UTPlayerController(C) != None) && (UTPlayerController(C).AutoObjectivePreference == AOP_OrbRunner) )
		  	{
				  return true;
		  	}
		}
	}
	return false;
}

/** ChoosePlayerStart()
* Return the 'best' player start for this player to start from.  PlayerStarts are rated by RatePlayerStart().
* @param Player is the controller for whom we are choosing a playerstart
* @param InTeam specifies the Player's team (if the player hasn't joined a team yet)
* @returns NavigationPoint chosen as player start (usually a PlayerStart)
 */
function PlayerStart ChoosePlayerStart( Controller Player, optional byte InTeam )
{
	local PlayerStart BestStart;
	local float CoreDistA, CoreDistB, BestRating, NewRating;
	local byte Team, EnemyTeam;
	local UTGameObjective SelectedPC;
	local int i;
	local bool bTeammateFound, bPrioritizeNodeWithFlag, bEnemyCanAttackCore;
	local controller C;
	local UTOnslaughtNodeObjective Node;

	if ( (Player != None) && (Player.PlayerReplicationInfo != None) )
	{
		// use InTeam if player doesn't have a team yet
		Team = (Player.PlayerReplicationInfo.Team != None) ? byte(Player.PlayerReplicationInfo.Team.TeamIndex) : InTeam;

		//Use the powernode the player selected (if it's valid)
		if ( UTPlayerReplicationInfo(Player.PlayerReplicationInfo) != None )
		{
			SelectedPC = UTPlayerReplicationInfo(Player.PlayerReplicationInfo).GetStartObjective();
		}
	}
	else
	{
		Team = InTeam;
	}

	bSpawnNodeSelected = (SelectedPC != None);
	if (SelectedPC == None)
	{
		bEnemyCanAttackCore = PowerCore[Team].PoweredBy(1 - Team);
		EnemyTeam = Abs(Team - 1);
		bPrioritizeNodeWithFlag = ShouldPrioritizeNodeWithFlag(Team, EnemyTeam, bEnemyCanAttackCore, Player);
		if (bEnemyCanAttackCore && !bPrioritizeNodeWithFlag)
		{
			SelectedPC = PowerCore[Team];
		}
		else
		{
			// Find the Closest Controlled Node(s) to Enemy PowerCore.
			BestRating = 256;
			for (i = 0; i < PowerNodes.Length; i++)
			{
				if ( PowerNodes[i].ValidSpawnPointFor(Team) )
				{
					if (bPrioritizeNodeWithFlag)
					{
						// if Onslaught Flag sitting at a node with no teammate close by, chose that node
						Node = UTOnslaughtNodeObjective(PowerNodes[i]);
						if (Node != None && Node.FlagBase != None && Node.FlagBase.MyFlag != None && Node.FlagBase.MyFlag.IsNearlyHome())
						{
							// check if nearby teammate
							bTeammateFound = false;
							ForEach WorldInfo.AllControllers(class'Controller', C)
							{
								if ( C.bIsPlayer && (C.Pawn != None) && WorldInfo.GRI.OnSameTeam(Player,C)
									&& (VSizeSq(C.Pawn.Location - Node.FlagBase.Location) < 4000000) )
								{
									bTeammateFound = true;
									break;
								}
							}
							if ( !bTeammateFound )
							{
								SelectedPC = Node;
								bSpawnNodeSelected = true;
								break;
							}
						}
					}
					if (!bEnemyCanAttackCore)
					{
						// rating based first on link distance, then available vehicles
						NewRating = PowerNodes[i].GetSpawnRating(EnemyTeam);
						if ( NewRating < BestRating )
						{
							BestRating = NewRating;
							SelectedPC = PowerNodes[i];
						}
						else if ( NewRating == BestRating ) // If we have two nodes at equal link distance, we check geometric distance
						{
							CoreDistA = VSize(PowerCore[EnemyTeam].Location - PowerNodes[i].Location);
							CoreDistB = VSize(PowerCore[EnemyTeam].Location - SelectedPC.Location);
							if (CoreDistA < CoreDistB)
							{
								SelectedPC = PowerNodes[i];
							}
						}
					}
				}
			}

			// If no valid power node found, set to power core.
			if (SelectedPC == None)
			{
				SelectedPC = PowerCore[Team];
			}
		}
	}

	BestStart = BestPlayerStartAtNode(SelectedPC, Team, Player);
	if ( (BestStart == None) && (SelectedPC != PowerCore[Team]) )
	{
		BestStart = BestPlayerStartAtNode(PowerCore[Team], Team, Player);
	}
	return BestStart;
}

function PlayerStart BestPlayerStartAtNode(UTGameObjective SelectedPC, byte Team, Controller Player)
{
	local PlayerStart BestStart, P;
	local float BestRating, NewRating, GoodEnoughRating;
	local int i, RandStart;

	SelectedStartNode = SelectedPC;
	GoodEnoughRating = (SelectedPC.bUnderAttack) ? 60.0 : 30.0;

	// Avoid randomness for profiling.
	if( bFixedPlayerStart )
	{
		RandStart = 0;
	}
	// start at random point to randomize finding "good enough" playerstart
	else
	{
		RandStart = Rand(SelectedPC.PlayerStarts.Length);
	}

	for ( i=RandStart; i<SelectedPC.PlayerStarts.Length; i++ )
	{
		P = SelectedPC.PlayerStarts[i];
		NewRating = RatePlayerStart(P,Team,Player);
		if (SelectedPC.bUnderAttack && P.IsA('UTWarfarePlayerStart') && UTWarfarePlayerStart(P).bPrioritizeWhenUnderAttack)
		{
			NewRating += 30.0;
		}
		if (NewRating >= GoodEnoughRating)
		{
			// this PlayerStart is good enough
			return P;
		}
		if ( NewRating > BestRating )
		{
			BestRating = NewRating;
			BestStart = P;
		}
	}
	for ( i=0; i<RandStart; i++ )
	{
		P = SelectedPC.PlayerStarts[i];
		NewRating = RatePlayerStart(P,Team,Player);
		if (SelectedPC.bUnderAttack && P.IsA('UTWarfarePlayerStart') && UTWarfarePlayerStart(P).bPrioritizeWhenUnderAttack)
		{
			NewRating += 30.0;
		}
		if (NewRating >= GoodEnoughRating)
		{
			// this PlayerStart is good enough
			return P;
		}
		if ( NewRating > BestRating )
		{
			BestRating = NewRating;
			BestStart = P;
		}
	}
	return BestStart;
}

function UTWeaponLocker GetBestLocker(Pawn PlayerPawn)
{
	return (SelectedStartNode != None) ? SelectedStartNode.GetBestLocker() : None;
}

/** finds the closest node to the enemy powercore that has vehicles available according to the passed in array
 * may return None if no node with vehicles is available for that team
 * @param Player the Player we're choosing a node for
 * @param NumVehicleFactories
 */
function UTGameObjective GetClosestNodeToEnemyWithVehicles(Controller Player, const out array<int> NumVehicleFactories)
{
	local float CoreDistA, CoreDistB, BestRating, NewRating;
	local byte Team, EnemyTeam;
	local UTGameObjective SelectedNode;
	local int i;
	local bool bPrioritizeNodeWithFlag;
	local UTOnslaughtNodeObjective Node;

	Team = Player.GetTeamNum();
	EnemyTeam = Abs(Team - 1);
	bPrioritizeNodeWithFlag = ShouldPrioritizeNodeWithFlag(Team, EnemyTeam, false, Player);
	BestRating = 255;
	for (i = 0; i < PowerNodes.Length; i++)
	{
		if (NumVehicleFactories[i] > 0 && PowerNodes[i].ValidSpawnPointFor(Team))
		{
			NewRating = PowerNodes[i].FinalCoreDistance[EnemyTeam];
			if (bPrioritizeNodeWithFlag)
			{
				Node = UTOnslaughtNodeObjective(PowerNodes[i]);
				if (Node != None && Node.FlagBase != None && Node.FlagBase.myFlag != None && Node.FlagBase.myFlag.bHome)
				{
					NewRating -= 1000.0;
				}
			}
			if (NewRating < BestRating)
			{
				BestRating = NewRating;
				SelectedNode = PowerNodes[i];
			}
			else if (NewRating == BestRating) // If we have two nodes at equal link distance, we check geometric distance
			{
				CoreDistA = VSize(PowerCore[EnemyTeam].Location - PowerNodes[i].Location);
				CoreDistB = VSize(PowerCore[EnemyTeam].Location - SelectedNode.Location);
				if (CoreDistA < CoreDistB)
				{
					SelectedNode = PowerNodes[i];
				}
			}
		}
	}

	return SelectedNode;
}

function StartHumans()
{
	// start everyone, including bots, in the same pass so we can count them and match them up with the number of vehicles at all starting nodes
	StartAllPlayers();
}

function StartBots();

function StartAllPlayers()
{
	local Controller C;
	local PlayerController PC;
	local array<int> NumVehicleFactories;
	local int i;
	local UTPlayerReplicationInfo PRI;
	local UTBot B;

	// construct an array containing the number of vehicle factories at each node
	for (i = 0; i < PowerNodes.Length; i++)
	{
		NumVehicleFactories[i] = PowerNodes[i].VehicleFactories.length;
	}

	// spawn players, prioritizing spawning them at a node that has a vehicle available
	foreach WorldInfo.AllControllers(class'Controller', C)
	{
		if (C.bIsPlayer && C.Pawn == None)
		{
			if (bGameEnded)
			{
				return; // telefrag ended the game with ridiculous frag limit
			}
			else
			{
				PC = PlayerController(C);
				if (PC == None || PC.CanRestartPlayer())
				{
					PRI = UTPlayerReplicationInfo(C.PlayerReplicationInfo);
					if (PRI != None)
					{
						B  = UTBot(C);
						// bots first try to spawn at their objective
						if ( B != None && B.Squad != None && B.Squad.SquadObjective != None &&
							B.Squad.SquadObjective.ValidSpawnPointFor(B.GetTeamNum()) )
						{
							PRI.TemporaryStartObjective = B.Squad.SquadObjective;
							i = PowerNodes.Find(UTOnslaughtNodeObjective(PRI.TemporaryStartObjective));
						}
						// if player specified a start, just use that
						else if (PRI.StartObjective != None && PRI.StartObjective.ValidSpawnPointFor(C.GetTeamNum()))
						{
							i = PowerNodes.Find(UTOnslaughtNodeObjective(PRI.StartObjective));
						}
						else if (ShouldSpawnAtStartSpot(C))
						{
							i = PowerNodes.Find(ClosestNodeTo(C.StartSpot));
						}
						else
						{
							// otherwise, set temporary start to a node with vehicles
							PRI.TemporaryStartObjective = GetClosestNodeToEnemyWithVehicles(C, NumVehicleFactories);
							i = PowerNodes.Find(UTOnslaughtNodeObjective(PRI.TemporaryStartObjective));
						}

						if (i != INDEX_NONE)
						{
							NumVehicleFactories[i]--;
						}
					}

					if (PC != None || WorldInfo.NetMode == NM_Standalone)
					{
						RestartPlayer(C);
					}
					else
					{
						C.GotoState('Dead','MPStart');
					}
				}
			}
		}
	}
}

function ShowPathTo(PlayerController P, int TeamNum)
{
	local int i;
	local UTOnslaughtObjective Best;
	local float BestDist;

	for (i = 0; i < PowerNodes.Length; i++)
	{
		if ( (!PowerNodes[i].IsActive() || PowerNodes[i].DefenderTeamIndex != TeamNum) && PowerNodes[i].PoweredBy(TeamNum)
		     && (Best == None || VSize(P.Pawn.Location - PowerNodes[i].Location) < BestDist) )
		{
			Best = PowerNodes[i];
			BestDist = VSize(P.Pawn.Location - PowerNodes[i].Location);
		}
	}

	if (Best != None)
	{
		for (i = 0; i < Best.ShootSpots.length; i++)
		{
			if (Best.ShootSpots[i] != None)
			{
				Best.ShootSpots[i].bTransientEndPoint = true;
			}
		}
		if (P.FindPathToward(Best, false) != None)
		{
			Spawn(class'UTWillowWhisp', P,, P.Pawn.Location);
		}
	}
}

function bool ChangeTeam(Controller Other, int num, bool bNewTeam)
{
	local int i;
	local UTOnslaughtPRI PRI;
	local PlayerController PC;

	if (Super.ChangeTeam(Other, num, bNewTeam))
	{
		ForEach LocalPlayerControllers(class'PlayerController', PC)
		{
			if ( Other == PC )
			{
				//Update client side effects on PowerNodes to reflect which ones the player can go after changing teams
				for (i = 0; i < PowerNodes.length; i++)
					PowerNodes[i].UpdateEffects(false);
			}
			break;
		}

		PRI = UTOnslaughtPRI(Other.PlayerReplicationInfo);
		if (PRI != None)
		{
			PRI.StartObjective = None;
			PRI.TemporaryStartObjective = None;
		}

		return true;
	}

	return false;
}

function ScoreObjective(PlayerReplicationInfo Scorer, int Score)
{
	AddObjectiveScore(Scorer,Score);
}

function ScoreFlag(Controller Scorer, UTOnslaughtFlag TheFlag)
{
	local UTPlayerReplicationInfo ScorerPRI;

	ScorerPRI = UTPlayerReplicationInfo(Scorer.PlayerReplicationInfo);

	if (ScorerPRI.Team != TheFlag.Team)
	{
		BroadcastLocalizedMessage(TheFlag.MessageClass, 1 + 7 * TheFlag.Team.TeamIndex, ScorerPRI, None, TheFlag.Team);
		ScorerPRI.IncrementHeroMeter(2.0);
		ScorerPRI.IncrementEventStat('EVENT_RETURNEDORB');
	}
	else
	{
		ScorerPRI.IncrementHeroMeter(2.0);
		ScorerPRI.IncrementEventStat('EVENT_SCOREDORB');
		ScorerPRI.CheckHeroMeter();
	}
}

function bool NearGoal(Controller C)
{
	local UTOnslaughtPowerNode Node;

	Node = UTOnslaughtPowerNode(ClosestNodeTo(C.Pawn));
	return (Node != None && Node.GetTeamNum() != C.GetTeamNum() && Node.PoweredBy(C.GetTeamNum()) && VSize(C.Pawn.Location - Node.Location) < 1000.0);
}

/** @return whether the given Pawn is touching/walking on an Actor that allows node teleporting */
function bool IsTouchingNodeTeleporter(Pawn P, optional out UTOnslaughtNodeTeleporter Teleporter)
{
	local UTOnslaughtNodeTeleporter TestTeleporter;

	// allow if touching a teleporter
	TestTeleporter = UTOnslaughtNodeTeleporter(P.Base);
	if (TestTeleporter != None && WorldInfo.GRI.OnSameTeam(P, P.Base))
	{
		Teleporter = TestTeleporter;
		return true;
	}
	foreach P.TouchingActors(class'UTOnslaughtNodeTeleporter', Teleporter)
	{
		if (WorldInfo.GRI.OnSameTeam(P, Teleporter))
		{
			Teleporter = TestTeleporter;
			return true;
		}
	}

	return false;
}

function bool AllowClientToTeleport(UTPlayerReplicationInfo ClientPRI, Actor DestinationActor)
{

	local bool IsTouchingTeleporter;
	local UTOnslaughtNodeTeleporter Tp;
	local UTOnslaughtNodeObjective Obj;
	local int i;

	IsTouchingTeleporter = IsTouchingNodeTeleporter(Controller(ClientPRI.Owner).Pawn, Tp);
	Obj = UTOnslaughtNodeObjective(DestinationActor);
	if (IsTouchingTeleporter && Tp!=none && Obj != none && Obj.ValidSpawnPointFor(ClientPRI.Team.TeamIndex) )
	{
		for (i=0;i<Obj.NodeTeleporters.Length;i++)
		{
			if (Obj.NodeTeleporters[i] == tp)
			{
				return false;
			}
		}
	}

	return (Super.AllowClientToTeleport(ClientPRI, DestinationActor) && IsTouchingTeleporter);
}

function FindNewObjectives(UTGameObjective DisabledObjective)
{
	local UTPlayerController PC;

	Super.FindNewObjectives(DisabledObjective);

	// check recommended objectives for human players
	foreach WorldInfo.AllControllers(class'UTPlayerController', PC)
	{
		if ( (PC.LastAutoObjective == DisabledObjective) && (PC.bWasDefendingObjective != WorldInfo.GRI.OnSameTeam(PC.LastAutoObjective, PC)) )
		{
			PC.LastAutoObjective = None;
		}
		PC.CheckAutoObjective(true);
	}
}

/**
  * Adjust skill level in campaign based on relative health of cores
  */
function AdjustOnslaughtSkill()
{
	if ( UTGameReplicationInfo(GameReplicationInfo).bStoryMode && (PowerCore[0].Health > 0) && (PowerCore[1].Health > 0) )
	{
		AdjustedDifficulty = GameDifficulty + 1.25 * (PowerCore[0].Health - PowerCore[1].Health)/PowerCore[0].DamageCapacity;
	}
}

function Actor GetAutoObjectiveFor(UTPlayerController PC)
{
	local UTTeamInfo Team;
	local UTOnslaughtFlag Flag;
	local UTPlayerReplicationInfo PRI;
	local int i;
	local UTOnslaughtPowerNode Node;
	local UTDeployable Deployable;
	local UTGameObjective Result, AltResult;
	local float BestDist, NewDist;
	local UTPickupFactory BestPickup, Pickup;
	local UTVehicle V;
	local UTWeapon Weap;
	local UTOnslaughtTeamAI TeamAI;

	PRI = UTPlayerReplicationInfo(PC.PlayerReplicationInfo);
	if (PRI != None)
	{
		Flag = UTOnslaughtFlag(PRI.GetFlag());
	}

	// if carrying deployable, ask it to recommend an objective
	if ( PC.Pawn != None )
	{
		Deployable = UTDeployable(PC.Pawn.Weapon);
		if ( Deployable != None )
		{
			Result = Deployable.RecommendObjective(PC);
			if ( Result != None )
			{
				return Result;
			}
		}
	}

	// ask the team AI for the best objective
	Team = UTTeamInfo(PC.PlayerReplicationInfo.Team);
	if ( Team != None )
	{
		TeamAI = UTOnslaughtTeamAI(Team.AI);
	}
	if ( TeamAI != None )
	{
		switch (PC.AutoObjectivePreference)
		{
			case AOP_Disabled:
				return None;
			case AOP_OrbRunner:
				Result = TeamAI.GetPriorityPlayerAttackObjectiveFor(PC);

				// override with node
				if ( UTOnslaughtPowerNode(Result) == None )
				{
					AltResult = TeamAI.GetLeastDefendedPlayerObjective(PC);
					if ( UTOnslaughtPowerNode(AltResult) != None )
					{
						return AltResult;
					}
					for (i = 0; i < PowerNodes.length; i++)
					{
						Node = UTOnslaughtPowerNode(PowerNodes[i]);
						if (Node != None && Node.PoweredBy(PRI.Team.TeamIndex) && !WorldInfo.GRI.OnSameTeam(Node, PC) && !Node.bIsDisabled )
						{
							return Node;
						}
					}
					for (i = 0; i < PowerNodes.length; i++)
					{
						Node = UTOnslaughtPowerNode(PowerNodes[i]);
						if (Node != None && Node.PoweredBy(1 - PRI.Team.TeamIndex) && WorldInfo.GRI.OnSameTeam(Node, PC) && !Node.bIsDisabled )
						{
							return Node;
						}
					}
				}
				return Result;
			case AOP_NoPreference:
				if ( (WorldInfo.TimeSeconds - PowerCore[Team.TeamIndex].LastDamagedTime < 5.0)
					&& PowerCore[Team.TeamIndex].PoweredBy(1 - Team.TeamIndex) )
				{
					// defend core if it is still vulnerable
					return PowerCore[Team.TeamIndex];
				}
			case AOP_Attack:
				Result = TeamAI.GetPriorityPlayerAttackObjectiveFor(PC);
				// override with attackable node if player has orb
				if ( Flag != None )
				{
					if ( UTOnslaughtPowerNode(Result) == None )
					{
						for (i = 0; i < PowerNodes.length; i++)
						{
							Node = UTOnslaughtPowerNode(PowerNodes[i]);
							if (Node != None && Node.PoweredBy(PRI.Team.TeamIndex) && !WorldInfo.GRI.OnSameTeam(Node, PC) && !Node.bIsDisabled )
							{
								Result = Node;
								break;
							}
						}
						if ( UTOnslaughtPowerCore(Result) != None )
						{
							// defend the prime node instead
							AltResult = TeamAI.GetLeastDefendedPlayerObjective(PC);
							if ( (AltResult != None) && (UTOnslaughtPowerCore(AltResult) == None) )
							{
								Result = AltResult;
							}
						}
					}
				}
				return Result;
			case AOP_SpecialOps:
				V = UTVehicle(PC.Pawn);
				if ( (Flag == None) && (PC.Pawn != None) && ((V == None) || (!V.bKeyVehicle && (UTVehicle_Deployable(V) == None))) )
				{
					Weap = (Vehicle(PC.Pawn) == None) ? UTWeapon(PC.Pawn.Weapon) : UTWeapon(Vehicle(PC.Pawn).Driver.Weapon);
					if ( (Weap == None) || (!Weap.bSuperWeapon && (UTDeployable(Weap) == None)) )
					{
						// look for super items, if not already holding one
						ForEach WorldInfo.AllNavigationPoints(class'UTPickupFactory', Pickup)
						{
							if ( Pickup.bIsSuperItem && ClassIsChildOf(Pickup.InventoryType, class'UTWeapon') && Pickup.ReadyToPickup(0) )
							{
								NewDist = VSize(Pickup.Location - PC.Pawn.Location);
								if ( (BestPickup == None) || (NewDist < BestDist) )
								{
									BestPickup = Pickup;
									BestDist = NewDist;
								}
							}
						}
						if ( BestPickup != None )
						{
							 return BestPickup;
						}

						// look for key vehicles
						ForEach WorldInfo.AllPawns(class'UTVehicle', V)
						{
							if ( (V.Driver == None) && V.bTeamLocked && (V.Health > 0)
								&& (V.bKeyVehicle || (UTVehicle_Deployable(V) != None))
								&& Worldinfo.GRI.OnSameTeam(PC,V) )
							{
								return V;
							}
						}
					}
				}
				if ( Flag == None )
				{
					Result = TeamAI.GetPriorityStandaloneObjectiveFor(None, PC);
				}
				if ( Result == None )
				{
					Result = TeamAI.GetPriorityPlayerAttackObjectiveFor(PC);
					// override with attackable node if player has orb
					if ( (Flag != None) && (UTOnslaughtPowerNode(Result) == None) )
					{
						for (i = 0; i < PowerNodes.length; i++)
						{
							Node = UTOnslaughtPowerNode(PowerNodes[i]);
							if (Node != None && Node.PoweredBy(PRI.Team.TeamIndex) && !WorldInfo.GRI.OnSameTeam(Node, PC) && !Node.bIsDisabled )
							{
								return Node;
							}
						}
					}
				}
				return Result;
			case AOP_Defend:
				Result = TeamAI.GetLeastDefendedPlayerObjective(PC);

				// override with defendable node if player has orb
				if ( (Flag != None) && (UTOnslaughtPowerNode(Result) == None) )
				{
					for (i = 0; i < PowerNodes.length; i++)
					{
						Node = UTOnslaughtPowerNode(PowerNodes[i]);
						if (Node != None && !Node.bStandalone && Node.PoweredBy(1 - PRI.Team.TeamIndex) && WorldInfo.GRI.OnSameTeam(Node, PC) && !Node.bIsDisabled )
						{
							return Node;
						}
					}
				}
				return Result;
			default:
				//`Warn("Unknown AutoObjectivePreference:" @ PC.AutoObjectivePreference);
				return None;
		}
	}
	else
	{
		return None;
	}
}

function int GetCurrentMapCycleIndex(const out array<string> MapList)
{
	local int Index;

	if (UTOnslaughtGRI(WorldInfo.GRI) != None)
	{
		Index = MapList.Find(WorldInfo.GetPackageName() $ "?LinkSetup=" $ UTOnslaughtGRI(WorldInfo.GRI).LinkSetupName);
		if (Index != INDEX_NONE)
		{
			return Index;
		}
	}
	return Super.GetCurrentMapCycleIndex(MapList);
}

function string GetNextMap()
{
	local string Result;

	// if we're going to a different map and a link setup wasn't specified, add 'Default' so the current URL isn't used
	Result = Super.GetNextMap();
	if (Result != "" && InStr(Caps(Result), "?LINKSETUP=") == INDEX_NONE)
	{
		Result $= "?LinkSetup=Default";
	}

	return Result;
}

defaultproperties
{
   OvertimeCoreDrainPerSec=20.000000
   bSwapSidesAfterReset=True
   bScoreTeamKills=False
   FlagKillMessageName="ORBKILL"
   bUndrivenVehicleDamage=True
   bStartWithLockerWeaps=True
   bAllowHoverboard=True
   bScoreDeaths=False
   bMidGameHasMap=True
   Acronym="WAR"
   Description="Create a power chain to the enemy Core by capturing Nodes in a 'connect the dots' fashion.  Nodes at the end of a chain may be controlled by either team.  Control Nodes for your team by touching them to start the build process (use the Link Gun alt-fire to speed things up).  Once your team has a link to the enemy Core, attack and destroy it."
   ResetTimeDelay=18
   MapPrefixes(0)="WAR"
   EndOfMatchRulesTemplateStr_Scoring="First team to score `g points wins"
   EndOfMatchRulesTemplateStr_ScoringSingle="First team to score one point wins"
   EndOfMatchRulesTemplateStr_Time="Team with most points in `t mins. wins"
   MidgameScorePanelTag="ONSPanel"
   GameName="Warfare"
   GoalScore=3
   DeathMessageClass=Class'UTGame.UTTeamDeathMessage'
   OnlineStatsWriteClass=Class'UTGame.UTLeaderboardWriteWAR'
   OnlineGameSettingsClass=Class'UTGame.UTGameSettingsWAR'
   Name="Default__UTOnslaughtGame"
   ObjectArchetype=UTTeamGame'UTGame.Default__UTTeamGame'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: tr 31-1-2018 17:18:38.000 - Creation time: sk 18-3-2018 10:01:23.072 - Created with UnCodeX