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

Onslaught.ONSOnslaughtGame


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

class ONSOnslaughtGame extends xTeamGame;

var array<ONSPowerCore>         PowerCores;
var int                         FinalCore[2];

// GameUMenuType - This menu is displayed to players when they die - it should contain the map for choosing where to respawn at

struct PowerLinkSetup
{
	var name BaseNode;
	var array<name> LinkedNodes;
};

var array<ONSPowerLinkOfficialSetup> OfficialPowerLinkSetups;
var array<ONSPowerLinkCustomSetup> CustomPowerLinkSetups;
var array<PowerLink> PowerLinks;

var config int OvertimeCoreDrainPerSec;
var config bool bRandSetupAfterReset;	//choose a random link setup to play after a reset
var config bool bSwapSidesAfterReset;
var bool        bSidesAreSwitched;

var bool bCurrentSetupIsOfficial;
var string CurrentSetupName;

// localized PlayInfo descriptions & extra info
const ONSPROPNUM = 3;
var localized string ONSPropsDisplayText[ONSPROPNUM];
var localized string ONSPropDescText[ONSPROPNUM];

var(LoadingHints) private localized array<string> ONSHints;

function bool AllowTransloc()
{
	return false;
}

static function bool NeverAllowTransloc()
{
	return true;
}

static function bool AllowMutator( string MutatorClassName )
{
	if ( MutatorClassName == "" )
		return false;

	if ( MutatorClassName ~= "xGame.MutInstagib" )
		return false;
	if ( MutatorClassName ~= "xGame.MutZoomInstagib" )
		return false;

	return super.AllowMutator(MutatorClassName);
}

event SetGrammar()
{
	LoadSRGrammar("ONS");
}

function bool ApplyOrder( PlayerController Sender, int RecipientID, int OrderID )
{
	local controller P;

	if ( OrderID == 299 )
	{
		for ( P=Level.ControllerList; P!= None; P=P.NextController )
		{
			if ( (Bot(P) != None) && (Bot(P).Pawn != None) && (P.PlayerReplicationInfo != None) && (P.PlayerReplicationInfo.Team == Sender.PlayerReplicationInfo.Team)
				&& ((RecipientID == -1) || (RecipientID == P.PlayerReplicationInfo.TeamID)) )
			{
				Bot(P).GetOutOfVehicle();
				if ( RecipientID == P.PlayerReplicationInfo.TeamID )
					break;
			}
		}
		return true;
	}

	return Super.ApplyOrder(Sender,RecipientID,OrderID);
}

function int ParseOrder(string OrderString)
{
	if ( OrderString == "GET OUT" )
		return 299;
	return Super.ParseOrder(OrderString);
}

static function PrecacheGameAnnouncements(AnnouncerVoice V, bool bRewardSounds)
{
	Super.PrecacheGameAnnouncements(V,bRewardSounds);
	if ( !bRewardSounds )
	{
		V.PrecacheSound('Red_powernode_destroyed');
		V.PrecacheSound('Blue_powernode_destroyed');
		V.PrecacheSound('Red_Powercore_under_attack');
		V.PrecacheSound('Blue_Powercore_under_attack');
		V.PrecacheSound('NewRoundIn');
		V.PrecacheSound('Red_Powercore_destroyed');
		V.PrecacheSound('Blue_Powercore_destroyed');
		V.PrecacheSound('Red_Powercore_critical');
		V.PrecacheSound('Blue_Powercore_critical');
		V.PrecacheSound('Red_Powercore_vulnerable');
		V.PrecacheSound('Blue_Powercore_vulnerable');
		V.PrecacheSound('Red_Powernode_under_construction');
		V.PrecacheSound('Blue_Powernode_under_construction');
		V.PrecacheSound('Red_powercore_damaged');
		V.PrecacheSound('Blue_powercore_damaged');
		V.PrecacheSound('Red_powernode_isolated');
		V.PrecacheSound('Blue_powernode_isolated');
	}
}

function SetInitialState()
{
    Super.SetInitialState();

    SetCoreDistance(PowerCores[FinalCore[0]], 0, 0);
    SetCoreDistance(PowerCores[FinalCore[1]], 1, 0);

    UpdateLinks();
}

event InitGame(string Options, out string Error)
{
	local string InOpt, MapName;
	local ONSPowerLinkOfficialSetup P;
	local int x;
	local NavigationPoint N;
	local array<string> CustomPowerLinkSetupNames;

	Super.InitGame(Options, Error);

	x = 0;
	for(N = Level.NavigationPointList; N != None; N = N.NextNavigationPoint)
	{
		// Reset all PlayerStarts so that the PowerCores can determine their team and Pre-Rate them
		if (N.IsA('PlayerStart'))
			PlayerStart(N).bEnabled = False;

		// Register all the PowerCores
		if (N.IsA('ONSPowerCore'))
		{
			PowerCores[x] = ONSPowerCore(N);
			PowerCores[x].NotifyUpdateLinks = UpdateLinks;
			PowerCores[x].OnCoreDestroyed = MainCoreDestroyed;

			if (PowerCores[x].bFinalCore)
				FinalCore[PowerCores[x].DefenderTeamIndex] = x;
			x++;
		}
	}

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

	MapName = Left(string(Level), InStr(string(Level), "."));

	OfficialPowerLinkSetups.length = 0;
	foreach AllActors(class'ONSPowerLinkOfficialSetup', P)
		OfficialPowerLinkSetups[OfficialPowerLinkSetups.length] = P;

	//For PerObjectConfig objects, the Outer overrides the default config file name.
	//This means by giving the Level as the Outer, the .ini name will be the same as the map name,
	//which is really cool because it makes it easy to trade custom setups - just copy that map's .ini
	CustomPowerLinkSetupNames = class'ONSPowerLinkCustomSetup'.static.GetPerObjectNames(MapName);
	for (x = 0; x < CustomPowerLinkSetupNames.length; x++)
		CustomPowerLinkSetups[CustomPowerLinkSetups.length] = new(Level, CustomPowerLinkSetupNames[x]) class'ONSPowerLinkCustomSetup';

	InOpt = ParseOption(Options, "bRandSetupAfterReset");
	if (InOpt != "")
		bRandSetupAfterReset = bool(InOpt);

	InOpt = ParseOption(Options, "LinkSetup");
	if (InOpt ~= "Random")
	{
		FindLinkSetup();
		return;
	}
	if (InOpt == "" || !SetPowerLinkSetup(InOpt, None))
	{
		if (!SetPowerLinkSetup("Default", None))
			FindLinkSetup();
	}

	// Big hack.. you shouldn't break scope this way :)

 	InOpt = ParseOption(Options,"BonusVehicles");
	if ( bool(InOpt) )
	{
		AddMutator("OnslaughtBP.MutBonusVehicles");
	}

}

