Skip to content

Commit

Permalink
Cultist bug "fix", perf improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
dwesterwick committed Aug 24, 2023
1 parent cdcdef2 commit 862d38d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
6 changes: 3 additions & 3 deletions bepinex_dev/SPTQuestingBots/BotLogic/LogicLayerMonitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class LogicLayerMonitor : MonoBehaviour
private Stopwatch lastRequestedTimer = new Stopwatch();
private float maxLayerSearchTime = 300;

public bool IsActive
public bool CanLayerBeUsed
{
get { return layer?.IsActive == true; }
}
Expand Down Expand Up @@ -61,7 +61,7 @@ private void Update()

public bool IsLayerRequested()
{
if (!IsActive)
if (!CanLayerBeUsed)
{
return false;
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public void RestartCanUseTimer()

public string GetActiveLogicReason()
{
if (!IsActive)
if (!CanLayerBeUsed)
{
return "";
}
Expand Down
20 changes: 14 additions & 6 deletions bepinex_dev/SPTQuestingBots/BotLogic/PMCObjectiveLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public override bool IsActive()
return false;
}

if (stationaryWSLayerMonitor.IsLayerRequested())
if (stationaryWSLayerMonitor.CanLayerBeUsed && stationaryWSLayerMonitor.IsLayerRequested())
{
return false;
}
Expand All @@ -117,13 +117,16 @@ public override bool IsActive()
return pauseLayer(ConfigController.Config.BotQuestingRequirements.BreakForLooting.MaxTimeToStartLooting);
}

string layerName = botOwner.Brain.ActiveLayerName() ?? "null";
if (layerName.Contains(extractLayerMonitor.LayerName) || extractLayerMonitor.IsLayerRequested())
if (extractLayerMonitor.CanLayerBeUsed)
{
objective.StopQuesting();
string layerName = botOwner.Brain.ActiveLayerName() ?? "null";
if (layerName.Contains(extractLayerMonitor.LayerName) || extractLayerMonitor.IsLayerRequested())
{
objective.StopQuesting();

LoggingController.LogWarning("Bot " + botOwner.Profile.Nickname + " wants to extract and will no longer quest.");
return false;
LoggingController.LogWarning("Bot " + botOwner.Profile.Nickname + " wants to extract and will no longer quest.");
return false;
}
}

if (shouldWaitForFollowers())
Expand Down Expand Up @@ -352,6 +355,11 @@ private bool shouldCheckForLoot(float minTimeBetweenLooting)
return false;
}

if (!lootingLayerMonitor.CanLayerBeUsed)
{
return false;
}

nextLootCheckDelay = ConfigController.Config.BotQuestingRequirements.BreakForLooting.MinTimeBetweenLootingChecks;

string activeLayerName = botOwner.Brain.ActiveLayerName() ?? "null";
Expand Down
29 changes: 19 additions & 10 deletions bepinex_dev/SPTQuestingBots/Patches/InitBossSpawnLocationPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,28 @@ private static void PatchPostfix(BossLocationSpawn[] bossWaves, Action<BossLocat
{
foreach (BossLocationSpawn bossWave in bossWaves)
{
if ((bossWave.Time <= 1) && bossWave.ShallSpawn)
if ((bossWave.Time > 1) || !bossWave.ShallSpawn)
{
int totalBots = 1 + bossWave.EscortCount;
if (bossWave.Supports != null)
{
totalBots -= bossWave.Supports.Sum(s => s.BossEscortAmount);
}
continue;
}

LoggingController.LogInfo("Spawn time for boss wave for " + bossWave.BossName + " is " + bossWave.Time);

LoggingController.LogInfo("Spawn time for boss wave for " + bossWave.BossName + " is " + bossWave.Time);
LocationController.ZeroWaveCount++;
LocationController.ZeroWaveTotalBotCount += totalBots;
LocationController.ZeroWaveTotalRogueCount += bossWave.BossName.ToLower() == "exusec" ? totalBots : 0;
if ((bossWave.BossType == WildSpawnType.sectantPriest) || (bossWave.BossType == WildSpawnType.sectantWarrior))
{
LoggingController.LogWarning("sectantPriest boss waves with initial PMC spawning may cause some bosses to spawn late.");
continue;
}

int totalBots = 1 + bossWave.EscortCount;
if (bossWave.Supports != null)
{
totalBots -= bossWave.Supports.Sum(s => s.BossEscortAmount);
}

LocationController.ZeroWaveCount++;
LocationController.ZeroWaveTotalBotCount += totalBots;
LocationController.ZeroWaveTotalRogueCount += bossWave.BossName.ToLower() == "exusec" ? totalBots : 0;
}

LoggingController.LogInfo("Total inital bosses and followers " + LocationController.ZeroWaveTotalBotCount);
Expand Down
Binary file modified dist/BepInEx/plugins/SPTQuestingBots.dll
Binary file not shown.
Binary file modified dist/DanW-SPTQuestingBots-0.1.1.zip
Binary file not shown.

0 comments on commit 862d38d

Please sign in to comment.