Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ad9987cac0 | ||
|
|
af00ddb866 | ||
|
|
796e898deb | ||
|
|
a5f241c1b3 | ||
|
|
b3aecc2bd5 | ||
|
|
7ac7c41645 |
No files matched your search
@@ -117,7 +117,6 @@ try {
|
|||||||
Write-Host 'Start Sons of the Forest, then:'
|
Write-Host 'Start Sons of the Forest, then:'
|
||||||
Write-Host ' 1. Check that MODS appears on the main menu and lists RifleScope'
|
Write-Host ' 1. Check that MODS appears on the main menu and lists RifleScope'
|
||||||
Write-Host ' 2. Load into a game, equip the rifle and aim down the scope'
|
Write-Host ' 2. Load into a game, equip the rifle and aim down the scope'
|
||||||
Write-Host ' 3. Press F1 and type scopezoom to see or change the zoom'
|
|
||||||
Write-Host ''
|
Write-Host ''
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
@@ -129,4 +128,3 @@ catch {
|
|||||||
Write-Host ''
|
Write-Host ''
|
||||||
}
|
}
|
||||||
|
|
||||||
Read-Host 'Press Enter to close' | Out-Null
|
|
||||||
@@ -1,206 +1,107 @@
|
|||||||
\# Rifle Scope
|
# Rifle Scope
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
A stronger rifle scope for Sons of the Forest. Aiming down the rifle scope zooms
|
A stronger rifle scope for Sons of the Forest. Aiming down the rifle scope zooms
|
||||||
|
|
||||||
5x further than the vanilla scope and shows a full screen scope view with a
|
5x further than the vanilla scope and shows a full screen scope view with a
|
||||||
|
|
||||||
crosshair reticle, mil dots and a rangefinder instead of the red dot.
|
crosshair reticle, mil dots and a rangefinder instead of the red dot.
|
||||||
|
|
||||||
|
Want a suppressed rifle too? Install
|
||||||
|
[RifleSuppressor](https://github.com/JustinOros/sotf-riflesuppressor). It used to
|
||||||
|
be part of this mod and is now its own mod, so you can use either one or both.
|
||||||
|
|
||||||
|
## Multiplayer
|
||||||
\## Multiplayer
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Client side only. Nothing gets installed on a dedicated server, and other players
|
Client side only. Nothing gets installed on a dedicated server, and other players
|
||||||
|
|
||||||
do not need the mod.
|
do not need the mod.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
### Easy install
|
||||||
\## Installation
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\### Easy install
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Close the game, open PowerShell and paste:
|
Close the game, open PowerShell and paste:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
|
|
||||||
irm https://raw.githubusercontent.com/JustinOros/sotf-riflescope/main/Install.ps1 | iex
|
irm https://raw.githubusercontent.com/JustinOros/sotf-riflescope/main/Install.ps1 | iex
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
It finds your game, installs RedLoader if needed, and installs the latest
|
It finds your game, installs RedLoader if needed, and installs the latest
|
||||||
|
|
||||||
RifleScope. Run it again any time to update.
|
RifleScope. Run it again any time to update.
|
||||||
|
|
||||||
|
### Manual install
|
||||||
|
|
||||||
|
#### Step 1: Install RedLoader
|
||||||
|
|
||||||
\### Manual install
|
[RedLoader](https://github.com/ToniMacaroni/RedLoader/releases/latest) is the mod
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\#### Step 1: Install RedLoader
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\[RedLoader](https://github.com/ToniMacaroni/RedLoader/releases/latest) is the mod
|
|
||||||
|
|
||||||
loader for Sons of the Forest. The game cannot load any mod without it, so
|
loader for Sons of the Forest. The game cannot load any mod without it, so
|
||||||
|
|
||||||
install it first. You only have to do this once.
|
install it first. You only have to do this once.
|
||||||
|
|
||||||
|
1. Download `RedLoader.zip` from the
|
||||||
|
[latest RedLoader release](https://github.com/ToniMacaroni/RedLoader/releases/latest)
|
||||||
|
2. Extract it into your Sons of the Forest folder, the one containing
|
||||||
|
`SonsOfTheForest.exe`, usually
|
||||||
|
`C:\Program Files (x86)\Steam\steamapps\common\Sons Of The Forest`
|
||||||
|
3. Launch the game once and wait until you reach the main menu. The first launch
|
||||||
|
takes a few minutes while RedLoader processes the game files
|
||||||
|
4. Check that `MODS` appears on the main menu, then quit
|
||||||
|
|
||||||
|
#### Step 2: Install RifleScope
|
||||||
|
|
||||||
1\. Download `RedLoader.zip` from the
|
1. Download `RifleScope.zip` from the
|
||||||
|
[latest release](https://github.com/JustinOros/sotf-riflescope/releases/latest)
|
||||||
  \[latest RedLoader release](https://github.com/ToniMacaroni/RedLoader/releases/latest)
|
2. Extract it into the `Mods` folder inside your game folder
|
||||||
|
3. You should end up with:
|
||||||
2\. Extract it into your Sons of the Forest folder, the one containing
|
|
||||||
|
|
||||||
  `SonsOfTheForest.exe`, usually
|
|
||||||
|
|
||||||
  `C:\\Program Files (x86)\\Steam\\steamapps\\common\\Sons Of The Forest`
|
|
||||||
|
|
||||||
3\. Launch the game once and wait until you reach the main menu. The first launch
|
|
||||||
|
|
||||||
  takes a few minutes while RedLoader processes the game files
|
|
||||||
|
|
||||||
4\. Check that `MODS` appears on the main menu, then quit
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\#### Step 2: Install RifleScope
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
1\. Download `RifleScope.zip` from the
|
|
||||||
|
|
||||||
  \[latest release](https://github.com/JustinOros/sotf-riflescope/releases/latest)
|
|
||||||
|
|
||||||
2\. Extract it into the `Mods` folder inside your game folder
|
|
||||||
|
|
||||||
3\. You should end up with:
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Mods\RifleScope.dll
|
||||||
Mods\\RifleScope.dll
|
Mods\RifleScope\manifest.json
|
||||||
|
|
||||||
Mods\\RifleScope\\manifest.json
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
\## Usage
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Equip the rifle and aim. Once zoomed in, the rifle model is hidden and the scope
|
Equip the rifle and aim. Once zoomed in, the rifle model is hidden and the scope
|
||||||
|
|
||||||
view is shown. Your shot goes where the crosshair is.
|
view is shown. Your shot goes where the crosshair is.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
The red number at the bottom left of the scope is the range in meters to whatever
|
The red number at the bottom left of the scope is the range in meters to whatever
|
||||||
|
|
||||||
is under the crosshair.
|
is under the crosshair.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
The reticle has 10 mil dots in each direction. At 5x each dot is 2 mils, which
|
The reticle has 10 mil dots in each direction. At 5x each dot is 2 mils, which
|
||||||
|
|
||||||
covers 20 cm at 100 m. At 10x and higher each dot is 1 mil. Use them to hold over
|
covers 20 cm at 100 m. At 10x and higher each dot is 1 mil. Use them to hold over
|
||||||
|
|
||||||
or to the side at long range.
|
or to the side at long range.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Press F1 to open the console, then use these commands:
|
Press F1 to open the console, then use these commands:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
| Command | Action |
|
| Command | Action |
|
||||||
|
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
|
| `scope` | Show whether the scope is on or off |
|
||||||
| `scope` | Show whether the mod is on or off |
|
| `scope off` | Go back to the vanilla scope |
|
||||||
|
| `scope on` | Turn the scope back on |
|
||||||
| `scope off` | Turn the mod off and go back to the vanilla scope |
|
|
||||||
|
|
||||||
| `scope on` | Turn the mod back on |
|
|
||||||
|
|
||||||
| `scopezoom` | Show the current zoom |
|
| `scopezoom` | Show the current zoom |
|
||||||
|
|
||||||
| `scopezoom 5` | Set the zoom as a multiple of the vanilla scope, 1 to 50. The default is 5 |
|
| `scopezoom 5` | Set the zoom as a multiple of the vanilla scope, 1 to 50. The default is 5 |
|
||||||
|
|
||||||
| `scopetrim` | Show the current vertical trim |
|
| `scopetrim` | Show the current vertical trim |
|
||||||
|
| `scopetrim 60` | Set the vertical trim, -200 to 200. Positive moves hits down, negative moves hits up. The default is 60 |
|
||||||
| `scopetrim 50` | Set the vertical trim, -200 to 200. Positive moves hits down, negative moves hits up. The default is 50 |
|
|
||||||
|
|
||||||
| `scopewind` | Show the current windage |
|
| `scopewind` | Show the current windage |
|
||||||
|
|
||||||
| `scopewind 20` | Set the windage, -200 to 200. Positive moves hits right, negative moves hits left. The default is 0 |
|
| `scopewind 20` | Set the windage, -200 to 200. Positive moves hits right, negative moves hits left. The default is 0 |
|
||||||
|
|
||||||
| `scopedebug` | Toggle a debug readout above the range |
|
| `scopedebug` | Toggle a debug readout above the range |
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Trim and windage are angle adjustments, so a setting that is right at one range
|
Trim and windage are angle adjustments, so a setting that is right at one range
|
||||||
|
|
||||||
stays right at every range.
|
stays right at every range.
|
||||||
|
|
||||||
|
The on or off setting, zoom, trim and windage are saved to `UserData\RifleScope.txt` in your game
|
||||||
|
|
||||||
The on or off setting, zoom, trim and windage are saved to `UserData\\RifleScope.txt` in your game
|
|
||||||
|
|
||||||
folder. Setting the zoom to 1 keeps vanilla zoom and the normal scope view,
|
folder. Setting the zoom to 1 keeps vanilla zoom and the normal scope view,
|
||||||
|
|
||||||
without the red dot.
|
without the red dot.
|
||||||
|
|
||||||
|
## Building from source
|
||||||
|
|
||||||
\## Building from source
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Requires the .NET 8 SDK and RedLoader installed with its game assemblies
|
Requires the .NET 8 SDK and RedLoader installed with its game assemblies
|
||||||
|
|
||||||
generated.
|
generated.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
|
.\build.ps1 -Install
|
||||||
.\\build.ps1 -Install
|
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Use `-Package` to build `RifleScope.zip` for a release. Pass `-GameDir "path"` if
|
Use `-Package` to build `RifleScope.zip` for a release. Pass `-GameDir "path"` if
|
||||||
|
|
||||||
the game is not found automatically.
|
the game is not found automatically.
|
||||||
|
|
||||||
|
## Troubleshooting
|
||||||
|
|
||||||
|
Check `_RedLoader\Latest.log` in your game folder. RifleScope logs a line when it
|
||||||
\## Troubleshooting
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Check `\_RedLoader\\Latest.log` in your game folder. RifleScope logs a line when it
|
|
||||||
|
|
||||||
loads.
|
loads.
|
||||||
|
|
||||||
+47
-17
@@ -2,9 +2,15 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2CppInterop.Runtime;
|
||||||
|
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||||
using RedLoader;
|
using RedLoader;
|
||||||
using RedLoader.Utils;
|
using RedLoader.Utils;
|
||||||
using Sons.FieldOfView;
|
using Sons.FieldOfView;
|
||||||
|
using Sons.Items.Core;
|
||||||
using Sons.Weapon;
|
using Sons.Weapon;
|
||||||
using SonsSdk;
|
using SonsSdk;
|
||||||
using SonsSdk.Attributes;
|
using SonsSdk.Attributes;
|
||||||
@@ -20,7 +26,7 @@ public class RifleScope : SonsMod
|
|||||||
private const float DefaultZoom = 5f;
|
private const float DefaultZoom = 5f;
|
||||||
private const float MinZoom = 1f;
|
private const float MinZoom = 1f;
|
||||||
private const float MaxZoom = 50f;
|
private const float MaxZoom = 50f;
|
||||||
private const float DefaultTrimCm = 50f;
|
private const float DefaultTrimCm = 60f;
|
||||||
private const float MaxTrimCm = 200f;
|
private const float MaxTrimCm = 200f;
|
||||||
private const float MaxWindCm = 200f;
|
private const float MaxWindCm = 200f;
|
||||||
private const float TrimReferenceRange = 50f;
|
private const float TrimReferenceRange = 50f;
|
||||||
@@ -48,7 +54,7 @@ public class RifleScope : SonsMod
|
|||||||
private static string _configPath;
|
private static string _configPath;
|
||||||
|
|
||||||
private static RifleAnimatorController _rifle;
|
private static RifleAnimatorController _rifle;
|
||||||
private static float _nextSearch;
|
private static RifleAnimatorController _pendingRifle;
|
||||||
private static float _hipFov;
|
private static float _hipFov;
|
||||||
private static float _vanillaAimFov = 35f;
|
private static float _vanillaAimFov = 35f;
|
||||||
private static float _targetAimFov;
|
private static float _targetAimFov;
|
||||||
@@ -76,6 +82,7 @@ public class RifleScope : SonsMod
|
|||||||
public RifleScope()
|
public RifleScope()
|
||||||
{
|
{
|
||||||
OnUpdateCallback = OnUpdate;
|
OnUpdateCallback = OnUpdate;
|
||||||
|
HarmonyPatchAll = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnSdkInitialized()
|
protected override void OnSdkInitialized()
|
||||||
@@ -101,20 +108,24 @@ public class RifleScope : SonsMod
|
|||||||
|
|
||||||
private static void Tick()
|
private static void Tick()
|
||||||
{
|
{
|
||||||
if (!_enabled)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!_rifle || !_rifle.gameObject.activeInHierarchy)
|
if (!_rifle || !_rifle.gameObject.activeInHierarchy)
|
||||||
|
{
|
||||||
|
if (_rifle || _hiddenCam)
|
||||||
{
|
{
|
||||||
_rifle = null;
|
_rifle = null;
|
||||||
SetZoomed(false, null);
|
SetZoomed(false, null);
|
||||||
if (Time.unscaledTime < _nextSearch)
|
|
||||||
return;
|
|
||||||
_nextSearch = Time.unscaledTime + 0.5f;
|
|
||||||
if (!FindRifle())
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pending = _pendingRifle;
|
||||||
|
_pendingRifle = null;
|
||||||
|
if (!pending || !pending.gameObject.activeInHierarchy)
|
||||||
|
return;
|
||||||
|
AdoptRifle(pending);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!_enabled)
|
||||||
|
return;
|
||||||
|
|
||||||
var manager = _rifle._cameraFovManager;
|
var manager = _rifle._cameraFovManager;
|
||||||
if (!manager)
|
if (!manager)
|
||||||
{
|
{
|
||||||
@@ -129,20 +140,25 @@ public class RifleScope : SonsMod
|
|||||||
SetZoomed(zoomed, cam);
|
SetZoomed(zoomed, cam);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool FindRifle()
|
internal static void OnWeaponTick(RangedWeaponController controller)
|
||||||
{
|
{
|
||||||
foreach (var rifle in UnityEngine.Object.FindObjectsOfType<RifleAnimatorController>())
|
if (!controller || (_rifle && _rifle.Pointer == controller.Pointer))
|
||||||
|
return;
|
||||||
|
var rifle = controller.TryCast<RifleAnimatorController>();
|
||||||
|
if (rifle && rifle.IsLocalPlayer())
|
||||||
|
_pendingRifle = rifle;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AdoptRifle(RifleAnimatorController rifle)
|
||||||
{
|
{
|
||||||
if (!rifle || !rifle.gameObject.activeInHierarchy || !rifle.IsLocalPlayer())
|
|
||||||
continue;
|
|
||||||
_rifle = rifle;
|
_rifle = rifle;
|
||||||
_projectile = FindProjectileTransform(rifle);
|
_projectile = FindProjectileTransform(rifle);
|
||||||
|
if (_enabled)
|
||||||
|
{
|
||||||
if (!_overlay)
|
if (!_overlay)
|
||||||
CreateOverlay();
|
CreateOverlay();
|
||||||
HideRedDot(rifle);
|
HideRedDot(rifle);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Transform FindProjectileTransform(RangedWeaponController rifle)
|
private static Transform FindProjectileTransform(RangedWeaponController rifle)
|
||||||
@@ -308,7 +324,6 @@ public class RifleScope : SonsMod
|
|||||||
settings._FieldOfViewTargetOffset_k__BackingField = original;
|
settings._FieldOfViewTargetOffset_k__BackingField = original;
|
||||||
}
|
}
|
||||||
RestoreRedDot();
|
RestoreRedDot();
|
||||||
_rifle = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Material HiddenFor(Material original)
|
private static Material HiddenFor(Material original)
|
||||||
@@ -809,3 +824,18 @@ public class RifleScope : SonsMod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(RangedWeaponController), nameof(RangedWeaponController.CheckFireInput))]
|
||||||
|
internal static class CheckFireInputPatch
|
||||||
|
{
|
||||||
|
private static void Postfix(RangedWeaponController __instance)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
global::RifleScope.RifleScope.OnWeaponTick(__instance);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -6,7 +6,7 @@
|
|||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<AssemblyName>RifleScope</AssemblyName>
|
<AssemblyName>RifleScope</AssemblyName>
|
||||||
<RootNamespace>RifleScope</RootNamespace>
|
<RootNamespace>RifleScope</RootNamespace>
|
||||||
<Version>1.0.1</Version>
|
<Version>1.2.0</Version>
|
||||||
<NoWarn>CS0436;CS1701;CS1702;MSB3277;MSB3106</NoWarn>
|
<NoWarn>CS0436;CS1701;CS1702;MSB3277;MSB3106</NoWarn>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"id": "RifleScope",
|
"id": "RifleScope",
|
||||||
"name": "RifleScope",
|
"name": "RifleScope",
|
||||||
"author": "JustinOros",
|
"author": "JustinOros",
|
||||||
"version": "1.0.1",
|
"version": "1.2.0",
|
||||||
"description": "Stronger rifle scope magnification and a crosshair reticle",
|
"description": "Stronger rifle scope magnification and a crosshair reticle",
|
||||||
"gameVersion": "1.0.0",
|
"gameVersion": "1.0.0",
|
||||||
"platform": "Client",
|
"platform": "Client",
|
||||||
|
|||||||
Reference in new issue
Block a user