Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split dynamic AI toggles into different AI types. #29

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions Fika.Core/Coop/GameMode/CoopGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ internal sealed class CoopGame : BaseLocalGame<GamePlayerOwner>, IBotGame, IFika
private CoopExfilManager exfilManager;
private GameObject fikaStartButton;

//WildSpawnType for sptUsec and sptBear
const int sptUsecValue = 47;
const int sptBearValue = 48;

public ISession BackEndSession { get => PatchConstants.BackEndSession; }

BotsController IBotGame.BotsController
Expand Down Expand Up @@ -285,7 +281,7 @@ private bool IsInvalidBotForDespawning(KeyValuePair<string, Player> kvp)

WildSpawnType role = kvp.Value.Profile.Info.Settings.Role;

if ((int)role != sptUsecValue && (int)role != sptBearValue && role != EFT.WildSpawnType.assault)
if ((int)role != FikaPlugin.sptUsecValue && (int)role != FikaPlugin.sptBearValue && role != EFT.WildSpawnType.assault)
{
// We skip all the bots that are not sptUsec, sptBear or assault. That means we never remove bosses, bossfollowers, and raiders
return true;
Expand All @@ -312,7 +308,7 @@ private async Task<LocalPlayer> CreatePhysicalBot(Profile profile, Vector3 posit

WildSpawnType role = profile.Info.Settings.Role;
bool isSpecial = false;
if ((int)role != sptUsecValue && (int)role != sptBearValue && role != EFT.WildSpawnType.assault)
if ((int)role != FikaPlugin.sptUsecValue && (int)role != FikaPlugin.sptBearValue && role != EFT.WildSpawnType.assault)
{
#if DEBUG
Logger.LogWarning($"Bot {profile.Info.Settings.Role} is a special bot.");
Expand Down
27 changes: 26 additions & 1 deletion Fika.Core/Coop/Players/CoopBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,35 @@ protected override void Start()
isStarted = true;
}

if (FikaPlugin.DynamicAI.Value)
WildSpawnType botType = Profile.Info.Settings.Role;

if( UseDynamicAI(botType) )
{
dynamicAi = gameObject.AddComponent<FikaDynamicAI>();
}
}

private bool UseDynamicAI( WildSpawnType botType)
{
if (botType == (WildSpawnType)FikaPlugin.sptUsecValue || botType == (WildSpawnType)FikaPlugin.sptBearValue)
{
if (FikaPlugin.DynamicAIPMC.Value)
{
return true;
}
}
else if (botType == WildSpawnType.assault)
{
if (FikaPlugin.DynamicAIScav.Value)
{
return true;
}
}
else if (FikaPlugin.DynamicAIRest.Value)
{
return true;
}
return false;
}

public override void BtrInteraction()
Expand Down
14 changes: 12 additions & 2 deletions Fika.Core/FikaPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public class FikaPlugin : BaseUnityPlugin

public string Locale { get; private set; } = "en";

//WildSpawnType for sptUsec and sptBear
public const int sptUsecValue = 47;
public const int sptBearValue = 48;

public static Dictionary<string, string> RespectedPlayersList = new()
{
{ "samswat", "godfather of modern SPT modding ~ SSH" },
Expand Down Expand Up @@ -131,7 +135,9 @@ public class FikaPlugin : BaseUnityPlugin
public static ConfigEntry<KeyboardShortcut> FreeCamButton { get; set; }

// Performance
public static ConfigEntry<bool> DynamicAI { get; set; }
public static ConfigEntry<bool> DynamicAIPMC { get; set; }
public static ConfigEntry<bool> DynamicAIScav { get; set; }
public static ConfigEntry<bool> DynamicAIRest { get; set; }
public static ConfigEntry<float> DynamicAIRange { get; set; }
public static ConfigEntry<DynamicAIRates> DynamicAIRate { get; set; }
public static ConfigEntry<bool> CullPlayers { get; set; }
Expand Down Expand Up @@ -309,7 +315,11 @@ private void SetupConfig()

// Performance

DynamicAI = Config.Bind("Performance", "Dynamic AI", false, new ConfigDescription("Use the dynamic AI system, disabling AI when they are outside of any player's range.", tags: new ConfigurationManagerAttributes() { Order = 5 }));
DynamicAIPMC = Config.Bind("Performance", "Dynamic AI PMC", false, new ConfigDescription("Use the dynamic AI system, disabling PMC AI when they are outside of any player's range.", tags: new ConfigurationManagerAttributes() { Order = 7 }));

DynamicAIScav = Config.Bind("Performance", "Dynamic AI SCAV", false, new ConfigDescription("Use the dynamic AI system, disabling SCAV AI when they are outside of any player's range.", tags: new ConfigurationManagerAttributes() { Order = 6 }));

DynamicAIRest = Config.Bind("Performance", "Dynamic AI REST", false, new ConfigDescription("Use the dynamic AI system, disabling AI that arent Scavs or PMCs when they are outside of any player's range.", tags: new ConfigurationManagerAttributes() { Order = 5 }));

DynamicAIRange = Config.Bind("Performance", "Dynamic AI Range", 100f, new ConfigDescription("The range at which AI will be disabled dynamically.", new AcceptableValueRange<float>(50f, 750f), new ConfigurationManagerAttributes() { Order = 4 }));

Expand Down
Loading