2022-09-08 21:29:16 +02:00
|
|
|
|
using BepInEx;
|
|
|
|
|
using BepInEx.Configuration;
|
|
|
|
|
using Comfort.Common;
|
2023-01-10 11:49:09 +01:00
|
|
|
|
using EFT;
|
2022-09-18 23:54:23 +02:00
|
|
|
|
using EFT.Settings.Graphics;
|
2023-01-10 11:49:09 +01:00
|
|
|
|
using System.Collections;
|
2022-09-20 22:43:40 +02:00
|
|
|
|
using System.ComponentModel;
|
2023-01-10 11:49:09 +01:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
using UnityEngine;
|
2022-09-08 21:29:16 +02:00
|
|
|
|
|
2023-01-10 11:49:09 +01:00
|
|
|
|
/* Dependencies:
|
|
|
|
|
* ../BepInEx/core/
|
|
|
|
|
* BepInEx.dll
|
|
|
|
|
* ../EscapeFromTarkov_Data/Managed/
|
|
|
|
|
* Aki.Reflection.dll
|
|
|
|
|
* Assembly-CSharp.dll
|
|
|
|
|
* Comfort.dll
|
|
|
|
|
* ItemComponent.Types.dll
|
|
|
|
|
* System.dll
|
|
|
|
|
* Unity.Postprocessing.Runtime.dll
|
|
|
|
|
* UnityEngine.dll
|
|
|
|
|
* UnityEngine.CoreModule.dll
|
|
|
|
|
*/
|
2022-09-17 20:08:36 +02:00
|
|
|
|
namespace ScopeTweaks
|
2022-09-08 21:29:16 +02:00
|
|
|
|
{
|
2023-02-19 11:58:12 +01:00
|
|
|
|
[BepInPlugin("com.notGreg.scopeTweaks", "notGreg's Scope Tweaks", "3.5.0")]
|
2022-09-08 21:29:16 +02:00
|
|
|
|
public class Plugin : BaseUnityPlugin
|
|
|
|
|
{
|
|
|
|
|
ConfigEntry<int> cameraResolutionScale;
|
|
|
|
|
ConfigEntry<int> scopeCameraResolutionScale;
|
2022-09-18 22:12:16 +02:00
|
|
|
|
ConfigEntry<EFOVScalingMode> scopeFixType;
|
2022-09-28 20:14:35 +02:00
|
|
|
|
ConfigEntry<bool> enableDebug;
|
2022-09-16 13:24:26 +02:00
|
|
|
|
|
2022-09-18 22:12:16 +02:00
|
|
|
|
enum EFOVScalingMode
|
2022-09-17 19:49:55 +02:00
|
|
|
|
{
|
2022-09-16 13:24:26 +02:00
|
|
|
|
Disabled,
|
2022-09-20 22:43:40 +02:00
|
|
|
|
[Description("Magnified optics")]
|
|
|
|
|
ScopesOnly,
|
|
|
|
|
[Description("All sights")]
|
|
|
|
|
All,
|
2022-09-16 13:24:26 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-01-10 11:49:09 +01:00
|
|
|
|
//The following assignments should allow for faster patching in the future.
|
|
|
|
|
//The correct GClass can be found by searching for "ClearSettings" in Assembly-CSharp.dll via dnSpy, netFiddle, ilSpy, etc.
|
|
|
|
|
|
|
|
|
|
//GClass1642 settingsLibrary = Singleton<GClass1642>.Instance; //used by SPT-AKI 3.2.3
|
|
|
|
|
//GClass1653 settingsLibrary = Singleton<GClass1653>.Instance; //used by SPT-AKI 3.3.0
|
2023-01-10 11:57:07 +01:00
|
|
|
|
//GClass1659 settingsLibrary = Singleton<GClass1659>.Instance; //used by SPT-AKI 3.4.1
|
2023-01-10 11:49:09 +01:00
|
|
|
|
|
|
|
|
|
//The correct GClass can be found by searching for "SetFov" in Assembly-CSharp.dll via dnSpy, netFiddle, ilSpy, etc.
|
|
|
|
|
|
|
|
|
|
//GClass1774 setFovLibrary = Singleton<GClass1774>.Instance; //used by SPT-AKI 3.2.3
|
|
|
|
|
//GClass1785 setFovLibrary = Singleton<GClass1785>.Instance; //used by SPT-AKI 3.3.0
|
2023-02-19 11:58:12 +01:00
|
|
|
|
CameraClass setFovLibrary = CameraClass.Instance; //used by SPT-AKI 3.4.1 and 3.5.0
|
2023-01-10 11:49:09 +01:00
|
|
|
|
|
2022-09-17 19:49:55 +02:00
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
cameraResolutionScale = Config.Bind(
|
|
|
|
|
"General",
|
|
|
|
|
"Main camera scale %",
|
|
|
|
|
80,
|
2022-09-24 08:42:25 +02:00
|
|
|
|
new ConfigDescription("Additional override applied on top of currently enabled resolution scaling method.", new AcceptableValueRange<int>(25, 100)));
|
2022-09-17 19:49:55 +02:00
|
|
|
|
|
|
|
|
|
scopeCameraResolutionScale = Config.Bind(
|
|
|
|
|
"General",
|
|
|
|
|
"Scope camera scale %",
|
2022-09-20 22:02:46 +02:00
|
|
|
|
80,
|
2022-09-28 20:14:35 +02:00
|
|
|
|
new ConfigDescription("Additional override applied on top of currently enabled resolution scaling method.", new AcceptableValueRange<int>(25, 100)));
|
2022-09-24 08:42:25 +02:00
|
|
|
|
|
2022-09-28 20:14:35 +02:00
|
|
|
|
scopeFixType = Config.Bind(
|
|
|
|
|
"General",
|
|
|
|
|
"High FOV sight tweak",
|
|
|
|
|
EFOVScalingMode.ScopesOnly,
|
|
|
|
|
new ConfigDescription(""));
|
2022-09-24 08:42:25 +02:00
|
|
|
|
|
2022-09-28 20:14:35 +02:00
|
|
|
|
enableDebug = Config.Bind("Debug", "Enable debug logging", false);
|
|
|
|
|
}
|
2022-09-16 10:29:54 +02:00
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
void Update()
|
2022-09-17 19:49:55 +02:00
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
//Check if the game is in a valid state and execute logic depening on the status of the game
|
2022-09-20 22:02:46 +02:00
|
|
|
|
if (Singleton<AbstractGame>.Instance == null) return;
|
|
|
|
|
GameStatus currentGameState = Singleton<AbstractGame>.Instance.Status;
|
2022-09-16 13:24:26 +02:00
|
|
|
|
|
2023-01-10 11:49:09 +01:00
|
|
|
|
//logic should only execute once per game instead of every frame
|
2022-09-20 22:02:46 +02:00
|
|
|
|
if (!gameStateChanged(currentGameState)) return;
|
2022-09-16 10:29:54 +02:00
|
|
|
|
|
2023-01-10 11:49:09 +01:00
|
|
|
|
switch (currentGameState)
|
2022-09-16 10:29:54 +02:00
|
|
|
|
{
|
2022-09-20 22:02:46 +02:00
|
|
|
|
case GameStatus.Started:
|
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo("Getting local player");
|
2022-09-20 22:02:46 +02:00
|
|
|
|
mainPlayer = getLocalPlayer();
|
2022-09-08 21:29:16 +02:00
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
subscribeHandsChangedEvent();
|
2022-09-08 21:29:16 +02:00
|
|
|
|
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo("Assigning cameras...");
|
2022-09-20 22:02:46 +02:00
|
|
|
|
StartCoroutine(tryGetMainCamera());
|
|
|
|
|
StartCoroutine(tryGetScopeCamera());
|
2022-09-15 21:14:26 +02:00
|
|
|
|
|
2022-09-28 20:14:35 +02:00
|
|
|
|
defaultInGameFOV = inGameFOV;
|
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case GameStatus.SoftStopping:
|
2022-09-28 20:14:35 +02:00
|
|
|
|
case GameStatus.Stopping:
|
2022-09-20 22:02:46 +02:00
|
|
|
|
case GameStatus.Stopped:
|
|
|
|
|
{
|
2022-09-28 20:14:35 +02:00
|
|
|
|
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo("Resetting...");
|
2022-09-20 22:02:46 +02:00
|
|
|
|
FPSCamera = null;
|
|
|
|
|
scopeCamera = null;
|
|
|
|
|
mainPlayer = null;
|
2022-09-28 20:14:35 +02:00
|
|
|
|
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"Restoring FOV in settings: {defaultInGameFOV}");
|
2022-09-28 20:14:35 +02:00
|
|
|
|
inGameFOV = defaultInGameFOV;
|
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default: break;
|
2022-09-15 21:14:26 +02:00
|
|
|
|
}
|
2022-09-20 22:02:46 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// GAME STATUS
|
|
|
|
|
/// </summary>
|
2022-09-15 21:14:26 +02:00
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
GameStatus lastGameState;
|
2023-01-10 11:49:09 +01:00
|
|
|
|
//compare current game status to the last saved game status, return true if game status has changed
|
2022-09-20 22:02:46 +02:00
|
|
|
|
bool gameStateChanged(GameStatus currentState)
|
|
|
|
|
{
|
|
|
|
|
if (currentState == lastGameState) return false;
|
|
|
|
|
lastGameState = currentState;
|
|
|
|
|
return true;
|
2022-09-17 19:49:55 +02:00
|
|
|
|
}
|
2022-09-16 13:24:26 +02:00
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
Player mainPlayer;
|
2023-01-10 11:49:09 +01:00
|
|
|
|
//find and return the player character in the session
|
2022-09-20 22:02:46 +02:00
|
|
|
|
Player getLocalPlayer()
|
2022-09-18 22:12:16 +02:00
|
|
|
|
{
|
2022-09-20 22:02:46 +02:00
|
|
|
|
return Singleton<GameWorld>.Instance.RegisteredPlayers.Find(p => p.IsYourPlayer);
|
2022-09-18 22:12:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// FIELD OF VIEW
|
|
|
|
|
/// </summary>
|
2022-09-28 20:14:35 +02:00
|
|
|
|
///
|
|
|
|
|
private int defaultInGameFOV;
|
|
|
|
|
private int inGameFOV
|
2022-09-18 22:12:16 +02:00
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
get
|
|
|
|
|
{
|
2023-01-10 11:57:07 +01:00
|
|
|
|
//int fov = settingsLibrary.Game.Settings.FieldOfView.Value;
|
2023-02-19 11:58:12 +01:00
|
|
|
|
//int fov = Singleton<GClass1659>.Instance.Game.Settings.FieldOfView.Value; //SPT-AKI 3.4.1
|
|
|
|
|
int fov = Singleton<GClass1776>.Instance.Game.Settings.FieldOfView.Value; // SPT-AKI 3.5.0
|
2022-09-28 20:14:35 +02:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"get_defaultInGameFOV: Reading from settings: {fov}");
|
|
|
|
|
return fov;
|
|
|
|
|
}
|
2023-01-10 11:49:09 +01:00
|
|
|
|
set
|
|
|
|
|
{
|
2022-09-28 20:14:35 +02:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"set_defaultInGameFOV: Writing to settings: {value}");
|
2023-01-10 11:57:07 +01:00
|
|
|
|
//settingsLibrary.Game.Settings.FieldOfView.Value = value;
|
2023-02-19 11:58:12 +01:00
|
|
|
|
//int fov = Singleton<GClass1659>.Instance.Game.Settings.FieldOfView.Value;
|
2023-02-20 17:08:45 +01:00
|
|
|
|
Singleton<GClass1776>.Instance.Game.Settings.FieldOfView.Value = value; // SPT-AKI 3.5.0
|
2022-09-28 20:14:35 +02:00
|
|
|
|
}
|
2022-09-18 22:12:16 +02:00
|
|
|
|
}
|
2022-09-18 23:54:23 +02:00
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// CAMERA SETUP
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
2022-09-24 08:42:25 +02:00
|
|
|
|
Camera FPSCamera = null;
|
|
|
|
|
Camera scopeCamera = null;
|
|
|
|
|
|
|
|
|
|
SSAA ssaaInstance = null;
|
|
|
|
|
FieldInfo _nextSSRation = null;
|
|
|
|
|
|
|
|
|
|
WaitForSeconds myDelaySec = new WaitForSeconds(1);
|
2022-09-20 22:02:46 +02:00
|
|
|
|
IEnumerator tryGetMainCamera()
|
2022-09-17 19:49:55 +02:00
|
|
|
|
{
|
2022-09-20 22:02:46 +02:00
|
|
|
|
string cameraName = "FPS Camera";
|
|
|
|
|
if (GameObject.Find(cameraName) != null)
|
2022-09-17 19:49:55 +02:00
|
|
|
|
{
|
2022-09-20 22:02:46 +02:00
|
|
|
|
FPSCamera = GameObject.Find(cameraName).GetComponent<Camera>();
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"{FPSCamera.name} found!");
|
2023-02-20 17:08:45 +01:00
|
|
|
|
StopCoroutine(tryGetMainCamera());
|
2022-09-18 23:54:23 +02:00
|
|
|
|
}
|
2022-09-20 22:02:46 +02:00
|
|
|
|
else
|
2022-09-18 23:54:23 +02:00
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogMessage($"Camera \"{cameraName}\" not found.");
|
2022-09-20 22:02:46 +02:00
|
|
|
|
yield return myDelaySec;
|
|
|
|
|
StartCoroutine(tryGetMainCamera());
|
|
|
|
|
yield break;
|
2022-09-18 23:54:23 +02:00
|
|
|
|
}
|
2022-09-20 22:02:46 +02:00
|
|
|
|
yield return null;
|
2022-09-18 23:54:23 +02:00
|
|
|
|
}
|
2022-09-20 22:02:46 +02:00
|
|
|
|
|
|
|
|
|
FieldInfo getFieldInfo(string fieldName)
|
2022-09-18 23:54:23 +02:00
|
|
|
|
{
|
2022-09-20 22:02:46 +02:00
|
|
|
|
return typeof(SSAA).GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
|
2022-09-17 19:49:55 +02:00
|
|
|
|
}
|
2022-09-16 13:24:26 +02:00
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
IEnumerator tryGetScopeCamera()
|
2022-09-17 19:49:55 +02:00
|
|
|
|
{
|
2022-09-20 22:02:46 +02:00
|
|
|
|
string cameraName = "BaseOpticCamera(Clone)";
|
|
|
|
|
if (GameObject.Find(cameraName) != null)
|
2022-09-17 19:49:55 +02:00
|
|
|
|
{
|
2022-09-20 22:02:46 +02:00
|
|
|
|
scopeCamera = GameObject.Find(cameraName).GetComponent<Camera>();
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"Camera \"{scopeCamera.name}\" found!");
|
2023-02-20 17:08:45 +01:00
|
|
|
|
StopCoroutine(tryGetScopeCamera());
|
2022-09-17 19:49:55 +02:00
|
|
|
|
}
|
2022-09-20 22:02:46 +02:00
|
|
|
|
yield break;
|
2022-09-17 19:49:55 +02:00
|
|
|
|
}
|
2022-09-20 22:02:46 +02:00
|
|
|
|
void setMainCameraResolutionScale(int value = 100)
|
2022-09-18 22:12:16 +02:00
|
|
|
|
{
|
2023-02-20 17:08:45 +01:00
|
|
|
|
if (ssaaInstance == null)
|
2023-01-10 11:49:09 +01:00
|
|
|
|
{
|
2023-02-20 17:08:45 +01:00
|
|
|
|
ssaaInstance = FPSCamera.GetComponent<SSAA>();
|
|
|
|
|
_nextSSRation = getFieldInfo("_nextSSRation");
|
2023-01-10 11:49:09 +01:00
|
|
|
|
}
|
2023-02-20 17:08:45 +01:00
|
|
|
|
float target_res = currentScalingFactor * (value / 100.0f);
|
2023-01-10 11:49:09 +01:00
|
|
|
|
|
2023-02-20 17:08:45 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"Setting MainCam res scale to {target_res}%");
|
|
|
|
|
//_nextSSRation.SetValue(ssaaInstance, (float)(currentScalingFactor * (value / 100.0f)));
|
|
|
|
|
|
2022-09-18 22:12:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
2023-02-20 17:08:45 +01:00
|
|
|
|
SSAAOptic ssaaOpticInstance = null;
|
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
void setScopeCameraResolutionScale(int value)
|
2022-09-17 19:49:55 +02:00
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (scopeCamera == null || !scopeCamera.isActiveAndEnabled)
|
|
|
|
|
{
|
|
|
|
|
if (enableDebug.Value) Logger.LogInfo("ScopeCam inactive or absent!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-09-16 13:24:26 +02:00
|
|
|
|
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"Setting Scope res scale to {value}%");
|
2023-02-20 17:08:45 +01:00
|
|
|
|
|
|
|
|
|
if (ssaaOpticInstance == null)
|
|
|
|
|
{
|
|
|
|
|
ssaaOpticInstance = scopeCamera.GetComponent<SSAAOptic>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ssaaOpticInstance.OpticCameraToMainCameraResolutionRatio = (float)(currentScalingFactor * (value / 100.0f));
|
2022-09-20 22:02:46 +02:00
|
|
|
|
}
|
2022-09-15 21:14:26 +02:00
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// PLAYER WEAPON EVENTS
|
|
|
|
|
/// </summary>
|
|
|
|
|
void subscribeHandsChangedEvent()
|
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo("Subscribing to HandsChanged Event");
|
2022-09-20 22:02:46 +02:00
|
|
|
|
mainPlayer.HandsChangedEvent += (handsArgs) =>
|
2022-09-17 19:49:55 +02:00
|
|
|
|
{
|
2022-09-20 22:02:46 +02:00
|
|
|
|
subscribeOnAimingChangedEvent();
|
|
|
|
|
};
|
|
|
|
|
}
|
2022-09-15 21:14:26 +02:00
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
void subscribeOnAimingChangedEvent()
|
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
|
|
|
|
|
if (enableDebug.Value) Logger.LogInfo("Subscribing to OnAimingChanged Event");
|
2022-09-20 22:02:46 +02:00
|
|
|
|
mainPlayer.HandsController.OnAimingChanged += (aimingArgs) =>
|
2022-09-08 21:29:16 +02:00
|
|
|
|
{
|
2022-09-20 22:43:40 +02:00
|
|
|
|
currentScalingFactor = getCurrentScalingFactor();
|
|
|
|
|
StartCoroutine(tryGetScopeCamera());
|
2023-02-20 17:08:45 +01:00
|
|
|
|
|
2022-09-20 22:43:40 +02:00
|
|
|
|
if (!mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
2022-09-20 22:02:46 +02:00
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
switch (scopeFixType.Value)
|
|
|
|
|
{
|
2022-09-20 22:43:40 +02:00
|
|
|
|
case EFOVScalingMode.Disabled:
|
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"Switch: Not Aiming: ScalingMode: {scopeFixType.Value}");
|
2022-09-20 22:43:40 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case EFOVScalingMode.ScopesOnly:
|
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"Switch: Not Aiming: ScalingMode: {scopeFixType.Value}");
|
2022-09-20 22:43:40 +02:00
|
|
|
|
setMainCameraResolutionScale();
|
2022-09-28 20:14:35 +02:00
|
|
|
|
|
2023-01-10 11:49:09 +01:00
|
|
|
|
setFovLibrary.SetFov(defaultInGameFOV, 0.33f, false);
|
2022-09-28 20:14:35 +02:00
|
|
|
|
inGameFOV = defaultInGameFOV;
|
|
|
|
|
|
2022-09-20 22:43:40 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case EFOVScalingMode.All:
|
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"Switch: Not Aiming: ScalingMode: {scopeFixType.Value}");
|
2022-09-20 22:43:40 +02:00
|
|
|
|
setMainCameraResolutionScale();
|
2022-09-28 20:14:35 +02:00
|
|
|
|
|
2023-01-10 11:49:09 +01:00
|
|
|
|
setFovLibrary.SetFov(defaultInGameFOV, 0.33f, false);
|
2022-09-28 20:14:35 +02:00
|
|
|
|
inGameFOV = defaultInGameFOV;
|
|
|
|
|
|
2022-09-20 22:43:40 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
2023-01-10 11:49:09 +01:00
|
|
|
|
}
|
2023-01-10 11:57:07 +01:00
|
|
|
|
return;
|
2022-09-20 22:02:46 +02:00
|
|
|
|
}
|
2022-09-16 13:24:26 +02:00
|
|
|
|
|
2022-09-20 22:43:40 +02:00
|
|
|
|
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
2022-09-18 23:54:23 +02:00
|
|
|
|
{
|
2022-09-28 20:14:35 +02:00
|
|
|
|
defaultInGameFOV = inGameFOV;
|
2022-09-20 22:43:40 +02:00
|
|
|
|
switch (scopeFixType.Value)
|
|
|
|
|
{
|
|
|
|
|
case EFOVScalingMode.Disabled:
|
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"Switch: Aiming: ScalingMode: {scopeFixType.Value}");
|
2022-09-20 22:43:40 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case EFOVScalingMode.ScopesOnly:
|
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"Switch: Aiming: ScalingMode: {scopeFixType.Value}");
|
2023-02-20 17:08:45 +01:00
|
|
|
|
if (scopeCamera != null && scopeCamera.isActiveAndEnabled)
|
2022-09-20 22:43:40 +02:00
|
|
|
|
{
|
|
|
|
|
applyFixesWhileAiming();
|
|
|
|
|
}
|
2023-02-20 17:08:45 +01:00
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (enableDebug.Value) Logger.LogInfo("ScopeCamera not found or disabled!");
|
|
|
|
|
}
|
2022-09-20 22:43:40 +02:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case EFOVScalingMode.All:
|
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"Switch: Aiming: ScalingMode: {scopeFixType.Value}");
|
2022-09-20 22:43:40 +02:00
|
|
|
|
|
|
|
|
|
applyFixesWhileAiming();
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-20 22:02:46 +02:00
|
|
|
|
}
|
|
|
|
|
};
|
2022-09-18 23:54:23 +02:00
|
|
|
|
}
|
2022-09-08 21:29:16 +02:00
|
|
|
|
|
2022-09-20 22:43:40 +02:00
|
|
|
|
void applyFixesWhileAiming()
|
|
|
|
|
{
|
2023-02-20 17:08:45 +01:00
|
|
|
|
//if (enableDebug.Value) Logger.LogInfo($"AimingSpeed: {mainPlayer.ProceduralWeaponAnimation.AimingSpeed}");
|
|
|
|
|
if (enableDebug.Value) Logger.LogInfo("Applying aiming tweaks");
|
2023-01-10 11:49:09 +01:00
|
|
|
|
|
2023-02-20 17:08:45 +01:00
|
|
|
|
setFovLibrary.SetFov(35, 0.25f, false);
|
2022-09-28 20:14:35 +02:00
|
|
|
|
inGameFOV = 50;
|
2022-09-20 22:43:40 +02:00
|
|
|
|
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo("Updating scope resolution");
|
2022-09-20 22:43:40 +02:00
|
|
|
|
setMainCameraResolutionScale(cameraResolutionScale.Value);
|
|
|
|
|
setScopeCameraResolutionScale(scopeCameraResolutionScale.Value);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-20 22:02:46 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// IN-GAME SETTINGS
|
|
|
|
|
/// </summary>
|
2022-09-24 08:42:25 +02:00
|
|
|
|
|
|
|
|
|
float currentScalingFactor = 1.0f;
|
2022-09-20 22:02:46 +02:00
|
|
|
|
|
2022-09-18 23:54:23 +02:00
|
|
|
|
float getCurrentScalingFactor()
|
|
|
|
|
{
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo("Getting current scaling factor:");
|
2023-01-10 11:57:07 +01:00
|
|
|
|
//var graphics = settingsLibrary.Graphics.Settings; //SPT-AKI 3.3.0
|
2023-02-19 11:58:12 +01:00
|
|
|
|
//var graphics = Singleton<GClass1659>.Instance.Graphics.Settings; // SPT-AKI 3.4.1
|
|
|
|
|
var graphics = Singleton<GClass1776>.Instance.Graphics.Settings; // SPT-AKI 3.5.0
|
2022-09-18 23:54:23 +02:00
|
|
|
|
|
2023-02-20 17:08:45 +01:00
|
|
|
|
//if (!graphics.DLSSEnabled && !graphics.FSREnabled)
|
|
|
|
|
//{
|
|
|
|
|
// if (enableDebug.Value) Logger.LogInfo($"Supersampling factor: {graphics.SuperSamplingFactor}");
|
|
|
|
|
// return graphics.SuperSamplingFactor;
|
|
|
|
|
//}
|
2022-09-18 23:54:23 +02:00
|
|
|
|
|
|
|
|
|
if (graphics.DLSSEnabled)
|
|
|
|
|
{
|
|
|
|
|
float DLSSFactor = 1.0f;
|
|
|
|
|
switch (graphics.DLSSMode.Value)
|
|
|
|
|
{
|
|
|
|
|
case EDLSSMode.Off: { DLSSFactor = 1.0f; break; }
|
|
|
|
|
case EDLSSMode.Quality: { DLSSFactor = 0.67f; break; }
|
|
|
|
|
case EDLSSMode.Balanced: { DLSSFactor = 0.58f; break; }
|
|
|
|
|
case EDLSSMode.Performance: { DLSSFactor = 0.5f; break; }
|
2022-09-18 23:59:26 +02:00
|
|
|
|
case EDLSSMode.UltraPerformance: { DLSSFactor = 0.33f; break; }
|
2022-09-18 23:54:23 +02:00
|
|
|
|
}
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"DLSS factor: {DLSSFactor}");
|
2022-09-18 23:54:23 +02:00
|
|
|
|
return DLSSFactor;
|
|
|
|
|
}
|
|
|
|
|
if (graphics.FSREnabled)
|
|
|
|
|
{
|
|
|
|
|
float FSRFactor = 1.0f;
|
|
|
|
|
switch (graphics.FSRMode.Value)
|
|
|
|
|
{
|
|
|
|
|
case EFSRMode.Off: { FSRFactor = 1.0f; break; }
|
2022-09-18 23:59:26 +02:00
|
|
|
|
case EFSRMode.UltraQuality: { FSRFactor = 0.77f; break; }
|
2022-09-18 23:54:23 +02:00
|
|
|
|
case EFSRMode.Quality: { FSRFactor = 0.66f; break; }
|
|
|
|
|
case EFSRMode.Balanced: { FSRFactor = 0.59f; break; }
|
|
|
|
|
case EFSRMode.Performance: { FSRFactor = 0.5f; break; }
|
|
|
|
|
}
|
2023-01-10 11:49:09 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"FSR factor: {FSRFactor}");
|
2022-09-18 23:54:23 +02:00
|
|
|
|
return FSRFactor;
|
2022-09-08 21:29:16 +02:00
|
|
|
|
}
|
2023-02-19 11:58:12 +01:00
|
|
|
|
if (graphics.FSR2Enabled)
|
|
|
|
|
{
|
|
|
|
|
float FSR2Factor = 1.0f;
|
|
|
|
|
switch (graphics.FSR2Mode.Value)
|
|
|
|
|
{
|
|
|
|
|
case EFSR2Mode.Off: { FSR2Factor = 1.0f; break; }
|
|
|
|
|
case EFSR2Mode.Quality: { FSR2Factor = 0.67f; break; }
|
|
|
|
|
case EFSR2Mode.Balanced: { FSR2Factor = 0.59f; break; }
|
|
|
|
|
case EFSR2Mode.Performance: { FSR2Factor = 0.5f; break; }
|
|
|
|
|
case EFSR2Mode.UltraPerformance: { FSR2Factor = 0.33f; break; }
|
|
|
|
|
}
|
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"FSR factor: {FSR2Factor}");
|
|
|
|
|
return FSR2Factor;
|
|
|
|
|
}
|
2022-09-18 23:54:23 +02:00
|
|
|
|
|
2023-02-20 17:08:45 +01:00
|
|
|
|
if (enableDebug.Value) Logger.LogInfo($"Supersampling factor: {graphics.SuperSamplingFactor}");
|
|
|
|
|
return graphics.SuperSamplingFactor;
|
|
|
|
|
|
|
|
|
|
//if (enableDebug.Value) Logger.LogInfo($"GetCurrentScalingFactor(): Something went wrong. Returning 1.0f");
|
|
|
|
|
//return 1.0f;
|
2022-09-08 21:29:16 +02:00
|
|
|
|
}
|
2023-01-10 11:49:09 +01:00
|
|
|
|
}
|
2022-09-20 22:02:46 +02:00
|
|
|
|
}
|