2022-05-16 02:42:13 +00:00
class 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
} ;
2022-05-20 21:31:35 +00:00
var public config Array < S _SpawnEntryCfg > Spawn ;
2022-05-11 12:43:39 +00:00
2022-06-13 14:02:03 +00:00
delegate int SpawnListSort ( S _SpawnEntryCfg A , S _SpawnEntryCfg B )
{
return A . Wave > B . Wave ? - 1 : 0 ;
}
2022-05-20 20:45:26 +00:00
public static function InitConfig ( int Version , int LatestVersion , KFGI _Access KFGIA )
{
switch ( Version )
{
case ` NO_CONFIG:
ApplyDefault ( KFGIA ) ;
default : break ;
}
if ( LatestVersion != Version )
{
StaticSaveConfig ( ) ;
}
}
private static function ApplyDefault ( KFGI _Access KFGIA )
2022-05-11 12:43:39 +00:00
{
2022-06-01 00:03:02 +00:00
local S _SpawnEntryCfg SpawnEntry ;
2022-05-20 20:45:26 +00:00
local Array < class < KFPawn _Monster > > KFPM _Zeds ;
2022-06-01 00:03:02 +00:00
local class < KFPawn _Monster > KFPMC ;
2022-05-11 12:43:39 +00:00
default . Spawn . Length = 0 ;
2022-05-20 20:45:26 +00:00
SpawnEntry . Wave = 0 ;
2022-05-16 02:42:13 +00:00
SpawnEntry . SpawnCountBase = 2 ;
SpawnEntry . SingleSpawnLimit = 1 ;
2022-05-20 20:45:26 +00:00
SpawnEntry . RelativeStart = 25 ;
2022-05-11 12:43:39 +00:00
SpawnEntry . Delay = 60 ;
SpawnEntry . Probability = 100 ;
2022-06-13 14:02:03 +00:00
2022-05-20 20:45:26 +00:00
KFPM _Zeds = KFGIA . GetAIClassList ( ) ;
foreach KFPM _Zeds ( KFPMC )
{
2022-05-23 16:06:49 +00:00
++ SpawnEntry . Wave ;
2022-05-20 20:45:26 +00:00
SpawnEntry . ZedClass = "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-07-13 07:00:06 +00:00
` Log_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-07-13 07:00:06 +00:00
` Log_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-07-13 07:00:06 +00:00
` Log_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-07-13 07:00:06 +00:00
` Log_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-07-13 07:00:06 +00:00
` Log_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-07-13 07:00:06 +00:00
` Log_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-07-13 07:00:06 +00:00
` Log_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-07-13 07:00:06 +00:00
` Log_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
if ( ! Errors )
{
SpawnList . AddItem ( SpawnEntry ) ;
2022-07-13 07:00:06 +00:00
` Log_Debug("[" $ Line + 1 $ "]" @ "Loaded successfully: (w" $ SpawnEntryCfg.Wave $ ")" @ SpawnEntryCfg.ZedClass);
2022-05-11 12:43:39 +00:00
}
}
2022-06-13 14:02:03 +00:00
default . Spawn . Sort ( SpawnListSort ) ;
2022-07-13 06:56:35 +00:00
if ( SpawnList . Length == default . Spawn . Length )
2022-06-01 00:03:02 +00:00
{
2022-07-13 07:00:06 +00:00
` Log_Info("Regular spawn list loaded successfully (" $ default.Spawn.Length @ "entries)");
2022-06-01 00:03:02 +00:00
}
else
{
2022-07-13 07:00:06 +00:00
` Log_Info("Regular spawn list: loaded" @ SpawnList.Length @ "of" @ default.Spawn.Length @ "entries");
2022-06-01 00:03:02 +00:00
}
2022-05-11 12:43:39 +00:00
return SpawnList ;
}
defaultproperties
{
}