event PostBeginPlay()
{
	SetupLinks();
	Super.PostBeginPlay();
}

function bool SetupExists(string SetupName)
{
	local int x;

	for (x = 0; x < OfficialPowerLinkSetups.length; x++)
		if (OfficialPowerLinkSetups[x].SetupName ~= SetupName)
			return true;

	for (x = 0; x < CustomPowerLinkSetups.length; x++)
		if (string(CustomPowerLinkSetups[x].Name) ~= SetupName)
			return true;

	return false;
}

function bool SetPowerLinkSetup(string SetupName, PlayerController Caller)
{
	local int x, y, z, i;
	local array<ONSPowerCore> Traveled;

	SetupName = Repl(SetupName, " ", "_");

	for (x = 0; x < OfficialPowerLinkSetups.length; x++)
		if (OfficialPowerLinkSetups[x].SetupName ~= SetupName)
		{
			//activate this setup
			for (y = 0; y < OfficialPowerLinkSetups[x].LinkSetups.length; y++)
				for (z = 0; z < PowerCores.length; z++)
					if (PowerCores[z].Name == OfficialPowerLinkSetups[x].LinkSetups[y].BaseNode)
						PowerCores[z].LinkedNodes = OfficialPowerLinkSetups[x].LinkSetups[y].LinkedNodes;
			ResetPowerLinks();
			Log("Using Official Link Setup: "$SetupName);
			CurrentSetupName = SetupName;
			bCurrentSetupIsOfficial = true;
			if (Caller != None)
				Caller.ReceiveLocalizedMessage(class'ONSLinkDesignMessage', 2);
			return true;
		}

	for (x = 0; x < CustomPowerLinkSetups.length; x++)
		if (string(CustomPowerLinkSetups[x].Name) ~= SetupName)
		{
			//activate this setup
			for (y = 0; y < CustomPowerLinkSetups[x].LinkSetups.length; y++)
				for (z = 0; z < PowerCores.length; z++)
					if (PowerCores[z].Name == CustomPowerLinkSetups[x].LinkSetups[y].BaseNode)
						PowerCores[z].LinkedNodes = CustomPowerLinkSetups[x].LinkSetups[y].LinkedNodes;
			ResetPowerLinks();
			if (PowerLinks.length > 0 && !ExistsLinkPathTo(PowerCores[FinalCore[0]], PowerCores[FinalCore[1]], Traveled))
			{
				//trying to load an invalid setup, revert to previous one
				CustomPowerLinkSetups.Remove(x, 1);
				if (Caller != None)
					Caller.ReceiveLocalizedMessage(class'ONSLinkDesignMessage', 8);
				else
					Log("Failed to load Custom Link Setup"@SetupName$": There is not a complete path between the PowerCores.");
				if (CurrentSetupName != "" && CurrentSetupName != SetupName && SetPowerLinkSetup(CurrentSetupName, None))
					return true;
				if (OfficialPowerLinkSetups.Length > 0)
				{
					FindLinkSetup();
					return true;
				}
				Log("Can't find a better link setup to load, so using"@SetupName@" anyway and forcing a connection between the PowerCores.");
				AddLink(PowerCores[FinalCore[0]], PowerCores[FinalCore[1]]);
				UpdateLinks();
				for (i = 0; i < GameReplicationInfo.PRIArray.Length; i++)
					if (PlayerController(GameReplicationInfo.PRIArray[i].Owner) != None && ONSPlayerReplicationInfo(GameReplicationInfo.PRIArray[i]) != None)
						ONSPlayerReplicationInfo(GameReplicationInfo.PRIArray[i]).ClientReceivePowerLink(PowerCores[FinalCore[0]], PowerCores[FinalCore[1]]);
				return true;
			}
			Log("Using Custom Link Setup: "$SetupName);
			CurrentSetupName = SetupName;
			bCurrentSetupIsOfficial = false;
			if (Caller != None)
				Caller.ReceiveLocalizedMessage(class'ONSLinkDesignMessage', 2);
			return true;
		}

	if (Caller != None)
		Caller.ReceiveLocalizedMessage(class'ONSLinkDesignMessage', 3);
	return false;
}

function ClearLinks()
{
	local int i;

	for ( i = 0; i < PowerLinks.Length; i++ )
		if ( PowerLinks[i] != None )
			PowerLinks[i].Destroy();

	PowerLinks.Remove(0, PowerLinks.Length);
}

function ResetPowerLinks()
{
	local int x;
	local ONSPlayerReplicationInfo PRI;

	if ( PowerLinks.Length == 0 )
		return;

	ClearLinks();

	for ( x = 0; x < PowerCores.Length; x++ )
		PowerCores[x].ResetLinks();

	SetupLinks();

	if (GameReplicationInfo != None)
	{
		for (x = 0; x < GameReplicationInfo.PRIArray.length; x++)
		{
			PRI = ONSPlayerReplicationInfo(GameReplicationInfo.PRIArray[x]);
			if ( PRI == None || PlayerController(PRI.Owner) == None )
				continue;

			PRI.ClientPrepareToReceivePowerLinks();
		}
	}
}

