Skip to content

Commit 11b9f9c

Browse files
authored
Merge pull request #404 from project-fika/dev-2.2.4
Dev 2.2.4
2 parents cb919a5 + 90ebd01 commit 11b9f9c

188 files changed

Lines changed: 5129 additions & 2773 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
248 KB
Binary file not shown.

Fika.Core/ConsoleCommands/FikaCommands.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
namespace Fika.Core.ConsoleCommands;
1717

18+
#pragma warning disable RCS1102
1819
public class FikaCommands
20+
#pragma warning restore RCS1102
1921
{
2022
#if DEBUG
2123
[ConsoleCommand("bring", "", null, "Teleports all AI to yourself as the host", [])]
@@ -301,11 +303,11 @@ public static void SpawnItem([ConsoleArgument("", "The templateId to spawn an it
301303
/// Based on SSH's TarkyMenu command
302304
/// </summary>
303305
/// <param name="wildSpawnType"></param>
304-
/// <param name="number"></param>
306+
/// <param name="amount"></param>
305307
[ConsoleCommand("spawnNPC", "", null, "Spawn NPC with specified WildSpawnType")]
306308
public static void SpawnNPC([ConsoleArgument("assault", "The WildSpawnType to spawn (use help for a list)")] string wildSpawnType, [ConsoleArgument(1, "The amount of AI to spawn")] int amount)
307309
{
308-
if (string.IsNullOrEmpty(wildSpawnType) || wildSpawnType.ToLower() == "help")
310+
if (string.IsNullOrEmpty(wildSpawnType) || string.Equals(wildSpawnType, "help", StringComparison.OrdinalIgnoreCase))
309311
{
310312
foreach (WildSpawnType availableSpawnType in Enum.GetValues(typeof(WildSpawnType)))
311313
{

Fika.Core/Fika.Core.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@
6464
<Reference Include="UnityEngine" HintPath="..\References\UnityEngine.dll" Private="false" />
6565
<Reference Include="UnityEngine.UI" HintPath="..\References\UnityEngine.UI.dll" Private="false" />
6666
<Reference Include="websocket-sharp" HintPath="..\References\websocket-sharp.dll" Private="false" />
67-
</ItemGroup> <Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition=" '$(OS)' == 'Windows_NT' ">
67+
</ItemGroup>
68+
69+
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition=" '$(OS)' == 'Windows_NT' ">
6870
<Exec Condition=" '$(Configuration)|$(Platform)' != 'GoldMaster|AnyCPU' " Command="call ../Properties/build/postbuild-core.bat &quot;$(TargetPath)&quot; &quot;$(ProjectDir)&quot;" />
6971
<!--<Exec Condition=" '$(Configuration)|$(Platform)' == 'GoldMaster|AnyCPU' " Command="call ../Properties/build/goldmaster-core.bat" />-->
7072
</Target>

Fika.Core/FikaConfig.cs

Lines changed: 69 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
using Comfort.Common;
55
using EFT.UI;
66
using Fika.Core.Main.Utils;
7+
using Fika.Core.Networking.Http;
8+
79
#if GOLDMASTER
810
using Fika.Core.UI;
911
#endif
@@ -13,7 +15,7 @@
1315

1416
namespace Fika.Core;
1517

16-
public class FikaConfig(ConfigFile config)
18+
public sealed class FikaConfig(ConfigFile config)
1719
{
1820
private readonly ConfigFile _config = config;
1921

@@ -59,6 +61,7 @@ public class FikaConfig(ConfigFile config)
5961
public ConfigEntry<Color> FullHealthColor { get; set; }
6062
public ConfigEntry<Color> LowHealthColor { get; set; }
6163
public ConfigEntry<Color> NamePlateTextColor { get; set; }
64+
public ConfigEntry<bool> ShowBrokenLimbs { get; set; }
6265

6366
// Coop | Quest Sharing
6467
public ConfigEntry<EQuestSharingTypes> QuestTypesToShareAndReceive { get; set; }
@@ -102,6 +105,28 @@ public class FikaConfig(ConfigFile config)
102105
public ConfigEntry<bool> DisableBotMetabolism { get; set; }
103106
#endregion
104107

108+
#region client config values
109+
public bool UseBTR { get; set; }
110+
public bool FriendlyFire { get; set; }
111+
public bool DynamicVExfils { get; set; }
112+
public bool AllowFreeCam { get; set; }
113+
public bool AllowSpectateFreeCam { get; set; }
114+
public bool AllowItemSending { get; set; }
115+
public string[] BlacklistedItems { get; set; }
116+
public bool ForceSaveOnDeath { get; set; }
117+
public bool UseInertia { get; set; }
118+
public bool SharedQuestProgression { get; set; }
119+
public bool CanEditRaidSettings { get; set; }
120+
public bool EnableTransits { get; set; }
121+
public bool AnyoneCanStartRaid { get; set; }
122+
public bool AllowNamePlates { get; set; }
123+
public bool RandomLabyrinthSpawns { get; set; }
124+
public bool PMCFoundInRaid { get; set; }
125+
public bool AllowSpectateBots { get; set; }
126+
public bool InstantLoad { get; set; }
127+
public bool FastLoad { get; set; }
128+
#endregion
129+
105130
private ConfigEntry<T> SetupSetting<T>(string section, string key, T defValue, ConfigDescription configDescription, string fallback, ref bool failed, List<string> error)
106131
{
107132
try
@@ -305,12 +330,12 @@ public void SetupConfig()
305330
const string coopDefaultNamePlatesHeader = "Coop | Name Plates";
306331

307332
UseNamePlates = SetupSetting(coopDefaultNamePlatesHeader, "Show Player Name Plates", true,
308-
new ConfigDescription(FikaPlugin.Instance.AllowNamePlates ? LocaleUtils.BEPINEX_USE_NAME_PLATES_D.Localized() : disabledMessage, tags: new ConfigurationManagerAttributes()
333+
new ConfigDescription(AllowNamePlates ? LocaleUtils.BEPINEX_USE_NAME_PLATES_D.Localized() : disabledMessage, tags: new ConfigurationManagerAttributes()
309334
{
310335
Category = coopNameplatesHeader,
311336
DispName = LocaleUtils.BEPINEX_USE_NAME_PLATES_T.Localized(),
312337
Order = 16,
313-
ReadOnly = !FikaPlugin.Instance.AllowNamePlates
338+
ReadOnly = !AllowNamePlates
314339
}),
315340
"Show Player Name Plates", ref failed, headers);
316341

@@ -423,7 +448,7 @@ public void SetupConfig()
423448
{
424449
Category = coopNameplatesHeader,
425450
DispName = LocaleUtils.BEPINEX_USE_OCCLUSION_T.Localized(),
426-
Order = 3
451+
Order = 4
427452
}),
428453
"Use Occlusion", ref failed, headers);
429454

@@ -432,7 +457,7 @@ public void SetupConfig()
432457
{
433458
Category = coopNameplatesHeader,
434459
DispName = LocaleUtils.BEPINEX_HEALTHCOLOR_FULL_T.Localized(),
435-
Order = 2
460+
Order = 3
436461
}),
437462
"Full Health Color", ref failed, headers);
438463

@@ -441,7 +466,7 @@ public void SetupConfig()
441466
{
442467
Category = coopNameplatesHeader,
443468
DispName = LocaleUtils.BEPINEX_HEALTHCOLOR_LOW_T.Localized(),
444-
Order = 1
469+
Order = 2
445470
}),
446471
"Low Health Color", ref failed, headers);
447472

@@ -450,15 +475,24 @@ public void SetupConfig()
450475
{
451476
Category = coopNameplatesHeader,
452477
DispName = LocaleUtils.BEPINEX_NAMEPLATECOLOR_T.Localized(),
453-
Order = 0
478+
Order = 1
454479
}),
455480
"Name Plate Text Color", ref failed, headers);
456481

482+
ShowBrokenLimbs = SetupSetting(coopDefaultNamePlatesHeader, "Show Broken Limbs", failed,
483+
new ConfigDescription(LocaleUtils.BEPINEX_SHOWBROKENLIMBS_D.Localized(), tags: new ConfigurationManagerAttributes()
484+
{
485+
Category = coopNameplatesHeader,
486+
DispName = LocaleUtils.BEPINEX_SHOWBROKENLIMBS_T.Localized(),
487+
Order = 0
488+
}),
489+
"Show Broken Limbs", ref failed, headers);
490+
457491
// Coop | Quest Sharing
458492

459493
var coopQuestSharingHeader = CleanConfigString(LocaleUtils.BEPINEX_H_COOP_QUEST_SHARING.Localized());
460494
const string coopDefaultQuestSharingHeader = "Coop | Quest Sharing";
461-
var questSharingEnabled = Instance.SharedQuestProgression;
495+
var questSharingEnabled = SharedQuestProgression;
462496

463497
QuestTypesToShareAndReceive = SetupSetting(coopDefaultQuestSharingHeader, "Quest Types", EQuestSharingTypes.All,
464498
new ConfigDescription(questSharingEnabled ? LocaleUtils.BEPINEX_QUEST_TYPES_D.Localized() : disabledMessage, tags: new ConfigurationManagerAttributes()
@@ -815,4 +849,31 @@ private string CleanConfigString(string header)
815849
}
816850
return header;
817851
}
852+
853+
internal void GetClientConfig()
854+
{
855+
var clientConfig = FikaRequestHandler.GetClientConfig();
856+
857+
UseBTR = clientConfig.UseBTR;
858+
FriendlyFire = clientConfig.FriendlyFire;
859+
DynamicVExfils = clientConfig.DynamicVExfils;
860+
AllowFreeCam = clientConfig.AllowFreeCam;
861+
AllowSpectateFreeCam = clientConfig.AllowSpectateFreeCam;
862+
AllowItemSending = clientConfig.AllowItemSending;
863+
BlacklistedItems = clientConfig.BlacklistedItems;
864+
ForceSaveOnDeath = clientConfig.ForceSaveOnDeath;
865+
UseInertia = clientConfig.UseInertia;
866+
SharedQuestProgression = clientConfig.SharedQuestProgression;
867+
CanEditRaidSettings = clientConfig.CanEditRaidSettings;
868+
EnableTransits = clientConfig.EnableTransits;
869+
AnyoneCanStartRaid = clientConfig.AnyoneCanStartRaid;
870+
AllowNamePlates = clientConfig.AllowNamePlates;
871+
RandomLabyrinthSpawns = clientConfig.RandomLabyrinthSpawns;
872+
PMCFoundInRaid = clientConfig.PMCFoundInRaid;
873+
AllowSpectateBots = clientConfig.AllowSpectateBots;
874+
InstantLoad = clientConfig.InstantLoad;
875+
FastLoad = clientConfig.FastLoad && !InstantLoad; // can only use one, prioritize InstantLoad
876+
877+
clientConfig.LogValues();
878+
}
818879
}

Fika.Core/FikaPlugin.cs

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Fika.Core.Bundles;
77
using Fika.Core.ConsoleCommands;
88
using Fika.Core.Main.Custom;
9+
using Fika.Core.Main.Patches.InventoryController;
910
using Fika.Core.Main.Utils;
1011
using Fika.Core.Networking.Http;
1112
using Fika.Core.Networking.Websocket;
@@ -45,7 +46,7 @@ namespace Fika.Core;
4546
[BepInDependency("com.SPT.debugging", BepInDependency.DependencyFlags.HardDependency)] // This is used so that we guarantee to load after spt-debugging, that way we can disable its patches
4647
public class FikaPlugin : BaseUnityPlugin
4748
{
48-
public const string FikaVersion = "2.2.3";
49+
public const string FikaVersion = "2.2.4";
4950
public const string FikaNATPunchMasterServer = "natpunch.project-fika.com";
5051
public const ushort FikaNATPunchMasterPort = 6790;
5152

@@ -106,25 +107,6 @@ public ManualLogSource FikaLogger
106107
{ "trippy", "One of the chads that made the headless client a reality ~ Archangel" }
107108
};
108109

109-
#region client config
110-
public bool UseBTR;
111-
public bool FriendlyFire;
112-
public bool DynamicVExfils;
113-
public bool AllowFreeCam;
114-
public bool AllowSpectateFreeCam;
115-
public bool AllowItemSending;
116-
public string[] BlacklistedItems;
117-
public bool ForceSaveOnDeath;
118-
public bool UseInertia;
119-
public bool SharedQuestProgression;
120-
public bool CanEditRaidSettings;
121-
public bool EnableTransits;
122-
public bool AnyoneCanStartRaid;
123-
public bool AllowNamePlates;
124-
public bool RandomLabyrinthSpawns;
125-
public bool PMCFoundInRaid;
126-
#endregion
127-
128110
#region natpunch config
129111
public bool NatPunchServerEnable;
130112
public string NatPunchServerIP;
@@ -157,10 +139,16 @@ protected void Awake()
157139
BotDifficulties = FikaRequestHandler.GetBotDifficulties();
158140
ConsoleScreen.Processor.RegisterCommandGroup<FikaCommands>();
159141

160-
if (AllowItemSending)
142+
if (Settings.AllowItemSending)
161143
{
162144
_patchManager.EnablePatch(new ItemContext_Patch());
163145
}
146+
147+
if (Settings.FastLoad)
148+
{
149+
_patchManager.EnablePatch(new LoadAmmo_Task_Transpiler());
150+
_patchManager.EnablePatch(new ItemViewLoadAmmoComponent_Show_Patch());
151+
}
164152
}
165153

