WT_Data.zsc 20.9 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
enum WT_RankType
{
	Type_Genocide,
	Type_Player,
	Type_Weapons
}

enum WT_ScorecardPage
{
	Page_Main,
	Page_Weapons,
	Page_Monsters
}

class WT_WeaponData
{
	class<Weapon> Object;
	string FolderName;
	string DictionaryName;
	Array<WT_MonsterData> Monsters;

	WT_MonsterData FindMonster(class<Actor> monster)
	{
		for (int i = 0; i < Monsters.Size(); ++i)
		{
			if (Monsters[i].Object == monster)
			{
				return Monsters[i];
			}
		}

		return null;
	}

	int GetKills()
	{
		int TotalKills = 0;
		for (int i = 0; i < Monsters.Size(); ++i)
		{
			TotalKills += Monsters[i].Kills;
		}

		return TotalKills;
	}

	void Reset()
	{
		Monsters.Clear();
	}
}

class WT_MonsterData
{
	class<Actor> Object;
	string DictionaryName;
	int Kills;
}

extend class WT_MainHandler
{
	static const int WeapKillReq[] = { 0, 50, 100, 250, 400, 550, 700, 900, 1000, 1300, 1650, 2000, 2500, 3000, 4000, 5000, 6500, 8000, 10000, 12500, 15000, 20000, 25000 };
	static const string WeapRanks[] =
	{
		"Strange", "Uninteresting", "Barely Threatening", "Slightly Scary", "Unfriendly", "Not Too Rough", "Plenty Hurtful", "Perfectly Ordinary", "Face-Gibbing", "Agitating", "Map-clearing", "Barbaric", "Megawad-purging", "Ultraviolent", "Absolutely Barbaric", "Nightmare-inducing", "Epic", "Legendary", "American", "id Select", "Hall's Custom", "Carmack's Prized", "Romero's Own",
		"Neophyte", "Beginner", "Rookie", "Trainee", "Disciple", "Adept", "Regular User", "Operator", "Skilled Handler", "Aficionado", "Enthusiast", "Connoisseur", "Whizkid", "Specialist", "Professional", "Expert", "Veteran", "Master", "Ace", "Virtuoso", "Supreme Talent", "Godlike", "Transcended",
66
67
		"Sad", "Unmerry", "Barely Mirthful", "Slightly Enjoyed", "Unboxed", "Not Too Festive", "Plenty Pleasant", "Perfectly Giftable", "Face-Smiling", "Exciting", "Map-blessing", "Beautiful", "Megawad-prettying", "Ultralovable", "Absolutely Bountiful", "Nightmare-reducing", "Frown-Annihilating", "Epically Enjoyable", "Legendarily Lively", "Christmas Select", "Krampus Select", "Nick's Favorite", "Santa's Own",
		"Scrap", "Unworthy",  "Desperately Used", "Ordinary", "Often Overlooked", "Basic Arm", "Proved Useful", "Legion Standard", "Armorer Recommended", "Merciless", "Army-destroying", "Royal Supply", "Brutal", "Creed's Option", "Hell-forged", "Black Death", "Sacred", "Sigil's Torment", "Armageddon's Tool", "King's Chosen", "Demon's Ultimatum", "Archangel's Instrument", "Outlander's Own"
68
69
70
71
72
73
	};

	static const int GenocideReqs[] = { 0, 50, 100, 250, 500, 1000, 1500, 2500, 3500, 4500, 6000, 7500, 9000, 11111, 13333, 16666, 20000, 25000, 30000, 35000, 50000, 70000, 99999, 125000, 175000, 250000, 350000, 500000, 750000, 1000000 };
	static const string GenocideRanks[] =
	{
		"Pacifist", "Innocent", "Craven", "Unbloodied", "Gun-shy", "Rank-and-file", "Basic Grunt", "Diablophobe", "Grave Digger", "Butcher", "Spree Killer", "Bounty Hunter", "Master Gunman", "Elite Warrior", "Mass Assassin", "Basically Mor'Ladim", "Ludicrous", "The Cleaner", "Psychopath", "Warlord", "Bloodthirsty", "Anti-Army Weapon", "Okuplok", "Unstoppable Force", "Carnage Elemental", "Grim Reaper", "Icon of Slay", "Death Incarnate", "Doomslayer", "Origin Exstinctum",
74
75
		"Destitute", "Sad", "Morose", "Unfun", "Groveling", "Ambivalent", "Silly", "Pleased", "Happy", "Cheerful", "Delighted", "Joyous", "Bold", "Proud", "Dignified", "Honored", "Noble", "Exalted", "Breathtaking", "Awe-Inspiring", "Outrageous", "Extravagant", "Spectacular", "Majestic", "Magnificient", "Sublime", "Icon of Festivity", "Generosity Incarnate", "Dourslayer", "Origin Gaudium",
		"Lost Soul", "Former Human", "Z-Sec", "Maggot", "Imp", "Wraith", "Hellhound", "Demon", "Spectre", "Former Commando", "Cacodemon", "Arachnotron", "Revenant", "Hell Knight", "Mancubus", "Pain Elemental", "Summoner", "Baron of Hell", "Hell Guard", "Arch-Vile", "Hell Hunter", "Marauder", "Gladiator", "Cyberdemon", "Spider Mastermind", "Harbinger", "Mother Demon", "Maledict", "Khan Maykr", "Icon Of Sin"
76
77
78
79
80
81
	};

	static const int XPReq[] = { 0, 5000, 8500, 12500, 16000, 20000, 25000, 31000, 37000, 45000, 60000, 85000, 100000, 125000, 175000, 250000, 400000, 600000, 900000, 1150000, 1400000, 1900000, 2850000, 4000000, 5000000 };
	static const string XPRanks[] =
	{
		"Private", "Private 1st Class", "Corporal", "Sergeant", "Staff Sergeant", "Sergeant 1st Class", "Master Sergeant", "First Sergeant", "Sergeant Major", "Cmd. Sergeant Major", "Master Chief Sergeant", "2nd Lieutenant", "1st Lieutenant", "Captain", "Major", "Lieutenant Colonel", "Colonel", "Brigadier General", "Major General", "Lieutenant General", "General", "General of the Army", "Field Marshal", "Force Of Freedom", "Savior of Humanity",
82
83
		"Elf", "Basic Benefactor", "Competent Contributor", "Adequate Altruist", "Satisfactory Santa", "Sufficient Samaritan", "Distinguished Donator", "Dynamic Do-gooder", "Consummate Conferrer", "Bequeathment Baron", "Lord of Largesses", "Chieftain of Charity", "General of Generosity", "Bigshot Backer", "Caesar of Pleasers", "First-class Philanthropist", "Humanitarian Hotshot", "Selfless Subscriber", "Epic Endorser", "Legendary Lender", "Awe-inspiry Ally", "Champion Collaborator", "Fabulous Friend", "Perfect Partner", "Seriously Santa",
		"Unemployed", "UAC Employee", "Mars Security", "Marine Private", "Marine Grunt", "Marine Specialist", "Marine Sergeant", "Marine Recon", "Marine Commando", "Marine Lieutenant", "Marine Captain", "Rapid Response Operative", "ARC Soldier", "ARC Mech Pilot", "ARC Strike Operative", "ARC Elite", "Outlander", "Argent Conscript", "Night Sentinel", "Sentinel Priest", "Sentinel Inquisitor", "Sentinel Paladin", "Sentinel Commander", "Sentinel Patriarch", "Divine Destroyer"
84
85
	};

86
	private Dictionary ProjectileBinds; // [Ace] Key - projectile, value - weapon.
87

Accensus's avatar
Accensus committed
88
89
	private int AutosaveTimer;

90
91
92
	private bool DrawUi;
	private bool DisableSaving;

93
	private string SearchFilter;
94

95
96
97
	private CVar WeaponStorage;
	private CVar ExperienceStorage;
	private CVar PrestigeStorage;
98

Accensus's avatar
Accensus committed
99
100
	private CVar AutosaveInterval;

101
102
	private CVar UiFont;
	private CVar RankSets[3];
103

104
	private CVar KillSoundType;
105

106
107
108
	private CVar ScorecardTheme;
	private CVar ScorecardScale;
	private CVar DarkerDisplays;
109

110
111
112
113
114
115
116
117
	private CVar LiteHudType;
	private CVar LiteHudOrientation;
	private CVar LiteHudScale;
	private CVar LiteHudOffsetX;
	private CVar LiteHudOffsetY;
	private CVar LiteHudColors[7];
	private CVar LiteHudAlpha;
	private CVar LiteHudVisibilityFlags;
118

119
120
	private CVar ScreenBlocks;

121
	private int SelectedPage;
122

123
124
	private class<Weapon> SelectedWeaponWorld;
	private WT_WeaponData SelectedWeaponLite;
125

126
127
	private int SelectedWeaponListIndex;
	private WT_WeaponData SelectedWeaponList;
128

129
	private Array<WT_WeaponData> AllWeapons;
130

131
132
	private Array<WT_WeaponData> AvailableWeapons;
	private Array<WT_MonsterData> AvailableMonsters; // [Ace] This is used for two things: monster list for current weapon and full monster list.
133

134
135
	private int Experience;
	private int Prestige;
136
137

	// [Ace] Global cache. These are here so they don't get reset all the time. With some exceptions. Part of the memory leak patch. Also boosts performance.
138
139
140
141
	private int TotalKillsEver;
	private int TotalKillsAvailable;
	private int SelWeaponKills;
	private int MaxRankMedals;
142
143
144
145
146

	// --------------------------------------------------
	// SAVING
	// --------------------------------------------------

147
	private void SetSavingStatus(bool status)
148
	{
149
		switch (status)
150
		{
151
152
			case false: SaveData(true, true); break;
			case true: Initialize(); break;
153
		}
154
155
156

		DisableSaving = !status;
		Console.Printf("Kill saving "..(DisableSaving ? "disabled." : "enabled. Old stats restored."));		
157
158
	}

159
	private void SaveData(bool manual, bool print)
160
161
162
163
164
165
166
167
168
169
	{
		if (DisableSaving)
		{
			if (manual)
			{
				Console.Printf("You are trying to save stats while kill saving is disabled. Turn it off first.");
				return;
			}
			else
			{
170
				SetSavingStatus(true);
171
172
173
			}
		}

174
175
176
177
178
179
180
181
182
183
184
185
186
		Dictionary WeaponStats = Dictionary.Create();
		for (int i = 0; i < AllWeapons.Size(); ++i)
		{
			WT_WeaponData CurrWeapon = AllWeapons[i];
			Dictionary MonsterStats = Dictionary.Create();
			for (int j = 0; j < CurrWeapon.Monsters.Size(); ++j)
			{
				WT_MonsterData CurrMonster = CurrWeapon.Monsters[j];
				MonsterStats.Insert(CurrMonster.DictionaryName, String.Format("%i", CurrMonster.Kills));
			}
			WeaponStats.Insert(CurrWeapon.DictionaryName, MonsterStats.ToString());
		}
		
187
188
189
190
191
192
		if (WeaponStorage)
		{
			WeaponStorage.SetString(WeaponStats.ToString());
			ExperienceStorage.SetInt(Experience);
			PrestigeStorage.SetInt(Prestige);
		}
193

194
195
196
197
		if (print)
		{
			Console.Printf("Stats have been saved.");
		}
198
199
200
201
	}

	override void WorldUnloaded(WorldEvent e)
	{
202
		SaveData(false, false);
203
204
205
206
	}

	override void OnUnregister()
	{
207
		SaveData(false, false);
208
209
	}

Accensus's avatar
Accensus committed
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
	override void WorldTick()
	{
		// [Ace] Update weapon.
		if (level.time % 2 == 0)
		{
			let plr = PlayerPawn(players[consoleplayer].mo);
			if (plr && plr.player && plr.player.ReadyWeapon)
			{
				class<Weapon> OldWeapon = SelectedWeaponWorld;

				// [Ace] If the weapon is a powered up version, use the main one instead.
				SelectedWeaponWorld = plr.player.ReadyWeapon.bPOWERED_UP ? plr.Player.ReadyWeapon.SisterWeaponType : plr.player.ReadyWeapon.GetClass();

				if (SelectedWeaponWorld != OldWeapon)
				{
					SelectLiteWeapon();
				}
			}
		}

		if (AutosaveInterval.GetInt() > 0 && --AutosaveTimer <= 0)
		{
232
			SaveData(false, false);
Accensus's avatar
Accensus committed
233
234
235
236
			AutosaveTimer = (35 * 60) * AutosaveInterval.GetInt();
		}
	}

237
238
239
240
	// --------------------------------------------------
	// INITIALIZATION
	// --------------------------------------------------

Accensus's avatar
Accensus committed
241
	override void WorldLoaded(WorldEvent e)
242
243
244
245
246
	{
		WeaponStorage = CVar.FindCVar('wt_stats_weapons_kills');
		ExperienceStorage = CVar.FindCVar('wt_stats_experience');
		PrestigeStorage = CVar.FindCVar('wt_stats_prestige');

247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
		AutosaveInterval = CVar.FindCVar('wt_autosave_interval');

		IWADWeaponFilter = CVar.FindCVar('wt_filter_iwad_weapons');
		IWADMonsterFilter = CVar.FindCVar('wt_filter_iwad_monsters');

		ScorecardTheme = CVar.FindCVar('wt_scorecard_theme');
		ScorecardScale = CVar.FindCVar('wt_scorecard_scale');
		DarkerDisplays = CVar.FindCVar('wt_scorecard_blackdisplays');

		RankSets[Type_Genocide] = CVar.FindCVar('wt_rankset_genocide');
		RankSets[Type_Player] = CVar.FindCVar('wt_rankset_player');
		RankSets[Type_Weapons] = CVar.FindCVar('wt_rankset_weapons');

		LiteHudType = CVar.FindCVar('wt_showlite');
		LiteHudOrientation = CVar.FindCVar('wt_lite_orientation');
		LiteHudScale = CVar.FindCVar('wt_lite_scale');
		LiteHudOffsetX = CVar.FindCVar('wt_lite_offset_x');
		LiteHudOffsetY = CVar.FindCVar('wt_lite_offset_y');
		LiteHudAlpha = CVar.FindCVar('wt_lite_alpha');
		LiteFolderView = CVar.FindCVar('wt_lite_usefolders');
		LiteHudColors[LElement_Labels] = CVar.FindCVar('wt_lite_color_labels');
		LiteHudColors[LElement_TotalKills] = CVar.FindCVar('wt_lite_color_totalkills');
		LiteHudColors[LElement_GenocideRank] = CVar.FindCVar('wt_lite_color_genociderank');
		LiteHudColors[LElement_PlayerRank] = CVar.FindCVar('wt_lite_color_playerrank');
		LiteHudColors[LElement_WeaponName] = CVar.FindCVar('wt_lite_color_weaponname');
		LiteHudColors[LElement_WeaponRank] = CVar.FindCVar('wt_lite_color_weaponrank');
		LiteHudColors[LElement_WeaponKills] = CVar.FindCVar('wt_lite_color_weaponkills');
		LiteHudVisibilityFlags = CVar.FindCVar('wt_lite_adv_visibility');

		UiFont = CVar.FindCVar('wt_ui_font');
		KillSoundType = CVar.FindCVar('wt_killsound');
		BlacklistEnabled = CVar.FindCVar('wt_blacklist_enable');

		ScreenBlocks = CVar.FindCVar('screenblocks');
281

282
		Initialize();
283
284
	}

285
	private void Initialize()
286
287
	{
		ProjectileBinds = Dictionary.Create();
288
		InitCompatibilityBinds();
289

290
291
		Experience = ExperienceStorage.GetInt();
		Prestige = PrestigeStorage.GetInt();
292

Accensus's avatar
Accensus committed
293
294
		AutosaveTimer = (35 * 60) * AutosaveInterval.GetInt();

295
296
297
298
		InitAllWeapons();
		InitWeaponFolders();
		InitLiteHud();
	}
299

300
301
302
303
304
	private void ResetProgress()
	{
		WeaponStorage.ResetToDefault();
		ExperienceStorage.ResetToDefault();
		PrestigeStorage.ResetToDefault();
305

306
307
		Experience = 0;
		Prestige = 0;
308

309
		AllWeapons.Clear();
310

311
		Initialize();
312
313
314
315
316
317
	}

	private void InitAllWeapons()
	{
		AllWeapons.Clear();

318
		let it1 = DictionaryIterator.Create(Dictionary.FromString(WeaponStorage.GetString().MakeLower()));
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
		while (it1.Next())
		{
			class<Weapon> wpn = it1.Key();

			WT_WeaponData WeaponData = new("WT_WeaponData");
			WeaponData.DictionaryName = it1.Key();
			WeaponData.Object = wpn;
				
			// Monsters.
			Array<WT_MonsterData> MonsterList;
			let it2 = DictionaryIterator.Create(Dictionary.FromString(it1.Value()));
			while (it2.Next())
			{
				class<Actor> mon = it2.Key();
				
				WT_MonsterData MonsterData = new("WT_MonsterData");
				MonsterData.DictionaryName = it2.Key();
				MonsterData.Object = mon;
				MonsterData.Kills = int(it2.Value().ToDouble());

				MonsterList.Push(MonsterData);
			}

			WeaponData.Monsters.Move(MonsterList);
			AllWeapons.Push(WeaponData);
		}
	}

	private void InitScorecard(WT_ScorecardPage page)
	{
		switch (page)
		{
			case Page_Main:
352
				InitAvailableWeapons(1);
353
				SelectScorecardWeapon();
354
355
				TotalKillsEver = GetTotalKillsEver();
				TotalKillsAvailable = GetTotalKillsAvailable();
356
357
358
				MaxRankMedals = GetMaxRankMedalCount();
				break;
			case Page_Weapons:
359
				InitAvailableWeapons(2);
360
361
362
363
364
365
366
367
368
369
370
371
372
373
				break;
			case Page_Monsters:
				InitAllAvailableMonsters();
				break;
		}
	}

	private void InitLiteHud()
	{
		InitAvailableWeapons();
		SelectLiteWeapon();
		TotalKillsEver = GetTotalKillsEver();
	}

374
	private void InitAvailableWeapons(int sortType = 0)
375
376
377
378
379
380
381
382
	{
		AvailableWeapons.Clear();
		int WFilter = IWADWeaponFilter.GetInt();

		for (int i = 0; i < AllWeapons.Size(); ++i)
		{
			WT_WeaponData wpn = AllWeapons[i];
			int IwadTypeWpn = GetIwadType(Search_Weapons, wpn.Object);
383
			if (wpn.Object && ((WFilter == Filter_All || WFilter == IWadTypeWpn || IwadTypeWpn == Filter_None) && (SearchFilter == "" || GetActorTag(wpn.Object).MakeLower().IndexOf(SearchFilter.MakeLower()) != -1)))
384
385
386
387
			{
				AvailableWeapons.Push(AllWeapons[i]);
			}
		}
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417

		for (int i = 0; sortType > 0 && i < AvailableWeapons.Size() - 1; ++i)
		{
			for (int j = i + 1; j < AvailableWeapons.Size(); ++j)
			{
				bool Check;
				switch (sortType)
				{
					// [Ace] Sort by numbers first, then by first letter if the numbers match.
					case 1:
						let CurrWeapon = GetDefaultByType(AvailableWeapons[i].Object);
						let NextWeapon = GetDefaultByType(AvailableWeapons[j].Object);

						Check = CurrWeapon.SlotNumber >= NextWeapon.SlotNumber || (CurrWeapon.SlotNumber == NextWeapon.SlotNumber && String.Format("%s", CurrWeapon.GetClassName()).ByteAt(0) >= String.Format("%s", NextWeapon.GetClassName()).ByteAt(0));
						break;

					// [Ace] Sort by kills.
					case 2:
						Check = AvailableWeapons[i].GetKills() <= AvailableWeapons[j].GetKills();
						break;
				}

				if (Check)
				{
					let Swap = AvailableWeapons[i];
					AvailableWeapons[i] = AvailableWeapons[j];
					AvailableWeapons[j] = Swap;
				}
			}
		}
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
	}

	private void InitAvailableMonsters(WT_WeaponData wpn)
	{
		AvailableMonsters.Clear();
		int MFilter = IWADMonsterFilter.GetInt();

		for (int i = 0; wpn && i < wpn.Monsters.Size(); ++i)
		{
			WT_MonsterData mon = wpn.Monsters[i];
			int IwadTypeMon = GetIwadType(Search_Monsters, mon.Object);
			if (mon.Object && (MFilter == Filter_All || MFilter == IWadTypeMon || IwadTypeMon == Filter_None))
			{
				AvailableMonsters.Push(wpn.Monsters[i]);
			}
		}
434
435
436
437
438
439
440
441
442
443
444
445
446
447

		// [Ace] Sort by kills.
		for (int i = 0; i < AvailableMonsters.Size() - 1; ++i)
		{
			for (int j = i + 1; j < AvailableMonsters.Size(); ++j)
			{
				if (AvailableMonsters[i].Kills <= AvailableMonsters[j].Kills)
				{
					let Swap = AvailableMonsters[i];
					AvailableMonsters[i] = AvailableMonsters[j];
					AvailableMonsters[j] = Swap;
				}
			}
		}
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
	}

	private void InitAllAvailableMonsters()
	{
		InitAvailableWeapons();
		AvailableMonsters.Clear();

		for (int i = 0; i < AvailableWeapons.Size(); ++i)
		{
			let CurrWeapon = AvailableWeapons[i];

			for (int j = 0; j < CurrWeapon.Monsters.Size(); ++j)
			{
				let CurrMonster = CurrWeapon.Monsters[j];
				
				if (CurrMonster.Object && !MonsterExists(AvailableMonsters, CurrMonster))
				{
					WT_MonsterData NewMonster = new("WT_MonsterData");
					NewMonster.Object = CurrMonster.Object;
					NewMonster.DictionaryName = CurrMonster.DictionaryName;
					NewMonster.Kills = GetTotalKillsForMonster(CurrMonster.Object);

					AvailableMonsters.Push(NewMonster);
				}
			}
		}
474
475
476
477
478
479
480
481
482
483
484
485
486
487

		// [Ace] Sort by kills. Yes, this was copy-pasted.
		for (int i = 0; i < AvailableMonsters.Size() - 1; ++i)
		{
			for (int j = i + 1; j < AvailableMonsters.Size(); ++j)
			{
				if (AvailableMonsters[i].Kills <= AvailableMonsters[j].Kills)
				{
					let Swap = AvailableMonsters[i];
					AvailableMonsters[i] = AvailableMonsters[j];
					AvailableMonsters[j] = Swap;
				}
			}
		}
488
489
490
491
492
493
494
495
496
497
498
	}

	private void InitWeaponFolders()
	{
		CreateFolderBindings();
		for (int i = 0; i < AllWeapons.Size(); ++i)
		{
			AllWeapons[i].FolderName = FolderBindings.At(AllWeapons[i].DictionaryName); // [Ace] DictionaryName is guaranteed to be lower case. If it's not, see a doctor.
		}
	}

499
500
501
502
503
504
	private void InitCompatibilityBinds()
	{
		ProjectileBinds.Insert("fdjpcpsealingdamage", "fdjpcpplasmarifle");
		ProjectileBinds.Insert("fdjpcpfancysealingdamage", "fdjpcpplasmarifle");
	}

505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
	// --------------------------------------------------
	// FUNCTIONS
	// --------------------------------------------------

	private void SwitchScorecardPage(int page)
	{
		SelectedPage = page > Page_Monsters ? Page_Main : (page < 0 ? Page_Monsters : page);
		InitScorecard(SelectedPage);
	}

	private void SelectScorecardWeapon()
	{
		if (AvailableWeapons.Size() == 0)
		{
			SelectWeaponInList(-1);
			return;
		}

		for (int i = 0; i < AvailableWeapons.Size(); ++i)
		{
			if (AvailableWeapons[i].Object == SelectedWeaponWorld)
			{
				SelectWeaponInList(i);
				return;
			}

			SelectWeaponInList(0);
		}
	}

	private void SelectLiteWeapon()
	{
		SelectedWeaponLite = FindWeapon(SelectedWeaponWorld);
		if (SelectedWeaponLite)
		{
			int FolderKills = -1;
			if (LiteFolderView.GetInt() > 0)
			{
				FolderKills = GetFolderKills(SelectedWeaponLite.FolderName);
			}
			SelWeaponKills = FolderKills > -1 ? FolderKills : SelectedWeaponLite.GetKills();
		}
	}

	// [Ace] If the list suddenly goes blank, reset the index to 0. It also prevents out-of-index exceptions if you've selected the last weapon in the list and apply a filter which will reduce the total count.
	private void SelectWeaponInList(int index)
	{
		if (AvailableWeapons.Size() > 0)
		{
554
			SelectedWeaponListIndex = clamp(index, 0, AvailableWeapons.Size() - 1);
555
556
557
558
559
560
561
			SelectedWeaponList = AvailableWeapons[SelectedWeaponListIndex];
			InitAvailableMonsters(SelectedWeaponList);
			SelWeaponKills = SelectedWeaponList.GetKills();
			return;
		}

		SelectedWeaponListIndex = 0;
562
		SelectedWeaponList = null;
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
	}

	private WT_WeaponData FindWeapon(class<Weapon> wpn)
	{
		if (!wpn)
		{
			return null;
		}

		for (int i = 0; i < AllWeapons.Size(); ++i)
		{
			if (AllWeapons[i].Object == wpn)
			{
				return AllWeapons[i];
			}
		}

		return null;
	}

	// --------------------------------------------------
	// INFORMATION
	// --------------------------------------------------

	// [Ace] Checks if there's a custom tag. If not, gets the tag. If no tag is present either, get class name.
	private string GetActorTag(class<Actor> a) const
	{
		string Tag = GetDefaultByType(a).GetTag();
		string CustomTag = GetCustomTag(a);
		
		return CustomTag != "" ? CustomTag : Tag; // [Ace] Tag will be class name if it doesn't exist.
	}

	private int GetFolderKills(string folder)
	{
		if (folder == "")
		{
			return -1;
		}

		int TotalKills = 0;
		for (int i = 0; i < AllWeapons.Size(); ++i)
		{
			if (AllWeapons[i].FolderName ~== folder)
			{
				TotalKills += AllWeapons[i].GetKills();
			}
		}
		return TotalKills;
	}

	private int GetTotalKillsEver()
	{
		int TotalKills = 0;
		for (int i = 0; i < AllWeapons.Size(); ++i)
		{
			TotalKills += AllWeapons[i].GetKills();
		}
		return TotalKills;
	}

624
	// [Ace] This doesn't use the AvailableWeapons array because it needs to be independent from search filter, as the filter affects what gets put in that array.
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
	// This is only used to get the preference percentage for the available weapons.
	private int GetTotalKillsAvailable()
	{
		int TotalKills = 0;
		for (int i = 0; i < AllWeapons.Size(); ++i)
		{
			let CurrWeapon = AllWeapons[i];
			if (CurrWeapon.Object)
			{
				TotalKills += CurrWeapon.GetKills();
			}
		}
		return TotalKills;
	}

	private int GetTotalKillsForMonster(class<Actor> monster)
	{
		int TotalKills = 0;
		for (int i = 0; i < AvailableWeapons.Size(); ++i)
		{
			WT_MonsterData Mon;
			if (Mon = AvailableWeapons[i].FindMonster(monster))
			{
				TotalKills += Mon.Kills;
			}
		}
		return TotalKills;
	}

	private int GetMaxRankMedalCount()
	{
		int Count = 0;
		for (int i = 0; i < AvailableWeapons.Size(); ++i)
		{
			if (AvailableWeapons[i].GetKills() >= WeapKillReq[WeapKillReq.Size() - 1])
			{
				Count++;
			}
		}
		return Count;
	}

	private bool MonsterExists(Array<WT_MonsterData> arr, WT_MonsterData monster)
	{
		for (int i = 0; i < arr.Size(); ++i)
		{
			if (arr[i].Object == monster.Object)
			{
				return true;
			}
		}

		return false;
	}
}