//Save a powercore link setup. Returns true if it successfully created a NEW setup and neither failed nor overwrote an old setup
function bool SavePowerLinkSetup(string SetupName, PlayerController Caller)
{
	local int x, y, z;
	local PowerLinkSetup BlankSetup;
	local string MapName;

	MapName = Left(string(Level), InStr(string(Level), "."));
	SetupName = Repl(SetupName, " ", "_");

	for (x = 0; x < OfficialPowerLinkSetups.length; x++)
		if (OfficialPowerLinkSetups[x].SetupName ~= SetupName)
		{
			Caller.ReceiveLocalizedMessage(class'ONSLinkDesignMessage', 1);
			return false;
		}

	for (x = 0; x < CustomPowerLinkSetups.length; x++)
		if (string(CustomPowerLinkSetups[x].Name) ~= SetupName)
		{
			//overwrite
			CustomPowerLinkSetups[x].LinkSetups.length = 0;
			for (y = 0; y < PowerCores.length; y++)
			{
				CustomPowerLinkSetups[x].LinkSetups[y] = BlankSetup;
				CustomPowerLinkSetups[x].LinkSetups[y].BaseNode = PowerCores[y].Name;
				for (z = 0; z < PowerCores[y].PowerLinks.length; z++)
					CustomPowerLinkSetups[x].LinkSetups[y].LinkedNodes[z] = PowerCores[y].PowerLinks[z].Name;
			}
			CustomPowerLinkSetups[x].SaveConfig();
			Caller.ReceiveLocalizedMessage(class'ONSLinkDesignMessage', 0);
			return false;
		}

	//save new
	x = CustomPowerLinkSetups.length;
	CustomPowerLinkSetups.length = CustomPowerLinkSetups.length + 1;
	CustomPowerLinkSetups[x] = new(Level, SetupName) class'ONSPowerLinkCustomSetup';
	CustomPowerLinkSetups[x].LinkSetups.length = 0;
	for (y = 0; y < PowerCores.length; y++)
	{
		CustomPowerLinkSetups[x].LinkSetups[y] = BlankSetup;
		CustomPowerLinkSetups[x].LinkSetups[y].BaseNode = PowerCores[y].Name;
		for (z = 0; z < PowerCores[y].PowerLinks.length; z++)
			CustomPowerLinkSetups[x].LinkSetups[y].LinkedNodes[z] = PowerCores[y].PowerLinks[z].Name;
	}
	CustomPowerLinkSetups[x].SaveConfig();
	Caller.ReceiveLocalizedMessage(class'ONSLinkDesignMessage', 0);

	return true;
}

//Deletes a powercore link setup. Returns true if successful, false if not
function bool DeletePowerLinkSetup(string SetupName, PlayerController Caller)
{
	local int x;
	local string MapName;

	MapName = Left(string(Level), InStr(string(Level), "."));
	SetupName = Repl(SetupName, " ", "_");

	for (x = 0; x < OfficialPowerLinkSetups.length; x++)
		if (OfficialPowerLinkSetups[x].SetupName ~= SetupName)
		{
			Caller.ReceiveLocalizedMessage(class'ONSLinkDesignMessage', 5);
			return false;
		}

	for (x = 0; x < CustomPowerLinkSetups.length; x++)
		if (string(CustomPowerLinkSetups[x].Name) ~= SetupName)
		{
			CustomPowerLinkSetups[x].ClearConfig();
			CustomPowerLinkSetups.Remove(x, 1);
			Caller.ReceiveLocalizedMessage(class'ONSLinkDesignMessage', 4);
			return true;
		}

	Caller.ReceiveLocalizedMessage(class'ONSLinkDesignMessage', 6);
	return false;
}

function FindLinkSetup(optional string IgnoredSetup)
{
	local int i, Sanity, TotalNumSetups;
	local string NewSetupName;

	TotalNumSetups = OfficialPowerLinkSetups.length + CustomPowerLinkSetups.length;

	if (TotalNumSetups == 0)
		Log("Using default Link Setup");
	else if (TotalNumSetups == 1 && CurrentSetupName != "")
		SetPowerLinkSetup(CurrentSetupName, None);
	else
	{
		do
		{
			i = Rand(TotalNumSetups);
			if (i < OfficialPowerLinkSetups.length)
				NewSetupName = OfficialPowerLinkSetups[i].SetupName;
			else
				NewSetupName = string(CustomPowerLinkSetups[i-OfficialPowerLinkSetups.length].Name);
			Sanity++;
		} until (NewSetupName != IgnoredSetup || Sanity > 1000)

		SetPowerLinkSetup(NewSetupName, None);
	}
}

static simulated function bool ExistsLinkPathTo(ONSPowerCore Start, ONSPowerCore Destination, out array<ONSPowerCore> Traveled)
{
	local int i, j;
	local bool bSkip;

	if (Start == None || Destination == None)
		return false;

	Traveled[Traveled.length] = Start;

	for (i = 0; i < Start.PowerLinks.Length; i++)
	{
		if (Start.PowerLinks[i] == Destination)
			return true;
		bSkip = false;
		for (j = 0; j < Traveled.length; j++)
		{
			if (Traveled[j] == Start.PowerLinks[i])
			{
				bSkip = true;
				break;
			}
		}
		if (!bSkip && ExistsLinkPathTo(Start.PowerLinks[i], Destination, Traveled))
			return true;
	}

	return false;
}

function SetCoreDistance(ONSPowerCore PC, byte T, byte Distance)
{
    local int i;

    PC.FinalCoreDistance[T] = Distance;

    for (i=0; i<PC.PowerLinks.Length; i++)
    {
        if (PC.PowerLinks[i].FinalCoreDistance[T] > Distance + 1)
            SetCoreDistance(PC.PowerLinks[i], T, Distance + 1);
    }
}

