first version
This commit is contained in:
40
TRB/Classes/KFGI_Access.uc
Normal file
40
TRB/Classes/KFGI_Access.uc
Normal file
@ -0,0 +1,40 @@
|
||||
class KFGI_Access extends Object
|
||||
within KFGameInfo;
|
||||
|
||||
public function SetRandomBoss()
|
||||
{
|
||||
OverrideBossIndex(Rand(default.AIBossClassList.Length));
|
||||
}
|
||||
|
||||
public function class<KFPawn_Monster> Boss()
|
||||
{
|
||||
return BossAITypePawn(BossIndex);
|
||||
}
|
||||
|
||||
public function OverrideBossIndex(int Index, optional bool Force = false)
|
||||
{
|
||||
if (Index < 0 || Index >= default.AIBossClassList.Length)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UseSpecificBossIndex(BossIndex) || Force)
|
||||
{
|
||||
BossIndex = Index;
|
||||
}
|
||||
|
||||
MyKFGRI.CacheSelectedBoss(BossIndex);
|
||||
}
|
||||
|
||||
public function class<KFPawn_Monster> BossAITypePawn(int AIType)
|
||||
{
|
||||
if (AIType < AIBossClassList.Length)
|
||||
return AIBossClassList[AIType];
|
||||
else
|
||||
return None;
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
|
||||
}
|
222
TRB/Classes/TRB.uc
Normal file
222
TRB/Classes/TRB.uc
Normal file
@ -0,0 +1,222 @@
|
||||
class TRB extends Info
|
||||
config(TRB);
|
||||
|
||||
const LatestVersion = 1;
|
||||
|
||||
enum E_State
|
||||
{
|
||||
S_WAIT,
|
||||
S_WAVE,
|
||||
S_TRADER,
|
||||
S_END
|
||||
};
|
||||
|
||||
var private config int Version;
|
||||
var private config E_LogLevel LogLevel;
|
||||
var private config float WavePollingDT;
|
||||
var private config float TraderPollingDT;
|
||||
|
||||
var private KFGameInfo KFGI;
|
||||
var private KFGI_Access KFGIA;
|
||||
var private KFGameReplicationInfo KFGRI;
|
||||
|
||||
var private E_State GameState;
|
||||
|
||||
public simulated function bool SafeDestroy()
|
||||
{
|
||||
return (bPendingDelete || bDeleteMe || Destroy());
|
||||
}
|
||||
|
||||
public event PreBeginPlay()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (WorldInfo.NetMode == NM_Client)
|
||||
{
|
||||
`Log_Fatal("NetMode == NM_Client, Destroy...");
|
||||
SafeDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
Super.PreBeginPlay();
|
||||
|
||||
PreInit();
|
||||
}
|
||||
|
||||
private function PreInit()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (Version == `NO_CONFIG)
|
||||
{
|
||||
LogLevel = LL_Info;
|
||||
WavePollingDT = 5.0f;
|
||||
TraderPollingDT = 1.0f;
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
switch (Version)
|
||||
{
|
||||
case `NO_CONFIG:
|
||||
`Log_Info("Config created");
|
||||
|
||||
case MaxInt:
|
||||
`Log_Info("Config updated to version"@LatestVersion);
|
||||
break;
|
||||
|
||||
case LatestVersion:
|
||||
`Log_Info("Config is up-to-date");
|
||||
break;
|
||||
|
||||
default:
|
||||
`Log_Warn("The config version is higher than the current version");
|
||||
`Log_Warn("Config version is" @ Version @ "but current version is" @ LatestVersion);
|
||||
`Log_Warn("The config version will be changed to" @ LatestVersion);
|
||||
break;
|
||||
}
|
||||
|
||||
if (LatestVersion != Version)
|
||||
{
|
||||
Version = LatestVersion;
|
||||
SaveConfig();
|
||||
}
|
||||
|
||||
if (LogLevel == LL_WrongLevel)
|
||||
{
|
||||
LogLevel = LL_Info;
|
||||
`Log_Warn("Wrong 'LogLevel', return to default value");
|
||||
SaveConfig();
|
||||
}
|
||||
`Log_Base("LogLevel:" @ LogLevel);
|
||||
}
|
||||
|
||||
public event PostBeginPlay()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (bPendingDelete || bDeleteMe) return;
|
||||
|
||||
Super.PostBeginPlay();
|
||||
|
||||
PostInit();
|
||||
}
|
||||
|
||||
private function PostInit()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (WorldInfo == None || WorldInfo.Game == None)
|
||||
{
|
||||
SetTimer(1.0f, false, nameof(PostInit));
|
||||
return;
|
||||
}
|
||||
|
||||
KFGI = KFGameInfo(WorldInfo.Game);
|
||||
if (KFGI == None)
|
||||
{
|
||||
`Log_Fatal("Incompatible gamemode:" @ WorldInfo.Game $ ". Destroy...");
|
||||
SafeDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
if (KFGI.GameReplicationInfo == None)
|
||||
{
|
||||
SetTimer(1.0f, false, nameof(PostInit));
|
||||
return;
|
||||
}
|
||||
|
||||
KFGRI = KFGameReplicationInfo(KFGI.GameReplicationInfo);
|
||||
if (KFGRI == None)
|
||||
{
|
||||
`Log_Fatal("Incompatible Replication info:" @ KFGI.GameReplicationInfo);
|
||||
SafeDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
KFGIA = new(KFGI) class'KFGI_Access';
|
||||
if (KFGIA == None)
|
||||
{
|
||||
`Log_Fatal("Can't create KFGI_Access object");
|
||||
SafeDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
SetTimer(WavePollingDT, true, nameof(WavePolling));
|
||||
}
|
||||
|
||||
private function WavePolling()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (!StateChanged()) return;
|
||||
|
||||
`Log_Debug("GameState:" @ GameState);
|
||||
|
||||
switch (GameState)
|
||||
{
|
||||
case S_TRADER:
|
||||
if (KFGRI.IsBossWaveNext())
|
||||
{
|
||||
`Log_Debug("Prepare to boss wave");
|
||||
SetTimer(TraderPollingDT, true, nameof(TraderPolling));
|
||||
ClearTimer(nameof(WavePolling));
|
||||
}
|
||||
break;
|
||||
|
||||
case S_END:
|
||||
`Log_Debug("Cleanup");
|
||||
ClearTimer(nameof(WavePolling));
|
||||
ClearTimer(nameof(TraderPolling));
|
||||
SafeDestroy();
|
||||
break;
|
||||
|
||||
case S_WAIT:
|
||||
case S_WAVE:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private function TraderPolling()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (KFGRI.GetTraderTimeRemaining() < class'KFGame.KFVoteCollector'.default.TimeAfterSkipTrader || KFGRI.bWaveStarted)
|
||||
{
|
||||
`Log_Debug("Prev boss:" @ String(KFGIA.Boss()));
|
||||
KFGIA.SetRandomBoss();
|
||||
`Log_Info("New boss:" @ String(KFGIA.Boss()));
|
||||
ClearTimer(nameof(TraderPolling));
|
||||
SetTimer(WavePollingDT, true, nameof(WavePolling));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private function E_State GetState()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (KFGRI.bMatchIsOver) return S_END;
|
||||
if (!KFGRI.bMatchHasBegun) return S_WAIT;
|
||||
if (KFGRI.bTraderIsOpen) return S_TRADER;
|
||||
if (KFGRI.bWaveStarted) return S_WAVE;
|
||||
}
|
||||
|
||||
private function bool StateChanged()
|
||||
{
|
||||
local E_State NewState;
|
||||
local bool StateChanged;
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
NewState = GetState();
|
||||
StateChanged = (GameState != NewState);
|
||||
GameState = NewState;
|
||||
|
||||
return StateChanged;
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
GameState = S_WAIT
|
||||
}
|
4
TRB/Classes/TRB.upkg
Normal file
4
TRB/Classes/TRB.upkg
Normal file
@ -0,0 +1,4 @@
|
||||
[Flags]
|
||||
AllowDownload=False
|
||||
ClientOptional=False
|
||||
ServerSideOnly=True
|
47
TRB/Classes/TRBMut.uc
Normal file
47
TRB/Classes/TRBMut.uc
Normal file
@ -0,0 +1,47 @@
|
||||
class TRBMut extends KFMutator
|
||||
dependson(TRB);
|
||||
|
||||
var private TRB TRB;
|
||||
|
||||
public simulated function bool SafeDestroy()
|
||||
{
|
||||
return (bPendingDelete || bDeleteMe || Destroy());
|
||||
}
|
||||
|
||||
public event PreBeginPlay()
|
||||
{
|
||||
Super.PreBeginPlay();
|
||||
|
||||
if (WorldInfo.NetMode == NM_Client) return;
|
||||
|
||||
foreach WorldInfo.DynamicActors(class'TRB', TRB)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (TRB == None)
|
||||
{
|
||||
TRB = WorldInfo.Spawn(class'TRB');
|
||||
}
|
||||
|
||||
if (TRB == None)
|
||||
{
|
||||
`Log_Base("FATAL: Can't Spawn 'TRB'");
|
||||
SafeDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
public function AddMutator(Mutator Mut)
|
||||
{
|
||||
if (Mut == Self) return;
|
||||
|
||||
if (Mut.Class == Class)
|
||||
TRBMut(Mut).SafeDestroy();
|
||||
else
|
||||
Super.AddMutator(Mut);
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
|
||||
}
|
20
TRB/Classes/_Logger.uc
Normal file
20
TRB/Classes/_Logger.uc
Normal file
@ -0,0 +1,20 @@
|
||||
class _Logger extends Object
|
||||
abstract;
|
||||
|
||||
enum E_LogLevel
|
||||
{
|
||||
LL_WrongLevel,
|
||||
LL_None,
|
||||
LL_Fatal,
|
||||
LL_Error,
|
||||
LL_Warning,
|
||||
LL_Info,
|
||||
LL_Debug,
|
||||
LL_Trace,
|
||||
LL_All
|
||||
};
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
|
||||
}
|
2
TRB/Constants.uci
Normal file
2
TRB/Constants.uci
Normal file
@ -0,0 +1,2 @@
|
||||
// Constants
|
||||
`define NO_CONFIG 0
|
3
TRB/Globals.uci
Normal file
3
TRB/Globals.uci
Normal file
@ -0,0 +1,3 @@
|
||||
// Imports
|
||||
`include(Logger.uci)
|
||||
`include(Constants.uci)
|
15
TRB/Logger.uci
Normal file
15
TRB/Logger.uci
Normal file
@ -0,0 +1,15 @@
|
||||
// Logger
|
||||
`define Log_Tag 'TRB'
|
||||
|
||||
`define LocationStatic "`{ClassName}::" $ GetFuncName()
|
||||
|
||||
`define Log_Base(msg, cond) `log(`msg `if(`cond), `cond`{endif}, `Log_Tag)
|
||||
|
||||
`define Log_Fatal(msg) `log("FATAL:" @ `msg, (LogLevel >= LL_Fatal), `Log_Tag)
|
||||
`define Log_Error(msg) `log("ERROR:" @ `msg, (LogLevel >= LL_Error), `Log_Tag)
|
||||
`define Log_Warn(msg) `log("WARN:" @ `msg, (LogLevel >= LL_Warning), `Log_Tag)
|
||||
`define Log_Info(msg) `log("INFO:" @ `msg, (LogLevel >= LL_Info), `Log_Tag)
|
||||
`define Log_Debug(msg) `log("DEBUG:" @ `msg, (LogLevel >= LL_Debug), `Log_Tag)
|
||||
|
||||
`define Log_Trace(msg) `log("TRACE:" @ `Location `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag)
|
||||
`define Log_TraceStatic(msg) `log("TRACE:" @ `LocationStatic `if(`msg) @ `msg`{endif}, (LogLevel >= LL_Trace), `Log_Tag)
|
Reference in New Issue
Block a user