mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 01:30:45 -05:00
Added ability to convert assault scavs to bosses (!141)
Co-authored-by: Kaeno <kaeno@noreply.dev.sp-tarkov.com> Co-authored-by: Dev <dev@dev.sp-tarkov.com> Reviewed-on: SPT/Modules#141
This commit is contained in:
parent
9a7b415310
commit
a5f8ee494e
@ -24,32 +24,34 @@ namespace SPT.Custom.Patches
|
||||
/// Postfix will adjust it back to original type
|
||||
/// </summary>
|
||||
/// <param name="__state">state to save for postfix to use later</param>
|
||||
/// <param name="__instance"></param>
|
||||
/// <param name="__instance">StandartBotBrain</param>
|
||||
/// <param name="___botOwner_0">botOwner_0 property</param>
|
||||
[PatchPrefix]
|
||||
private static bool PatchPrefix(out WildSpawnType __state, StandartBotBrain __instance, BotOwner ___botOwner_0)
|
||||
{
|
||||
var player = Singleton<GameWorld>.Instance.MainPlayer;
|
||||
___botOwner_0.Profile.Info.Settings.Role = FixAssaultGroupPmcsRole(___botOwner_0);
|
||||
__state = ___botOwner_0.Profile.Info.Settings.Role; // Store original type in state param to allow access in PatchPostFix()
|
||||
try
|
||||
{
|
||||
string currentMapName = GetCurrentMap();
|
||||
if (AiHelpers.BotIsPlayerScav(__state, ___botOwner_0.Profile.Info.Nickname))
|
||||
var isPlayerScav = AiHelpers.BotIsPlayerScav(__state, ___botOwner_0.Profile.Info.Nickname);
|
||||
if (isPlayerScav)
|
||||
{
|
||||
___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetRandomisedPlayerScavType(___botOwner_0, currentMapName);
|
||||
|
||||
return true; // Do original
|
||||
}
|
||||
|
||||
if (AiHelpers.BotIsNormalAssaultScav(__state, ___botOwner_0))
|
||||
var isNormalAssaultScav = AiHelpers.BotIsNormalAssaultScav(__state, ___botOwner_0);
|
||||
if (isNormalAssaultScav)
|
||||
{
|
||||
___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetAssaultScavWildSpawnType(___botOwner_0, currentMapName);
|
||||
|
||||
return true; // Do original
|
||||
}
|
||||
|
||||
if (AiHelpers.BotIsSptPmc(__state, ___botOwner_0))
|
||||
var isSptPmc = AiHelpers.BotIsSptPmc(__state, ___botOwner_0);
|
||||
if (isSptPmc)
|
||||
{
|
||||
// Bot has inventory equipment
|
||||
if (___botOwner_0.Profile?.Inventory?.Equipment != null)
|
||||
@ -59,6 +61,20 @@ namespace SPT.Custom.Patches
|
||||
|
||||
___botOwner_0.Profile.Info.Settings.Role = aIBrainSpawnWeightAdjustment.GetPmcWildSpawnType(___botOwner_0, ___botOwner_0.Profile.Info.Settings.Role, currentMapName);
|
||||
}
|
||||
|
||||
// Is a boss bot and not already handled above
|
||||
if (___botOwner_0.Profile.Info.Settings.IsBoss()
|
||||
&& !isPlayerScav
|
||||
&& !isNormalAssaultScav
|
||||
&& !isSptPmc)
|
||||
{
|
||||
if (___botOwner_0.Boss.BossLogic == null)
|
||||
{
|
||||
// Ensure boss has AI init
|
||||
Logger.LogError($"[SPT.CUSTOM] [CUSTOMAIPATCH] : bot: {___botOwner_0.Profile.Nickname} type: {___botOwner_0.Profile.Info.Settings.Role} lacked BossLogic, generating");
|
||||
___botOwner_0.Boss.SetBoss(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -75,6 +91,7 @@ namespace SPT.Custom.Patches
|
||||
/// <returns>WildSpawnType</returns>
|
||||
private static WildSpawnType FixAssaultGroupPmcsRole(BotOwner botOwner)
|
||||
{
|
||||
// Is PMC
|
||||
if (botOwner.Profile.Info.IsStreamerModeAvailable && botOwner.Profile.Info.Settings.Role == WildSpawnType.assaultGroup)
|
||||
{
|
||||
Logger.LogError($"Broken PMC found: {botOwner.Profile.Nickname}, was {botOwner.Profile.Info.Settings.Role}");
|
||||
|
@ -15,16 +15,19 @@ namespace SPT.Custom.Patches
|
||||
[PatchPrefix]
|
||||
private static void PatchPrefix(BotOwner bot)
|
||||
{
|
||||
if (bot.Profile.Info.Settings.Role == WildSpawnType.pmcBEAR || bot.Profile.Info.Settings.Role == WildSpawnType.pmcUSEC)
|
||||
// is a boss and not a follower and not a PMC
|
||||
if (!bot.Profile.Info.Settings.IsBoss() && !CustomAI.AiHelpers.BotIsSptPmc(bot.Profile.Info.Settings.Role, bot))
|
||||
{
|
||||
if (bot.SpawnProfileData.SpawnParams == null)
|
||||
{
|
||||
bot.SpawnProfileData.SpawnParams = new BotSpawnParams();
|
||||
}
|
||||
if (bot.SpawnProfileData.SpawnParams.ShallBeGroup == null)
|
||||
{
|
||||
bot.SpawnProfileData.SpawnParams.ShallBeGroup = new ShallBeGroupParams(false, false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
// is a boss and follower and a pmc
|
||||
if (bot.SpawnProfileData.SpawnParams == null)
|
||||
{
|
||||
bot.SpawnProfileData.SpawnParams = new BotSpawnParams();
|
||||
}
|
||||
if (bot.SpawnProfileData.SpawnParams.ShallBeGroup == null)
|
||||
{
|
||||
bot.SpawnProfileData.SpawnParams.ShallBeGroup = new ShallBeGroupParams(false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user