diff --git a/README.md b/README.md index 0c94c42..b8430f1 100644 --- a/README.md +++ b/README.md @@ -4,30 +4,31 @@ An SPT-AKI module mod that allows you to detach the camera and fly around freely ### Controls -For now, the keybinds are non-configurable (unless you change it in code and build from source). +The default controls are as follows: - Keypad Plus - toggle free camera mode - Keypad Enter - teleport player to camera position - Keypad Multiply - toggle UI +If you need to change them, press F12 in-game and expand the `Freecam #.#.#` section and configure your keybinds there. +Alternatively, you can find the `com.terkoiz.freecam.cfg` file in your `BepInEx/config/` folder after you've started up the game at least once with Freecam installed, and change the keybinds there. + + ### How to install 1. Download the latest release here: [link](https://dev.sp-tarkov.com/Terkoiz/Freecam/releases) -OR- build from source (instructions below) -2. Simply drop the folder `Terkoiz-Freecam` into your SPT-AKI `user/mods/` directory. +2. Simply extract the zip file contents into your root SPT-AKI folder (where EscapeFromTarkov.exe is). +3. Your `BepInEx/plugins` folder should now contain a `Terkoiz.Freecam.dll` file inside. ### Known issues 1. Your weapon doesn't turn invisible when you enter freecam mode 2. When teleporting to camera position, the camera rotation gets copied exactly, potentially causing the player model to tilt 3. Game version UI element is not hidden when toggling UI -4. None of the camera settings (speed, senstivity, etc.) are user-configurable -5. When flying to distant parts of the map in freecam mode, LODs are not triggered (these seem to follow the player) +4. When flying to distant parts of the map in freecam mode, LODs are not triggered (these seem to follow the player) ### How to build from source 1. Download/clone this repository -2. Download/clone the `SPT-AKI/Modules` repository: [link](https://dev.sp-tarkov.com/SPT-AKI/Modules) -3. Move the contents of the `project` folder over to the SPT-AKI Modules `project` folder -4. Add the `Terkoiz.Freecam` project to the SPT-AKI Modules solution -5. Build modules - `Terkoiz.Freecam.dll` should appear under `Build/EscapeFromTarkov_Data/Managed` in the SPT-AKI Modules directory -6. Copy the .dll into the `mod/Terkoiz-Freecam` folder and rename to `module.dll` -7. That's it, you have a working release of this mod! Follow the `How to install` instructions on how to get the mod into your game \ No newline at end of file +2. Re-import dependencies. I recommend you do this from the SPT-AKI/Modules project's `Shared/Managed` folder, if you have the Modules project fully setup. +3. Rebuild the project in the Release configuration. +4. Grab the `Terkoiz.Freecam.dll` file from the `bin/Release` folder and use it wherever. Refer to the "How to install" section if you need help here. \ No newline at end of file diff --git a/mod/Terkoiz-Freecam/LICENSE b/mod/Terkoiz-Freecam/LICENSE deleted file mode 100644 index 32560ba..0000000 --- a/mod/Terkoiz-Freecam/LICENSE +++ /dev/null @@ -1,31 +0,0 @@ -Copyright (c) 2021 Martynas Gestautas. All rights reserved. - -Developed by: SPT-Aki - Martynas Gestautas - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation files -(the "Software"), to deal with the Software without restriction, -including without limitation the rights to use, copy, modify, merge, -publish, distribute, sublicense, and/or sell copies of the Software, -and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -* Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - -* Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimers in the - documentation and/or other materials provided with the distribution. - -* Neither the names of Martynas Gestautas, SPT-Aki nor the names of its - contributors may be used to endorse or promote products derived from - this Software without specific prior written permission. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH -THE SOFTWARE. \ No newline at end of file diff --git a/mod/Terkoiz-Freecam/disclaimer.pdf b/mod/Terkoiz-Freecam/disclaimer.pdf deleted file mode 100644 index 4ad7dc5..0000000 Binary files a/mod/Terkoiz-Freecam/disclaimer.pdf and /dev/null differ diff --git a/mod/Terkoiz-Freecam/module.dll b/mod/Terkoiz-Freecam/module.dll deleted file mode 100644 index 745d3e0..0000000 Binary files a/mod/Terkoiz-Freecam/module.dll and /dev/null differ diff --git a/mod/Terkoiz-Freecam/package.json b/mod/Terkoiz-Freecam/package.json deleted file mode 100644 index 9c381eb..0000000 --- a/mod/Terkoiz-Freecam/package.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "Freecam", - "author": "Terkoiz", - "version": "1.0.1", - "license": "NCSA Open Source", - "dependencies": {} -} \ No newline at end of file diff --git a/project/Terkoiz.Freecam/Freecam.cs b/project/Terkoiz.Freecam/Freecam.cs index 70c438a..8125da9 100644 --- a/project/Terkoiz.Freecam/Freecam.cs +++ b/project/Terkoiz.Freecam/Freecam.cs @@ -11,31 +11,6 @@ namespace Terkoiz.Freecam /// public class Freecam : MonoBehaviour { - /// - /// Normal speed of camera movement. - /// - public float MovementSpeed = 10f; - - /// - /// Speed of camera movement when shift is held down. - /// - public float FastMovementSpeed = 100f; - - /// - /// Sensitivity for free look. - /// - public float FreeLookSensitivity = 3f; - - /// - /// Amount to zoom the camera when using the mouse wheel. - /// - public float ZoomSensitivity = 10f; - - /// - /// Amount to zoom the camera when using the mouse wheel (fast mode). - /// - public float FastZoomSensitivity = 50f; - public bool IsActive = false; void Update() @@ -44,9 +19,9 @@ namespace Terkoiz.Freecam { return; } - + var fastMode = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift); - var movementSpeed = fastMode ? FastMovementSpeed : MovementSpeed; + var movementSpeed = fastMode ? FreecamPlugin.CameraFastMoveSpeed.Value : FreecamPlugin.CameraMoveSpeed.Value; if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.LeftArrow)) { @@ -88,14 +63,14 @@ namespace Terkoiz.Freecam transform.position += (-Vector3.up * movementSpeed * Time.deltaTime); } - float newRotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * FreeLookSensitivity; - float newRotationY = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * FreeLookSensitivity; + float newRotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * FreecamPlugin.CameraLookSensitivity.Value; + float newRotationY = transform.localEulerAngles.x - Input.GetAxis("Mouse Y") * FreecamPlugin.CameraLookSensitivity.Value; transform.localEulerAngles = new Vector3(newRotationY, newRotationX, 0f); float axis = Input.GetAxis("Mouse ScrollWheel"); if (axis != 0) { - var zoomSensitivity = fastMode ? FastZoomSensitivity : ZoomSensitivity; + var zoomSensitivity = fastMode ? FreecamPlugin.CameraFastZoomSpeed.Value : FreecamPlugin.CameraZoomSpeed.Value; transform.position += transform.forward * axis * zoomSensitivity; } } diff --git a/project/Terkoiz.Freecam/FreecamController.cs b/project/Terkoiz.Freecam/FreecamController.cs index c0244c5..a2a54e4 100644 --- a/project/Terkoiz.Freecam/FreecamController.cs +++ b/project/Terkoiz.Freecam/FreecamController.cs @@ -13,30 +13,24 @@ namespace Terkoiz.Freecam private BattleUIScreen playerUi; private bool uiHidden; - // TODO: - // Menu for adjusting settings - // Config file for default settings - // Configurable keybinds - // TODO MAYBE: // Hide player weapon // Hide version number UI element // FreeCam controller support (camera could be smoother with an analog stick, apparently) - // Adjusting speed/sensitivity without a menu (Ctrl+ScrollWheel for example) public void Update() { - if (Input.GetKeyDown(KeyCode.KeypadMultiply)) + if (FreecamPlugin.ToggleUi.Value.IsDown()) { ToggleUi(); } - if (Input.GetKeyDown(KeyCode.KeypadPlus)) + if (FreecamPlugin.ToggleFreecamMode.Value.IsDown()) { ToggleCamera(); } - if (Input.GetKeyDown(KeyCode.KeypadEnter)) + if (FreecamPlugin.TeleportToCamera.Value.IsDown()) { MovePlayerToCamera(); } diff --git a/project/Terkoiz.Freecam/FreecamPlugin.cs b/project/Terkoiz.Freecam/FreecamPlugin.cs new file mode 100644 index 0000000..8178136 --- /dev/null +++ b/project/Terkoiz.Freecam/FreecamPlugin.cs @@ -0,0 +1,98 @@ +using BepInEx; +using BepInEx.Configuration; +using UnityEngine; + +namespace Terkoiz.Freecam +{ + [BepInPlugin("com.terkoiz.freecam", "Terkoiz.Freecam", "1.1.0")] + public class FreecamPlugin : BaseUnityPlugin + { + private static GameObject HookObject; + + // Keyboard shortcut config entries + private const string KeybindSectionName = "Keybinds"; + internal static ConfigEntry ToggleFreecamMode; + internal static ConfigEntry TeleportToCamera; + internal static ConfigEntry ToggleUi; + + // Camera settings config entries + private const string CameraSettingsSectionName = "CameraSettings"; + internal static ConfigEntry CameraMoveSpeed; + internal static ConfigEntry CameraFastMoveSpeed; + internal static ConfigEntry CameraLookSensitivity; + internal static ConfigEntry CameraZoomSpeed; + internal static ConfigEntry CameraFastZoomSpeed; + + private void Awake() + { + Logger.LogError("Loading Freecam..."); + + InitConfiguration(); + + HookObject = new GameObject(); + HookObject.AddComponent(); + Object.DontDestroyOnLoad(HookObject); + } + + private void InitConfiguration() + { + ToggleFreecamMode = Config.Bind( + KeybindSectionName, + "ToggleCamera", + new KeyboardShortcut(KeyCode.KeypadPlus), + "The keyboard shortcut that toggles Freecam"); + + TeleportToCamera = Config.Bind( + KeybindSectionName, + "TeleportToCamera", + new KeyboardShortcut(KeyCode.KeypadEnter), + "The keyboard shortcut that teleports the player to camera position"); + + ToggleUi = Config.Bind( + KeybindSectionName, + "ToggleUi", + new KeyboardShortcut(KeyCode.KeypadMultiply), + "The keyboard shortcut that toggles the game UI"); + + CameraMoveSpeed = Config.Bind( + CameraSettingsSectionName, + "CameraMoveSpeed", + 10f, + new ConfigDescription( + "The speed at which the camera will move normally", + new AcceptableValueRange(0.01f, 100f))); + + CameraFastMoveSpeed = Config.Bind( + CameraSettingsSectionName, + "CameraFastMoveSpeed", + 100f, + new ConfigDescription( + "The speed at which the camera will move when the Shift key is held down", + new AcceptableValueRange(0.01f, 1000f))); + + CameraLookSensitivity = Config.Bind( + CameraSettingsSectionName, + "CameraLookSensitivity", + 3f, + new ConfigDescription( + "Camera free look mouse sensitivity", + new AcceptableValueRange(0.1f, 10f))); + + CameraZoomSpeed = Config.Bind( + CameraSettingsSectionName, + "CameraMousewheelZoomSpeed", + 10f, + new ConfigDescription( + "Amount to zoom the camera when using the mouse wheel", + new AcceptableValueRange(0.01f, 100f))); + + CameraFastZoomSpeed = Config.Bind( + CameraSettingsSectionName, + "CameraMousewheelFastZoomSpeed", + 50f, + new ConfigDescription( + "Amount to zoom the camera when using the mouse wheel while holding Shift", + new AcceptableValueRange(0.01f, 1000f))); + } + } +} diff --git a/project/Terkoiz.Freecam/Program.cs b/project/Terkoiz.Freecam/Program.cs deleted file mode 100644 index 21a6da5..0000000 --- a/project/Terkoiz.Freecam/Program.cs +++ /dev/null @@ -1,17 +0,0 @@ -using UnityEngine; - -namespace Terkoiz.Freecam -{ - public class Program - { - private static GameObject HookObject; - - static void Main(string[] args) - { - Debug.LogError("Terkoiz.Freecam: Loading..."); - HookObject = new GameObject(); - HookObject.AddComponent(); - Object.DontDestroyOnLoad(HookObject); - } - } -} diff --git a/project/Terkoiz.Freecam/Terkoiz.Freecam.csproj b/project/Terkoiz.Freecam/Terkoiz.Freecam.csproj index 4a92a90..b28ec79 100644 --- a/project/Terkoiz.Freecam/Terkoiz.Freecam.csproj +++ b/project/Terkoiz.Freecam/Terkoiz.Freecam.csproj @@ -9,7 +9,7 @@ Properties Terkoiz.Freecam Terkoiz.Freecam - v4.7.1 + v4.7.2 512 true @@ -32,62 +32,48 @@ 4 - true + false - key.snk + + - - ..\Shared\References\0Harmony.dll - False - - ..\Shared\References\Assembly-CSharp.dll - False + ..\Shared\Hollowed\Assembly-CSharp.dll - - ..\Shared\References\ItemComponent.Types.dll - False + + ..\packages\BepInEx.BaseLib.5.4.17\lib\net35\BepInEx.dll - ..\Shared\References\Comfort.dll - False + ..\Shared\Managed\Comfort.dll - - False - ..\Shared\References\Newtonsoft.Json.dll - False + + ..\Shared\Managed\ItemComponent.Types.dll - ..\Shared\References\UnityEngine.dll - False + ..\Shared\Managed\UnityEngine.dll - ..\Shared\References\UnityEngine.CoreModule.dll - False + ..\Shared\Managed\UnityEngine.CoreModule.dll - - ..\Shared\References\UnityEngine.PhysicsModule.dll - False + + ..\Shared\Managed\UnityEngine.InputLegacyModule.dll + + + ..\Shared\Managed\UnityEngine.UIModule.dll - + - - {7584f43a-5937-417e-abf4-c5f680f300fb} - Aki.Common - False - - - - + + \ No newline at end of file diff --git a/project/Terkoiz.Freecam/app.config b/project/Terkoiz.Freecam/app.config new file mode 100644 index 0000000..2a4bf25 --- /dev/null +++ b/project/Terkoiz.Freecam/app.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/project/Terkoiz.Freecam/packages.config b/project/Terkoiz.Freecam/packages.config new file mode 100644 index 0000000..14409c9 --- /dev/null +++ b/project/Terkoiz.Freecam/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file