function UpdateLinks()
{
    local int i, j;
    local bool bRedCoreWasVulnerable, bBlueCoreWasVulnerable;

    if (!bScriptInitialized)	//PowerCores haven't done PostBeginPlay() yet
        return;

//	log(Name@"UpdateLinks");
    bRedCoreWasVulnerable = PowerCores[FinalCore[0]].bPoweredByBlue;
    bBlueCoreWasVulnerable = PowerCores[FinalCore[1]].bPoweredByRed;

    UpdateSeveredLinks();

    for (i=0; i<PowerCores.Length; i++)
    {
        PowerCores[i].bPoweredByRed = False;
        PowerCores[i].bPoweredByBlue = False;
        for (j=0; j<PowerCores[i].PowerLinks.Length; j++)
            if (PowerCores[i].PowerLinks[j].CoreStage == 0 && !PowerCores[i].PowerLinks[j].bSevered)
            {
                if (PowerCores[i].PowerLinks[j].DefenderTeamIndex == 0)
                    PowerCores[i].bPoweredByRed = True;
                else if (PowerCores[i].PowerLinks[j].DefenderTeamIndex == 1)
                    PowerCores[i].bPoweredByBlue = True;
            }

	if (PowerCores[i].CoreStage == 4 && (PowerCores[i].bPoweredByRed || PowerCores[i].bPoweredByBlue))
		PowerCores[i].CheckTouching();
        PowerCores[i].CheckShield();
    }

    if (!bRedCoreWasVulnerable && PowerCores[FinalCore[0]].bPoweredByBlue)
    	BroadcastLocalizedMessage(class'ONSOnslaughtMessage', 20);
    if (!bBlueCoreWasVulnerable && PowerCores[FinalCore[1]].bPoweredByRed)
    	BroadcastLocalizedMessage(class'ONSOnslaughtMessage', 21);
}

function UpdateSeveredLinks()
{
    local int i;
    local array<byte> WasSevered;

    for (i = 0; i < PowerCores.Length; i++)
    {
        WasSevered[i] = byte(PowerCores[i].bSevered);
        PowerCores[i].bSevered = True;
    }

    Sever(PowerCores[FinalCore[0]], 0);
    Sever(PowerCores[FinalCore[1]], 1);

    for (i = 0; i < PowerCores.Length; i++)
        if (!PowerCores[i].bDisabled && PowerCores[i].CoreStage != 4)
        {
            if (PowerCores[i].bSevered && WasSevered[i] == 0)
		PowerCores[i].Sever();
	    else if (!PowerCores[i].bSevered && WasSevered[i] == 1)
	    	PowerCores[i].UnSever();
	}
}

function Sever(ONSPowerCore PC, int TeamIndex)
{
    local int i;
    PC.bSevered = False;
    if (PC.CoreStage != 0)
        return;
    for (i = 0; i < PC.PowerLinks.Length; i++)
        if (PC.PowerLinks[i].bSevered && PC.PowerLinks[i].DefenderTeamIndex == TeamIndex)
            Sever(PC.PowerLinks[i], TeamIndex);
}

function Reset()
{
	bOverTime = false;
	bOverTimeBroadcast = false;
}

function StartMatch()
{
	local array<ONSPowerCore> Traveled;
	local int i;

	//check if the link setup is valid (in case host/admin edited it before game start)
	if (Level.NetMode != NM_Standalone && !ExistsLinkPathTo(PowerCores[FinalCore[0]], PowerCores[FinalCore[1]], Traveled))
	{
		//trying to load an invalid setup, revert to previous one
		Log("Current link setup is invalid: There is not a complete path between the PowerCores.");
		if (CurrentSetupName == "" || !SetPowerLinkSetup(CurrentSetupName, None))
		{
			if (OfficialPowerLinkSetups.length > 0)
				FindLinkSetup();
			else
			{
				Log("Can't find a better link setup to load, so forcing a connection between the PowerCores.");
				AddLink(PowerCores[FinalCore[0]], PowerCores[FinalCore[1]]);
				UpdateLinks();
				for (i = 0; i < GameReplicationInfo.PRIArray.Length; i++)
					if (PlayerController(GameReplicationInfo.PRIArray[i].Owner) != None && ONSPlayerReplicationInfo(GameReplicationInfo.PRIArray[i]) != None)
						ONSPlayerReplicationInfo(GameReplicationInfo.PRIArray[i]).ClientReceivePowerLink(PowerCores[FinalCore[0]], PowerCores[FinalCore[1]]);
			}
		}
	}

	Super.StartMatch();
}