166154
/// <summary>
@@ -256,26 +244,7 @@ private async Task RunChecks()
256244

257245
private void GetClientConfig()
258246
{
259-
var clientConfig = FikaRequestHandler.GetClientConfig();
260-
261-
UseBTR = clientConfig.UseBTR;
262-
FriendlyFire = clientConfig.FriendlyFire;
263-
DynamicVExfils = clientConfig.DynamicVExfils;
264-
AllowFreeCam = clientConfig.AllowFreeCam;
265-
AllowSpectateFreeCam = clientConfig.AllowSpectateFreeCam;
266-
AllowItemSending = clientConfig.AllowItemSending;
267-
BlacklistedItems = clientConfig.BlacklistedItems;
268-
ForceSaveOnDeath = clientConfig.ForceSaveOnDeath;
269-
UseInertia = clientConfig.UseInertia;
270-
SharedQuestProgression = clientConfig.SharedQuestProgression;
271-
CanEditRaidSettings = clientConfig.CanEditRaidSettings;
272-
EnableTransits = clientConfig.EnableTransits;
273-
AnyoneCanStartRaid = clientConfig.AnyoneCanStartRaid;
274-
AllowNamePlates = clientConfig.AllowNamePlates;
275-
RandomLabyrinthSpawns = clientConfig.RandomLabyrinthSpawns;
276-
PMCFoundInRaid = clientConfig.PMCFoundInRaid;
277-
278-
clientConfig.LogValues();
247+
Settings.GetClientConfig();
279248
}
280249

