optimize boss override
This commit is contained in:
parent
363e003dff
commit
c367e00f63
22
StartWave/Classes/KFGI_Access.uc
Normal file
22
StartWave/Classes/KFGI_Access.uc
Normal file
@ -0,0 +1,22 @@
|
||||
class KFGI_Access extends Object
|
||||
within KFGameInfo;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
defaultproperties
|
||||
{
|
||||
|
||||
}
|
@ -7,6 +7,8 @@ var private KFGameInfo KFGI;
|
||||
var private KFGameInfo_Survival KFGIS;
|
||||
var private KFGameInfo_Endless KFGIE;
|
||||
|
||||
var private KFGI_Access KFGIA;
|
||||
|
||||
var private KFGameReplicationInfo KFGRI;
|
||||
|
||||
/*********************************************************************************************************
|
||||
@ -112,15 +114,55 @@ private function PreInit()
|
||||
`Log_Debug("bStartWithTrader:" @ bStartWithTrader);
|
||||
|
||||
bOverridenDifficultySettings = false;
|
||||
bOverridenTraderDuration = false;
|
||||
bOverridenTraderDuration = false;
|
||||
}
|
||||
|
||||
private function PostInit()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
if (WorldInfo.Game == None || WorldInfo.GRI == None)
|
||||
{
|
||||
SetTimer(0.2, false, nameof(PostInit));
|
||||
return;
|
||||
}
|
||||
|
||||
KFGI = KFGameInfo(WorldInfo.Game);
|
||||
if (KFGI == None)
|
||||
{
|
||||
`Log_Fatal("Incompatible gamemode:" @ WorldInfo.Game $ ". Destroy...");
|
||||
SafeDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
KFGIA = new(KFGI) class'KFGI_Access';
|
||||
if (KFGIA == None)
|
||||
{
|
||||
`Log_Fatal("Can't create KFGI_Access object");
|
||||
SafeDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
KFGIS = KFGameInfo_Survival(KFGI);
|
||||
if (KFGIS == None)
|
||||
{
|
||||
`Log_Warn("The game mode does not extend KFGameInfo_Survival. Most features of this mutator are not compatible with non-wave-based game modes.");
|
||||
}
|
||||
|
||||
KFGIE = KFGameInfo_Endless(KFGIS);
|
||||
|
||||
KFGRI = KFGameReplicationInfo(WorldInfo.GRI);
|
||||
if (KFGRI == None)
|
||||
{
|
||||
`Log_Fatal("Incompatible game replication info:" @ WorldInfo.GRI $ ". Destroy...");
|
||||
SafeDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
SetTimer(0.1, false, nameof(OverrideTimer));
|
||||
|
||||
//Override the boss with the boss corresponding to the specified boss index. -1 signifies random.
|
||||
if (Boss != -1)
|
||||
{
|
||||
SetTimer(0.1, false, nameof(OverrideBoss));
|
||||
}
|
||||
KFGIA.OverrideBossIndex(Boss);
|
||||
|
||||
CheckForceInitialTrader();
|
||||
|
||||
@ -142,28 +184,6 @@ private function PreInit()
|
||||
}
|
||||
}
|
||||
|
||||
private function PostInit()
|
||||
{
|
||||
`Log_Trace();
|
||||
|
||||
KFGI = KFGameInfo(WorldInfo.Game);
|
||||
if (KFGIS == None)
|
||||
{
|
||||
`Log_Fatal("Incompatible gamemode:" @ WorldInfo.Game $ ". Destroy...");
|
||||
SafeDestroy();
|
||||
return;
|
||||
}
|
||||
|
||||
KFGIS = KFGameInfo_Survival(KFGI);
|
||||
if (KFGIS == None)
|
||||
{
|
||||
`Log_Warn("The game mode does not extend KFGameInfo_Survival. Most features of this mutator are not compatible with non-wave-based game modes.");
|
||||
}
|
||||
|
||||
KFGIE = KFGameInfo_Endless(KFGIS);
|
||||
KFGRI = KFGI.MyKFGRI;
|
||||
}
|
||||
|
||||
/** Allows for handling player input in the console by the mutator. */
|
||||
public function Mutate(string MutateString, PlayerController Sender)
|
||||
{
|
||||
@ -316,13 +336,6 @@ private function OverrideBoss()
|
||||
|
||||
`Log_Trace();
|
||||
|
||||
//We need a valid KFGRI reference as we use its public BossIndex field.
|
||||
if (KFGRI == None)
|
||||
{
|
||||
SetTimer(0.2, false, nameof(OverrideBoss));
|
||||
return;
|
||||
}
|
||||
|
||||
//Unfortunately, we cannot directly set the boss index since KFGameInfo.BossIndex is protected. The only
|
||||
//way we can affect BossIndex is through KFGameInfo.SetBossIndex which randomly chooses a value in the
|
||||
//valid range. So we have to continue calling SetBossIndex until the desired index has been chosen. We
|
||||
|
Loading…
x
Reference in New Issue
Block a user