State MatchInProgress
{
	event Timer()
	{
        local Controller C;
    	local int i, TeamNodes[2], TotalNodes;
    	local Actor A;
    	local bool bOldUnderAttack;

        for(i=0;i<PowerCores.Length;i++)
        {
        	if ( Level.TimeSeconds > PowerCores[i].LastAttackExpirationTime )
        	{
	            bOldUnderAttack = PowerCores[i].bUnderAttack;
	            PowerCores[i].bUnderAttack = (Level.TimeSeconds - PowerCores[i].LastAttackTime < PowerCores[i].LastAttackExpirationTime);
	            if (bOldUnderAttack != PowerCores[i].bUnderAttack)
	                PowerCores[i].UnderAttackChange();
	        }

            if (!PowerCores[i].bFinalCore && PowerCores[i].CoreStage != 255)
    	    {
    	    	if (PowerCores[i].CoreStage == 0 && PowerCores[i].DefenderTeamIndex < 2)
    	            	TeamNodes[PowerCores[i].DefenderTeamIndex]++;
    	        TotalNodes++;
    	    }
        }

        if (bOverTime)
        {
        	PowerCores[FinalCore[0]].TakeDamage(OvertimeCoreDrainPerSec - OvertimeCoreDrainPerSec * (float(TeamNodes[0]) / TotalNodes), None, vect(0,0,0), vect(0,0,0), None);
        	PowerCores[FinalCore[1]].TakeDamage(OvertimeCoreDrainPerSec - OvertimeCoreDrainPerSec * (float(TeamNodes[1]) / TotalNodes), None, vect(0,0,0), vect(0,0,0), None);
        }

        Super.Timer(); // Need this!!!

        if (ResetCountDown > 0)
        {
            ResetCountDown--;
            if ( ResetCountDown < 3 )
            {
				// blow up all redeemer guided warheads
				for ( C=Level.ControllerList; C!=None; C=C.NextController )
					if ( (C.Pawn != None) && C.Pawn.IsA('RedeemerWarhead') )
						C.Pawn.Fire(1);

			}
            if ( ResetCountDown == 8 )
            {
                for ( C = Level.ControllerList; C != None; C = C.NextController )
                    if ( PlayerController(C) != None )
                        PlayerController(C).PlayStatusAnnouncement('NewRoundIn',1,true);
            }
            else if ( (ResetCountDown > 1) && (ResetCountDown < 7) )
                BroadcastLocalizedMessage(class'TimerMessage', ResetCountDown-1);
            else if (ResetCountDown == 1)
            {
                Log("Reset Onslaught.");

            	for (C = Level.ControllerList; C != None; C = C.NextController)
            	{
                    if (PlayerController(C) != None)
                        PlayerController(C).ClientReset();
                    C.Reset();
                }

            	foreach AllActors(class'Actor', A)
            		if (!A.IsA('Controller') && !A.IsA('ONSPowerCore') && !A.IsA('TeamInfo'))
            			A.Reset();

            	//we reset powercores after everything else because their reset might cause
            	//vehiclefactories, etc to activate and spawn new actors that we don't want to affect
            	for (i = 0; i < PowerCores.length; i++)
            	{
                    if (bSwapSidesAfterReset && PowerCores[i].bFinalCore)
                    {
                        if (bSidesAreSwitched)
                            PowerCores[i].DefenderTeamIndex = PowerCores[i].default.DefenderTeamIndex;
                        else
                            PowerCores[i].DefenderTeamIndex = abs(PowerCores[i].default.DefenderTeamIndex - 1);

                        FinalCore[PowerCores[i].DefenderTeamIndex] = i;
                    }
                    else
                        PowerCores[i].DefenderTeamIndex = PowerCores[i].default.DefenderTeamIndex;

                    PowerCores[i].FinalCoreDistance[0] = 255;
                    PowerCores[i].FinalCoreDistance[1] = 255;

            		PowerCores[i].Reset();
            	}

            	if (bSwapSidesAfterReset)
            	{
                    SetCoreDistance(PowerCores[FinalCore[0]], 0, 0);
                    SetCoreDistance(PowerCores[FinalCore[1]], 1, 0);
                    bSidesAreSwitched = !bSidesAreSwitched;
                }

        		//possibly choose a new link setup
            	if (bRandSetupAfterReset && (OfficialPowerLinkSetups.length + CustomPowerLinkSetups.length) > 1)
            		FindLinkSetup(CurrentSetupName);
            	else
            		UpdateLinks();

                FindNewObjectives(None); //update AI

            	//now respawn all the players
            	for (C = Level.ControllerList; C != None; C = C.nextController)
            		if (C.PlayerReplicationInfo != None && !C.PlayerReplicationInfo.bOnlySpectator)
	            		RestartPlayer(C);

            	//reset timelimit
            	RemainingTime = 60 * TimeLimit;
            	GameReplicationInfo.RemainingMinute = RemainingTime;

                ResetCountDown = 0;
           }
        }
    }
}

function MainCoreDestroyed(byte T)
{
    local Controller C;
    local PlayerController PC;
    local int Score;

    if (bOverTime)
    	Score = 1;
    else
    	Score = 2;

    if (T == 1)
    {
        BroadcastLocalizedMessage( class'ONSOnslaughtMessage', 0);
        TeamScoreEvent(0, Score, "enemy_core_destroyed");
        Teams[0].Score += Score;
 		Teams[0].NetUpdateTime = Level.TimeSeconds - 1;
       CheckScore(PowerCores[FinalCore[1]].LastDamagedBy);
    }
    else
    {
        BroadcastLocalizedMessage( class'ONSOnslaughtMessage', 1);
        TeamScoreEvent(1, Score, "enemy_core_destroyed");
        Teams[1].Score += Score;
		Teams[1].NetUpdateTime = Level.TimeSeconds - 1;
        CheckScore(PowerCores[FinalCore[0]].LastDamagedBy);
    }

    //round has ended
    for (C = Level.ControllerList; C != None; C = C.NextController)
    {
    	PC = PlayerController(C);
    	if (PC != None)
    	{
    		PC.ClientSetBehindView(true);
    		PC.ClientSetViewTarget(PowerCores[FinalCore[T]]);
    		PC.SetViewTarget(PowerCores[FinalCore[T]]);
    		if (!bGameEnded)
    			PC.ClientRoundEnded();
    	}
    	if (!bGameEnded)
	    	C.RoundHasEnded();
    }

    ResetCountDown = ResetTimeDelay;
}

function CheckScore(PlayerReplicationInfo Scorer)
{
	if (CheckMaxLives(Scorer))
		return;

	if (GameRulesModifiers != None && GameRulesModifiers.CheckScore(Scorer))
		return;

	if (GoalScore != 0 && (Teams[0].Score >= GoalScore || Teams[1].Score >= GoalScore))
		EndGame(Scorer,"teamscorelimit");
}

function bool CheckEndGame(PlayerReplicationInfo Winner, string Reason)
{
	if (Reason ~= "TimeLimit")
	{
		if ( !bOverTimeBroadcast )
		{
			StartupStage = 7;
			PlayStartupMessage();
			bOverTimeBroadcast = true;
		}
		return false;
	}

	return Super.CheckEndGame(Winner, Reason);
}

function SetEndGameFocus(PlayerReplicationInfo Winner)
{
	local Controller P;
	local PlayerController player;

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

	for ( P=Level.ControllerList; P!=None; P=P.nextController )
	{
		player = PlayerController(P);
		if ( Player != None )
		{
			if ( !Player.PlayerReplicationInfo.bOnlySpectator )
				PlayWinMessage(Player, (Player.PlayerReplicationInfo.Team == GameReplicationInfo.Winner));
			Player.ClientSetBehindView(true);
			Player.CameraDist = 10;
			if ( EndGameFocus != None )
			{
				Player.ClientSetViewTarget(EndGameFocus);
				Player.SetViewTarget(EndGameFocus);
			}
			Player.ClientGameEnded();
			if ( CurrentGameProfile != None )
				CurrentGameProfile.bWonMatch = (Player.PlayerReplicationInfo.Team == GameReplicationInfo.Winner);
		}
		P.GameHasEnded();
	}
}

