RPL
This commit is contained in:
139
MSKGS-SRV/Classes/CfgLevels.uc
Normal file
139
MSKGS-SRV/Classes/CfgLevels.uc
Normal file
@ -0,0 +1,139 @@
|
||||
class CfgLevels extends Object
|
||||
config(RPL)
|
||||
abstract;
|
||||
|
||||
var protected const int DefaultMin;
|
||||
var protected const int DefaultMax;
|
||||
|
||||
var protected const int NoRestrictionsMin;
|
||||
var protected const int NoRestrictionsMax;
|
||||
|
||||
var public config int DisconnectTime;
|
||||
var private config int Min;
|
||||
var private config int Max;
|
||||
|
||||
var public config String HexColorInfo;
|
||||
var public config String HexColorWarn;
|
||||
var public config String HexColorError;
|
||||
|
||||
public static function InitConfig(int Version, int LatestVersion, E_LogLevel LogLevel)
|
||||
{
|
||||
switch (Version)
|
||||
{
|
||||
case `NO_CONFIG:
|
||||
ApplyDefault();
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (LatestVersion != Version)
|
||||
{
|
||||
StaticSaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public static function Load(E_LogLevel LogLevel)
|
||||
{
|
||||
if (default.Min < default.NoRestrictionsMin)
|
||||
{
|
||||
`Log_Error("Min" @ "(" $ default.Min $ ")" @ "must be equal or greater than" @ default.NoRestrictionsMin);
|
||||
}
|
||||
|
||||
if (default.Max > default.NoRestrictionsMax)
|
||||
{
|
||||
`Log_Error("Max" @ "(" $ default.Max $ ")" @ "must be equal or less than" @ default.NoRestrictionsMax);
|
||||
}
|
||||
|
||||
if (default.Min > default.Max)
|
||||
{
|
||||
`Log_Error("Min" @ "(" $ default.Min $ ")" @ "must be less than Max (" $ default.Max $ ")");
|
||||
}
|
||||
|
||||
if (!IsValidHexColor(default.HexColorInfo, LogLevel))
|
||||
{
|
||||
`Log_Error("HexColorInfo" @ "(" $ default.HexColorInfo $ ")" @ "is not valid hex color");
|
||||
}
|
||||
|
||||
if (!IsValidHexColor(default.HexColorWarn, LogLevel))
|
||||
{
|
||||
`Log_Error("HexColorWarn" @ "(" $ default.HexColorWarn $ ")" @ "is not valid hex color");
|
||||
}
|
||||
|
||||
if (!IsValidHexColor(default.HexColorError, LogLevel))
|
||||
{
|
||||
`Log_Error("HexColorError" @ "(" $ default.HexColorError $ ")" @ "is not valid hex color");
|
||||
}
|
||||
}
|
||||
|
||||
public static function bool Available(byte Level)
|
||||
{
|
||||
return Level >= MinLevel() && Level <= MaxLevel();
|
||||
}
|
||||
|
||||
public static function byte MinLevel()
|
||||
{
|
||||
return byte(default.Min);
|
||||
}
|
||||
|
||||
public static function byte MaxLevel()
|
||||
{
|
||||
return byte(default.Max);
|
||||
}
|
||||
|
||||
protected static function ApplyDefault()
|
||||
{
|
||||
default.Min = default.DefaultMin;
|
||||
default.Max = default.DefaultMax;
|
||||
|
||||
default.DisconnectTime = 15;
|
||||
|
||||
default.HexColorInfo = class'KFLocalMessage'.default.EventColor;
|
||||
default.HexColorWarn = class'KFLocalMessage'.default.PriorityColor;
|
||||
default.HexColorError = class'KFLocalMessage'.default.InteractionColor;
|
||||
}
|
||||
|
||||
private static function bool IsValidHexColor(String HexColor, E_LogLevel LogLevel)
|
||||
{
|
||||
local byte Index;
|
||||
|
||||
`Log_TraceStatic();
|
||||
|
||||
if (len(HexColor) != 6) return false;
|
||||
|
||||
HexColor = Locs(HexColor);
|
||||
|
||||
for (Index = 0; Index < 6; ++Index)
|
||||
{
|
||||
switch (Mid(HexColor, Index, 1))
|
||||
{
|
||||
case "0": break;
|
||||
case "1": break;
|
||||
case "2": break;
|
||||
case "3": break;
|
||||
case "4": break;
|
||||
case "5": break;
|
||||
case "6": break;
|
||||
case "7": break;
|
||||
case "8": break;
|
||||
case "9": break;
|
||||
case "a": break;
|
||||
case "b": break;
|
||||
case "c": break;
|
||||
case "d": break;
|
||||
case "e": break;
|
||||
case "f": break;
|
||||
default: return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
DefaultMin = 0
|
||||
DefaultMax = `MAX_PERK_LEVEL
|
||||
|
||||
NoRestrictionsMin = 0
|
||||
NoRestrictionsMax = `MAX_PERK_LEVEL
|
||||
}
|
106
MSKGS-SRV/Classes/CfgPerks.uc
Normal file
106
MSKGS-SRV/Classes/CfgPerks.uc
Normal file
@ -0,0 +1,106 @@
|
||||
class CfgPerks extends Object
|
||||
config(RPL)
|
||||
abstract;
|
||||
|
||||
var public config bool bHideDisabledPerks;
|
||||
|
||||
var private config bool bBerserker;
|
||||
var private config bool bCommando;
|
||||
var private config bool bSupport;
|
||||
var private config bool bFieldMedic;
|
||||
var private config bool bDemolitionist;
|
||||
var private config bool bFirebug;
|
||||
var private config bool bGunslinger;
|
||||
var private config bool bSharpshooter;
|
||||
var private config bool bSwat;
|
||||
var private config bool bSurvivalist;
|
||||
|
||||
public static function InitConfig(int Version, int LatestVersion, E_LogLevel LogLevel)
|
||||
{
|
||||
switch (Version)
|
||||
{
|
||||
case `NO_CONFIG:
|
||||
ApplyDefault();
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
if (LatestVersion != Version)
|
||||
{
|
||||
StaticSaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public static function PerkAvailableData Load(E_LogLevel LogLevel)
|
||||
{
|
||||
local PerkAvailableData PerkAvailableData;
|
||||
|
||||
PerkAvailableData.bPerksAvailableLimited = PerksAvailableLimited();
|
||||
|
||||
PerkAvailableData.bBerserkerAvailable = default.bBerserker;
|
||||
PerkAvailableData.bCommandoAvailable = default.bCommando;
|
||||
PerkAvailableData.bSupportAvailable = default.bSupport;
|
||||
PerkAvailableData.bFieldMedicAvailable = default.bFieldMedic;
|
||||
PerkAvailableData.bDemolitionistAvailable = default.bDemolitionist;
|
||||
PerkAvailableData.bFirebugAvailable = default.bFirebug;
|
||||
PerkAvailableData.bGunslingerAvailable = default.bGunslinger;
|
||||
PerkAvailableData.bSharpshooterAvailable = default.bSharpshooter;
|
||||
PerkAvailableData.bSwatAvailable = default.bSwat;
|
||||
PerkAvailableData.bSurvivalistAvailable = default.bSurvivalist;
|
||||
|
||||
return PerkAvailableData;
|
||||
}
|
||||
|
||||
public static function bool Available(class<KFPerk> Perk)
|
||||
{
|
||||
switch (Perk)
|
||||
{
|
||||
case class'KFPerk_Berserker': return default.bBerserker;
|
||||
case class'KFPerk_Commando': return default.bCommando;
|
||||
case class'KFPerk_Support': return default.bSupport;
|
||||
case class'KFPerk_FieldMedic': return default.bFieldMedic;
|
||||
case class'KFPerk_Demolitionist': return default.bDemolitionist;
|
||||
case class'KFPerk_Firebug': return default.bFirebug;
|
||||
case class'KFPerk_Gunslinger': return default.bGunslinger;
|
||||
case class'KFPerk_Sharpshooter': return default.bSharpshooter;
|
||||
case class'KFPerk_SWAT': return default.bSwat;
|
||||
case class'KFPerk_Survivalist': return default.bSurvivalist;
|
||||
default: return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static function bool PerksAvailableLimited()
|
||||
{
|
||||
return (
|
||||
!default.bBerserker ||
|
||||
!default.bCommando ||
|
||||
!default.bSupport ||
|
||||
!default.bFieldMedic ||
|
||||
!default.bDemolitionist ||
|
||||
!default.bFirebug ||
|
||||
!default.bGunslinger ||
|
||||
!default.bSharpshooter ||
|
||||
!default.bSwat ||
|
||||
!default.bSurvivalist);
|
||||
}
|
||||
|
||||
private static function ApplyDefault()
|
||||
{
|
||||
default.bHideDisabledPerks = true;
|
||||
|
||||
default.bBerserker = true;
|
||||
default.bCommando = true;
|
||||
default.bSupport = true;
|
||||
default.bFieldMedic = true;
|
||||
default.bDemolitionist = true;
|
||||
default.bFirebug = true;
|
||||
default.bGunslinger = true;
|
||||
default.bSharpshooter = true;
|
||||
default.bSwat = true;
|
||||
default.bSurvivalist = true;
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
|
||||
}
|
@ -10,6 +10,9 @@ const CfgSpawnManager = class'CfgSpawnManager';
|
||||
const CfgXPBoost = class'CfgXPBoost';
|
||||
const CfgSrvRank = class'CfgSrvRank';
|
||||
|
||||
const CfgPerks = class'CfgPerks';
|
||||
const CfgLevels = class'CfgLevels';
|
||||
|
||||
const MSKGS_GameInfo = class'MSKGS_GameInfo';
|
||||
|
||||
struct ZedMap
|
||||
@ -91,7 +94,9 @@ private function PreInit()
|
||||
CfgSpawnManager.static.InitConfig(Version, LatestVersion, LogLevel);
|
||||
CfgXPBoost.static.InitConfig(Version, LatestVersion, LogLevel);
|
||||
CfgSrvRank.static.InitConfig(Version, LatestVersion, LogLevel);
|
||||
|
||||
CfgPerks.static.InitConfig(Version, LatestVersion, LogLevel);
|
||||
CfgLevels.static.InitConfig(Version, LatestVersion, LogLevel);
|
||||
|
||||
switch (Version)
|
||||
{
|
||||
case `NO_CONFIG:
|
||||
@ -132,6 +137,8 @@ private function PreInit()
|
||||
CfgXPBoost.static.Load(LogLevel);
|
||||
CfgSrvRank.static.Load(LogLevel);
|
||||
|
||||
CfgLevels.static.Load(LogLevel);
|
||||
|
||||
OS = class'GameEngine'.static.GetOnlineSubsystem();
|
||||
if (OS == None)
|
||||
{
|
||||
@ -154,6 +161,8 @@ private function PostInit()
|
||||
return;
|
||||
}
|
||||
|
||||
WorldInfo.Game.PlayerControllerClass = class'MSKGS_PlayerController';
|
||||
|
||||
KFGI = KFGameInfo(WorldInfo.Game);
|
||||
if (KFGI == None)
|
||||
{
|
||||
@ -168,14 +177,7 @@ private function PostInit()
|
||||
return;
|
||||
}
|
||||
|
||||
KFGRI = KFGameReplicationInfo(KFGI.GameReplicationInfo);
|
||||
if (KFGRI == None)
|
||||
{
|
||||
`Log_Fatal("Incompatible Replication info:" @ KFGI.GameReplicationInfo);
|
||||
SafeDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
XPNotifications = false;
|
||||
if (MSKGS_Endless(KFGI) != None)
|
||||
{
|
||||
XPNotifications = true;
|
||||
@ -185,21 +187,21 @@ private function PostInit()
|
||||
}
|
||||
else if (MSKGS_Objective(KFGI) != None)
|
||||
{
|
||||
XPNotifications = (KFGI.GameDifficulty != 3);
|
||||
XPNotifications = true;
|
||||
MSKGS_Objective(KFGI).MSKGS = Self;
|
||||
MSKGS_Objective(KFGI).GI = new MSKGS_GameInfo;
|
||||
MSKGS_Objective(KFGI).LogLevel = LogLevel;
|
||||
}
|
||||
else if (MSKGS_Survival(KFGI) != None)
|
||||
{
|
||||
XPNotifications = (KFGI.GameDifficulty != 3);
|
||||
XPNotifications = true;
|
||||
MSKGS_Survival(KFGI).MSKGS = Self;
|
||||
MSKGS_Survival(KFGI).GI = new MSKGS_GameInfo;
|
||||
MSKGS_Survival(KFGI).LogLevel = LogLevel;
|
||||
}
|
||||
else if (MSKGS_VersusSurvival(KFGI) != None)
|
||||
{
|
||||
XPNotifications = false;
|
||||
XPNotifications = true;
|
||||
MSKGS_VersusSurvival(KFGI).MSKGS = Self;
|
||||
MSKGS_VersusSurvival(KFGI).GI = new MSKGS_GameInfo;
|
||||
MSKGS_VersusSurvival(KFGI).LogLevel = LogLevel;
|
||||
@ -212,9 +214,19 @@ private function PostInit()
|
||||
MSKGS_WeeklySurvival(KFGI).LogLevel = LogLevel;
|
||||
}
|
||||
|
||||
KFGI.UpdateGameSettings();
|
||||
|
||||
`Log_Info("GameInfo initialized:" @ KFGI);
|
||||
|
||||
KFGI.UpdateGameSettings();
|
||||
KFGRI = KFGameReplicationInfo(KFGI.GameReplicationInfo);
|
||||
if (KFGRI == None)
|
||||
{
|
||||
`Log_Fatal("Incompatible Replication info:" @ KFGI.GameReplicationInfo);
|
||||
SafeDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
KFGRI.PerksAvailableData = CfgPerks.static.Load(LogLevel);
|
||||
|
||||
ModifySpawnManager();
|
||||
|
||||
@ -313,9 +325,23 @@ public function SetMaxPlayers(int MaxPlayers)
|
||||
|
||||
public function NotifyLogin(Controller C)
|
||||
{
|
||||
local MSKGS_PlayerController MSKGSPC;
|
||||
local MSKGS_RepInfo RepInfo;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
MSKGSPC = MSKGS_PlayerController(C);
|
||||
|
||||
if (MSKGSPC == None)
|
||||
{
|
||||
`Log_Error("Can't cast" @ C @ "to MSKGS_PlayerController");
|
||||
return;
|
||||
}
|
||||
|
||||
if (CfgPerks.default.bHideDisabledPerks)
|
||||
{
|
||||
MSKGSPC.ServerHidePerks();
|
||||
}
|
||||
|
||||
RepInfo = CreateRepInfo(C);
|
||||
if (RepInfo == None)
|
||||
@ -324,11 +350,22 @@ public function NotifyLogin(Controller C)
|
||||
return;
|
||||
}
|
||||
|
||||
MSKGSPC.RepInfo = RepInfo;
|
||||
MSKGSPC.MinLevel = CfgLevels.static.MinLevel();
|
||||
MSKGSPC.MaxLevel = CfgLevels.static.MaxLevel();
|
||||
MSKGSPC.DisconnectTimer = CfgLevels.default.DisconnectTime;
|
||||
|
||||
if (RepInfo.PlayerType() >= MSKGS_Admin)
|
||||
{
|
||||
`Log_Info("Increase boost:" @ RepInfo.PlayerType());
|
||||
IncreaseXPBoost(RepInfo.GetKFPC());
|
||||
}
|
||||
|
||||
RepInfo.WriteToChatLocalized(
|
||||
MSKGS_AllowedLevels,
|
||||
CfgLevels.default.HexColorInfo,
|
||||
String(CfgLevels.static.MinLevel()),
|
||||
String(CfgLevels.static.MaxLevel()));
|
||||
}
|
||||
|
||||
public function NotifyLogout(Controller C)
|
||||
@ -557,6 +594,8 @@ private function int PlayerXPBoost(MSKGS_RepInfo RepInfo)
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
`Log_Debug("PlayerType:" @ RepInfo.PlayerType());
|
||||
|
||||
if (RepInfo != None) switch (RepInfo.PlayerType())
|
||||
{
|
||||
case MSKGS_Owner: return CfgXPBoost.default.BoostOwner;
|
||||
|
Reference in New Issue
Block a user