KF2-ZedSpawner/ZedSpawner/Classes/SpawnListBossWaves.uc

130 lines
3.6 KiB
Ucode
Raw Normal View History

2022-05-11 12:43:39 +00:00
class SpawnListBossWaves extends Object
dependson(ZedSpawner)
config(ZedSpawner);
struct S_SpawnEntryCfg
{
var String BossClass;
var String ZedClass;
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;
};
2022-05-20 21:31:35 +00:00
var public config bool bStopRegularSpawn;
var private config Array<S_SpawnEntryCfg> Spawn;
2022-05-11 12:43:39 +00:00
2022-05-20 20:45:26 +00:00
public static function InitConfig(int Version, int LatestVersion, KFGI_Access KFGIA)
2022-05-11 12:43:39 +00:00
{
2022-05-20 20:45:26 +00:00
switch (Version)
{
case `NO_CONFIG:
ApplyDefault(KFGIA);
default: break;
}
2022-05-11 12:43:39 +00:00
2022-05-20 20:45:26 +00:00
if (LatestVersion != Version)
{
StaticSaveConfig();
}
}
private static function ApplyDefault(KFGI_Access KFGIA)
{
local S_SpawnEntryCfg SpawnEntry;
local Array<class<KFPawn_Monster> > KFPM_Bosses;
local class<KFPawn_Monster> KFPMC;
2022-05-11 12:43:39 +00:00
2022-05-20 20:45:26 +00:00
default.bStopRegularSpawn = true;
default.Spawn.Length = 0;
SpawnEntry.ZedClass = "SomePackage.SomeClass";
2022-05-16 02:42:13 +00:00
SpawnEntry.SpawnCountBase = 2;
SpawnEntry.SingleSpawnLimit = 1;
2022-05-20 20:45:26 +00:00
SpawnEntry.Delay = 30;
2022-05-16 02:42:13 +00:00
SpawnEntry.Probability = 100;
2022-05-11 12:43:39 +00:00
SpawnEntry.bSpawnAtPlayerStart = false;
2022-05-20 20:45:26 +00:00
KFPM_Bosses = KFGIA.GetAIBossClassList();
foreach KFPM_Bosses(KFPMC)
{
SpawnEntry.BossClass = "KFGameContent." $ String(KFPMC);
default.Spawn.AddItem(SpawnEntry);
}
2022-05-11 12:43:39 +00:00
}
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 boss waves spawn list:");
2022-05-11 12:43:39 +00:00
foreach default.Spawn(SpawnEntryCfg, Line)
{
Errors = false;
SpawnEntry.BossClass = class<KFPawn_Monster>(DynamicLoadObject(SpawnEntryCfg.BossClass, class'Class'));
if (SpawnEntry.BossClass == None)
{
2022-05-17 09:56:31 +00:00
`ZS_Warn("[" $ Line + 1 $ "]" @ "Can't load boss class:" @ SpawnEntryCfg.BossClass);
2022-05-11 12:43:39 +00:00
Errors = true;
}
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 = 0.f;
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;
}
SpawnEntry.SpawnAtPlayerStart = SpawnEntryCfg.bSpawnAtPlayerStart;
if (!Errors)
{
SpawnList.AddItem(SpawnEntry);
2022-05-17 09:56:31 +00:00
`ZS_Info("[" $ Line + 1 $ "]" @ "Loaded successfully:" @ SpawnEntryCfg.BossClass @ SpawnEntryCfg.ZedClass);
2022-05-11 12:43:39 +00:00
}
}
return SpawnList;
}
defaultproperties
{
}