Add project files.
This commit is contained in:
parent
489b21c22c
commit
a43b0237c8
25
TarkovUniformAim.sln
Normal file
25
TarkovUniformAim.sln
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.2.32602.215
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TarkovUniformAim", "TarkovUniformAim\TarkovUniformAim.csproj", "{B2F4587D-CFE6-42A6-8462-A884EB6E15CD}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{B2F4587D-CFE6-42A6-8462-A884EB6E15CD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B2F4587D-CFE6-42A6-8462-A884EB6E15CD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B2F4587D-CFE6-42A6-8462-A884EB6E15CD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B2F4587D-CFE6-42A6-8462-A884EB6E15CD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {49C52BAD-50C6-43D2-AF11-112E812415E4}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
36
TarkovUniformAim/Properties/AssemblyInfo.cs
Normal file
36
TarkovUniformAim/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("TarkovUniformAim")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("TarkovUniformAim")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2022")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("b2f4587d-cfe6-42a6-8462-a884eb6e15cd")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
64
TarkovUniformAim/TarkovUniformAim.csproj
Normal file
64
TarkovUniformAim/TarkovUniformAim.csproj
Normal file
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{B2F4587D-CFE6-42A6-8462-A884EB6E15CD}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>TarkovUniformAim</RootNamespace>
|
||||
<AssemblyName>TarkovUniformAim</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<Deterministic>true</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Aki.Reflection">
|
||||
<HintPath>E:\SPT-AKI\SPT-AKI 2.3.1 UniformAimTest\EscapeFromTarkov_Data\Managed\Aki.Reflection.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Assembly-CSharp">
|
||||
<HintPath>..\..\libs\EFT Trainer DLLs\Assembly-CSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="BepInEx">
|
||||
<HintPath>..\..\MyFirstPlugin\MyFirstPlugin\lib\BepInEx.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>..\..\MyFirstPlugin\MyFirstPlugin\lib\UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>..\..\MyFirstPlugin\MyFirstPlugin\lib\UnityEngine.CoreModule.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="UniformAimPatch.cs" />
|
||||
<Compile Include="UniformAimUtils.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
21
TarkovUniformAim/UniformAimPatch.cs
Normal file
21
TarkovUniformAim/UniformAimPatch.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.Reflection;
|
||||
using Aki.Reflection.Patching;
|
||||
using EFT;
|
||||
using UniformAim;
|
||||
|
||||
namespace TarkovUniformAim
|
||||
{
|
||||
public class UpdateSensitivityPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return typeof(Player.FirearmController).GetMethod("UpdateSensitivity");
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static void PatchPostfix(ref float ____aimingSens)
|
||||
{
|
||||
____aimingSens = UniformAimUtils.adjustedSensitivity;
|
||||
}
|
||||
}
|
||||
}
|
129
TarkovUniformAim/UniformAimUtils.cs
Normal file
129
TarkovUniformAim/UniformAimUtils.cs
Normal file
@ -0,0 +1,129 @@
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using TarkovUniformAim;
|
||||
|
||||
namespace UniformAim
|
||||
{
|
||||
|
||||
[BepInPlugin("com.greg.tarkovuniformaim", "Uniform Aim for Tarkov", "0.1.1")]
|
||||
[BepInProcess("EscapeFromTarkov.exe")]
|
||||
|
||||
public class UniformAimConfig : BaseUnityPlugin
|
||||
{
|
||||
//Bepinex.Configurator fields
|
||||
public static ConfigEntry<int> configFOV;
|
||||
public static ConfigEntry<float> configCoeff;
|
||||
public static ConfigEntry<int> configSens;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
|
||||
//Enable uniform aim patch
|
||||
new UpdateSensitivityPatch().Enable();
|
||||
|
||||
//add configuration slider for field of view
|
||||
configFOV = Config.Bind("General", "FOV", 75, new ConfigDescription("In-game Field of View value", new AcceptableValueRange<int>(50, 75)));
|
||||
|
||||
//add coefficient slider
|
||||
configCoeff = Config.Bind("General", "Coefficient", 1.33f, new ConfigDescription("Coefficient - increases sensitivity at higher zoom levels, default 4/3", new AcceptableValueRange<float>(0.001f, 5.0f)));
|
||||
|
||||
//add secondary sensitivity slider for greater control
|
||||
configSens = Config.Bind("General", "Sensitivity", 25, new ConfigDescription("Secondary sensitivity multiplier in case Tarkov's default isn't enough", new AcceptableValueRange<int>(1, 200)));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public class UniformAimUtils : MonoBehaviour
|
||||
{
|
||||
//Return aspect ratio based on game window resolution
|
||||
float GetAspectRatio()
|
||||
{
|
||||
string screenWidth = Screen.width.ToString();
|
||||
string screenHeight = Screen.height.ToString();
|
||||
float resX = Convert.ToUInt16(screenWidth);
|
||||
float resY = Convert.ToUInt16(screenHeight);
|
||||
|
||||
//Logger.LogInfo("GetAspectRatio(): resX: " + resX + " resY: " + resY);
|
||||
return (resX / resY);
|
||||
}
|
||||
//convert degrees to radians
|
||||
float Deg2Rad(float angle)
|
||||
{
|
||||
return (float)(angle * Math.PI / 180);
|
||||
}
|
||||
//convert radians to degrees
|
||||
float Rad2Deg(float radian)
|
||||
{
|
||||
return (float)(radian * 180 / Math.PI);
|
||||
}
|
||||
//calculate horizontal FOV based on vertical FOV
|
||||
float CalculateHFOV(float FOV)
|
||||
{
|
||||
float vFOVRad = Deg2Rad(FOV);
|
||||
float hFOVRad = (float)(2 * Math.Atan(Math.Tan(Deg2Rad(FOV) / 2) * GetAspectRatio()));
|
||||
|
||||
return (float)(Math.Round(Rad2Deg(hFOVRad)));
|
||||
}
|
||||
//calculate sensitivity based on FOV difference and coefficient
|
||||
float CalculateSensitivity(float aimedFOV, float hipFOV)
|
||||
{ //clamp to avoid invalid values
|
||||
aimedFOV = Mathf.Clamp(aimedFOV, 0.001f, 90f);
|
||||
hipFOV = Mathf.Clamp(hipFOV, 0.001f, 90f);
|
||||
|
||||
//halve and convert to radians
|
||||
aimedFOV = Deg2Rad(aimedFOV / 2);
|
||||
hipFOV = Deg2Rad(hipFOV / 2);
|
||||
|
||||
//ratio of tangents as sensitivity
|
||||
float sensitivity = (float)(Math.Tan(aimedFOV) / Math.Tan(hipFOV));
|
||||
|
||||
return sensitivity;
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static float adjustedSensitivity = -1f;
|
||||
|
||||
float lastFOV = -1f;
|
||||
float lastFOV2 = -1f;
|
||||
|
||||
float FPSCameraFOV = -1f;
|
||||
float ScopeFOV = -1f;
|
||||
float currentFOV = -1f;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (Camera.allCamerasCount >= 1)
|
||||
{
|
||||
FPSCameraFOV = Camera.allCameras[0].fieldOfView;
|
||||
}
|
||||
if (Camera.allCamerasCount >= 2)
|
||||
{
|
||||
ScopeFOV = Camera.allCameras[1].fieldOfView;
|
||||
}
|
||||
if (Camera.allCamerasCount >= 1 && FPSCameraFOV != lastFOV)
|
||||
{
|
||||
//Logger.LogInfo("[0] FOV: " + FPSCameraFOV);
|
||||
lastFOV = FPSCameraFOV;
|
||||
}
|
||||
if (Camera.allCamerasCount >= 2 && ScopeFOV != lastFOV2)
|
||||
{
|
||||
//Logger.LogInfo("[1] FOV: " + ScopeFOV);
|
||||
lastFOV2 = ScopeFOV;
|
||||
}
|
||||
|
||||
//nasty workaround for sensitivity while using PIP scopes, WILL break when FOV is set to 50
|
||||
if (35 < FPSCameraFOV && FPSCameraFOV < UniformAimConfig.configFOV.Value) { currentFOV = FPSCameraFOV; }
|
||||
if (Camera.allCamerasCount >= 2)
|
||||
{
|
||||
if (FPSCameraFOV == 35) { currentFOV = ScopeFOV; }
|
||||
if (FPSCameraFOV == UniformAimConfig.configFOV.Value - 15) { currentFOV = FPSCameraFOV; }
|
||||
}
|
||||
|
||||
adjustedSensitivity = CalculateSensitivity(currentFOV, UniformAimConfig.configFOV.Value) * 0.25f; //(float)(UniformAimConfig.configSens.Value/100)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user