function Killed(Controller Killer, Controller Killed, Pawn KilledPawn, class<DamageType> damageType)
{
	if (PlayerController(Killed) != None && ONSPlayerReplicationInfo(Killed.PlayerReplicationInfo) != None)
		ONSPlayerReplicationInfo(Killed.PlayerReplicationInfo).OwnerDied();

	Super.Killed(Killer, Killed, KilledPawn, damageType);
}

function bool CriticalPlayer(Controller Other)
{
	local int x;

	if (Other.Pawn == None || Other.PlayerReplicationInfo == None)
		return Super.CriticalPlayer(Other);

	for (x = 0; x < PowerCores.length; x++)
		if ( (PowerCores[x].CoreStage == 0 || PowerCores[x].CoreStage == 2) && PowerCores[x].DefenderTeamIndex != Other.GetTeamNum()
		     && ((PowerCores[x].bUnderAttack && Other.PlayerReplicationInfo == PowerCores[x].LastDamagedBy) || VSize(Other.Pawn.Location - PowerCores[x].Location) < 2000) )
			return true;

	return Super.CriticalPlayer(Other);
}

function bool ValidSpawnPoint(ONSPowerCore PC, int TeamIndex)
{
    return (PC != None && PC.DefenderTeamIndex == TeamIndex &&
            !PC.IsInState('NeutralCore') && !PC.IsInState('Reconstruction') &&
            (!PC.bUnderAttack || PC.bFinalCore));
}

