Aiming Sensitivity and Field of View values should now update correctly if the player hasn't spawned.
Debug log should be less spammy now.
This commit is contained in:
parent
c92693880c
commit
f477cd17d0
@ -1,5 +1,4 @@
|
||||
using BepInEx;
|
||||
using System;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniformAim
|
||||
@ -18,15 +17,16 @@ namespace UniformAim
|
||||
float vFOVRad = FOV / 2 * Mathf.Deg2Rad;
|
||||
float hFOVRad = (float)(2 * Math.Atan(GetAspectRatio() * Math.Tan(vFOVRad)));
|
||||
|
||||
return (float)(hFOVRad * Mathf.Rad2Deg);
|
||||
//RETURNS RADIANS
|
||||
return hFOVRad;
|
||||
}
|
||||
|
||||
//calculate sensitivity based on FOV delta and coefficient
|
||||
public static float CalculateSensitivity(float aimedFOV, float hipFOV)
|
||||
{
|
||||
//calculate horizontal FOV values for inputs
|
||||
aimedFOV = CalculateHFOV(aimedFOV) * Mathf.Deg2Rad;
|
||||
hipFOV = CalculateHFOV(hipFOV) * Mathf.Deg2Rad;
|
||||
aimedFOV = CalculateHFOV(aimedFOV);
|
||||
hipFOV = CalculateHFOV(hipFOV);
|
||||
|
||||
float exponent = (float)(100f / Plugin.configCoeff.Value);
|
||||
|
||||
|
@ -6,7 +6,7 @@ using UnityEngine;
|
||||
|
||||
namespace UniformAim
|
||||
{
|
||||
[BepInPlugin("com.greg.tarkovuniformaim", "Uniform Aim for Tarkov", "1.1.0")]
|
||||
[BepInPlugin("com.greg.tarkovuniformaim", "Uniform Aim for Tarkov", "1.1.1")]
|
||||
[BepInProcess("EscapeFromTarkov.exe")]
|
||||
|
||||
public class Plugin : BaseUnityPlugin
|
||||
@ -36,14 +36,16 @@ namespace UniformAim
|
||||
public static float currentFPSCameraFOV = 75;
|
||||
public static float currentScopeCameraFOV = 75;
|
||||
|
||||
string lastDebugLog;
|
||||
void printDebug()
|
||||
{
|
||||
Logger.LogInfo($"\nIn-Game FOV: {configFOV.Value} In-Game Sens: {inGameSens.Value} FOV Override: {configFOVRangeOverride.Value}" +
|
||||
$"\nFPS Camera FOV: {currentFPSCameraFOV} / {Core.CalculateHFOV(currentFPSCameraFOV)} BaseOpticCamera FOV: {currentScopeCameraFOV} / {Core.CalculateHFOV(currentScopeCameraFOV)} CurrentFOV: {Core.DetermineCurrentFOV()} / {Core.CalculateHFOV(Core.DetermineCurrentFOV())}" +
|
||||
$"\nisAiming? {isAiming} SelectedScope: {SelectedScope} SelectedScopeMode:{SelectedScopeMode}" +
|
||||
string debugLog = $"\nIn-Game FOV: {configFOV.Value} | In-Game Sens: {inGameSens.Value} | FOV Override: {configFOVRangeOverride.Value}" +
|
||||
$"\nFPS Camera FOV: {currentFPSCameraFOV}V / {Core.CalculateHFOV(currentFPSCameraFOV)}H | BaseOpticCamera FOV: {currentScopeCameraFOV}V / {Core.CalculateHFOV(currentScopeCameraFOV)}H | CurrentFOV: {Core.DetermineCurrentFOV()}V / {Core.CalculateHFOV(Core.DetermineCurrentFOV())}H" +
|
||||
$"\nisAiming? {isAiming} | SelectedScope: {SelectedScope} | SelectedScopeMode:{SelectedScopeMode}" +
|
||||
$"\nCalculated sensitivity: {Core.CalculateSensitivity(Core.DetermineCurrentFOV(), baseCameraFOV)}" +
|
||||
$"\nAspect Ratio: {Core.GetAspectRatio()}" +
|
||||
$"\nFinal Sensitivity: {mySens * inGameSens.Value}");
|
||||
$"\nFinal Sensitivity: {mySens * inGameSens.Value}";
|
||||
if (lastDebugLog != debugLog) { Logger.LogInfo(debugLog); lastDebugLog = debugLog; }
|
||||
}
|
||||
|
||||
void Awake()
|
||||
@ -82,22 +84,27 @@ namespace UniformAim
|
||||
//FixedUpdate() at 50Hz (Unity default) tickrate appears to resolve the issue of this script breaking when AI spawns
|
||||
Time.fixedDeltaTime = (1f / 50f);
|
||||
|
||||
//check if the game is running
|
||||
if (Utils.SetRootObject() != null)
|
||||
{
|
||||
var rootObject = Utils.SetRootObject();
|
||||
//only update these values if the menu has been opened, otherwise read the config
|
||||
if (rootObject.transform.Find("Game Settings").gameObject.activeInHierarchy)
|
||||
{
|
||||
if (!configFOVRangeOverride.Value) { configFOV.Value = 50 + Utils.GetInGameFOV(rootObject); }
|
||||
inGameSens.Value = Utils.GetInGameSens(rootObject);
|
||||
}
|
||||
}
|
||||
|
||||
//Print debug info in BepInEx console
|
||||
if (configDebug.Value) printDebug();
|
||||
|
||||
//check if the player is in the Hideout or in a Raid
|
||||
var isRunning = Utils.checkIsReady();
|
||||
if (!isRunning) return;
|
||||
|
||||
if (isRunning)
|
||||
{
|
||||
if (Utils.SetRootObject() != null) {
|
||||
var rootObject = Utils.SetRootObject();
|
||||
//only update these values if the menu has been opened, otherwise read the config
|
||||
if (rootObject.transform.Find("Game Settings").gameObject.activeInHierarchy)
|
||||
{
|
||||
if (!configFOVRangeOverride.Value) { configFOV.Value = 50 + Utils.GetInGameFOV(rootObject); }
|
||||
inGameSens.Value = Utils.GetInGameSens(rootObject);
|
||||
}
|
||||
}
|
||||
//cgheck if the player is aiming
|
||||
//check if the player is aiming
|
||||
if (isAiming)
|
||||
{
|
||||
//Grab FOV values for calculation
|
||||
@ -110,8 +117,6 @@ namespace UniformAim
|
||||
}
|
||||
}
|
||||
}
|
||||
//Print debug info in BepInEx console
|
||||
if (configDebug.Value) printDebug();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user