281250
private void GetNatPunchServerConfig()

Fika.Core/Main/BotClasses/BotFirearmController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace Fika.Core.Main.BotClasses;
66

7-
public class BotFirearmController : FikaClientFirearmController
7+
public sealed class BotFirearmController : FikaClientFirearmController
88
{
99
public override Vector3 WeaponDirection
1010
{

Fika.Core/Main/BotClasses/BotInventoryController.cs

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
using Fika.Core.Main.Utils;
1010
using Fika.Core.Networking.Packets.Generic;
1111
using Fika.Core.Networking.Packets.Generic.SubPackets;
12+
using Fika.Core.Networking.Pooling;
1213
using JetBrains.Annotations;
1314
using static EFT.Player;
1415

1516
namespace Fika.Core.Main.BotClasses;
1617

17-
public class BotInventoryController : PlayerInventoryController
18+
public sealed class BotInventoryController : PlayerInventoryController
1819
{
1920
public override bool HasDiscardLimits
2021
{
@@ -24,23 +25,18 @@ public override bool HasDiscardLimits
2425
}
2526
}
2627
private readonly FikaBot _fikaBot;
27-
private readonly IPlayerSearchController _searchController;
28+
private readonly BotInventoryOperationHandlerPool _botInventoryOperationHandlerPool;
2829

2930
public BotInventoryController(Player player, Profile profile, bool examined, MongoID currentId, ushort nextOperationId) : base(player, profile, examined)
3031
{
3132
_fikaBot = (FikaBot)player;
3233
MongoID_0 = currentId;
3334
Ushort_0 = nextOperationId;
34-
_searchController = new BotSearchControllerClass(profile);
35+
PlayerSearchController = new BotSearchControllerClass(profile);
36+
_botInventoryOperationHandlerPool = BotInventoryOperationHandlerPool.Instance;
3537
}
3638

37-
public override IPlayerSearchController PlayerSearchController
38-
{
39-
get
40-
{
41-
return _searchController;
42-
}
43-
}
39+
public override IPlayerSearchController PlayerSearchController { get; }
4440

4541
public override void CallMalfunctionRepaired(Weapon weapon)
4642
{
@@ -83,35 +79,26 @@ private async Task HandleOperation(BaseInventoryOperationClass operation, Callba
8379

8480
private void RunBotOperation(BaseInventoryOperationClass operation, Callback callback)
8581
{
86-
BotInventoryOperationHandler handler = new(this, operation, callback);
87-
if (vmethod_0(operation))
82+
var handler = _botInventoryOperationHandlerPool.Get();
83+
handler.Set(this, operation, callback);
84+
try
8885
{
89-
handler.Operation.method_1(handler.HandleResult);
90-
return;
86+
if (vmethod_0(operation))
87+
{
88+
handler.Operation.method_1(handler.HandleResult);
89+
return;
90+
}
91+
handler.Operation.Dispose();
92+
handler.Callback?.Fail($"Can't execute {handler.Operation}", 1);
93+
}
94+
finally
95+
{
96+
_botInventoryOperationHandlerPool.ReturnHandler(handler);
9197
}
92-
handler.Operation.Dispose();
93-
handler.Callback?.Fail($"Can't execute {handler.Operation}", 1);
9498
}
9599

96100
public override SearchContentOperation vmethod_2(SearchableItemItemClass item)
97101
{
98102
return new SearchContentOperationResultClass(method_12(), this, PlayerSearchController, Profile, item);
99103
}
100-
101-
private class BotInventoryOperationHandler(BotInventoryController controller, BaseInventoryOperationClass operation, Callback callback)
102-
{
103-
private readonly BotInventoryController controller = controller;
104-
public readonly BaseInventoryOperationClass Operation = operation;
105-
public readonly Callback Callback = callback;
106-
107-
public void HandleResult(IResult result)
108-
{
109-
if (result.Failed)
110-
{
111-
FikaGlobals.LogWarning($"BotInventoryOperationHandler: Operation has failed! Controller: {controller.Name}, Operation ID: {Operation.Id}, Operation: {Operation}, Error: {result.Error}");
112-
}
113-
114-
Callback?.Invoke(result);
115-
}
116-
}
117104
}

0 commit comments

Comments
 (0)