0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 06:10:45 -05:00

Feature: new-remapper (!143)

Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Reviewed-on: SPT/Modules#143
This commit is contained in:
chomp 2024-07-04 14:11:11 +00:00
parent f10742586c
commit ffde317c59
19 changed files with 59 additions and 53 deletions

View File

@ -1,5 +1,5 @@
using HarmonyLib;
using SPT.Reflection.Patching; using SPT.Reflection.Patching;
using SPT.Reflection.Utils;
using System; using System;
using System.Reflection; using System.Reflection;
@ -9,10 +9,7 @@ namespace SPT.Core.Patches
{ {
protected override MethodBase GetTargetMethod() protected override MethodBase GetTargetMethod()
{ {
var targetInterface = PatchConstants.EftTypes.SingleCustom(x => x == typeof(IConnectionHandler) && x.IsInterface); return AccessTools.Method(typeof(UriParamsClass), nameof(UriParamsClass.method_0));
var typeThatMatches = PatchConstants.EftTypes.SingleCustom(x => targetInterface.IsAssignableFrom(x) && x.IsAbstract && !x.IsInterface);
return typeThatMatches.GetMethods(BindingFlags.Public | BindingFlags.Instance).SingleCustom(x => x.ReturnType == typeof(Uri));
} }
// This is a pass through postfix and behaves a little differently than usual // This is a pass through postfix and behaves a little differently than usual

View File

@ -8,7 +8,7 @@ namespace SPT.Custom.BTR
{ {
public override bool IsStatic => false; public override bool IsStatic => false;
public override void AddPenalty(GInterface106 player) public override void AddPenalty(IPlayerOwner player)
{ {
} }
@ -16,7 +16,7 @@ namespace SPT.Custom.BTR
{ {
} }
public override void ProceedDamage(GInterface106 player, BodyPartCollider bodyPart) public override void ProceedDamage(IPlayerOwner player, BodyPartCollider bodyPart)
{ {
bodyPart.ApplyInstantKill(new DamageInfo() bodyPart.ApplyInstantKill(new DamageInfo()
{ {
@ -31,7 +31,7 @@ namespace SPT.Custom.BTR
}); });
} }
public override void RemovePenalty(GInterface106 player) public override void RemovePenalty(IPlayerOwner player)
{ {
} }
} }

View File

@ -6,7 +6,7 @@ using EFT.Vehicle;
using HarmonyLib; using HarmonyLib;
using System; using System;
using System.Reflection; using System.Reflection;
using BTRDialog = EFT.UI.TraderDialogScreen.GClass3157; using BTRDialog = EFT.UI.TraderDialogScreen.BTRDialogClass;
namespace SPT.Custom.BTR.Patches namespace SPT.Custom.BTR.Patches
{ {

View File

@ -1,5 +1,4 @@
using SPT.PrePatch; using EFT;
using EFT;
namespace SPT.Custom.CustomAI namespace SPT.Custom.CustomAI
{ {

View File

@ -3,7 +3,6 @@ using EFT;
using System; using System;
using Comfort.Common; using Comfort.Common;
using System.Reflection; using System.Reflection;
using SPT.PrePatch;
using SPT.Custom.CustomAI; using SPT.Custom.CustomAI;
using HarmonyLib; using HarmonyLib;

View File

@ -31,7 +31,7 @@ namespace SPT.Custom.Patches
var player = Singleton<GameWorld>.Instance.MainPlayer; var player = Singleton<GameWorld>.Instance.MainPlayer;
if (profileId == player?.Profile.Id) if (profileId == player?.Profile.Id)
{ {
GClass3131.Instance.CloseAllScreensForced(); CurrentScreenSingleton.Instance.CloseAllScreensForced();
} }
return true; return true;

View File

@ -22,6 +22,13 @@ namespace SPT.Custom.Patches
[PatchPrefix] [PatchPrefix]
private static bool PatchPrefix(ref bool __result, BotsGroup __instance, IPlayer requester) private static bool PatchPrefix(ref bool __result, BotsGroup __instance, IPlayer requester)
{ {
if (requester == null)
{
__result = false;
return false; // Skip original
}
if (__instance.InitialBotType == WildSpawnType.peacefullZryachiyEvent if (__instance.InitialBotType == WildSpawnType.peacefullZryachiyEvent
|| __instance.InitialBotType == WildSpawnType.shooterBTR || __instance.InitialBotType == WildSpawnType.shooterBTR
|| __instance.InitialBotType == WildSpawnType.gifter || __instance.InitialBotType == WildSpawnType.gifter

View File

@ -2,6 +2,8 @@ using SPT.Reflection.Patching;
using SPT.Reflection.Utils; using SPT.Reflection.Utils;
using System.Reflection; using System.Reflection;
using EFT; using EFT;
using HarmonyLib;
using System.Linq;
namespace SPT.Custom.Patches namespace SPT.Custom.Patches
{ {

View File

@ -1,5 +1,4 @@
using SPT.PrePatch; using SPT.Reflection.Patching;
using SPT.Reflection.Patching;
using SPT.Reflection.Utils; using SPT.Reflection.Utils;
using EFT; using EFT;
using System; using System;

View File

@ -17,8 +17,8 @@ namespace SPT.Custom.Patches
public RagfairFeePatch() public RagfairFeePatch()
{ {
// Remember to update prefix parameter if below lines are broken // Remember to update prefix parameter if below lines are broken
_ = nameof(GClass3091.IsAllSelectedItemSame); _ = nameof(RagfairOfferSellHelperClass.IsAllSelectedItemSame);
_ = nameof(GClass3091.AutoSelectSimilar); _ = nameof(RagfairOfferSellHelperClass.AutoSelectSimilar);
} }
protected override MethodBase GetTargetMethod() protected override MethodBase GetTargetMethod()
@ -34,14 +34,14 @@ namespace SPT.Custom.Patches
/// <param name="___double_0">RequirementsPrice</param> /// <param name="___double_0">RequirementsPrice</param>
/// <param name="___bool_0">SellInOnePiece</param> /// <param name="___bool_0">SellInOnePiece</param>
[PatchPrefix] [PatchPrefix]
private static void PatchPrefix(ref Item ___item_0, ref GClass3091 ___gclass3091_0, ref double ___double_0, ref bool ___bool_0) private static void PatchPrefix(ref Item ___item_0, ref RagfairOfferSellHelperClass ___ragfairOfferSellHelperClass, ref double ___double_0, ref bool ___bool_0)
{ {
RequestHandler.PutJson("/client/ragfair/offerfees", new RequestHandler.PutJson("/client/ragfair/offerfees", new
{ {
id = ___item_0.Id, id = ___item_0.Id,
tpl = ___item_0.TemplateId, tpl = ___item_0.TemplateId,
count = ___gclass3091_0.OfferItemCount, count = ___ragfairOfferSellHelperClass.OfferItemCount,
fee = Mathf.CeilToInt((float)GClass2105.CalculateTaxPrice(___item_0, ___gclass3091_0.OfferItemCount, ___double_0, ___bool_0)) fee = Mathf.CeilToInt((float)FleaTaxCalculatorAbstractClass.CalculateTaxPrice(___item_0, ___ragfairOfferSellHelperClass.OfferItemCount, ___double_0, ___bool_0))
}.ToJson()); }.ToJson());
} }
} }

View File

@ -5,7 +5,6 @@ using EFT;
using EFT.UI; using EFT.UI;
using HarmonyLib; using HarmonyLib;
using System.Reflection; using System.Reflection;
using DialogControlClass = GClass1973;
namespace SPT.Debugging.Patches namespace SPT.Debugging.Patches
{ {
@ -20,7 +19,7 @@ namespace SPT.Debugging.Patches
[PatchPostfix] [PatchPostfix]
internal static void PatchPostfix() internal static void PatchPostfix()
{ {
ConsoleScreen.Processor.RegisterCommandGroup<DialogControlClass>(); ConsoleScreen.Processor.RegisterCommandGroup<TraderDialogInteractionScreenClass>();
ConsoleScreen.Processor.RegisterCommand("btr_deliver_items", new System.Action(BtrDeliverItemsCommand)); ConsoleScreen.Processor.RegisterCommand("btr_deliver_items", new System.Action(BtrDeliverItemsCommand));
} }
@ -36,7 +35,7 @@ namespace SPT.Debugging.Patches
{ {
protected override MethodBase GetTargetMethod() protected override MethodBase GetTargetMethod()
{ {
return AccessTools.Method(typeof(DialogControlClass), nameof(DialogControlClass.ShowDialogScreen)); return AccessTools.Method(typeof(TraderDialogInteractionScreenClass), nameof(TraderDialogInteractionScreenClass.ShowDialogScreen));
} }
[PatchPrefix] [PatchPrefix]

View File

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using ExitSettingsClass = GClass1234;
namespace SPT.Debugging.Patches namespace SPT.Debugging.Patches
{ {
@ -23,7 +22,7 @@ namespace SPT.Debugging.Patches
} }
[PatchPostfix] [PatchPostfix]
public static void PatchPreFix(ExitSettingsClass[] settings) public static void PatchPreFix(LocationExitClass[] settings)
{ {
var gameWorld = Singleton<GameWorld>.Instance; var gameWorld = Singleton<GameWorld>.Instance;
string mapName = gameWorld.MainPlayer.Location.ToLower(); string mapName = gameWorld.MainPlayer.Location.ToLower();
@ -37,7 +36,7 @@ namespace SPT.Debugging.Patches
foreach (var exfil in pmcExfilPoints.Concat(scavExfilPoints)) foreach (var exfil in pmcExfilPoints.Concat(scavExfilPoints))
{ {
ExitSettingsClass exitSettings = settings.FirstOrDefault(x => x.Name == exfil.Settings.Name); LocationExitClass exitSettings = settings.FirstOrDefault(x => x.Name == exfil.Settings.Name);
exfils.Add(new SPTExfilData(exfil, exitSettings)); exfils.Add(new SPTExfilData(exfil, exitSettings));
} }
@ -73,7 +72,7 @@ namespace SPT.Debugging.Patches
public string RequirementTip = ""; public string RequirementTip = "";
public string Side = ""; public string Side = "";
public SPTExfilData(ExfiltrationPoint point, ExitSettingsClass settings) public SPTExfilData(ExfiltrationPoint point, LocationExitClass settings)
{ {
// PMC and shared extracts, prioritize settings over the map data to match base behaviour // PMC and shared extracts, prioritize settings over the map data to match base behaviour
if (settings != null && (!(point is ScavExfiltrationPoint) || point is SharedExfiltrationPoint)) if (settings != null && (!(point is ScavExfiltrationPoint) || point is SharedExfiltrationPoint))

View File

@ -20,7 +20,7 @@ namespace SPT.Debugging.Patches
public SptSpawnHelper() public SptSpawnHelper()
{ {
IEnumerable<ISpawnPoint> locationSpawnPoints = GClass2949.CreateFromScene(); IEnumerable<ISpawnPoint> locationSpawnPoints = SpawnPointManagerClass.CreateFromScene();
var playerSpawns = locationSpawnPoints.Where(x => x.Categories.HasFlag(ESpawnCategoryMask.Player)).ToList(); var playerSpawns = locationSpawnPoints.Where(x => x.Categories.HasFlag(ESpawnCategoryMask.Player)).ToList();
this.playerSpawnPoints = locationSpawnPoints.Where(x => x.Categories.HasFlag(ESpawnCategoryMask.Player)).ToList(); this.playerSpawnPoints = locationSpawnPoints.Where(x => x.Categories.HasFlag(ESpawnCategoryMask.Player)).ToList();
@ -61,7 +61,7 @@ namespace SPT.Debugging.Patches
} }
[PatchPrefix] [PatchPrefix]
public static bool PatchPrefix(GClass1483 __instance, GClass591 data) public static bool PatchPrefix(GClass1483 __instance, BotCreationDataClass data)
{ {
var firstBotRole = data.Profiles[0].Info.Settings.Role; var firstBotRole = data.Profiles[0].Info.Settings.Role;
if (firstBotRole != WildSpawnType.pmcBEAR || firstBotRole != WildSpawnType.pmcUSEC) if (firstBotRole != WildSpawnType.pmcBEAR || firstBotRole != WildSpawnType.pmcUSEC)

View File

@ -120,14 +120,14 @@ namespace SPT.SinglePlayer.Models.Progression
/// <summary> /// <summary>
/// Set all brdige mines to desire state /// Set all brdige mines to desire state
/// </summary> /// </summary>
/// <param name="active">What state mines should be</param> /// <param name="desiredMineState">What state should bridge mines be set to</param>
private void SetBridgeMinesStatus(bool active) private void SetBridgeMinesStatus(bool desiredMineState)
{ {
// Find mines with opposite state of what we want // Find mines with opposite state of what we want
foreach (var mine in _bridgeMines.Where(mine => mine.gameObject.activeSelf == !active && mine.transform.parent.gameObject.name == "Directional_mines_LHZONE")) var mines = _bridgeMines.Where(mine => mine.gameObject.activeSelf == !desiredMineState && mine.transform.parent.gameObject.name == "Directional_mines_LHZONE");
foreach (var mine in mines)
{ {
mine.gameObject.SetActive(active); mine.gameObject.SetActive(desiredMineState);
} }
} }
@ -137,7 +137,7 @@ namespace SPT.SinglePlayer.Models.Progression
/// </summary> /// </summary>
private void SetupZryachiyAndFollowerHostility() private void SetupZryachiyAndFollowerHostility()
{ {
// only process non-players (ai) // Only process non-players (ai)
foreach (var aiBot in _gameWorld.AllAlivePlayersList.Where(x => !x.IsYourPlayer)) foreach (var aiBot in _gameWorld.AllAlivePlayersList.Where(x => !x.IsYourPlayer))
{ {
// Bots that die on mounted guns get stuck in AllAlivePlayersList, need to check health // Bots that die on mounted guns get stuck in AllAlivePlayersList, need to check health
@ -150,16 +150,7 @@ namespace SPT.SinglePlayer.Models.Progression
if (aiBot.AIData.BotOwner.IsRole(WildSpawnType.bossZryachiy) || aiBot.AIData.BotOwner.IsRole(WildSpawnType.followerZryachiy)) if (aiBot.AIData.BotOwner.IsRole(WildSpawnType.bossZryachiy) || aiBot.AIData.BotOwner.IsRole(WildSpawnType.followerZryachiy))
{ {
// Subscribe to bots OnDeath event // Subscribe to bots OnDeath event
aiBot.OnPlayerDeadOrUnspawn += player1 => aiBot.OnPlayerDeadOrUnspawn += OnZryachiyOrFollowerDeath;
{
// If player kills zryachiy or follower, force aggressor state
// Also set players Lk standing to negative (allows access to quest chain (Making Amends))
if (player1?.KillerId == _player?.ProfileId)
{
_aggressor = true;
_player?.Profile.TradersInfo[_lightKeeperTid].SetStanding(-0.01);
}
};
// Save bot to list for later access // Save bot to list for later access
if (!_zryachiyAndFollowers.Contains(aiBot)) if (!_zryachiyAndFollowers.Contains(aiBot))
@ -170,6 +161,22 @@ namespace SPT.SinglePlayer.Models.Progression
} }
} }
/// <summary>
/// Set aggression + standing loss when Zryachiy/follower is killed by player
/// </summary>
/// <param name="player">The player who killed Zryachiy/follower.</param>
private void OnZryachiyOrFollowerDeath(Player player)
{
// Check if zryachiy/follower was killed by player
if (player?.KillerId == _player?.ProfileId)
{
// If player kills zryachiy or follower, force aggressor state
// Also set players Lk standing to negative (allows access to quest chain (Making Amends))
_aggressor = true;
_player?.Profile.TradersInfo[_lightKeeperTid].SetStanding(-0.01);
}
}
/// <summary> /// <summary>
/// Disable door + set transmitter to 'red' /// Disable door + set transmitter to 'red'
/// </summary> /// </summary>

View File

@ -44,7 +44,7 @@ namespace SPT.SinglePlayer.Patches.RaidFix
/// BotsPresets.GetNewProfile() /// BotsPresets.GetNewProfile()
/// </summary> /// </summary>
[PatchPrefix] [PatchPrefix]
private static bool PatchPrefix(ref Task<Profile> __result, BotsPresets __instance, List<Profile> ___list_0, GClass591 data, ref bool withDelete) private static bool PatchPrefix(ref Task<Profile> __result, BotsPresets __instance, List<Profile> ___list_0, BotCreationDataClass data, ref bool withDelete)
{ {
/* /*
When client wants new bot and GetNewProfile() return null (if not more available templates or they don't satisfy by Role and Difficulty condition) When client wants new bot and GetNewProfile() return null (if not more available templates or they don't satisfy by Role and Difficulty condition)

View File

@ -124,7 +124,7 @@ namespace SPT.SinglePlayer.Patches.ScavMode
.Single(field => field.FieldType == typeof(MatchmakerPlayerControllerClass)) .Single(field => field.FieldType == typeof(MatchmakerPlayerControllerClass))
?.GetValue(menuController) as MatchmakerPlayerControllerClass; ?.GetValue(menuController) as MatchmakerPlayerControllerClass;
var gclass = new MatchmakerOfflineRaidScreen.GClass3182(profile?.Info, ref raidSettings, matchmakerPlayersController, ESessionMode.Regular); var gclass = new MatchmakerOfflineRaidScreen.CreateRaidSettingsForProfileClass(profile?.Info, ref raidSettings, matchmakerPlayersController, ESessionMode.Regular);
gclass.OnShowNextScreen += LoadOfflineRaidNextScreen; gclass.OnShowNextScreen += LoadOfflineRaidNextScreen;

View File

@ -13,7 +13,7 @@ namespace SPT.SinglePlayer.Patches.ScavMode
protected override MethodBase GetTargetMethod() protected override MethodBase GetTargetMethod()
{ {
// Correct Gclass has sessionCounters // Correct Gclass has sessionCounters
return AccessTools.Method(typeof(GClass1802), nameof(GClass1802.OnEnemyKill)); return AccessTools.Method(typeof(LocationStatisticsCollectorAbstractClass), nameof(LocationStatisticsCollectorAbstractClass.OnEnemyKill));
} }
[PatchPrefix] [PatchPrefix]

View File

@ -10,8 +10,6 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
using static BackendConfigSettingsClass; using static BackendConfigSettingsClass;
using TraderServiceClass = GClass1806;
using QuestDictClass = GClass2147<string>;
using StandingListClass = GClass2149<float>; using StandingListClass = GClass2149<float>;
namespace SPT.SinglePlayer.Utils.TraderServices namespace SPT.SinglePlayer.Utils.TraderServices
@ -86,7 +84,7 @@ namespace SPT.SinglePlayer.Utils.TraderServices
// Only populate trader services that don't exist yet // Only populate trader services that don't exist yet
if (!servicesData.ContainsKey(traderServiceModel.ServiceType)) if (!servicesData.ContainsKey(traderServiceModel.ServiceType))
{ {
TraderServiceClass traderService = new TraderServiceClass TraderServicesClass traderService = new TraderServicesClass
{ {
TraderId = traderId, TraderId = traderId,
ServiceType = serviceType, ServiceType = serviceType,
@ -110,12 +108,12 @@ namespace SPT.SinglePlayer.Utils.TraderServices
serviceData.TraderServiceRequirements.Standings.AddRange(traderServiceModel.Requirements.Standings); serviceData.TraderServiceRequirements.Standings.AddRange(traderServiceModel.Requirements.Standings);
// BSG has a bug in their code, we _need_ to initialize this if Standings isn't null // BSG has a bug in their code, we _need_ to initialize this if Standings isn't null
serviceData.TraderServiceRequirements.CompletedQuests = new QuestDictClass(); serviceData.TraderServiceRequirements.CompletedQuests = new QuestDictionaryClass<string>();
} }
if (traderServiceModel.Requirements.CompletedQuests != null) if (traderServiceModel.Requirements.CompletedQuests != null)
{ {
serviceData.TraderServiceRequirements.CompletedQuests = new QuestDictClass(); serviceData.TraderServiceRequirements.CompletedQuests = new QuestDictionaryClass<string>();
serviceData.TraderServiceRequirements.CompletedQuests.Concat(traderServiceModel.Requirements.CompletedQuests); serviceData.TraderServiceRequirements.CompletedQuests.Concat(traderServiceModel.Requirements.CompletedQuests);
} }
} }

Binary file not shown.