function NavigationPoint FindPlayerStart( Controller Player, optional byte InTeam, optional string incomingName )
{
    local NavigationPoint N, BestStart;
    local Teleporter Tel;
    local float BestRating, NewRating;
    local byte Team, EnemyTeam;
    local ONSPowerCore SelectedPC;
    local float CoreDistA, CoreDistB;
    local int i;
    local Bot B;

    if ( GameRulesModifiers != None )
    {
        N = GameRulesModifiers.FindPlayerStart(Player,InTeam,incomingName);
        if ( N != None )
            return N;
    }

    // if incoming start is specified, then just use it
    if( incomingName!="" )
        foreach AllActors( class 'Teleporter', Tel )
            if( string(Tel.Tag)~=incomingName )
                return Tel;

    // use InTeam if player doesn't have a team yet
    if ( (Player != None) && (Player.PlayerReplicationInfo != None) )
    {
        if ( Player.PlayerReplicationInfo.Team != None )
            Team = Player.PlayerReplicationInfo.Team.TeamIndex;
        else
            Team = InTeam;
        //Use the powercore the player selected (if it's valid)
		if ( ONSPlayerReplicationInfo(Player.PlayerReplicationInfo) != None )
        {
    		SelectedPC = ONSPlayerReplicationInfo(Player.PlayerReplicationInfo).TemporaryStartCore;
    		ONSPlayerReplicationInfo(Player.PlayerReplicationInfo).TemporaryStartCore = None;
    		if (SelectedPC != None && !ValidSpawnPoint(SelectedPC, Team))
    			SelectedPC = None;
    		if (SelectedPC == None)
    		{
	        	SelectedPC = ONSPlayerReplicationInfo(Player.PlayerReplicationInfo).StartCore;
		        if (!ValidSpawnPoint(SelectedPC, Team))
                    SelectedPC = None;
	        }
        }
        if ( SelectedPC == None )
        {
	        //Bots always want to go to their SquadObjective
	        B = Bot(Player);
        	if (B != None && B.Squad != None && ONSPowerCore(B.Squad.SquadObjective) != None && ValidSpawnPoint(ONSPowerCore(B.Squad.SquadObjective), Team))
        		SelectedPC = ONSPowerCore(B.Squad.SquadObjective);
        }
    }
    else
        Team = InTeam;

    if (SelectedPC == None)
    {
    	if (PowerCores[FinalCore[Team]].PoweredBy(1 - Team))
    		SelectedPC = PowerCores[FinalCore[Team]];

    	if (SelectedPC == None)
    	{
	        // Find the Closest Controlled Node(s) to Enemy PowerCore.
	        EnemyTeam = abs(Team - 1);
	        BestRating = 255;
	        for (i = 0; i < PowerCores.Length; i++)
	        {
	            if (ValidSpawnPoint(PowerCores[i], Team))
	            {
	                NewRating = PowerCores[i].FinalCoreDistance[EnemyTeam];
	                if ( NewRating < BestRating )
	                {
	                    BestRating = NewRating;
	                    SelectedPC = PowerCores[i];
	                }
	                else if ( NewRating == BestRating ) // If we have two nodes at equal link distance, we check geometric distance
	                {
                        CoreDistA = VSize(PowerCores[FinalCore[EnemyTeam]].Location - PowerCores[i].Location);
                        CoreDistB = VSize(PowerCores[FinalCore[EnemyTeam]].Location - SelectedPC.Location);
                        if (CoreDistA < CoreDistB)
                            SelectedPC = PowerCores[i];
                    }
	            }
	        }

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

    for (i = 0; i < SelectedPC.CloseActors.length; i++)
        if (NavigationPoint(SelectedPC.CloseActors[i]) != None)
        {
	        NewRating = RatePlayerStart(NavigationPoint(SelectedPC.CloseActors[i]),Team,Player);
        	if ( NewRating > BestRating )
	        {
        	    BestRating = NewRating;
	            BestStart = NavigationPoint(SelectedPC.CloseActors[i]);
        	}
	}

    if (PlayerStart(BestStart) == None && SelectedPC != PowerCores[FinalCore[Team]])
    {
    	//couldn't find a start at the requested node, so try powercore
    	SelectedPC = PowerCores[FinalCore[Team]];
    	for (i = 0; i < SelectedPC.CloseActors.length; i++)
	        if (NavigationPoint(SelectedPC.CloseActors[i]) != None)
	        {
		        NewRating = RatePlayerStart(NavigationPoint(SelectedPC.CloseActors[i]),Team,Player);
	        	if ( NewRating > BestRating )
		        {
	        	    BestRating = NewRating;
		            BestStart = NavigationPoint(SelectedPC.CloseActors[i]);
	        	}
		}
    }

    if (PlayerStart(BestStart) == None)
    {
        log("Warning - PATHS NOT DEFINED or NO PLAYERSTART with positive rating");
	BestRating = -100000000;
        ForEach AllActors( class 'NavigationPoint', N )
        {
            NewRating = RatePlayerStart(N,0,Player);
            if ( InventorySpot(N) != None )
				NewRating -= 50;
			NewRating += 20 * FRand();
            if ( NewRating > BestRating )
            {
                BestRating = NewRating;
                BestStart = N;
            }
        }
    }

    return BestStart;
}

function ShowPathTo(PlayerController P, int TeamNum)
{
	local int x;
	local ONSPowerCore Best;
	local float BestDist;
	local class<WillowWhisp>	WWclass;

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

	if (Best != None && P.FindPathToward(Best, false) != None)
	{
		WWclass = class<WillowWhisp>(DynamicLoadObject(PathWhisps[TeamNum], class'Class'));
		Spawn(WWclass, P,, P.Pawn.Location);
	}
}

function GetServerInfo(out ServerResponseLine ServerState)
{
	Super.GetServerInfo(ServerState);

	if (!bCurrentSetupIsOfficial)
		ServerState.MapName $= "*";
}

function GetServerDetails(out ServerResponseLine ServerState)
{
	Super.GetServerDetails(ServerState);

	AddServerDetail( ServerState, "LinkSetup", CurrentSetupName );
}

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

	if (Super.ChangeTeam(Other, num, bNewTeam))
	{
		if (Other == Level.GetLocalPlayerController())
		{
			//Update client side effects on powercores to reflect which ones the player can go after changing teams
			for (i = 0; i < PowerCores.length; i++)
				PowerCores[i].CheckShield();
		}

		PRI = ONSPlayerReplicationInfo(Other.PlayerReplicationInfo);
		if (PRI != None)
		{
			PRI.StartCore = None;
			PRI.TemporaryStartCore = None;
		}

		return true;
	}

	return false;
}

function PlayStartupMessage()
{
	Super.PlayStartupMessage();

	if (StartupStage == 7 && OvertimeCoreDrainPerSec > 0)
		BroadcastLocalizedMessage(class'ONSOnslaughtMessage', 29);
}

function ScoreObjective(PlayerReplicationInfo Scorer, float Score)
{
	if (Scorer != None)
		Scorer.Score += Score;

	if (GameRulesModifiers != None)
		GameRulesModifiers.ScoreObjective(Scorer,Score);
}

static event bool AcceptPlayInfoProperty(string PropertyName)
{
	if ( InStr(PropertyName, "bAllowTrans") != -1 )
		return false;

	return Super.AcceptPlayInfoProperty(PropertyName);
}

static function FillPlayInfo(PlayInfo PlayInfo)
{
	local int i;

	Super.FillPlayInfo(PlayInfo);  // Always begin with calling parent

	PlayInfo.AddSetting(default.GameGroup, "OvertimeCoreDrainPerSec", default.ONSPropsDisplayText[i++], 40, 1, "Text", "2;0:99");
	PlayInfo.AddSetting(default.GameGroup, "bRandSetupAfterReset",    default.ONSPropsDisplayText[i++], 0,  1, "Check",        ,,     , true);
	PlayInfo.AddSetting(default.GameGroup, "bSwapSidesAfterReset",    default.ONSPropsDisplayText[i++], 0,  1, "Check",        ,,     , true);
}

static event string GetDescriptionText(string PropName)
{
	switch (PropName)
	{
		case "OvertimeCoreDrainPerSec":	return default.ONSPropDescText[0];
		case "bRandSetupAfterReset":	return default.ONSPropDescText[1];
		case "bSwapSidesAfterReset":	return default.ONSPropDescText[2];
	}

	return Super.GetDescriptionText(PropName);
}

static function array<string> GetAllLoadHints(optional bool bThisClassOnly)
{
	local int i;
	local array<string> Hints;

	if ( !bThisClassOnly || default.ONSHints.Length == 0 )
		Hints = Super.GetAllLoadHints();

	for ( i = 0; i < default.ONSHints.Length; i++ )
		Hints[Hints.Length] = default.ONSHints[i];

	return Hints;
}

event Destroyed()
{
	CustomPowerLinkSetups.length = 0;

	Super.Destroyed();
}

function SetupLinks()
{
	local ONSPowerCore Core;
	local int i;

	if ( PowerCores.Length == 0 )
		return;

	Core = PowerCores[0];
	do
	{
		for ( i = 0; i < Core.PowerLinks.Length; i++ )
			AddLink(Core, Core.PowerLinks[i]);

		Core = Core.NextCore;
	} until ( Core == None || Core == PowerCores[0] );
}

function bool AddLink( ONSPowerCore A, ONSPowerCore B )
{
	local PowerLink Link;

	if ( HasLink(A,B) )
		return false;

	Link = Spawn(class'PowerLink');
	Link.SetNodes(A,B);

//	log(Name@"AddLink Link:"$Link.Name@"A:"$A.Name@"B:"$B.Name);
	PowerLinks[PowerLinks.Length] = Link;
//	A.AddPowerLink(B);
//	A.PowerCoreReset();
//	B.PowerCoreReset();
	return True;
}

function bool RemoveLink( ONSPowerCore A, ONSPowerCore B )
{
	local int i;

	for ( i = PowerLinks.Length - 1; i >= 0; i-- )
	{
		if ( PowerLinks[i] == None )
		{
			PowerLinks.Remove(i,1);
			continue;
		}

		if ( PowerLinks[i].HasNodes(A,B) )
		{
//			A.RemovePowerLink(B);

//			A.PowerCoreReset();
//			B.PowerCoreReset();
			PowerLinks[i].Destroy();
			PowerLinks.Remove(i,1);
			return True;
		}
	}

	return False;
}

function bool HasLink( ONSPowerCore A, ONSPowerCore B )
{
	local int i;

	for ( i = PowerLinks.Length - 1; i >= 0; i-- )
	{
		if ( PowerLinks[i] == None )
		{
			PowerLinks.Remove(i,1);
			continue;
		}

		if ( PowerLinks[i].HasNodes(A,B) )
			return True;
	}

	return False;
}

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

	if ( ONSPlayerReplicationInfo(NewPlayer.PlayerReplicationInfo) != None )
		ONSPlayerReplicationInfo(NewPlayer.PlayerReplicationInfo).ClientPrepareToReceivePowerLinks();
}

