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;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace UniformAim
|
namespace UniformAim
|
||||||
@ -18,15 +17,16 @@ namespace UniformAim
|
|||||||
float vFOVRad = FOV / 2 * Mathf.Deg2Rad;
|
float vFOVRad = FOV / 2 * Mathf.Deg2Rad;
|
||||||
float hFOVRad = (float)(2 * Math.Atan(GetAspectRatio() * Math.Tan(vFOVRad)));
|
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
|
//calculate sensitivity based on FOV delta and coefficient
|
||||||
public static float CalculateSensitivity(float aimedFOV, float hipFOV)
|
public static float CalculateSensitivity(float aimedFOV, float hipFOV)
|
||||||
{
|
{
|
||||||
//calculate horizontal FOV values for inputs
|
//calculate horizontal FOV values for inputs
|
||||||
aimedFOV = CalculateHFOV(aimedFOV) * Mathf.Deg2Rad;
|
aimedFOV = CalculateHFOV(aimedFOV);
|
||||||
hipFOV = CalculateHFOV(hipFOV) * Mathf.Deg2Rad;
|
hipFOV = CalculateHFOV(hipFOV);
|
||||||
|
|
||||||
float exponent = (float)(100f / Plugin.configCoeff.Value);
|
float exponent = (float)(100f / Plugin.configCoeff.Value);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace UniformAim
|
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")]
|
[BepInProcess("EscapeFromTarkov.exe")]
|
||||||
|
|
||||||
public class Plugin : BaseUnityPlugin
|
public class Plugin : BaseUnityPlugin
|
||||||
@ -36,14 +36,16 @@ namespace UniformAim
|
|||||||
public static float currentFPSCameraFOV = 75;
|
public static float currentFPSCameraFOV = 75;
|
||||||
public static float currentScopeCameraFOV = 75;
|
public static float currentScopeCameraFOV = 75;
|
||||||
|
|
||||||
|
string lastDebugLog;
|
||||||
void printDebug()
|
void printDebug()
|
||||||
{
|
{
|
||||||
Logger.LogInfo($"\nIn-Game FOV: {configFOV.Value} In-Game Sens: {inGameSens.Value} FOV Override: {configFOVRangeOverride.Value}" +
|
string debugLog = $"\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())}" +
|
$"\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}" +
|
$"\nisAiming? {isAiming} | SelectedScope: {SelectedScope} | SelectedScopeMode:{SelectedScopeMode}" +
|
||||||
$"\nCalculated sensitivity: {Core.CalculateSensitivity(Core.DetermineCurrentFOV(), baseCameraFOV)}" +
|
$"\nCalculated sensitivity: {Core.CalculateSensitivity(Core.DetermineCurrentFOV(), baseCameraFOV)}" +
|
||||||
$"\nAspect Ratio: {Core.GetAspectRatio()}" +
|
$"\nAspect Ratio: {Core.GetAspectRatio()}" +
|
||||||
$"\nFinal Sensitivity: {mySens * inGameSens.Value}");
|
$"\nFinal Sensitivity: {mySens * inGameSens.Value}";
|
||||||
|
if (lastDebugLog != debugLog) { Logger.LogInfo(debugLog); lastDebugLog = debugLog; }
|
||||||
}
|
}
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
@ -82,13 +84,8 @@ namespace UniformAim
|
|||||||
//FixedUpdate() at 50Hz (Unity default) tickrate appears to resolve the issue of this script breaking when AI spawns
|
//FixedUpdate() at 50Hz (Unity default) tickrate appears to resolve the issue of this script breaking when AI spawns
|
||||||
Time.fixedDeltaTime = (1f / 50f);
|
Time.fixedDeltaTime = (1f / 50f);
|
||||||
|
|
||||||
//check if the game is running
|
if (Utils.SetRootObject() != null)
|
||||||
var isRunning = Utils.checkIsReady();
|
|
||||||
if (!isRunning) return;
|
|
||||||
|
|
||||||
if (isRunning)
|
|
||||||
{
|
{
|
||||||
if (Utils.SetRootObject() != null) {
|
|
||||||
var rootObject = Utils.SetRootObject();
|
var rootObject = Utils.SetRootObject();
|
||||||
//only update these values if the menu has been opened, otherwise read the config
|
//only update these values if the menu has been opened, otherwise read the config
|
||||||
if (rootObject.transform.Find("Game Settings").gameObject.activeInHierarchy)
|
if (rootObject.transform.Find("Game Settings").gameObject.activeInHierarchy)
|
||||||
@ -97,7 +94,17 @@ namespace UniformAim
|
|||||||
inGameSens.Value = Utils.GetInGameSens(rootObject);
|
inGameSens.Value = Utils.GetInGameSens(rootObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//cgheck if the player is aiming
|
|
||||||
|
//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)
|
||||||
|
{
|
||||||
|
//check if the player is aiming
|
||||||
if (isAiming)
|
if (isAiming)
|
||||||
{
|
{
|
||||||
//Grab FOV values for calculation
|
//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