KF2-ZedSpawner/ZedSpawner/Classes/Config_SpawnListRegular.uc

126 lines
3.8 KiB
Ucode
Raw Normal View History

2022-05-17 18:02:07 +00:00
class Config_SpawnListRegular extends Object
2022-05-11 12:43:39 +00:00
dependson(ZedSpawner)
config(ZedSpawner);
struct S_SpawnEntryCfg
{
var int Wave;
var String ZedClass;
2022-05-16 02:42:13 +00:00
var int RelativeStart;
2022-05-11 12:43:39 +00:00
var int Delay;
var int Probability;
2022-05-16 02:42:13 +00:00
var int SpawnCountBase;
var int SingleSpawnLimit;
2022-05-11 12:43:39 +00:00
var bool bSpawnAtPlayerStart;
};
var config Array<S_SpawnEntryCfg> Spawn;
public static function InitConfig()
{
local S_SpawnEntryCfg SpawnEntry;
default.Spawn.Length = 0;
SpawnEntry.Wave = 1;
SpawnEntry.ZedClass = "SomePackage.SomeZedClass1";
2022-05-16 02:42:13 +00:00
SpawnEntry.SpawnCountBase = 2;
SpawnEntry.SingleSpawnLimit = 1;
SpawnEntry.RelativeStart = 0;
2022-05-11 12:43:39 +00:00
SpawnEntry.Delay = 60;
SpawnEntry.Probability = 100;
SpawnEntry.bSpawnAtPlayerStart = false;
default.Spawn.AddItem(SpawnEntry);
SpawnEntry.Wave = 2;
SpawnEntry.ZedClass = "SomePackage.SomeZedClass2";
2022-05-16 02:42:13 +00:00
SpawnEntry.SpawnCountBase = 2;
SpawnEntry.SingleSpawnLimit = 1;
SpawnEntry.RelativeStart = 25;
2022-05-11 12:43:39 +00:00
SpawnEntry.Delay = 30;
SpawnEntry.Probability = 50;
SpawnEntry.bSpawnAtPlayerStart = false;
default.Spawn.AddItem(SpawnEntry);
StaticSaveConfig();
}
public static function Array<S_SpawnEntry> Load(E_LogLevel LogLevel)
{
local Array<S_SpawnEntry> SpawnList;
local S_SpawnEntryCfg SpawnEntryCfg;
local S_SpawnEntry SpawnEntry;
local int Line;
local bool Errors;
2022-05-17 09:56:31 +00:00
`ZS_Info("Load spawn list:");
2022-05-11 12:43:39 +00:00
foreach default.Spawn(SpawnEntryCfg, Line)
{
Errors = false;
2022-05-16 02:42:13 +00:00
SpawnEntry.Wave = SpawnEntryCfg.Wave;
if (SpawnEntryCfg.Wave <= 0 || SpawnEntryCfg.Wave > 255)
{
2022-05-17 09:56:31 +00:00
`ZS_Warn("[" $ Line + 1 $ "]" @ "Wave" @ "(" $ SpawnEntryCfg.ZedClass $ ")" @ "must be greater than 0 and less than 256");
2022-05-16 02:42:13 +00:00
Errors = true;
}
2022-05-11 12:43:39 +00:00
SpawnEntry.ZedClass = class<KFPawn_Monster>(DynamicLoadObject(SpawnEntryCfg.ZedClass, class'Class'));
if (SpawnEntry.ZedClass == None)
{
2022-05-17 09:56:31 +00:00
`ZS_Warn("[" $ Line + 1 $ "]" @ "Can't load zed class:" @ SpawnEntryCfg.ZedClass);
2022-05-11 12:43:39 +00:00
Errors = true;
}
2022-05-16 02:42:13 +00:00
SpawnEntry.RelativeStartDefault = SpawnEntryCfg.RelativeStart / 100.f;
if (SpawnEntryCfg.RelativeStart < 0 || SpawnEntryCfg.RelativeStart > 100)
2022-05-11 12:43:39 +00:00
{
2022-05-17 09:56:31 +00:00
`ZS_Warn("[" $ Line + 1 $ "]" @ "RelativeStart" @ "(" $ SpawnEntryCfg.RelativeStart $ ")" @ "must be greater than or equal 0 and less than or equal 100");
2022-05-11 12:43:39 +00:00
Errors = true;
}
2022-05-16 02:42:13 +00:00
SpawnEntry.DelayDefault = SpawnEntryCfg.Delay;
if (SpawnEntryCfg.Delay <= 0)
2022-05-11 12:43:39 +00:00
{
2022-05-17 09:56:31 +00:00
`ZS_Warn("[" $ Line + 1 $ "]" @ "Delay" @ "(" $ SpawnEntryCfg.Delay $ ")" @ "must be greater than 0");
2022-05-11 12:43:39 +00:00
Errors = true;
}
SpawnEntry.Probability = SpawnEntryCfg.Probability / 100.f;
if (SpawnEntryCfg.Probability <= 0 || SpawnEntryCfg.Probability > 100)
{
2022-05-17 09:56:31 +00:00
`ZS_Warn("[" $ Line + 1 $ "]" @ "Probability" @ "(" $ SpawnEntryCfg.Probability $ ")" @ "must be greater than 0 and less than or equal 100");
2022-05-11 12:43:39 +00:00
Errors = true;
}
2022-05-16 02:42:13 +00:00
SpawnEntry.SpawnCountBase = SpawnEntryCfg.SpawnCountBase;
if (SpawnEntry.SpawnCountBase <= 0)
2022-05-11 12:43:39 +00:00
{
2022-05-17 09:56:31 +00:00
`ZS_Warn("[" $ Line + 1 $ "]" @ "SpawnCountBase" @ "(" $ SpawnEntryCfg.SpawnCountBase $ ")" @ "must be greater than 0");
2022-05-11 12:43:39 +00:00
Errors = true;
}
2022-05-16 02:42:13 +00:00
SpawnEntry.SingleSpawnLimitDefault = SpawnEntryCfg.SingleSpawnLimit;
if (SpawnEntry.SingleSpawnLimit < 0)
2022-05-11 12:43:39 +00:00
{
2022-05-17 09:56:31 +00:00
`ZS_Warn("[" $ Line + 1 $ "]" @ "SingleSpawnLimit" @ "(" $ SpawnEntryCfg.SingleSpawnLimit $ ")" @ "must be equal or greater than 0");
2022-05-11 12:43:39 +00:00
Errors = true;
}
2022-05-16 02:42:13 +00:00
2022-05-11 12:43:39 +00:00
SpawnEntry.SpawnAtPlayerStart = SpawnEntryCfg.bSpawnAtPlayerStart;
if (!Errors)
{
SpawnList.AddItem(SpawnEntry);
2022-05-17 09:56:31 +00:00
`ZS_Info("[" $ Line + 1 $ "]" @ "Loaded successfully:" @ SpawnEntryCfg.Wave @ SpawnEntryCfg.ZedClass);
2022-05-11 12:43:39 +00:00
}
}
return SpawnList;
}
defaultproperties
{
}