Skip to content

Commit

Permalink
fix environmentEnjoyer, add godmode debug setting, WIP camerashake an…
Browse files Browse the repository at this point in the history
…d staminascript
  • Loading branch information
CWXDEV committed Dec 11, 2024
1 parent 4ee6eb4 commit 2a34d75
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 42 deletions.
Binary file modified src/Build/BepInEx/plugins/CWX/CWX_MegaMod.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion src/CWX-MegaMod/CWX-MegaMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<AssemblyName>CWX_MegaMod</AssemblyName>
<TargetFramework>net471</TargetFramework>
<Version>1.3.2</Version>
<Version>1.3.3</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
30 changes: 30 additions & 0 deletions src/CWX-MegaMod/ChadMode/CameraShakeScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using Comfort.Common;
using EFT;
using UnityEngine;

namespace CWX_MegaMod.ChadMode
{
public class CameraShakeScript : MonoBehaviour
{
private CameraClass _camera;

private void Awake()
{
_camera = CameraClass.Instance;
}

public void StartTask()
{
if (_camera == null)
{
MegaMod.LogToScreen("Camera object was null, not changing Camera shake", EMessageType.Error);
return;
}

// _camera.EffectsController.enabled = !MegaMod.CameraShake.Value;
// also does this
// _camera.Camera.GetComponent<PrismEffects>().useVignette = !MegaMod.CameraShake.Value;
}
}
}
48 changes: 48 additions & 0 deletions src/CWX-MegaMod/ChadMode/GodModeScript.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;
using System.Threading.Tasks;
using Comfort.Common;
using EFT;
using UnityEngine;

