2021-06-20 05:04:22 +00:00
|
|
|
class YASMut extends KFMutator
|
2021-06-08 23:43:00 +00:00
|
|
|
dependson(Types)
|
2021-06-20 05:04:22 +00:00
|
|
|
config(YAS);
|
2021-05-31 01:46:53 +00:00
|
|
|
|
2021-06-12 20:11:37 +00:00
|
|
|
`include(Build.uci)
|
|
|
|
`include(Logger.uci)
|
2021-05-31 01:46:53 +00:00
|
|
|
|
2021-07-05 03:02:30 +00:00
|
|
|
const CurrentVersion = 2;
|
2021-06-13 00:02:17 +00:00
|
|
|
|
2021-05-31 01:46:53 +00:00
|
|
|
var config int ConfigVersion;
|
|
|
|
|
2021-06-12 18:44:20 +00:00
|
|
|
var private OnlineSubsystem Steamworks;
|
|
|
|
|
2021-05-31 01:46:53 +00:00
|
|
|
struct SClient
|
|
|
|
{
|
2021-06-20 05:04:22 +00:00
|
|
|
var YASRepInfo RepInfo;
|
2021-05-31 01:46:53 +00:00
|
|
|
var KFPlayerController KFPC;
|
|
|
|
};
|
|
|
|
|
2021-06-13 03:17:40 +00:00
|
|
|
var private array<SClient> RepClients;
|
|
|
|
var private array<UIDRankRelation> UIDRankRelationsPlayers;
|
|
|
|
var private array<UIDRankRelation> UIDRankRelationsSteamGroups;
|
|
|
|
var private array<UIDRankRelation> UIDRankRelationsActive;
|
2021-06-20 20:09:12 +00:00
|
|
|
var private YASSettings Settings;
|
2020-01-10 13:14:11 +00:00
|
|
|
|
2020-01-18 01:54:24 +00:00
|
|
|
function PostBeginPlay()
|
2020-01-10 13:14:11 +00:00
|
|
|
{
|
2021-06-12 20:11:37 +00:00
|
|
|
`callstack();
|
|
|
|
|
2021-05-16 09:40:02 +00:00
|
|
|
Super.PostBeginPlay();
|
2021-06-09 00:58:31 +00:00
|
|
|
|
2021-06-20 05:04:22 +00:00
|
|
|
WorldInfo.Game.HUDType = class'YASHUD';
|
2021-06-12 18:44:20 +00:00
|
|
|
Steamworks = class'GameEngine'.static.GetOnlineSubsystem();
|
2021-06-09 00:58:31 +00:00
|
|
|
|
2021-05-31 01:46:53 +00:00
|
|
|
InitConfig();
|
2021-06-12 18:44:20 +00:00
|
|
|
|
|
|
|
LoadRelations();
|
2021-06-09 00:58:31 +00:00
|
|
|
|
|
|
|
Settings.Style = class'ScoreboardStyle'.static.Settings();
|
|
|
|
Settings.Admin = class'SystemAdminRank'.static.Settings();
|
|
|
|
Settings.Player = class'SystemPlayerRank'.static.Settings();
|
2021-07-05 03:02:30 +00:00
|
|
|
Settings.Health = class'SettingsHealth'.static.Settings();
|
|
|
|
Settings.Armor = class'SettingsArmor'.static.Settings();
|
|
|
|
Settings.Ping = class'SettingsPing'.static.Settings();
|
|
|
|
Settings.Level = class'SettingsLevel'.static.Settings();
|
2021-05-31 01:46:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function NotifyLogin(Controller C)
|
|
|
|
{
|
2021-06-12 20:11:37 +00:00
|
|
|
`callstack();
|
|
|
|
|
2021-06-08 21:48:03 +00:00
|
|
|
AddPlayer(C);
|
2021-05-31 01:46:53 +00:00
|
|
|
Super.NotifyLogin(C);
|
|
|
|
}
|
|
|
|
|
|
|
|
function NotifyLogout(Controller C)
|
|
|
|
{
|
2021-06-12 20:11:37 +00:00
|
|
|
`callstack();
|
|
|
|
|
2021-06-08 21:48:03 +00:00
|
|
|
RemovePlayer(C);
|
2021-05-31 01:46:53 +00:00
|
|
|
Super.NotifyLogout(C);
|
|
|
|
}
|
|
|
|
|
2021-06-12 20:11:37 +00:00
|
|
|
private function bool IsUID(String ID)
|
|
|
|
{
|
|
|
|
`callstack();
|
|
|
|
|
|
|
|
return (Left(ID, 2) ~= "0x");
|
|
|
|
}
|
|
|
|
|
2021-05-31 01:46:53 +00:00
|
|
|
private function InitConfig()
|
|
|
|
{
|
2021-06-12 20:11:37 +00:00
|
|
|
`callstack();
|
|
|
|
|
2021-07-05 03:02:30 +00:00
|
|
|
if (ConfigVersion == 0) SaveConfig(); // because I want the main settings to be at the beginning of the config :)
|
|
|
|
|
|
|
|
class'ScoreboardStyle'.static.InitConfig(ConfigVersion);
|
|
|
|
class'SystemAdminRank'.static.InitConfig(ConfigVersion);
|
|
|
|
class'SystemPlayerRank'.static.InitConfig(ConfigVersion);
|
|
|
|
class'SettingsHealth'.static.InitConfig(ConfigVersion);
|
|
|
|
class'SettingsArmor'.static.InitConfig(ConfigVersion);
|
|
|
|
class'SettingsPing'.static.InitConfig(ConfigVersion);
|
|
|
|
class'SettingsLevel'.static.InitConfig(ConfigVersion);
|
|
|
|
class'CustomRanks'.static.InitConfig(ConfigVersion);
|
|
|
|
class'PlayerRankRelations'.static.InitConfig(ConfigVersion);
|
|
|
|
class'SteamGroupRankRelations'.static.InitConfig(ConfigVersion);
|
|
|
|
|
2021-05-31 01:46:53 +00:00
|
|
|
switch (ConfigVersion)
|
|
|
|
{
|
2021-07-05 03:02:30 +00:00
|
|
|
case 0:
|
|
|
|
case 1:
|
2021-05-31 01:46:53 +00:00
|
|
|
case 2147483647:
|
2021-06-13 00:02:17 +00:00
|
|
|
`info("Config updated to version"@CurrentVersion);
|
2021-05-31 01:46:53 +00:00
|
|
|
break;
|
2021-06-12 18:44:20 +00:00
|
|
|
|
2021-06-13 00:02:17 +00:00
|
|
|
case CurrentVersion:
|
2021-06-12 20:11:37 +00:00
|
|
|
`info("Config is up-to-date");
|
2021-05-31 01:46:53 +00:00
|
|
|
break;
|
2021-06-12 18:44:20 +00:00
|
|
|
|
2021-05-31 01:46:53 +00:00
|
|
|
default:
|
2021-06-12 20:11:37 +00:00
|
|
|
`warning("The config version is higher than the current version (are you using an old mutator?)");
|
2021-06-13 00:02:17 +00:00
|
|
|
`warning("Config version is"@ConfigVersion@"but current version is"@CurrentVersion);
|
|
|
|
`warning("The config version will be changed to "@CurrentVersion);
|
2021-05-31 01:46:53 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-06-13 00:02:17 +00:00
|
|
|
if (ConfigVersion != CurrentVersion)
|
2021-06-08 20:31:56 +00:00
|
|
|
{
|
2021-06-13 00:02:17 +00:00
|
|
|
ConfigVersion = CurrentVersion;
|
2021-06-08 20:31:56 +00:00
|
|
|
SaveConfig();
|
|
|
|
}
|
2021-05-31 01:46:53 +00:00
|
|
|
}
|
|
|
|
|
2021-06-12 18:44:20 +00:00
|
|
|
private function LoadRelations()
|
2021-05-31 01:46:53 +00:00
|
|
|
{
|
2021-06-12 18:44:20 +00:00
|
|
|
local RankRelation Player, SteamGroup;
|
2021-06-08 21:21:28 +00:00
|
|
|
local UIDRankRelation UIDInfo;
|
2021-05-31 01:46:53 +00:00
|
|
|
|
2021-06-12 20:11:37 +00:00
|
|
|
`callstack();
|
|
|
|
|
2021-06-08 21:48:03 +00:00
|
|
|
foreach class'PlayerRankRelations'.default.Relation(Player)
|
2021-05-31 01:46:53 +00:00
|
|
|
{
|
2021-06-08 21:21:28 +00:00
|
|
|
UIDInfo.RankID = Player.RankID;
|
2021-06-12 20:11:37 +00:00
|
|
|
if (IsUID(Player.ObjectID) && Steamworks.StringToUniqueNetId(Player.ObjectID, UIDInfo.UID))
|
2021-05-31 01:46:53 +00:00
|
|
|
{
|
2021-06-12 18:44:20 +00:00
|
|
|
if (UIDRankRelationsPlayers.Find('Uid', UIDInfo.UID) == INDEX_NONE)
|
|
|
|
UIDRankRelationsPlayers.AddItem(UIDInfo);
|
2021-05-31 01:46:53 +00:00
|
|
|
}
|
2021-06-12 20:11:37 +00:00
|
|
|
else if (Steamworks.Int64ToUniqueNetId(Player.ObjectID, UIDInfo.UID))
|
2021-05-31 01:46:53 +00:00
|
|
|
{
|
2021-06-12 18:44:20 +00:00
|
|
|
if (UIDRankRelationsPlayers.Find('Uid', UIDInfo.UID) == INDEX_NONE)
|
|
|
|
UIDRankRelationsPlayers.AddItem(UIDInfo);
|
2021-05-31 01:46:53 +00:00
|
|
|
}
|
2021-06-12 20:11:37 +00:00
|
|
|
else `warning("Can't add player:"@Player.ObjectID);
|
2021-06-12 18:44:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach class'SteamGroupRankRelations'.default.Relation(SteamGroup)
|
|
|
|
{
|
|
|
|
UIDInfo.RankID = SteamGroup.RankID;
|
2021-06-12 20:11:37 +00:00
|
|
|
if (IsUID(SteamGroup.ObjectID) && Steamworks.StringToUniqueNetId(SteamGroup.ObjectID, UIDInfo.UID))
|
|
|
|
{
|
|
|
|
if (UIDRankRelationsPlayers.Find('Uid', UIDInfo.UID) == INDEX_NONE)
|
|
|
|
UIDRankRelationsPlayers.AddItem(UIDInfo);
|
|
|
|
}
|
|
|
|
else if (Steamworks.Int64ToUniqueNetId(SteamGroup.ObjectID, UIDInfo.UID))
|
2021-06-12 18:44:20 +00:00
|
|
|
{
|
|
|
|
if (UIDRankRelationsSteamGroups.Find('Uid', UIDInfo.UID) == INDEX_NONE)
|
|
|
|
UIDRankRelationsSteamGroups.AddItem(UIDInfo);
|
|
|
|
}
|
2021-06-12 20:11:37 +00:00
|
|
|
else `warning("Can't add steamgroup:"@SteamGroup.ObjectID);
|
2021-05-31 01:46:53 +00:00
|
|
|
}
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|
|
|
|
|
2021-06-12 18:44:20 +00:00
|
|
|
private function AddPlayer(Controller C)
|
2020-01-17 18:46:21 +00:00
|
|
|
{
|
2021-05-31 01:46:53 +00:00
|
|
|
local KFPlayerController KFPC;
|
2021-06-12 18:44:20 +00:00
|
|
|
local UIDRankRelation Relation;
|
2021-06-12 20:11:37 +00:00
|
|
|
local SClient RepClient, RepClientNew;
|
|
|
|
|
|
|
|
`callstack();
|
2021-05-31 04:04:26 +00:00
|
|
|
|
2021-05-31 01:46:53 +00:00
|
|
|
KFPC = KFPlayerController(C);
|
2021-05-31 04:04:26 +00:00
|
|
|
if (KFPC == None)
|
2021-05-31 01:46:53 +00:00
|
|
|
return;
|
|
|
|
|
2021-06-12 20:11:37 +00:00
|
|
|
RepClientNew.KFPC = KFPC;
|
2021-06-20 05:04:22 +00:00
|
|
|
RepClientNew.RepInfo = Spawn(class'YASRepInfo', KFPC);
|
2021-06-13 02:14:00 +00:00
|
|
|
|
2021-06-12 20:11:37 +00:00
|
|
|
RepClientNew.RepInfo.Mut = Self;
|
|
|
|
RepClientNew.RepInfo.CustomRanks = class'CustomRanks'.default.Rank;
|
|
|
|
RepClientNew.RepInfo.SteamGroupRelations = UIDRankRelationsSteamGroups;
|
|
|
|
RepClientNew.RepInfo.Settings = Settings;
|
|
|
|
RepClientNew.RepInfo.RankRelation.UID = KFPC.PlayerReplicationInfo.UniqueId;
|
|
|
|
RepClientNew.RepInfo.RankRelation.RankID = UIDRankRelationsPlayers.Find('UID', RepClientNew.RepInfo.RankRelation.UID);
|
2021-05-31 01:46:53 +00:00
|
|
|
|
2021-06-12 20:11:37 +00:00
|
|
|
RepClients.AddItem(RepClientNew);
|
2021-05-31 01:46:53 +00:00
|
|
|
|
2021-06-13 01:57:20 +00:00
|
|
|
foreach UIDRankRelationsActive(Relation)
|
2021-06-12 20:11:37 +00:00
|
|
|
RepClientNew.RepInfo.AddRankRelation(Relation);
|
2021-05-31 04:04:26 +00:00
|
|
|
|
2021-06-12 20:11:37 +00:00
|
|
|
RepClientNew.RepInfo.StartFirstTimeReplication();
|
|
|
|
|
2021-06-13 01:57:20 +00:00
|
|
|
if (RepClientNew.RepInfo.RankRelation.RankID != INDEX_NONE)
|
|
|
|
{
|
|
|
|
UIDRankRelationsActive.AddItem(RepClientNew.RepInfo.RankRelation);
|
|
|
|
foreach RepClients(RepClient)
|
|
|
|
RepClient.RepInfo.AddRankRelation(RepClientNew.RepInfo.RankRelation);
|
|
|
|
}
|
2021-05-31 01:46:53 +00:00
|
|
|
}
|
|
|
|
|
2021-06-12 18:44:20 +00:00
|
|
|
private function RemovePlayer(Controller C)
|
2021-05-31 01:46:53 +00:00
|
|
|
{
|
|
|
|
local KFPlayerController KFPC;
|
2021-06-13 01:57:20 +00:00
|
|
|
local int Index, i;
|
|
|
|
local UniqueNetId UID;
|
2021-05-31 01:46:53 +00:00
|
|
|
|
2021-06-12 20:11:37 +00:00
|
|
|
`callstack();
|
|
|
|
|
2021-05-31 01:46:53 +00:00
|
|
|
KFPC = KFPlayerController(C);
|
|
|
|
if (KFPC == None)
|
|
|
|
return;
|
|
|
|
|
2021-06-13 01:57:20 +00:00
|
|
|
UID = KFPC.PlayerReplicationInfo.UniqueId;
|
|
|
|
Index = UIDRankRelationsActive.Find('UID', UID);
|
|
|
|
if (Index != INDEX_NONE)
|
|
|
|
for (i = 0; i < UIDRankRelationsActive.Length; ++i)
|
|
|
|
if (Index != i)
|
|
|
|
RepClients[i].RepInfo.RemoveRankRelation(UIDRankRelationsActive[Index]);
|
|
|
|
|
2021-05-31 01:46:53 +00:00
|
|
|
Index = RepClients.Find('KFPC', KFPC);
|
|
|
|
if (Index == INDEX_NONE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (RepClients[Index].RepInfo != None)
|
|
|
|
RepClients[Index].RepInfo.Destroy();
|
|
|
|
|
|
|
|
RepClients.Remove(Index, 1);
|
|
|
|
}
|
|
|
|
|
2021-06-12 18:44:20 +00:00
|
|
|
public function UpdatePlayerRank(UIDRankRelation Rel)
|
|
|
|
{
|
|
|
|
local SClient RepClient;
|
|
|
|
local int Index;
|
|
|
|
|
2021-06-12 20:11:37 +00:00
|
|
|
`callstack();
|
|
|
|
|
2021-06-12 18:44:20 +00:00
|
|
|
Index = UIDRankRelationsActive.Find('UID', Rel.UID);
|
|
|
|
if (Index != INDEX_NONE)
|
|
|
|
UIDRankRelationsActive[Index] = Rel;
|
2021-06-13 01:57:20 +00:00
|
|
|
else
|
|
|
|
UIDRankRelationsActive.AddItem(Rel);
|
2021-06-12 18:44:20 +00:00
|
|
|
|
|
|
|
foreach RepClients(RepClient)
|
|
|
|
RepClient.RepInfo.UpdateRankRelation(Rel);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function AddPlayerRank(UIDRankRelation Rel)
|
|
|
|
{
|
|
|
|
local SClient RepClient;
|
2021-06-12 20:11:37 +00:00
|
|
|
|
|
|
|
`callstack();
|
|
|
|
|
2021-06-12 18:44:20 +00:00
|
|
|
foreach RepClients(RepClient)
|
|
|
|
RepClient.RepInfo.AddRankRelation(Rel);
|
|
|
|
}
|
|
|
|
|
2021-05-31 01:46:53 +00:00
|
|
|
DefaultProperties
|
|
|
|
{
|
|
|
|
|
2020-01-10 13:14:11 +00:00
|
|
|
}
|