Skip to content

Commit

Permalink
SIT Prepatcher (#305)
Browse files Browse the repository at this point in the history
This PR adds a WildSpawnType PrePatcher & more fixes that allows SIT to:

- Run SIT without Aki Pre Patcher
- Improve compatibility with Aki & Aki's own PrePatcher
- Adds the PrePatcher to the build & release zip packages
  • Loading branch information
paulov-t authored May 2, 2024
2 parents 95865ac + ad53c5b commit e7de995
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 8 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/SIT-CD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ jobs:

env:
SolutionName: StayInTarkov
CSProj: Source/StayInTarkov.csproj
ProjectClient: Source/StayInTarkov.csproj
ProjectPrePatcher: SIT.WildSpawnType.PrePatcher/SIT.WildSpawnType.PrePatcher.csproj

steps:
- name: Checkout
Expand All @@ -38,7 +39,8 @@ jobs:
- name: dotnet build
run: |
mkdir ${{ env.SolutionName }}-${{ matrix.configuration }}
dotnet build ${{ env.CSProj }} -c ${{ matrix.configuration }} -o ${{ env.SolutionName }}-${{ matrix.configuration }}
dotnet build ${{ env.ProjectClient }} -c ${{ matrix.configuration }} -o ${{ env.SolutionName }}-${{ matrix.configuration }}
dotnet build ${{ env.ProjectPrePatcher }} -c ${{ matrix.configuration }} -o ${{ env.SolutionName }}-${{ matrix.configuration }}
- name: Get version from DLL
id: extract-version
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/SIT-CI-Linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ jobs:

env:
SolutionName: StayInTarkov
CSProj: Source/StayInTarkov.csproj
ProjectClient: Source/StayInTarkov.csproj
ProjectPrePatcher: SIT.WildSpawnType.PrePatcher/SIT.WildSpawnType.PrePatcher.csproj

steps:
- name: Checkout
Expand All @@ -49,12 +50,13 @@ jobs:
- name: dotnet Publish
run: |
mkdir ${{ env.SolutionName }}-${{ matrix.configuration }}
dotnet build ${{ env.CSProj }} -c ${{ matrix.configuration }} -o ${{ env.SolutionName }}-${{ matrix.configuration }}
dotnet build ${{ env.ProjectClient }} -c ${{ matrix.configuration }} -o ${{ env.SolutionName }}-${{ matrix.configuration }}
dotnet build ${{ env.ProjectPrePatcher }} -c ${{ matrix.configuration }} -o ${{ env.SolutionName }}-${{ matrix.configuration }}
# Remove unnecessary files
- name: Remove unnecessary files
run: |
rm ${{ env.SolutionName }}-${{ matrix.configuration }}/StayInTarkov.pdb
rm ${{ env.SolutionName }}-${{ matrix.configuration }}/*.pdb
# Zip remaining files
- name: Zip remaining files
Expand Down
28 changes: 28 additions & 0 deletions SIT.WildSpawnType.PrePatcher/SIT.WildSpawnType.PrePatcher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net471</TargetFramework>
<AssemblyName>SIT.WildSpawnType.PrePatcher</AssemblyName>
<Configuration>Release</Configuration>
</PropertyGroup>

<PropertyGroup>
<Company>Stay In Tarkov</Company>
<Copyright>Copyright @ Stay In Tarkov 2024</Copyright>
<Description>Stay in Tarkov plugin for Escape From Tarkov</Description>
</PropertyGroup>

<ItemGroup>
<Reference Include="Assembly-CSharp" HintPath="..\References\Assembly-CSharp.dll" Private="False" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="BepInEx.Core" Version="5.4.21" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" ExcludeAssets="runtime" PrivateAssets="all">
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" Private="False" ExcludeAssets="runtime" PrivateAssets="all" />
</ItemGroup>

</Project>
35 changes: 35 additions & 0 deletions SIT.WildSpawnType.PrePatcher/WildSpawnTypePrePatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Collections.Generic;
using System.Linq;
using Mono.Cecil;

namespace StayInTarkov
{
public static class WildSpawnTypePrePatcher
{
public static IEnumerable<string> TargetDLLs { get; } = new[] { "Assembly-CSharp.dll" };

public static int sptUsecValue = 47;
public static int sptBearValue = 48;

public static void Patch(ref AssemblyDefinition assembly)
{
var botEnums = assembly.MainModule.GetType("EFT.WildSpawnType");

var sptUsec = new FieldDefinition("sptUsec",
FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal | FieldAttributes.HasDefault,
botEnums)
{ Constant = sptUsecValue };

var sptBear = new FieldDefinition("sptBear",
FieldAttributes.Public | FieldAttributes.Static | FieldAttributes.Literal | FieldAttributes.HasDefault,
botEnums)
{ Constant = sptBearValue };

if(!botEnums.Fields.Any(x => x.Name == "sptUsec"))
botEnums.Fields.Add(sptUsec);

if(!botEnums.Fields.Any(x => x.Name == "sptBear"))
botEnums.Fields.Add(sptBear);
}
}
}
1 change: 1 addition & 0 deletions Source/StayInTarkov.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<LangVersion>preview</LangVersion>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Deterministic>false</Deterministic>
<Copyright>Copyright @ Stay In Tarkov 2024</Copyright>
</PropertyGroup>

<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions Source/StayInTarkovPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public class StayInTarkovPlugin : BaseUnityPlugin

private string[] SPTPatchesToRemove => [
"AddEnemyToAllGroupsInBotZonePatch",
"AddSptBotSettingsPatch", // Requires Aki.PrePatch
"AirdropPatch",
"AirdropFlarePatch",
"AmmoUsedCounterPatch",
Expand All @@ -104,13 +105,15 @@ public class StayInTarkovPlugin : BaseUnityPlugin
"BTRInteractionPatch",
"BTRExtractPassengersPatch",
"BTRPatch",
"CustomAiPatch", // Requires Aki.PrePatch
"DogtagPatch",
"EmptyInfilFixPatch",
"LabsKeycardRemovalPatch",
"LoadOfflineRaidScreenPatch",
"MaxBotPatch",
"OfflineSpawnPointPatch",
"OfflineRaidSettingsMenuPatch",
"PmcFirstAidPatch", // Requires Aki.PrePatch
"ScavExfilPatch",
"ScavLateStartPatch",
"ScavLateStartPatch",
Expand Down
10 changes: 7 additions & 3 deletions StayInTarkov.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{A9DA
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{DEB9463E-0556-44FD-A150-BFAFBB433D0B}"
ProjectSection(SolutionItems) = preProject
.github\workflows\ci.yml = .github\workflows\ci.yml
.github\workflows\comment-on-pr.yml = .github\workflows\comment-on-pr.yml
.github\workflows\publish-wiki.yml = .github\workflows\publish-wiki.yml
.github\workflows\SIT-CD.yml = .github\workflows\SIT-CD.yml
.github\workflows\SIT-CI-Linux.yml = .github\workflows\SIT-CI-Linux.yml
.github\workflows\SIT-CI.yml = .github\workflows\SIT-CI.yml
.github\workflows\stay-in-tarkov-client.yml = .github\workflows\stay-in-tarkov-client.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SIT.WildSpawnType.PrePatcher", "SIT.WildSpawnType.PrePatcher\SIT.WildSpawnType.PrePatcher.csproj", "{D5AF3F81-9EAC-4584-A30C-73E6DF3B73E6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -40,6 +40,10 @@ Global
{79F0E889-A195-42B4-8656-4F35685BBB80}.Debug|Any CPU.Build.0 = Debug|Any CPU
{79F0E889-A195-42B4-8656-4F35685BBB80}.Release|Any CPU.ActiveCfg = Release|Any CPU
{79F0E889-A195-42B4-8656-4F35685BBB80}.Release|Any CPU.Build.0 = Release|Any CPU
{D5AF3F81-9EAC-4584-A30C-73E6DF3B73E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D5AF3F81-9EAC-4584-A30C-73E6DF3B73E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D5AF3F81-9EAC-4584-A30C-73E6DF3B73E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D5AF3F81-9EAC-4584-A30C-73E6DF3B73E6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit e7de995

Please sign in to comment.