namespace CWX_MegaMod.ChadMode
{
public class GodModeScript : MonoBehaviour
{
private GameWorld _gameWorld;
private Player _player;
private float _oldHealthCoef;
private float _newHealthCoef = 0;
private float _oldSafeFallHeight;
private float _newSafeFallHeight = 999999f;

private void Awake()
{
_gameWorld = Singleton<GameWorld>.Instance;
_player = _gameWorld.MainPlayer;
_oldHealthCoef = _player.ActiveHealthController.DamageCoeff;
_oldSafeFallHeight = _player.ActiveHealthController.FallSafeHeight;
}

public void StartTask()
{
if (_player == null)
{
MegaMod.LogToScreen("Player object was null, Not changing Damage coef", EMessageType.Error);
return;
}

if (MegaMod.GodMode.Value)
{
_player.ActiveHealthController.SetDamageCoeff(_newHealthCoef);
_player.ActiveHealthController.RemoveNegativeEffects(EBodyPart.Common);
_player.ActiveHealthController.RestoreFullHealth();
_player.ActiveHealthController.FallSafeHeight = _newSafeFallHeight;
}
else
{
_player.ActiveHealthController.SetDamageCoeff(_oldHealthCoef);
_player.ActiveHealthController.FallSafeHeight = _oldSafeFallHeight;
}
}
}
}
18 changes: 13 additions & 5 deletions src/CWX-MegaMod/ChadMode/StaminaScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,27 @@ namespace CWX_MegaMod.ChadMode
{
public class StaminaScript : MonoBehaviour
{
private BackendConfigSettingsClass backendConfigSettingsClass;
private GameWorld _gameWorld;
private Player _player;
private float _oldStaminaCoef;
private float _newStaminaCoef = 0;

private void Awake()
{
backendConfigSettingsClass = Singleton<BackendConfigSettingsClass>.Instance;
_gameWorld = Singleton<GameWorld>.Instance;
_player = _gameWorld.MainPlayer;
_oldStaminaCoef = _player.ActiveHealthController.StaminaCoeff;
}

public void StartTask()
{
if (backendConfigSettingsClass != null)
{
// backendConfigSettingsClass.Stamina
if (_player == null)
{
MegaMod.LogToScreen("Player object was null, Not changing stamina coef", EMessageType.Error);
return;
}

// _player.ActiveHealthController.SetStaminaCoeff((MegaMod.UnlimitesStamina.Value ? _newStaminaCoef : _oldStaminaCoef));
}
}
}
37 changes: 19 additions & 18 deletions src/CWX-MegaMod/EnvironmentEnjoyer/EnvironmentEnjoyerScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task GetGameObjects()
*/
public void GetCustoms()
{
var customs = FindObjectsOfType<GameObject>().Where(x => x.name.Contains("Slice_") && x.name.Contains("_trees")).ToList();
var customs = FindObjectsOfType<GameObject>().Where(x => x.name.ToLower().Contains("slice_") && x.name.ToLower().Contains("_trees")).ToList();

foreach (var item in customs)
{
Expand All @@ -103,7 +103,7 @@ public void GetCustoms()
*/
private void GetWoods()
{
var woods = FindObjectsOfType<GameObject>().Where(x => x.name.Contains("Slice_") && x.name.Contains("_trees")).ToList();
var woods = FindObjectsOfType<GameObject>().Where(x => x.name.ToLower().Contains("slice_") && x.name.ToLower().Contains("_trees")).ToList();

foreach (var item in woods)
{
Expand All @@ -124,7 +124,7 @@ private void GetWoods()
*/
private void GetGroundZero()
{
var groundzero = FindObjectsOfType<GameObject>().Where(x => x.name.Contains("SBG_Sandbox_") && x.name.Contains("_Plants")).ToList();
var groundzero = FindObjectsOfType<GameObject>().Where(x => x.name.ToLower().Contains("sbg_sandbox_") && x.name.ToLower().Contains("_plants")).ToList();

foreach (var item in groundzero)
{
Expand Down Expand Up @@ -157,17 +157,15 @@ private void GetGroundZero()
*/
private void GetShoreline()
{
var shoreline1 = GameObject.Find("SBG_Trees");
var shoreline2 = GameObject.Find("SBG_Shoreline_Plants");
// or for this one as they are different unlike other maps
var shoreline = FindObjectsOfType<GameObject>().Where(x => x.name.ToLower().Contains("sbg_trees") || x.name.ToLower().Contains("sbg_shoreline_plants")).ToList();

if (shoreline1 != null)
foreach (var item in shoreline)
{
TreeBush.Add(shoreline1);
}

if (shoreline2 != null)
{
TreeBush.Add(shoreline2);
if (item != null)
{
TreeBush.Add(item);
}
}
}

Expand All @@ -176,7 +174,7 @@ private void GetShoreline()
*/
private void GetReserve()
{
var reserve = FindObjectsOfType<GameObject>().Where(x => x.name.Contains("Slice_") && x.name.Contains("_trees")).ToList();
var reserve = FindObjectsOfType<GameObject>().Where(x => x.name.ToLower().Contains("slice_") && x.name.ToLower().Contains("_trees")).ToList();

foreach (var item in reserve)
{
Expand All @@ -197,7 +195,7 @@ private void GetReserve()
*/
private void GetStreets()
{
var streets = FindObjectsOfType<GameObject>().Where(x => x.name.Contains("_PLANTS")).ToList();
var streets = FindObjectsOfType<GameObject>().Where(x => x.name.ToLower().Contains("_plants")).ToList();

foreach (var item in streets)
{
Expand Down Expand Up @@ -258,11 +256,14 @@ private void GetStreets()
*/
private void GetLighthouse()
{
var lighthouse1 = GameObject.Find("SBG_Trees");
var lighthouse = FindObjectsOfType<GameObject>().Where(x => x.name.ToLower().Contains("sbg_trees")).ToList();

if (lighthouse1 != null)
foreach (var item in lighthouse)
{
TreeBush.Add(lighthouse1);
if (item != null)
{
TreeBush.Add(item);
}
}
}

Expand All @@ -271,7 +272,7 @@ private void GetLighthouse()
*/
private void GetInterchange()
{
var interchange = FindObjectsOfType<GameObject>().Where(x => x.name.Contains("Slice_") && x.name.Contains("_trees")).ToList();
var interchange = FindObjectsOfType<GameObject>().Where(x => x.name.ToLower().Contains("slice_") && x.name.ToLower().Contains("_trees")).ToList();

foreach (var item in interchange)
{
Expand Down
51 changes: 37 additions & 14 deletions src/CWX-MegaMod/MegaMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
using CWX_MegaMod.SpaceUser;
using CWX_MegaMod.TradingPlayerView;
using CWX_MegaMod.WeatherPatcher;
using EFT.Communications;
using EFT.UI;
using UnityEngine;

namespace CWX_MegaMod
{
[BepInPlugin("CWX.MegaMod", "CWX-MegaMod", "1.3.2")]
[BepInPlugin("CWX.MegaMod", "CWX-MegaMod", "1.3.3")]
public class MegaMod : BaseUnityPlugin
{
internal new static ManualLogSource Logger { get; private set; }
Expand All @@ -31,8 +33,9 @@ public class MegaMod : BaseUnityPlugin
internal static ConfigEntry<bool> BotMonitor { get; private set; }
internal static ConfigEntry<EMonitorMode> BotMonitorValue { get; private set; }
internal static ConfigEntry<int> BotMonitorFontSize { get; private set; }

// internal static ConfigEntry<bool> ChadMode { get; private set; }
internal static ConfigEntry<bool> GodMode { get; private set; }
// internal static ConfigEntry<bool> UnlimitesStamina { get; private set; }
// internal static ConfigEntry<bool> CameraShake { get; private set; }
// internal static ConfigEntry<bool> ChadModeStamJiggle { get; private set; }
// internal static ConfigEntry<bool> ChadModeCamRock { get; private set; }
// internal static ConfigEntry<bool> ChadModeBreathing { get; private set; }
Expand Down Expand Up @@ -68,14 +71,16 @@ private void InitConfig()
PainkillerDesat = Config.Bind("1- All Mods", "PainkillerDesat - On/Off", false, new ConfigDescription("Enable PainkillerDesat - Removes effects from taking painkillers", tags: new ConfigurationManagerAttributes() { Order = 3 }));
WeatherDebug = Config.Bind("1- All Mods", "WeatherDebugMode - On/Off", false, new ConfigDescription("Enable WeatherDebugMode - Makes it super sunny", tags: new ConfigurationManagerAttributes() { Order = 2 }));
FogRemover = Config.Bind("1- All Mods", "FogRemover - On/Off", false, new ConfigDescription("Enable FogRemover - Removes fog", tags: new ConfigurationManagerAttributes() { Order = 1 }));
//ChadMode = Config.Bind("All Mods", "ChadMode - On/Off", false, new ConfigDescription("Enable ChadMode - Sets stamina drain to 0", tags: new ConfigurationManagerAttributes() { Order = 12 }));

// MasterKey Settings
MasterKeyToUse = Config.Bind("2- MasterKey", "MasterKeyToUse", EMasterKeys.Yellow, new ConfigDescription("This will be set to all unlockable doors", tags: new ConfigurationManagerAttributes() { Order = 1 }));

// Debugging Mods
BotMonitor = Config.Bind("3- Debug Mods", "BotMonitor - On/Off", false, new ConfigDescription("Enable BotMonitor - Adds a custom gui for Bot Monitoring", tags: new ConfigurationManagerAttributes() { Order = 12 }));
InventoryViewer = Config.Bind("3- Debug Mods", "InventoryViewer - On/Off", false, new ConfigDescription("Enable InventoryViewer - Changes inventory view to show all containers or not", tags: new ConfigurationManagerAttributes() { Order = 2 }));
BotMonitor = Config.Bind("3- Debug Mods", "BotMonitor - On/Off", false, new ConfigDescription("Enable BotMonitor - Adds a custom gui for Bot Monitoring", tags: new ConfigurationManagerAttributes() { Order = 5 }));
InventoryViewer = Config.Bind("3- Debug Mods", "InventoryViewer - On/Off", false, new ConfigDescription("Enable InventoryViewer - Changes inventory view to show all containers or not", tags: new ConfigurationManagerAttributes() { Order = 4 }));
// UnlimitesStamina = Config.Bind("3- Debug Mods", "UnlimitedStamina - On/Off", false, new ConfigDescription("Enable UnlimitedStamina - Changes stamina to not drain", tags: new ConfigurationManagerAttributes() { Order = 3 }));
GodMode = Config.Bind("3- Debug Mods", "GodMode - On/Off", false, new ConfigDescription("Enable GodMode - Unable to be killed", tags: new ConfigurationManagerAttributes() { Order = 2 }));
// CameraShake = Config.Bind("3- Debug Mods", "CameraShake - On/Off", false, new ConfigDescription("Disable CameraShake - Removes CameraShake", tags: new ConfigurationManagerAttributes() { Order = 1 }));

// BotMonitor Settings
BotMonitorValue = Config.Bind("4- BotMonitor", "BotMonitorValue", EMonitorMode.Total, new ConfigDescription("This will be set to only show total", tags: new ConfigurationManagerAttributes() { Order = 2 }));
Expand All @@ -90,27 +95,45 @@ public static void LogToScreen(string message = "", EMessageType eMessageType =
{
switch (eMessageType)
{
case EMessageType.Warning:
ConsoleScreen.LogWarning("[CWX-MegaMod] " + message);
Logger.LogWarning("[CWX-MegaMod] " + message);
case EMessageType.NotiError:
ConsoleScreen.LogError("[CWX-MegaMod Error] " + message);
Logger.LogError("[CWX-MegaMod Error] " + message);
NotificationManagerClass.DisplayMessageNotification("[CWX-MegaMod Error] " + message, ENotificationDurationType.Default, ENotificationIconType.Alert, Color.red);
break;
case EMessageType.NotiWarn:
ConsoleScreen.LogWarning("[CWX-MegaMod Warning] " + message);
Logger.LogWarning("[CWX-MegaMod Warning] " + message);
NotificationManagerClass.DisplayMessageNotification("[CWX-MegaMod Warning] " + message, ENotificationDurationType.Default, ENotificationIconType.Default, Color.yellow);
break;
case EMessageType.NotiInfo:
ConsoleScreen.Log("[CWX-MegaMod Info] " + message);
Logger.LogDebug("[CWX-MegaMod Info] " + message);
NotificationManagerClass.DisplayMessageNotification("[CWX-MegaMod Info] " + message, ENotificationDurationType.Default, ENotificationIconType.Friend, Color.cyan);
break;
case EMessageType.Error:
ConsoleScreen.LogError("[CWX-MegaMod] " + message);
Logger.LogError("[CWX-MegaMod] " + message);
ConsoleScreen.LogError("[CWX-MegaMod Error] " + message);
Logger.LogError("[CWX-MegaMod Error] " + message);
break;
case EMessageType.Warning:
ConsoleScreen.LogWarning("[CWX-MegaMod Warning] " + message);
Logger.LogWarning("[CWX-MegaMod Warning] " + message);
break;
case EMessageType.Info:
default:
ConsoleScreen.Log("[CWX-MegaMod] " + message);
Logger.LogDebug("[CWX-MegaMod] " + message);
ConsoleScreen.Log("[CWX-MegaMod Info] " + message);
Logger.LogDebug("[CWX-MegaMod Info] " + message);
break;
}
}
}

public enum EMessageType
{
Warning,
NotiError,
NotiWarn,
NotiInfo,
Error,
Warning,
Info
}
}
13 changes: 9 additions & 4 deletions src/CWX-MegaMod/MegaModScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ public class MegaModScript : MonoBehaviour
public WeatherPatcherScript _weatherPatcherScript;
public AlarmChangerScript _alarmChangerScript;
public BotMonitorScript _botMonitorScript;
public GodModeScript _godModeScript;
// public StaminaScript _staminaScript;
// public CameraShakeScript _cameraShakeScript;

private void Awake()
{
Expand Down Expand Up @@ -66,8 +68,9 @@ private void SetupMegaModScripts()
_weatherPatcherScript = _gameWorld.gameObject.AddComponent<WeatherPatcherScript>();
_alarmChangerScript = _gameWorld.gameObject.AddComponent<AlarmChangerScript>();
_botMonitorScript = _gameWorld.gameObject.AddComponent<BotMonitorScript>();

_godModeScript = _gameWorld.gameObject.AddComponent<GodModeScript>();
// _staminaScript = _gameWorld.gameObject.AddComponent<StaminaScript>();
// _cameraShakeScript = _gameWorld.gameObject.AddComponent<CameraShakeScript>();
}

private void RunFirstTime()
Expand All @@ -77,8 +80,9 @@ private void RunFirstTime()
_masterKeyScript.StartTask();
_environmentEnjoyerScript.StartTask();
_weatherPatcherScript.StartTask();

_godModeScript.StartTask();
// _staminaScript.StartTask();
// _cameraShakeScript.StartTask();
}

private void SetupMegaModEvents()
Expand All @@ -93,8 +97,9 @@ private void SetupMegaModEvents()
MegaMod.BotMonitor.SettingChanged += (a, b) => RunBotMonitor();
// reset the text style so fontsize changes happen
MegaMod.BotMonitorFontSize.SettingChanged += (a, b) => _botMonitorScript.TextStyle = null;

// MegaMod.ChadMode.SettingChanged += (a, b) => _staminaScript.StartTask();
MegaMod.GodMode.SettingChanged += (a, b) => _godModeScript.StartTask();
// MegaMod.UnlimitesStamina.SettingChanged += (a, b) => _staminaScript.StartTask();
// MegaMod.CameraShake.SettingChanged += (a, b) => _cameraShakeScript.StartTask();
}

private void RunBotMonitor()
Expand Down

0 comments on commit 2a34d75

Please sign in to comment.