function DeadUse(PlayerController PC)
{
	Super.DeadUse(PC);
	PC.ShowMenu();
}

defaultproperties
{
     OvertimeCoreDrainPerSec=20
     bRandSetupAfterReset=True
     bSwapSidesAfterReset=True
     ONSPropsDisplayText(0)="Core Drain in Overtime"
     ONSPropsDisplayText(1)="Random Link Setup After Reset"
     ONSPropsDisplayText(2)="Teams Swap Sides After Reset"
     ONSPropDescText(0)="In overtime, PowerCores lose a maximum of this much health every second."
     ONSPropDescText(1)="After a reset, a new link setup will be chosen at random."
     ONSPropDescText(2)="After a reset, teams will switch sides so they are defending the PowerCore they were previously attacking."
     ONSHints(0)="If you receive a missile lock warning, try to get out of sight quickly!"
     ONSHints(1)="The Raptor's missiles will automatically lock onto Mantas and other Raptors."
     ONSHints(2)="In the Raptor press %JUMP% to fly higher and %DUCK% to fly lower."
     ONSHints(3)="The Manta can rapidly descend to smash your enemies by pressing %DUCK% or %ALTFIRE%."
     ONSHints(4)="Press %JUMP% to perform a 180 spin out in the Hellbender or Scorpion."
     ONSHints(5)="The Manta is the only vehicle that has the ability to jump."
     ONSHints(6)="When deployed, the Leviathan is highly vulnerable to air attacks."
     ONSHints(7)="You can heal a friendly vehicle with the link gun alt-fire."
     ONSHints(8)="You can heal a friendly PowerNode with the link gun alt-fire."
     ONSHints(9)="It is impossible to heal the final PowerCore, so defend it at all costs!"
     ONSHints(10)="Press %TOGGLERADARMAP% to toggle the radar map on and off."
     ONSHints(11)="You can be hurt or killed by vehicles exploding near you."
     ONSHints(12)="Enemy Spider Mines can be destroyed, but some weapons are better against them than others."
     ONSHints(13)="Pressing %USE% on a PowerNode allows you to teleport to any PowerNode your team controls."
     ONSHints(14)="You won't be able to spawn at a PowerNode that is under attack, even if your team controls it."
     ONSHints(15)="If you die, any Spider Mines or Grenades you fired will explode."
     ONSHints(16)="Press %VOICETALK% to voice chat with your team."
     ONSHints(17)="%BASEPATH 0% will show the way to the nearest PowerNode or PowerCore the Red Team can attack, while %BASEPATH 1% will do the same for the Blue Team."
     ONSHints(18)="Press %TOGGLEBEHINDVIEW% to switch between 1st and 3rd person mode in vehicles."
     ONSHints(19)="AVRiL rockets will home into an occupied enemy vehicle as long as you keep your crosshair on it."
     ONSHints(20)="When you find a target with the AVRiL, press alt-fire to zoom and lock your view to that target."
     ONSHints(21)="The green light on top of the weaponlockers indicates that additional ammo is available at that locker."
     ONSHints(22)="Attack PowerNodes that have the enemy team color sky beams above them."
     ONSHints(23)="You cannot attack the PowerCore or PowerNodes if there is an energy shield present. Remove the shield by controlling a node that is linked to it."
     ONSHints(24)="The Grenade Launcher shoots sticky grenades that attach themselves to vehicles and players. You must detonate them yourself with the alternate fire (press %ALTFIRE%)"
     ONSHints(25)="The bomber that the Target Painter calls in can be shot down by enemy fire."
     ONSHints(26)="In Onslaught, your team earns 2 points for winning before overtime and 1 point for a win during overtime."
     bScoreTeamKills=False
     bSpawnInTeamArea=True
     TeamAIType(0)=Class'Onslaught.ONSTeamAI'
     TeamAIType(1)=Class'Onslaught.ONSTeamAI'
     NetWait=15
     bAlwaysShowLoginMenu=True
     DefaultEnemyRosterClass="XGame.xTeamRoster"
     ADR_Kill=2.000000
     LoginMenuClass="GUI2K4.UT2K4OnslaughtLoginMenu"
     bAllowVehicles=True
     bLiberalVehiclePaths=True
     GameUMenuType="GUI2K4.UT2K4OnslaughtLoginMenu"
     HUDSettingsMenu="GUI2K4.CustomHUDMenuOnslaught"
     HUDType="Onslaught.ONSHUDOnslaught"
     MapListType="Onslaught.ONSMapListOnslaught"
     MapPrefix="ONS"
     BeaconName="ONS"
     ResetTimeDelay=11
     GoalScore=3
     MutatorClass="Onslaught.ONSDefaultMut"
     GameName="Onslaught"
     Description="Your team must take control over PowerNodes in a 'connect the dots' fashion to establish a direct line to the enemy PowerCore. Once you establish a link to the next PowerNode, you can destroy it if controlled by the enemy. Control the PowerNode for your team by touching it to start the build process (Use the linkgun alt-fire to speed things up). Once your team has a link to the enemy PowerCore, attack and destroy it."
     ScreenShotName="UT2004Thumbnails.OnslaughtShots"
     DecoTextName="Onslaught.ONSOnslaughtGame"
     Acronym="ONS"
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: pr 5-2-2018 12:35:54.000 - Creation time: sk 18-3-2018 09:50:15.536 - Created with UnCodeX