From 9bebe7aa2ea80df948338e8b8cee256f7b6454d9 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Thu, 2 Apr 2026 21:16:55 -0400 Subject: Gut graphics stuff, misc additions Signed-off-by: Andrew Opalach --- Animal.cs | 58 + Config.cs | 50 +- MHWNewCamera.csproj | 15 - MHWNewCamera.sln | 22 - NewCamera.csproj | 26 + NewCamera.sln | 22 + Plugin.cs | 3280 +++++++++++++------------------------------ README.txt | 2 +- Scripts/zip_from_gamedir.sh | 19 + changelog.txt | 2 +- 10 files changed, 1121 insertions(+), 2375 deletions(-) create mode 100644 Animal.cs delete mode 100755 MHWNewCamera.csproj delete mode 100755 MHWNewCamera.sln create mode 100755 NewCamera.csproj create mode 100755 NewCamera.sln create mode 100755 Scripts/zip_from_gamedir.sh diff --git a/Animal.cs b/Animal.cs new file mode 100644 index 0000000..1d27650 --- /dev/null +++ b/Animal.cs @@ -0,0 +1,58 @@ +using SharpPluginLoader.Core.Memory; + +namespace SharpPluginLoader.Core.Entities +{ + public class Animal : Entity + { + /// + /// The sAnimal singleton instance + /// + public static MtObject SingletonInstance => SingletonManager.GetSingleton("sAnimal")!; + + /// + /// Gets a list of all animals in the game + /// + /// + public static Animal[] GetAllAnimals() + { + lock (_animals) + return _animals.ToArray(); + } + + /// + /// Constructs a new Animal from a native pointer + /// + /// The native pointer + public Animal(nint instance) : base(instance) { } + + // @TODO: Map to names. + public int Id => Get(0x1AF8); // +0x294 + public int OtherId => Get(0x1AF0); + + private static void AnimalAddHook(nint instance) + { + var animal = new Animal(instance); + lock (_animals) _animals.Add(animal); + _animalAddHook.Original(instance); + } + + private static nint AnimalRemoveHook(nint instance) + { + var animal = new Animal(instance); + lock(_animals) _animals.Remove(animal); + return _animalRemoveHook.Original(instance); + } + + internal static void Initialize() + { + _animalAddHook = Hook.Create(0x141D2F610, AnimalAddHook); + _animalRemoveHook = Hook.Create(0x141D289D0, AnimalRemoveHook); + } + + private delegate void AnimalAddDelegate(nint instance); + private delegate nint AnimalRemoveDelegate(nint instance); + private static Hook _animalAddHook = null!; + private static Hook _animalRemoveHook = null!; + private static readonly List _animals = []; + } +} diff --git a/Config.cs b/Config.cs index 8570644..1da81b5 100755 --- a/Config.cs +++ b/Config.cs @@ -3,11 +3,11 @@ using SharpPluginLoader.Core.Configuration; using SharpPluginLoader.Core.IO; -namespace MHWNewCamera +namespace NewCamera { internal class Config : IConfig { - public String Name => "MHWNewCamera"; + public String Name => "NewCamera"; public String Version => "4.0"; public struct Settings @@ -77,50 +77,6 @@ namespace MHWNewCamera public bool DisableFading { get; set; } } - public struct GraphicalTweaks - { - public GraphicalTweaks() - { - TripleShadowResolution = false; - ShadowRangeOffset = 0.5f; - ApplyShadowRange = false; - ShadowRadiusOffset = -0.0001f; - ApplyShadowRadius = false; - HigherShadowDetailInHoarfrost = false; - EnableHQMode = false; - FullResolutionVolumeBlur = false; - HigherThanHighestVolumeRendering = false; - DisableLODLimits = false; - FoliageLODBias = 3.0f; - TerrainLODBias = 16.0f; - FoliageLODFactor = 0.0f; - TerrainLODFactor = 0.0f; - SnowLODBias = 32.0f; - ApplyLODFactors = false; - LargerFoliageSwayRange = false; - DisableReducedRateAnimations = false; - } - - public bool TripleShadowResolution { get; set; } - public float ShadowRangeOffset { get; set; } - public bool ApplyShadowRange { get; set; } - public float ShadowRadiusOffset { get; set; } - public bool ApplyShadowRadius { get; set; } - public bool HigherShadowDetailInHoarfrost { get; set; } - public bool EnableHQMode { get; set; } - public bool FullResolutionVolumeBlur { get; set; } - public bool HigherThanHighestVolumeRendering { get; set; } - public bool DisableLODLimits { get; set; } - public float FoliageLODBias { get; set; } - public float TerrainLODBias { get; set; } - public float FoliageLODFactor { get; set; } - public float TerrainLODFactor { get; set; } - public float SnowLODBias { get; set; } - public bool ApplyLODFactors { get; set; } - public bool LargerFoliageSwayRange { get; set; } - public bool DisableReducedRateAnimations { get; set; } - } - public struct Position { public float FieldOfView { get; set; } @@ -179,8 +135,6 @@ namespace MHWNewCamera public Dictionary Presets { get; set; } = new Dictionary(); public String Selected { get; set; } = ""; - public GraphicalTweaks Graphics { get; set; } = new GraphicalTweaks(); - public Dictionary Positions { get; set; } = new Dictionary(); } } diff --git a/MHWNewCamera.csproj b/MHWNewCamera.csproj deleted file mode 100755 index 760cd41..0000000 --- a/MHWNewCamera.csproj +++ /dev/null @@ -1,15 +0,0 @@ - - - - net8.0 - enable - enable - True - - - - - - - - diff --git a/MHWNewCamera.sln b/MHWNewCamera.sln deleted file mode 100755 index 8e9bad7..0000000 --- a/MHWNewCamera.sln +++ /dev/null @@ -1,22 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.12.35514.174 d17.12 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MHWNewCamera", "MHWNewCamera.csproj", "{E9DE1105-BC7A-4753-9181-E7DA03727E54}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {E9DE1105-BC7A-4753-9181-E7DA03727E54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E9DE1105-BC7A-4753-9181-E7DA03727E54}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E9DE1105-BC7A-4753-9181-E7DA03727E54}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E9DE1105-BC7A-4753-9181-E7DA03727E54}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/NewCamera.csproj b/NewCamera.csproj new file mode 100755 index 0000000..bde04c5 --- /dev/null +++ b/NewCamera.csproj @@ -0,0 +1,26 @@ + + + + net8.0 + enable + enable + True + + + + + + + + + ..\SharpPluginLoader-fork\SharpPluginLoader.Bootstrapper\bin\Release\net8.0\SharpPluginLoader.Bootstrapper.dll + + + ..\SharpPluginLoader-fork\SharpPluginLoader.Core\bin\Release\net8.0\SharpPluginLoader.Core.dll + + + ..\SharpPluginLoader-fork\SharpPluginLoader.InternalCallGenerator\bin\Release\netstandard2.0\SharpPluginLoader.InternalCallGenerator.dll + + + + diff --git a/NewCamera.sln b/NewCamera.sln new file mode 100755 index 0000000..ba20378 --- /dev/null +++ b/NewCamera.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.12.35514.174 d17.12 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NewCamera", "NewCamera.csproj", "{E9DE1105-BC7A-4753-9181-E7DA03727E54}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E9DE1105-BC7A-4753-9181-E7DA03727E54}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9DE1105-BC7A-4753-9181-E7DA03727E54}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9DE1105-BC7A-4753-9181-E7DA03727E54}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9DE1105-BC7A-4753-9181-E7DA03727E54}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Plugin.cs b/Plugin.cs index 860beb5..b3c9ae5 100755 --- a/Plugin.cs +++ b/Plugin.cs @@ -2,15 +2,15 @@ //#define HOOK_ORDER_ASSERTS //#define LOG_DEBUG_MESSAGES #define MOUSE_AND_KEYBOARD_LAYER -//#define SHADER_FEATURES -//#define QUARANTINED_FEATURES +#define QUARANTINED_FEATURES -using ImGuiNET; using System.Numerics; using System.Runtime.InteropServices; #if ADDR_ASSERTS || HOOK_ORDER_ASSERTS using System.Diagnostics; #endif + +using ImGuiNET; using SharpPluginLoader.Core; using SharpPluginLoader.Core.Entities; using SharpPluginLoader.Core.IO; @@ -46,11 +46,13 @@ using SharpPluginLoader.Core.Configuration; // - Open Poses Menu // @TODO: +// - pCamera refactor. +// - Facial contact shadows incorrectly move based on camera position. // - Attempt to document all test cases I can think of. +// - Make audio like waterfall follow camera position instead of player position. // - Better hook for renderer params. // - Centralize all bindings to get a better idea of how to structure custom binds. // - Use GetRef<>. -// - Hide Hunter's Knife/Slinger. // - General "A/B Graphical Settings" function. // - Save toggle state to config file. // - Include Hide Weapon. @@ -143,89 +145,27 @@ using SharpPluginLoader.Core.Configuration; // - Walk up the stairs towards the canteen and the shadow of the lift will fade-out. Move the camera // back and forth and make sure the lower resolution shadow aligns with the higher res one. -namespace MHWNewCamera +namespace NewCamera { - public struct SSAOParameters { - public float depthBias; // +0xB4B0 - public float slopedDepthBias; // +0xB4B4 - public float maxDepthBias; // +0xB4B8 - public float dispersion; // +0xB4BC - public float effect; // +0xB430 - public float effectGI; // +0xB434 - public float depthDifference; // +0xB4C0 - public float samplesPerPixel; // +0xB4C4 - public int maxSampleNum; // +0xB4C8 - public int maxSampleNumHQ; // +0xB4D0 - public float radius; // +0xB4D4 - public float bias; // +0xB4D8 - public float intensity; // +0xB4E0 - public bool useHiZ; // +0xB4E5 - public float edgeAttenRate; // +0xB4DC - }; - - public struct SSLRParameters { - public int loopCount; // +0xE628 - public float loopCountFactorForCBR; // +0xE62C - public float eliminateDepth; // +0xE630 - public float accurateThreshold; // +0xE644 - public float accurateThresholdHQ; // +0xE64C - public float ditherRadius; // +0xE634 - public float importanceBias; // +0xE638 - public float mipScale; // +0xE63C - public float mipBias; // +0xE640 - public bool ditherResolve; // +0xB43F - public float edgeAttenRate; // +0xB428 - public int mip0CountThreshold; // +0xB438 - public float depthEliminateRate; // +0xB42C - public bool useMipmap; // +0xE650 - public bool gBufferJitter; // +0xB440 - }; - - public struct DOFParameters { - public bool enabled; // +0x1DD - public bool newVersion; // +0x1DC - public float fNumber; // +0x1A0 - public float sensorSize; // +0x1A4 - public float focusDistance; // +0x1A8 - public float nearCoef; // +0x1CC - public float farCoef; // +0x1C8 - public bool nearEnable; // +0x1DE - public bool farEnable; // +0x1DF - public bool debugDraw; // +0x1E0 - public float radius; // +0x1D0 - public float depthScaleForeground; // +0x1D4 - public float aspect; // +0x1D8 - public bool vignettingEnabled; // +0x200 - public bool vignettingEllipse; // +0x201 - public float vignettingEllipticity; // +0x204 - public float vignettingOffset; // +0x1F8 - public float vignettingPow; // +0x1FC - public int vignettingColor; // +0x208 - }; - - public enum ZoneState : int { - Unknown = 0, - Hub = 1, - Combat = 2 - }; - public unsafe class Plugin : IPlugin { - public string Name => "MHW New Camera"; + public string Name => "New Camera"; public string Author => "Akon City Software"; private const float DEFAULT_FOV = 60.0f; private const float DEFAULT_NEAR_CLIP = 16.0f; - private static byte byteFlag(bool f) { return f ? (byte)0x1 : (byte)0x0; } + private static byte ByteFlag(bool f) { return f ? (byte)0x1 : (byte)0x0; } private bool disableMod = false; + private dynamic? tuningTool = null; + private static readonly MtObject sMain = SingletonManager.GetSingleton("sMhMain")!; - private static readonly MtObject sUmbra = SingletonManager.GetSingleton("sUmbra")!; private bool freezeGame = false; private bool decoupleDtFromGameTime = false; private int advanceFrame = 0; + private int forceOffMotionBlurOverride = 0; private float cameraSpeed; private float cameraSpeedModifier; @@ -264,6 +204,9 @@ namespace MHWNewCamera private bool playerMovementLocked => !(unlockMovementHeld || unlockMovementToggled) || unlockMovementPause; private bool lockVerticalToggled = false; + private NativeFunction getViewParamOffset; + private NativeFunction calcOffsetSettingAddr; + private bool orbitPlayer = false; private bool orbitIgnoreCamera = false; private float orbitMovementRotation = 0.0f; @@ -296,7 +239,6 @@ namespace MHWNewCamera private bool unlockInputToggled = false; private bool unlockInputForMenu = false; private bool unlockInputHideMenu = false; - //private bool inputBlockedForToggle = false; private bool buttonWasDown(Button button) { return (lastPadDown & (uint)button) == (uint)button; @@ -354,12 +296,6 @@ namespace MHWNewCamera private Hook? calculateViewHook; */ - private delegate void ShadowCascadeDelegate(nint unknownPtr, nint unknownPtr2); - private Hook? shadowCascadeHook; - - private delegate void RendererSetDelegate(nint unknownPtr, nint unknownPtr2, nint unknownPtr3); - private Hook? rendererSetHook; - private delegate void WritePadInputDelegate(nint unknownPtr, nint unknownPtr2, nint unknownPtr3); private Hook? writePadInputHook; @@ -369,160 +305,18 @@ namespace MHWNewCamera private delegate void CollisionCheckDelegate(nint unknownPtr, nint unknownPtr2); private Hook? collisionCheckHook; - private bool motionBlurDisabled = false; - private bool motionBlurWasDisabled; - private delegate void MotionBlurDelegate(nint unknownPtr, nint unknownPtr2); - private Hook? motionBlurHook; - - private bool dofDisabled = false; - private DOFParameters dofParams; - private bool fillOutDofParams = true; - private bool applyVignettingParams = false; - private bool fillOutVignettingParams = true; - private delegate void DofUpdateDelegate(nint unknownPtr); - private Hook? dofHook; - private delegate void CameraEffectDelegate(nint unknownPtr, nint unknownPtr2, nint unknownPtr3); private Hook? cameraEffectHook; - private bool higherVolumeQuality = false; - private Patch value2ForVolumeQuality; - - private bool disableVolumeDownsample = false; - private Patch volumeSars1; - private Patch volumeSars2; - private Patch volumeSars3; - private Patch volumeSars4; - private Patch volumeSars5; - private Patch volumeSars6; - private Patch volumeSars7; - private Patch volumeSars8; - private Patch volumeSars9; - - private delegate nint CreateLightingObject(nint unknownPtr); - private delegate nint DestroyLightingObject(nint unknownPtr, nint unknownPtr2); - private Hook? createLightingObject; - private Hook? destroyLightingObject; - private nint lightingObject = 0x0; - - private delegate nint CreateFXAAObject(nint unknownPtr, int unknownInt); - private delegate nint DestroyFXAAObject(nint unknownPtr, int unknownInt); - private Hook? createFXAAObject; - private Hook? destroyFXAAObject; - private nint fxaaObject = 0x0; - - private Patch swapMinimapFollowsCamera; + private Patch forceMinimapFollowsCamera; private bool uiToggled = false; private Patch jmpOverUi; - private Patch jmpOverDof; - private bool disableCharacterFade = false; private Patch noopCharacterFade; - private bool tripleShadowRes = false; - private bool lowShadowDetailOverride = false; - private Patch shadowRes1_3x; - private Patch shadowRes1_1; - private Patch shadowRes1_2; - private Patch shadowRes1_3; - private Patch shadowRes2; - private Patch shadowRes3; - //private Patch shadowRes4_Limit; - - private float shadowBiasOffset = 0.0f; - private float shadowRadiusOffset = 0.0f; - private bool applyShadowBias = false; - private bool applyShadowRadius = false; - private float lastShadowBias = -1.0f; - private float lastShadowRadius = -1.0f; - private nint lastShadowCascadeValue = -1; - - private bool applyShadowAdjust = false; - private float lastShadowDistance; - private float lastShadowDistribution; - private float lastShadowBackforwardDistance; - //private float lastBroadAreaShadowRange; - //private float lastShadowFov; - private float shadowDistance = 5000.0f; - private float shadowDistribution = 0.200000003f; - private float shadowBackforwardDistance = 15000.0f; - //private float broadAreaShadowRange = 50000.0f; - //private float shadowFov = 40.0f; - - private void tripleShadowResEnable() - { - shadowRes1_3x.Enable(); - shadowRes1_1.Enable(); - shadowRes1_2.Enable(); - shadowRes1_3.Enable(); - shadowRes2.Enable(); - shadowRes3.Enable(); - //shadowRes4_Limit.Enable(); - } - - private void tripleShadowResDisable() - { - shadowRes1_3x.Disable(); - shadowRes1_1.Disable(); - shadowRes1_2.Disable(); - shadowRes1_3.Disable(); - shadowRes2.Disable(); - shadowRes3.Disable(); - //shadowRes4_Limit.Disable(); - } - - private int internalShadowSampleNumHQ; // +0xE5CC - //private int shadowSampleNumHQ = 32; - - private bool ssaoAdjustments = false; - private bool ssaoB = false; - private SSAOParameters internalSSAOParams; - //private SSAOParameters aSSAOParams; - //private SSAOParameters bSSAOParams; - - private bool ssrAdjustments = false; - private SSLRParameters internalSSRParams; - - private bool enableHQMode = false; - - private float foliageLODBias; - private float terrainLODBias; - private float prevFoliageLODBias = 0.0f; - private float prevTerrainLODBias = 0.0f; - private float foliageLODFactor; - private float terrainLODFactor; - private float internalSnowField4GlobalLODParam = 0.0f; // +0x5718 - private float snowField4GlobalLODParam = 8.0f; - //private float snowField4AllowTesselationHQ; // +0x5741 - //private float snowField4LODBiasHQ; // +0x5748 - private bool applyLODFactors; - - private bool disableLODLimits = false; - private Patch defaultViewModeLODLimit; - private Patch defaultViewModeLODLimit_1; - private Patch defaultViewModeLODLimit_2; - - private void disableLODLimitsEnable() - { - defaultViewModeLODLimit.Enable(); - defaultViewModeLODLimit_1.Enable(); - defaultViewModeLODLimit_2.Enable(); - } - - private void disableLODLimitsDisable() - { - defaultViewModeLODLimit.Disable(); - defaultViewModeLODLimit_1.Disable(); - defaultViewModeLODLimit_2.Disable(); - } - - private bool largerFoliageSwayRange = false; - private Patch addressHigherValueForFoliageSway; - - private bool disableReducedRateAnimations = false; - private Patch zeroFrameSkip; + private int disableDofOverride = 0; private bool enableUnderwaterCamera = false; private Patch underwaterCamera1; @@ -530,9 +324,9 @@ namespace MHWNewCamera private Patch underwaterCamera3; private Patch underwaterCamera4; private Patch underwaterCamera5; - private delegate void UnderwaterCheckDelegate(nint unknownPtr); - private Hook? underwaterCheckHook; private bool cameraIsUnderwater = false; + private delegate void UnderwaterCheck(nint unknownPtr); + private Hook? underwaterCheck; private void underwaterCameraEnable() { @@ -552,6 +346,9 @@ namespace MHWNewCamera underwaterCamera5.Disable(); } + private static readonly MtObject sPlayer = SingletonManager.GetSingleton("sPlayer")!; + private bool saveSlotFallback = false; + private int saveSlotIndex = 0; private bool hideWeapon = false; private bool disableCollision = false; @@ -613,11 +410,11 @@ namespace MHWNewCamera disableGravityEval.Disable(); } - private bool allowHotSpringsAnywhere = false; - private Patch jmpOverHotSpringsEval; - - private bool disableHotSpringsSteam = false; - private Patch jmpOverHotSpringsSteam; + private enum ZoneState : int { + Unknown = 0, + Hub = 1, + Combat = 2 + }; #if QUARANTINED_FEATURES private ZoneState forceZoneState = ZoneState.Unknown; @@ -636,19 +433,76 @@ namespace MHWNewCamera private Patch zoneStateForceCombat2; #endif + private bool allowHotSpringsAnywhere = false; + private Patch jmpOverHotSpringsEval; + + private bool disableHotSpringsSteam = false; + private Patch jmpOverHotSpringsSteam; + private bool enableCrawl = false; private NativeAction procEnvironmentCollision; private nint psuedoObject1; private nint psuedoObject2; private float playerOpacityOverride = 1.0f; - private delegate void EntityParamsDelegate(nint entity, nint unknownPtr2); - private Hook? refreshEntityParams; + private delegate void RefreshEntityParams(nint entity, nint unknownPtr2); + private Hook? refreshEntityParams; + + private struct Wetness + { + public float head; + public float body; + public float waist; + public float legs; + public Wetness() + { + head = 0.0f; + body = 0.0f; + waist = 0.0f; + legs = 0.0f; + } + } - private bool applyCharacterWetness = false; + private Wetness readCharacterWetness(nint player) + { + Wetness wet; + nint wetnessAddr = player + 0x13BD0; + wet.head = MemoryUtil.Read(wetnessAddr); + wet.body = MemoryUtil.Read(wetnessAddr + 0x28); + wet.waist = MemoryUtil.Read(wetnessAddr + 0x50); + wet.legs = MemoryUtil.Read(wetnessAddr + 0x78); + return wet; + } + + private void writeCharacterWetness(nint player, Wetness wet) + { + nint wetnessAddr = player + 0x13BD0; + MemoryUtil.GetRef(wetnessAddr) = wet.head; + MemoryUtil.GetRef(wetnessAddr + 0x28) = wet.body; + MemoryUtil.GetRef(wetnessAddr + 0x50) = wet.waist; + MemoryUtil.GetRef(wetnessAddr + 0x78) = wet.legs; + } + + private bool overrideCharacterWetness = false; private Patch noopCharacterWetnessUpdate; + private Patch jmpOverChangeEquipmentWetnessUpdate_1; + private Patch jmpOverChangeEquipmentWetnessUpdate_2; private float wholeBodyWetness = 0.0f; + private void overrideCharacterWetnessEnable() + { + noopCharacterWetnessUpdate.Enable(); + jmpOverChangeEquipmentWetnessUpdate_1.Enable(); + jmpOverChangeEquipmentWetnessUpdate_2.Enable(); + } + + private void overrideCharacterWetnessDisable() + { + noopCharacterWetnessUpdate.Disable(); + jmpOverChangeEquipmentWetnessUpdate_1.Disable(); + jmpOverChangeEquipmentWetnessUpdate_2.Disable(); + } + private static readonly MtObject sOtomo = SingletonManager.GetSingleton("sOtomo")!; // Gui strings. @@ -705,30 +559,19 @@ namespace MHWNewCamera // @TODO: offsetPerspective doesn't affect disableCharacterFade when it is supposed to. enableOffsetPerspective = config.PerspectiveCameraEnabled; - Config.GraphicalTweaks graphics = config.Graphics; - tripleShadowRes = graphics.TripleShadowResolution; - shadowBiasOffset = graphics.ShadowRangeOffset; - shadowRadiusOffset = graphics.ShadowRadiusOffset; - applyShadowBias = graphics.ApplyShadowRange; - applyShadowRadius = graphics.ApplyShadowRadius; - //lowShadowDetailOverride = graphics.HigherShadowDetailInHoarfrost; - enableHQMode = graphics.EnableHQMode; - disableVolumeDownsample = graphics.FullResolutionVolumeBlur; - higherVolumeQuality = graphics.HigherThanHighestVolumeRendering; - ssaoAdjustments = enableHQMode; - ssrAdjustments = enableHQMode; - disableLODLimits = graphics.DisableLODLimits; - largerFoliageSwayRange = graphics.LargerFoliageSwayRange; - disableReducedRateAnimations = graphics.DisableReducedRateAnimations; - ConfigManager.SaveConfig(this); return config; } - public void OnPreMain() + public PluginData Initialize() { - Config config = loadConfig(); + PluginData data = new PluginData(); + + Animal.Initialize(); + + getViewParamOffset = new NativeFunction(0x14136E6C0); + calcOffsetSettingAddr = new NativeFunction(0x141B8DBB0); #if QUARANTINED_FEATURES // MonsterHunterWorld.exe+20354F7 - call MonsterHunterWorld.exe+1F73850 @@ -736,13 +579,10 @@ namespace MHWNewCamera setPlayerController1 = new NativeAction(0x141F73850); setPlayerController5 = new NativeAction(0x14118DDC0); setZoneStateHook = Hook.Create(0x142035020, SetZoneStateHook); // nint, int - unchecked - { - zoneStateForcePassive1 = new Patch((nint)0x140256A3F + 0x6, [0x1]); - zoneStateForcePassive2 = new Patch((nint)0x141AC2865 + 0x6, [0x1]); - zoneStateForceCombat1 = new Patch((nint)0x141AC2938 + 0x6, [0x0]); - zoneStateForceCombat2 = new Patch((nint)0x141AC28EC + 0x6, [0x0]); - } + zoneStateForcePassive1 = new Patch(new IntPtr(0x140256A3F) + 0x6, [0x1]); + zoneStateForcePassive2 = new Patch(new IntPtr(0x141AC2865) + 0x6, [0x1]); + zoneStateForceCombat1 = new Patch(new IntPtr(0x141AC2938) + 0x6, [0x0]); + zoneStateForceCombat2 = new Patch(new IntPtr(0x141AC28EC) + 0x6, [0x0]); #endif procEnvironmentCollision = new NativeAction(0x141F737D0); @@ -756,7 +596,7 @@ namespace MHWNewCamera // @TODO: Pick camera functions out of the upper function (they happen in immediate succession). // Place where we can check camera state early. - nint addr = PatternScanner.FindFirst(Pattern.FromString("40 53 48 81 EC 80 00 00 00 8B 81 B0 17 00 00 48 8B D9 85 C0 ?? ??")); + IntPtr addr = PatternScanner.FindFirst(Pattern.FromString("40 53 48 81 EC 80 00 00 00 8B 81 B0 17 00 00 48 8B D9 85 C0 ?? ??")); #if ADDR_ASSERTS Trace.Assert(addr == 0x141FA11A0); // nint #endif @@ -775,44 +615,41 @@ namespace MHWNewCamera setupGestureMenu = new NativeAction(0x141E12AF0); showGestureMenu = new NativeAction(0x141FB79B0); /* - unchecked - { - // @TODO: View mode collision check here - // MonsterHunterWorld.exe+23268DF - call MonsterHunterWorld.exe+2326B10 - // can be overridden by the player collision function here - // MonsterHunterWorld.exe+23268DF - call MonsterHunterWorld.exe+23269F0 - // to evaluate differences. - // Other TODOs for View Mode interop. - // - Don't colide with water. - // - Disable box around player collision. - // - View mode fade on close to player. - // - Weird LOD differences when in view mode. - startViewMode = new NativeAction(0x1405842E0); - stopViewMode = new NativeAction(0x1405825A0); - processViewMode = new NativeAction(0x140582820); - viewMode1 = new Patch((nint)0x141ADFAB9, [0x90, 0x90]); // Check input. - viewMode1.Enable(); - // rax = 0x73 -> 0x43 - //viewMode2 = new Patch((nint)0x1405843F8, [0x48, 0x8B, 0x43, 0x10, 0x90]); - //viewMode2.Enable(); - viewMode3 = new Patch((nint)0x1405844ED, [0x90, 0x90, 0x90, 0x90, 0x90]); // Screen flash related. - viewMode3.Enable(); - //viewMode2 = new Patch((nint)0x1405844CB, [0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90]); // Disables view mode from starting. - //viewMode2.Enable(); - // - //viewMode1 = new Patch((nint)0x140582578, [0xEB]); - ////viewMode1.Enable(); - //viewMode1_1 = new Patch((nint)0x140582F13, [0xEB]); - ////viewMode1_1.Enable(); - //viewMode2 = new Patch((nint)0x1405831A5, [0x90, 0x90, 0x90, 0x90]); - ////viewMode2.Enable(); - //viewMode3 = new Patch((nint)0x1405831A5 + 0xC, [0x90, 0x90, 0x90, 0x90, 0x90]); - ////viewMode3.Enable(); - //viewMode4 = new Patch((nint)0x1405831A5 + 0xC + 0x11, [0x90, 0x90, 0x90, 0x90, 0x90]); - ////viewMode4.Enable(); - psuedoViewModeObject = (nint)NativeMemory.AllocZeroed(240); - MemoryUtil.WriteBytes(psuedoViewModeObject, [0x28, 0x23, 0xFB, 0x42, 0x01, 0x00, 0x00, 0x00]); - } + // @TODO: View mode collision check here + // MonsterHunterWorld.exe+23268DF - call MonsterHunterWorld.exe+2326B10 + // can be overridden by the player collision function here + // MonsterHunterWorld.exe+23268DF - call MonsterHunterWorld.exe+23269F0 + // to evaluate differences. + // Other TODOs for View Mode interop. + // - Don't colide with water. + // - Disable box around player collision. + // - View mode fade on close to player. + // - Weird LOD differences when in view mode. + startViewMode = new NativeAction(0x1405842E0); + stopViewMode = new NativeAction(0x1405825A0); + processViewMode = new NativeAction(0x140582820); + viewMode1 = new Patch((nint)0x141ADFAB9, [0x90, 0x90]); // Check input. + viewMode1.Enable(); + // rax = 0x73 -> 0x43 + //viewMode2 = new Patch((nint)0x1405843F8, [0x48, 0x8B, 0x43, 0x10, 0x90]); + //viewMode2.Enable(); + viewMode3 = new Patch((nint)0x1405844ED, [0x90, 0x90, 0x90, 0x90, 0x90]); // Screen flash related. + viewMode3.Enable(); + //viewMode2 = new Patch((nint)0x1405844CB, [0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90]); // Disables view mode from starting. + //viewMode2.Enable(); + // + //viewMode1 = new Patch((nint)0x140582578, [0xEB]); + ////viewMode1.Enable(); + //viewMode1_1 = new Patch((nint)0x140582F13, [0xEB]); + ////viewMode1_1.Enable(); + //viewMode2 = new Patch((nint)0x1405831A5, [0x90, 0x90, 0x90, 0x90]); + ////viewMode2.Enable(); + //viewMode3 = new Patch((nint)0x1405831A5 + 0xC, [0x90, 0x90, 0x90, 0x90, 0x90]); + ////viewMode3.Enable(); + //viewMode4 = new Patch((nint)0x1405831A5 + 0xC + 0x11, [0x90, 0x90, 0x90, 0x90, 0x90]); + ////viewMode4.Enable(); + psuedoViewModeObject = (nint)NativeMemory.AllocZeroed(240); + MemoryUtil.WriteBytes(psuedoViewModeObject, [0x28, 0x23, 0xFB, 0x42, 0x01, 0x00, 0x00, 0x00]); */ // Very special case for inside tent. @@ -836,14 +673,6 @@ namespace MHWNewCamera calculateViewHook = Hook.Create(addr, CalculateViewHook); */ - addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 10 48 89 74 24 18 48 89 7C 24 20 55 41 56 41 57 48 8B EC 48 83 EC 30 48 8B FA 48 8B D9 E8 AA B6 C1 FF 48 8B 47 10 48 8D 57 50")); -#if ADDR_ASSERTS - Trace.Assert(addr == 0x141AB2260); // nint, nint -#endif - shadowCascadeHook = Hook.Create(addr, ShadowCascadeHook); - - rendererSetHook = Hook.Create(0x141ABDED0, RendererSetHook); // nint, nint, nint - addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 08 57 44 8B 9A 60 01 00 00 48 8B DA 41 0F BF 40 08 4D 8B D0 89 82 80 01 00 00 BF 00 10 00 00 41 0F BF 40 0A 89 82 84 01 00 00 41 0F BF 40 0C 89 82 78 01 00 00 41 0F BF 40 0E 89 82 7C 01 00 00")); #if ADDR_ASSERTS Trace.Assert(addr == 0x1422A1280); // nint, nint, nint @@ -859,260 +688,94 @@ namespace MHWNewCamera collisionCheckHook = Hook.Create(0x1411C4E50, CollisionCheckHook); // nint, nint - motionBlurHook = Hook.Create(0x1424CADF0, MotionBlurHook); // nint, nint - - dofHook = Hook.Create(0x1412BA6A0, DofHook); // nint - cameraEffectHook = Hook.Create(0x141AB6AE0, CameraEffectHook); // nint, nint, nint - unchecked - { - addr = PatternScanner.FindFirst(Pattern.FromString("84 C0 0F 84 ?? ?? ?? ?? 48 8B 57 28 45 33 C0 48 8B CE E8 ?? ?? ?? ?? 48 8B 97 E0 01 00 00 41 B0 01 48 8B CE E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B D8")); -#if ADDR_ASSERTS - Trace.Assert(addr == 0x141E55D9E); -#endif - swapMinimapFollowsCamera = new Patch(addr + 0x3, [0xE9]); // je -> jmp. - - addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 18 48 89 6C 24 20 57 48 83 EC 20 48 8B 59 68 48 8B FA 48 8B E9 48 85 DB 0F 84 ?? ?? ?? ?? 4C 89 74 24 38 4C 8B B3 80 00 00 00 4D 85 F6")); -#if ADDR_ASSERTS - Trace.Assert(addr == 0x14234DD60); -#endif - jmpOverUi = new Patch(addr + 0x1C, [0xE9, 0x65, 0x01, 0x00, 0x00, 0x90]); - - jmpOverDof = new Patch((nint)0x1424233C6, [0xEB]); // je -> jmp. - - addr = PatternScanner.FindFirst(Pattern.FromString("CC 48 89 5C 24 18 57 48 83 EC 30 48 89 74 24 48 48 8B D9 E8 ?? ?? ?? ?? 48 8B 8B B0 0D 00 00 8B 81 54 89 00 00 C1 E8 0D A8 01")); -#if ADDR_ASSERTS - Trace.Assert(addr == 0x1411A6A9F); -#endif - noopCharacterFade = new Patch(addr + 0x13, [0x90, 0x90, 0x90, 0x90, 0x90]); // call MonsterHunterWorld.exe+11A6D50. - if (disableCharacterFade && !disableMod) - { - noopCharacterFade.Enable(); - } - - addr = PatternScanner.FindFirst(Pattern.FromString("48 83 EC 28 F3 0F 10 0D ?? ?? ?? ?? 80 F9 04 75 2F 48 8B 0D ?? ?? ?? ?? E8 D3 8A E4 01 48 8B 0D ?? ?? ?? ?? 33 D2 E8 ?? ?? ?? ??")); -#if ADDR_ASSERTS - Trace.Assert(addr == 0x14043FF80); - Trace.Assert(MemoryUtil.Read(0x142E4FE5C) == 3.0f); -#endif - shadowRes1_3x = new Patch(addr + 0x8, [0xD0, 0xFE, 0xA0, 0x02]); // 3.0. - shadowRes1_1 = new Patch(addr + 0x65, [0x17]); // Always set "Value is not 1.0" flag. - shadowRes1_2 = new Patch(addr + 0x68, [0x59]); // movss -> mulss. - shadowRes1_3 = new Patch(addr + 0x77, [0x59]); // movss -> mulss. - - // shadowRes2/3 control the detail of the infrequently updated fallback shadows. - addr = PatternScanner.FindFirst(Pattern.FromString("83 FA FF 74 06 89 91 1C 55 00 00 8B 91 30 55 00 00 83 FA FF 7F 06 8B 91 1C 55 00 00 85 D2 74 4B 83 EA 01 74 3B 83 EA 01 74 2B 83 EA 01 74 1B 83 FA 01 74 0B C7 81 20 55 00 00 01 00 00 00 C3 C7 81 20 55 00 00 00 10 00 00")); -#if ADDR_ASSERTS - Trace.Assert(addr == 0x142287A50); -#endif - shadowRes2 = new Patch(addr + 0x3F, [ - 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, - 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, - 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, // High. - 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xC3, // Mid. - 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0xC3 // Low. - ]); - - addr = PatternScanner.FindFirst(Pattern.FromString("89 91 30 55 00 00 83 FA FF 7F 06 8B 91 1C 55 00 00 85 D2 74 4B 83 EA 01 74 3B 83 EA 01 74 2B 83 EA 01 74 1B 83 FA 01 74 0B C7 81 20 55 00 00 01 00 00 00 C3 C7 81 20 55 00 00 00 10 00 00")); -#if ADDR_ASSERTS - Trace.Assert(addr == 0x142287AD0); -#endif - shadowRes3 = new Patch(addr + 0x34, [ - 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, - 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, - 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0xC3, - 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0xC3, - 0xC7, 0x81, 0x20, 0x55, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0xC3 - ]); - - /* - addr = PatternScanner.FindFirst(Pattern.FromString("89 91 00 55 00 00 83 FA 05 77 41 48 63 C2 4C 8D 05 ?? ?? ?? ?? 41 8B 94 80 84 8B 28 02 49 03 D0 FF E2 B8 00 08 00 00")); -#if ADDR_ASSERTS - Trace.Assert(addr == 0x142288B00); -#endif - // This value controls the shadow map texture resolution. 16384x16384 is likely the limit for many drivers - // and any value higher would crash. Keeping this at the default value *should* work unless the game - // does something unpredictable. At 3x Shadow Resolution, the shadow map will be 8448x8448. - shadowRes4_Limit = new Patch(addr + 0x29, [ // N/64 = 255, fractional values closer to 256 not tested. - 0xB8, 0x40, 0x15, 0x00, 0x00, 0xEB, 0x21 // This case is used for Low, Medium and High in-game. - ]); - */ - if (tripleShadowRes && !disableMod) - { - tripleShadowResEnable(); - } - - // The game will crash when trying to switch to the FULL_RES path for SSR. It's likley because - // it tries to access resources (shader, buffer, texture, etc.) that are not loaded. - // Ex: MonsterHunterWorld.exe+228C4A7 - mov rdi,[rdi+00000120] # Attempted read. - // MonsterHunterWorld.exe+259329B - lea rcx,[rdi+00000120] # Zero. - // The code that zero's these addresses looks like a shell of where they would be loaded. So my assumption - // is that it's compiled out and that this method of increasing the SSR resolution will not work. - // Though, it may still be possible by finagling the parameters of the half res case. - /* - // Attempt to forcefully enable FULL_RES path for SSR. - ssrRes1 = new Patch((nint)0x14228894D, [0x0F, 0x85, 0xB9, 0xAA, 0x30, 0x00]); - ssrRes1_1 = new Patch((nint)0x14259340C, [0xC6, 0x81, 0x28, 0x02, 0x00, 0x00, 0x00, 0x90, 0x90, 0x90]); - ssrRes2 = new Patch((nint)0x14228897D, [0x0F, 0x85, 0x99, 0xAA, 0x30, 0x00]); - ssrRes2_1 = new Patch((nint)0x14259341C, [0xC6, 0x81, 0x30, 0x02, 0x00, 0x00, 0x00, 0x90, 0x90, 0x90]); - ssrRes3 = new Patch((nint)0x1422889AD, [0x0F, 0x85, 0x79, 0xAA, 0x30, 0x00]); - ssrRes3_1 = new Patch((nint)0x14259342C, [0xC6, 0x81, 0x2C, 0x02, 0x00, 0x00, 0x00, 0x90, 0x90, 0x90]); - ssrRes4 = new Patch((nint)0x14259268C, [0x41, 0xC7, 0x86, 0x28, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0xC7, 0x86, 0x2C, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0xC7, 0x86, 0x30, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x41, 0xC7, 0x86, 0x34, 0x02, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x41, 0xC7, 0x86, 0x38, 0x02, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3F, 0x41, 0xC6, 0x86, 0x3C, 0x02, 0x00, 0x00, 0x01]); - */ - // None of these work either. - /* - // Don't scale resolution by SSR Factor. - ssrRes10 = new Patch((nint)0x142592DEF, [0x90, 0x90, 0x90, 0x90]); - ssrRes11 = new Patch((nint)0x142592E00, [0x90, 0x90, 0x90, 0x90]); - - // Make SSR Factor 1.0. - ssrRes12 = new Patch((nint)0x1425926B8 + 0x7, [0x00, 0x00, 0x80, 0x3F]); - */ - /* Double width and height (3rd and 4th parameter). - initSSRHook = Hook.Create(0x1425924D5, InitSSRHook); // nint, nint, int, int - increaseSSRMipSize1 = new Patch((nint)0x142592EBA + 0x2, [0x2]); - increaseSSRMipSize2 = new Patch((nint)0x142592ED0 + 0x2, [0x2]); - */ - - // Gameplay. - addr = PatternScanner.FindFirst(Pattern.FromString("80 BB 34 EC 00 00 00 88 8B 31 EC 00 00 C6 83 30 EC 00 00 00 74 1C C6 83 34 EC 00 00 00 48 8B 0D 68 4B 4F 03 80 B9 58 02 00 00 00 75 05 E8 5A F5 01 00 48 8B CB E8 E2 05 00 00 83 BB DC EB 00 00 06 74 0A C7 83 DC EB 00 00 06 00 00 00")); -#if ADDR_ASSERTS - Trace.Assert(addr == 0x141B1A0B4); -#endif - defaultViewModeLODLimit = new Patch(addr + 0x40, [0x07, 0x74, 0x0A, 0xC7, 0x83, 0xDC, 0xEB, 0x00, 0x00, 0x07]); - - // In room. - addr = PatternScanner.FindFirst(Pattern.FromString("8B 9F CC 00 00 00 81 FB F9 01 00 00 74 0C 8B CB E8 95 3F 65 01 83 F8 05 75 11 48 8B 0D 61 C8 F6 04 BA 02 00 00 00 E8 DF 2D 8C 01 48 8B 0D A0 C7 F6 04 8B D3")); + addr = PatternScanner.FindFirst(Pattern.FromString("84 C0 0F 84 ?? ?? ?? ?? 48 8B 57 28 45 33 C0 48 8B CE E8 ?? ?? ?? ?? 48 8B 97 E0 01 00 00 41 B0 01 48 8B CE E8 ?? ?? ?? ?? 48 8B 0D ?? ?? ?? ?? E8 ?? ?? ?? ?? 48 8B D8")); #if ADDR_ASSERTS - Trace.Assert(addr == 0x140257AE6); + Trace.Assert(addr == 0x141E55D9E); #endif - defaultViewModeLODLimit_1 = new Patch(addr + 0x22, [0x07]); + forceMinimapFollowsCamera = new Patch(addr + 0x3, [0xE9]); // je -> jmp. - // Forging/Changing Equipment. - addr = PatternScanner.FindFirst(Pattern.FromString("BA 02 00 00 00 E8 6E C0 80 00 48 8B 74 24 38 48 8B 57 28 48 8D 4F 30 E8 4C 79 B4 FE 48 8B 0D 0D FF A6 03 BA 04 00 00 00 E8 8B 64 3C 00 48 8B 05 D4 01 A7 03 80 B8 FD 46 01 00 00")); + addr = PatternScanner.FindFirst(Pattern.FromString("48 89 5C 24 18 48 89 6C 24 20 57 48 83 EC 20 48 8B 59 68 48 8B FA 48 8B E9 48 85 DB 0F 84 ?? ?? ?? ?? 4C 89 74 24 38 4C 8B B3 80 00 00 00 4D 85 F6")); #if ADDR_ASSERTS - Trace.Assert(addr == 0x141754438); + Trace.Assert(addr == 0x14234DD60); #endif - defaultViewModeLODLimit_2 = new Patch(addr + 0x24, [0x07]); - if (disableLODLimits && !disableMod) - { - disableLODLimitsEnable(); - } + jmpOverUi = new Patch(addr + 0x1C, [0xE9, 0x65, 0x01, 0x00, 0x00, 0x90]); - addr = PatternScanner.FindFirst(Pattern.FromString("74 4D 33 C0 48 81 C1 00 02 00 00 F3 0F 10 11 0F 2F CA 72 0C FF C0 48 83 C1 04 83 F8 03 72 EC C3")); + addr = PatternScanner.FindFirst(Pattern.FromString("CC 48 89 5C 24 18 57 48 83 EC 30 48 89 74 24 48 48 8B D9 E8 ?? ?? ?? ?? 48 8B 8B B0 0D 00 00 8B 81 54 89 00 00 C1 E8 0D A8 01")); #if ADDR_ASSERTS - Trace.Assert(addr == 0x1426D89CA); + Trace.Assert(addr == 0x1411A6A9F); #endif - addressHigherValueForFoliageSway = new Patch(addr + 0x7, [0x04]); - if (largerFoliageSwayRange && !disableMod) - { - addressHigherValueForFoliageSway.Enable(); - } - - // Found using mFrameSkipNum annotation from MHW-DTI-Dumps. - zeroFrameSkip = new Patch((nint)0x142246948, [0x31, 0xC0, 0x90, 0x90, 0x90, 0x90]); - if (disableReducedRateAnimations && !disableMod) - { - zeroFrameSkip.Enable(); - } - - underwaterCamera1 = new Patch((nint)0x1412AD54D, [0x90, 0x90, 0x90, 0x90, 0x90, 0x90]); // Nop "Is diving" check. - underwaterCamera2 = new Patch((nint)0x1412AD571, [0xB1, 0x01, 0x28, 0xC1, 0x90, 0x90, 0x90]); // Make cl the inverse of al. - underwaterCamera3 = new Patch((nint)0x141FA5A7E, [0x90, 0x90]); // Nop check. - underwaterCamera4 = new Patch((nint)0x141FA5BA0, [0x40, 0x84, 0xF6, 0x90, 0x74]); // jae -> je. - underwaterCamera5 = new Patch((nint)0x141FA5A74, [0x0F, 0x57, 0xF6, 0x31, 0xD2, 0x48, 0x8D, 0x4D, 0x80, 0xE8, 0x9E, 0x41, 0x38, 0xFE, 0xC1, 0xE8, 0x14, 0x66, 0x25, 0xD8, 0x03, 0xFF, 0xC8, 0x66, 0x3D, 0x48, 0x00, 0x77]); - underwaterCheckHook = Hook.Create(0x1412AD500, UnderwaterCheckHook); // nint - - volumeSars1 = new Patch((nint)0x1424D0159, [0x90, 0x90]); - volumeSars2 = new Patch((nint)0x1424D01A0, [0x90, 0x90]); - volumeSars3 = new Patch((nint)0x1424D01C6, [0x90, 0x90]); - volumeSars4 = new Patch((nint)0x1424D0219, [0x90, 0x90]); - volumeSars5 = new Patch((nint)0x1424D0242, [0x90, 0x90]); - volumeSars6 = new Patch((nint)0x1424D029D, [0x90, 0x90]); - volumeSars7 = new Patch((nint)0x1424D02C6, [0x90, 0x90]); - volumeSars8 = new Patch((nint)0x1424D0321, [0x90, 0x90]); - volumeSars9 = new Patch((nint)0x1424D034A, [0x90, 0x90]); - if (disableVolumeDownsample && !disableMod) - { - volumeSars1.Enable(); - volumeSars2.Enable(); - volumeSars3.Enable(); - volumeSars4.Enable(); - volumeSars5.Enable(); - volumeSars6.Enable(); - volumeSars7.Enable(); - volumeSars8.Enable(); - volumeSars9.Enable(); - } - - value2ForVolumeQuality = new Patch((nint)0x142389652, [0xB8, 0x02, 0x00, 0x00, 0x00, 0x90]); - if (higherVolumeQuality && !disableMod) - { - value2ForVolumeQuality.Enable(); - } - - createLightingObject = Hook.Create(0x1424CE130, CreateLightingObjectHook); // nint - destroyLightingObject = Hook.Create(0x1424CE380, DestroyLightingObjectHook); // nint, nint - - createFXAAObject = Hook.Create(0x1423936E0, CreateFXAAObjectHook); // nint, int - destroyFXAAObject = Hook.Create(0x142393740, DestroyFXAAObjectHook); // nint, int + noopCharacterFade = new Patch(addr + 0x13, [0x90, 0x90, 0x90, 0x90, 0x90]); // call MonsterHunterWorld.exe+11A6D50. + if (disableCharacterFade && !disableMod) + { + noopCharacterFade.Enable(); + } - // Player + ECCC = How far underwater is the player. - jmpOverHotSpringsEval = new Patch((nint)0x1417C1B03, [0xEB]); + underwaterCamera1 = new Patch(new IntPtr(0x1412AD54D), [0x90, 0x90, 0x90, 0x90, 0x90, 0x90]); // Nop "Is diving" check. + underwaterCamera2 = new Patch(new IntPtr(0x1412AD571), [0xB1, 0x01, 0x28, 0xC1, 0x90, 0x90, 0x90]); // Make cl the inverse of al. + underwaterCamera3 = new Patch(new IntPtr(0x141FA5A7E), [0x90, 0x90]); // Nop check. + underwaterCamera4 = new Patch(new IntPtr(0x141FA5BA0), [0x40, 0x84, 0xF6, 0x90, 0x74]); // jae -> je. + underwaterCamera5 = new Patch(new IntPtr(0x141FA5A74), [0x0F, 0x57, 0xF6, 0x31, 0xD2, 0x48, 0x8D, 0x4D, 0x80, 0xE8, 0x9E, 0x41, 0x38, 0xFE, 0xC1, 0xE8, 0x14, 0x66, 0x25, 0xD8, 0x03, 0xFF, 0xC8, 0x66, 0x3D, 0x48, 0x00, 0x77]); + underwaterCheck = Hook.Create(0x1412AD500, UnderwaterCheckHook); // nint - jmpOverHotSpringsSteam = new Patch((nint)0x14203A494, [0xE9, 0x8D, 0x00, 0x00, 0x00, 0x90]); + // Player + ECCC = How far underwater is the player. + jmpOverHotSpringsEval = new Patch(new IntPtr(0x1417C1B03), [0xEB]); + jmpOverHotSpringsSteam = new Patch(new IntPtr(0x14203A494), [0xE9, 0x8D, 0x00, 0x00, 0x00, 0x90]); - refreshEntityParams = Hook.Create(0x141F605F0, RefreshEntityParamsHook); // nint, nint + refreshEntityParams = Hook.Create(0x141F605F0, RefreshEntityParamsHook); // nint, nint - noopCharacterWetnessUpdate = new Patch((nint)0x14203E893, [0x90, 0x90, 0x90, 0x90, 0x90]); + noopCharacterWetnessUpdate = new Patch(new IntPtr(0x14203E893), [0x90, 0x90, 0x90, 0x90, 0x90]); + jmpOverChangeEquipmentWetnessUpdate_1 = new Patch(new IntPtr(0x14203E310), [0xEB]); // je -> jmp. + jmpOverChangeEquipmentWetnessUpdate_2 = new Patch(new IntPtr(0x14203E397), [0xE9, 0xB9, 0x00, 0x00, 0x00, 0x90]); // je -> jmp. - // Noop collision checks. - addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 06 F3 0F 10 48 04 F3 0F 58 4E 04 F3 0F 11 4E 04 F3 0F 10 40 08 F3 0F 58 46 08 F3 0F 11 46 08 44 8B AF E0 0B 00 00")); + // Noop collision checks. + addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 06 F3 0F 10 48 04 F3 0F 58 4E 04 F3 0F 11 4E 04 F3 0F 10 40 08 F3 0F 58 46 08 F3 0F 11 46 08 44 8B AF E0 0B 00 00")); #if ADDR_ASSERTS - Trace.Assert(addr == 0x141C001B5); + Trace.Assert(addr == 0x141C001B5); #endif - disableXCollision = new Patch(addr, [0x90, 0x90, 0x90, 0x90]); + disableXCollision = new Patch(addr, [0x90, 0x90, 0x90, 0x90]); #if ADDR_ASSERTS - Trace.Assert(addr + 0xE == 0x141C001C3); + Trace.Assert(addr + 0xE == 0x141C001C3); #endif - disableYCollision = new Patch(addr + 0xE, [0x90, 0x90, 0x90, 0x90, 0x90]); + disableYCollision = new Patch(addr + 0xE, [0x90, 0x90, 0x90, 0x90, 0x90]); #if ADDR_ASSERTS - Trace.Assert(addr + 0x1D == 0x141C001D2); + Trace.Assert(addr + 0x1D == 0x141C001D2); #endif - disableZCollision = new Patch(addr + 0x1D, [0x90, 0x90, 0x90, 0x90, 0x90]); + disableZCollision = new Patch(addr + 0x1D, [0x90, 0x90, 0x90, 0x90, 0x90]); - addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 46 04 F3 0F 10 46 08 F3 0F 5C C2 F3 0F 11 46 08 ?? ?? F3 0F")); + addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 46 04 F3 0F 10 46 08 F3 0F 5C C2 F3 0F 11 46 08 ?? ?? F3 0F")); #if ADDR_ASSERTS - Trace.Assert(addr == 0x141C000D2); + Trace.Assert(addr == 0x141C000D2); #endif - disableSecondaryYCollision = new Patch(addr, [0x90, 0x90, 0x90, 0x90, 0x90]); + disableSecondaryYCollision = new Patch(addr, [0x90, 0x90, 0x90, 0x90, 0x90]); - addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 46 04 F3 0F 10 58 08 F3 0F 58 5E 08 F3 0F 11 5E 08 44 8B 87 D0 0B 00 00 41 F6 C0 03")); + addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 46 04 F3 0F 10 58 08 F3 0F 58 5E 08 F3 0F 11 5E 08 44 8B 87 D0 0B 00 00 41 F6 C0 03")); #if ADDR_ASSERTS - Trace.Assert(addr == 0x141BFFF90); + Trace.Assert(addr == 0x141BFFF90); #endif - disableExtraYCollision = new Patch(addr, [0x90, 0x90, 0x90, 0x90, 0x90]); + disableExtraYCollision = new Patch(addr, [0x90, 0x90, 0x90, 0x90, 0x90]); - addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 83 80 00 00 00 F3 0F 11 8B 84 00 00 00 F3 0F 11 93 88 00 00 00 89 B3 8C 00 00 00 8B 83 A4 01 00 00 C1 E8 05 44 0F 29 A4 24 D0 01 00 00 44 0F 29 B4 24 B0 01 00 00 A8 01")); + addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 83 80 00 00 00 F3 0F 11 8B 84 00 00 00 F3 0F 11 93 88 00 00 00 89 B3 8C 00 00 00 8B 83 A4 01 00 00 C1 E8 05 44 0F 29 A4 24 D0 01 00 00 44 0F 29 B4 24 B0 01 00 00 A8 01")); #if ADDR_ASSERTS - Trace.Assert(addr + 0x8 == 0x1413259ED); + Trace.Assert(addr + 0x8 == 0x1413259ED); #endif - disableGravityYUpdate = new Patch(addr + 0x8, [ + disableGravityYUpdate = new Patch(addr + 0x8, [ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, - ]); - disableGravityXZUpdate = new Patch(addr, [ + ]); + disableGravityXZUpdate = new Patch(addr, [ 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, // Will already be applied. 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 - ]); + ]); - addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 97 54 15 00 00 F3 0F 11 8F 58 15 00 00 F3 0F 10 47 68 F3 0F 5E D8 44 89 B7 6C 15 00 00 F3 0F 5E D0 F3 0F 5E C8 F3 0F 11 9F 60 15 00 00 F3 0F 11 97 64 15 00 00 F3 0F 11 8F 68 15 00 00")); + addr = PatternScanner.FindFirst(Pattern.FromString("F3 0F 11 97 54 15 00 00 F3 0F 11 8F 58 15 00 00 F3 0F 10 47 68 F3 0F 5E D8 44 89 B7 6C 15 00 00 F3 0F 5E D0 F3 0F 5E C8 F3 0F 11 9F 60 15 00 00 F3 0F 11 97 64 15 00 00 F3 0F 11 8F 68 15 00 00")); #if ADDR_ASSERTS - Trace.Assert(addr + 0x40 == 0x141BFFF75); + Trace.Assert(addr + 0x40 == 0x141BFFF75); #endif - disableGravityEval = new Patch(addr + 0x40, [0x90, 0x90, 0x90, 0x90, 0x90]); // call MonsterHunterWorld.exe+1325810. - } + disableGravityEval = new Patch(addr + 0x40, [0x90, 0x90, 0x90, 0x90, 0x90]); // call MonsterHunterWorld.exe+1325810. + + return data; } private bool getDisableFadingObjects(int viewportIndex) @@ -1127,6 +790,9 @@ namespace MHWNewCamera MemoryUtil.WriteBytes(vp.Instance + 0x21, disable ? [0x0] : [0x1]); } + // @TODO: + // - Doesn't apply right when switching presets. + // - Don't touch while in freecam and switching preset. private void setDisableCharacterFade(bool disable) { if (disable && !disableCharacterFade) @@ -1141,58 +807,6 @@ namespace MHWNewCamera } } - private bool areLODFactorsDefault() - { - return foliageLODBias == 3.0f && terrainLODBias == 3.0f && - foliageLODFactor == 1.0f && terrainLODFactor == 1.0f && - snowField4GlobalLODParam == 8.0f; - } - - private bool areLODFactorsSet() - { - nint baseAddr = MemoryUtil.Read(0x1451C4368); - float foliageLOD1 = MemoryUtil.Read(baseAddr + 0x21C); - float terrainLOD1 = MemoryUtil.Read(baseAddr + 0x220); - float foliageLOD2 = MemoryUtil.Read(baseAddr + 0x224); - float terrainLOD2 = MemoryUtil.Read(baseAddr + 0x228); - float snowLOD1 = MemoryUtil.Read(baseAddr + 0x5718); - return foliageLOD1 == foliageLODBias && terrainLOD1 == terrainLODBias && - foliageLOD2 == foliageLODFactor && terrainLOD2 == terrainLODFactor && - snowLOD1 == snowField4GlobalLODParam; - } - - private void setLODFactors(bool toggleOn) - { - nint baseAddr = MemoryUtil.Read(0x1451C4368); - if (toggleOn) - { - // Assume in-game setting is "High". - if (prevFoliageLODBias <= 0.0f) - { - prevFoliageLODBias = MemoryUtil.Read(baseAddr + 0x21C); - if (prevFoliageLODBias > 3.0f) prevFoliageLODBias = 3.0f; - } - MemoryUtil.WriteBytes(baseAddr + 0x21C, BitConverter.GetBytes(foliageLODBias)); - if (prevTerrainLODBias <= 0.0f) - { - prevTerrainLODBias = MemoryUtil.Read(baseAddr + 0x220); - if (prevTerrainLODBias > 3.0f) prevTerrainLODBias = 3.0f; - } - MemoryUtil.WriteBytes(baseAddr + 0x220, BitConverter.GetBytes(terrainLODBias)); - MemoryUtil.WriteBytes(baseAddr + 0x224, BitConverter.GetBytes(foliageLODFactor)); - MemoryUtil.WriteBytes(baseAddr + 0x228, BitConverter.GetBytes(terrainLODFactor)); - MemoryUtil.WriteBytes(baseAddr + 0x5718, BitConverter.GetBytes(snowField4GlobalLODParam)); - } - else - { - MemoryUtil.WriteBytes(baseAddr + 0x21C, BitConverter.GetBytes(prevFoliageLODBias)); - MemoryUtil.WriteBytes(baseAddr + 0x220, BitConverter.GetBytes(prevTerrainLODBias)); - MemoryUtil.WriteBytes(baseAddr + 0x224, BitConverter.GetBytes(1.0f)); - MemoryUtil.WriteBytes(baseAddr + 0x228, BitConverter.GetBytes(1.0f)); - MemoryUtil.WriteBytes(baseAddr + 0x5718, BitConverter.GetBytes(internalSnowField4GlobalLODParam)); - } - } - private void setPerspectivePreset(Config.Preset preset) { cameraFov = preset.FieldOfView; @@ -1219,22 +833,29 @@ namespace MHWNewCamera public void OnLoad() { - Config config = ConfigManager.GetConfig(this); + Config config = loadConfig(); if (config.Selected != "") { setPerspectivePreset(config.Presets[config.Selected]); } - Config.GraphicalTweaks graphics = config.Graphics; - foliageLODBias = graphics.FoliageLODBias; - terrainLODBias = graphics.TerrainLODBias; - foliageLODFactor = graphics.FoliageLODFactor; - terrainLODFactor = graphics.TerrainLODFactor; - snowField4GlobalLODParam = graphics.SnowLODBias; - applyLODFactors = graphics.ApplyLODFactors; - if (applyLODFactors) + tuningTool = IPlugin.GetInstance("World Tuning Tool"); + } + + private Player? getPlayerFromSaveSlot(int index) + { + nint offset = (Player.SingletonInstance.Instance + 0x40) + (0x740 * index); + nint playerAddr = MemoryUtil.Read(offset); + if (playerAddr != 0x1433FE588) + { + return null; + } + offset += 0x18; + playerAddr = MemoryUtil.Read(offset); + if (playerAddr == 0x0) { - setLODFactors(true); + return null; } + return new Player(playerAddr); } private void resetStatePerFrame() @@ -1286,15 +907,6 @@ namespace MHWNewCamera } if (Input.IsPressed(Key.NumPadSlash)) { - dofDisabled = !dofDisabled; - if (dofDisabled) - { - jmpOverDof.Enable(); - } - else - { - jmpOverDof.Disable(); - } } } #endif @@ -1342,6 +954,10 @@ namespace MHWNewCamera if (hideWeapon) { Player? player = Player.MainPlayer; + if (player == null && saveSlotFallback) + { + player = getPlayerFromSaveSlot(saveSlotIndex); + } if (player != null) { nint baseAddr = MemoryUtil.Read(player.Instance + 0x76B0); @@ -1371,11 +987,6 @@ namespace MHWNewCamera return q * Quaternion.CreateFromYawPitchRoll(MathF.PI, 0.0f, 0.0f); } - private static Quaternion getReverse(Quaternion q) - { - return q * Quaternion.CreateFromYawPitchRoll(MathF.PI, 0.0f, 0.0f); - } - private void setCameraRoll(Camera camera) { // Don't test our luck with precision weirdness if we know we can be exact. @@ -1483,7 +1094,7 @@ namespace MHWNewCamera cameraFov = camera.FieldOfView; setDisableFadingObjects(viewportIndex, true); setDisableCharacterFade(true); - swapMinimapFollowsCamera.Enable(); + forceMinimapFollowsCamera.Enable(); /* //MemoryUtil.WriteBytes(psuedoViewModeObject + 0x10, BitConverter.GetBytes(vCamera.Instance)); Player? player = Player.MainPlayer; @@ -1521,7 +1132,7 @@ namespace MHWNewCamera setTentBasePos(new Vector3(0.0f, -19850.0f, 270.0f), new Vector3(0.0f, -19830.0f, 0.0f)); setDisableFadingObjects(vCameraViewportIndex, (vCameraViewportIndex == pCameraViewportIndex) ? disableFading : false); setDisableCharacterFade(disableFading); - swapMinimapFollowsCamera.Disable(); + forceMinimapFollowsCamera.Disable(); //stopViewMode.Invoke(psuedoViewModeObject); } @@ -1959,7 +1570,7 @@ namespace MHWNewCamera } #if HOOK_ORDER_ASSERTS - debugLog($"SetCameraHook({cameraPointer:x}) @ {frameTick}"); + debugLog($"SetCameraHook({cameraPointer:X}) @ {frameTick}"); Trace.Assert(hookOrder == 0); hookOrder = 1; #endif @@ -2008,7 +1619,7 @@ namespace MHWNewCamera } #if HOOK_ORDER_ASSERTS - debugLog($"CalculateCameraHook({cameraPointer:x}) @ {frameTick}"); + debugLog($"CalculateCameraHook({cameraPointer:X}) @ {frameTick}"); Trace.Assert(hookOrder == 2); hookOrder = 3; #endif @@ -2090,7 +1701,7 @@ namespace MHWNewCamera } #if HOOK_ORDER_ASSERTS - debugLog($"CheckCameraHook({cameraPointer:x}) @ {frameTick}"); + debugLog($"CheckCameraHook({cameraPointer:X}) @ {frameTick}"); Trace.Assert(hookOrder == 1); hookOrder = 2; #endif @@ -2127,7 +1738,7 @@ namespace MHWNewCamera } #if HOOK_ORDER_ASSERTS - debugLog($"StartViewMode({viewModeObject:x}) @ {frameTick}"); + debugLog($"StartViewMode({viewModeObject:X}) @ {frameTick}"); #endif if (vCamera != null) @@ -2147,7 +1758,7 @@ namespace MHWNewCamera #if HOOK_ORDER_ASSERTS // The order of this hook between SetCameraHook() and CalculateCameraHook() is inconsistent. - debugLog($"SetCameraTentHook({unknownPtr:x}) @ {frameTick}"); + debugLog($"SetCameraTentHook({unknownPtr:X}) @ {frameTick}"); #endif if (freeCamera && vCamera != null) @@ -2177,7 +1788,7 @@ namespace MHWNewCamera } #if HOOK_ORDER_ASSERTS - debugLog($"SetCameraCutsceneHook({unknownPtr:x}) @ {frameTick}"); + debugLog($"SetCameraCutsceneHook({unknownPtr:X}) @ {frameTick}"); #endif setCameraCutsceneHook!.Original(unknownPtr); @@ -2211,195 +1822,6 @@ namespace MHWNewCamera } */ - private void ShadowCascadeHook(nint unknownPtr, nint unknownPtr2) - { - if (disableMod) - { - shadowCascadeHook!.Original(unknownPtr, unknownPtr2); - return; - } - -#if HOOK_ORDER_ASSERTS - debugLog($"ShadowCascadeHook({unknownPtr:x}, {unknownPtr2:x}) @ {frameTick}"); -#endif - - ref nint rax = ref MemoryUtil.GetRef(unknownPtr2 + 0x170); - nint shadowCascadeValue = rax >> 32; - if (shadowCascadeValue != 3) - { - lastShadowCascadeValue = shadowCascadeValue; - lastShadowBias = MemoryUtil.Read(unknownPtr2 + 0x17C); - lastShadowRadius = MemoryUtil.Read(unknownPtr2 + 0x1EC); - } - - float biasOverride = lastShadowBias + shadowBiasOffset; - if (lowShadowDetailOverride && shadowCascadeValue == 1) - { - shadowCascadeValue++; - rax = (nint)((shadowCascadeValue << 32) | (rax & 0x00000000FFFFFFFF)); - biasOverride += shadowBiasOffset; - } - - if (shadowCascadeValue != 3) - { - if (applyShadowBias) - { - // If HQ Mode is enabled, this value will be maxss'd with the HQ value before use. - MemoryUtil.GetRef(unknownPtr2 + 0x17C) = biasOverride; - } - if (applyShadowRadius) - { - MemoryUtil.GetRef(unknownPtr2 + 0x1EC) = lastShadowRadius + shadowRadiusOffset; - } - } - - if (applyLODFactors) - { - // @TODO: Find a more proper place where we can update snow parameters. - nint baseAddr = MemoryUtil.Read(0x1451C4368); - MemoryUtil.GetRef(baseAddr + 0x5718) = snowField4GlobalLODParam; - } - - shadowCascadeHook!.Original(unknownPtr, unknownPtr2); - - if (shadowCascadeValue != 3) - { - lastShadowDistance = MemoryUtil.GetRef(unknownPtr + 0x6C); - lastShadowDistribution = MemoryUtil.GetRef(unknownPtr + 0x74); - lastShadowBackforwardDistance = MemoryUtil.GetRef(unknownPtr + 0x7C); - //lastBroadAreaShadowRange = MemoryUtil.GetRef(unknownPtr + 0x1B0); - //lastShadowFov = MemoryUtil.GetRef(unknownPtr + 0x1F4); - - /* - if (Area.CurrentStage == Stage.Astera) - { - // @TODO: Account for moving values. - } - */ - - if (applyShadowAdjust) - { - MemoryUtil.GetRef(unknownPtr + 0x6C) = shadowDistance; - MemoryUtil.GetRef(unknownPtr + 0x74) = shadowDistribution; - MemoryUtil.GetRef(unknownPtr + 0x7C) = shadowBackforwardDistance; - //MemoryUtil.GetRef(unknownPtr + 0x1B0) = broadAreaShadowRange; - //MemoryUtil.GetRef(unknownPtr + 0x1F4) = shadowFov; - } - } - } - - private void setSSAOAdjustements(bool enable, bool b) - { - nint baseAddr = MemoryUtil.Read(0x1451C4368); - if (enable) - { - MemoryUtil.WriteBytes(baseAddr + 0xB4BC, BitConverter.GetBytes(1.75f)); - MemoryUtil.WriteBytes(baseAddr + 0xB4D0, BitConverter.GetBytes(16)); - if (b) - { - MemoryUtil.WriteBytes(baseAddr + 0xB430, BitConverter.GetBytes(0.0f)); - MemoryUtil.WriteBytes(baseAddr + 0xB434, BitConverter.GetBytes(0.0f)); - MemoryUtil.WriteBytes(baseAddr + 0xB4E0, BitConverter.GetBytes(0.0f)); - } - else - { - MemoryUtil.WriteBytes(baseAddr + 0xB430, BitConverter.GetBytes(internalSSAOParams.effect)); - MemoryUtil.WriteBytes(baseAddr + 0xB434, BitConverter.GetBytes(internalSSAOParams.effectGI)); - MemoryUtil.WriteBytes(baseAddr + 0xB4E0, BitConverter.GetBytes(internalSSAOParams.intensity)); - } - } - else - { - MemoryUtil.WriteBytes(baseAddr + 0xB4BC, BitConverter.GetBytes(internalSSAOParams.dispersion)); - MemoryUtil.WriteBytes(baseAddr + 0xB430, BitConverter.GetBytes(internalSSAOParams.effect)); - MemoryUtil.WriteBytes(baseAddr + 0xB434, BitConverter.GetBytes(internalSSAOParams.effectGI)); - MemoryUtil.WriteBytes(baseAddr + 0xB4D0, BitConverter.GetBytes(internalSSAOParams.maxSampleNumHQ)); - MemoryUtil.WriteBytes(baseAddr + 0xB4E0, BitConverter.GetBytes(internalSSAOParams.intensity)); - } - } - - private void setSSRAdjustements(bool enable) - { - nint baseAddr = MemoryUtil.Read(0x1451C4368); - if (enable) - { - MemoryUtil.WriteBytes(baseAddr + 0xE644, BitConverter.GetBytes(0.2f)); - MemoryUtil.WriteBytes(baseAddr + 0xE64C, BitConverter.GetBytes(0.2f)); - } - else - { - MemoryUtil.WriteBytes(baseAddr + 0xE644, BitConverter.GetBytes(internalSSRParams.accurateThreshold)); - MemoryUtil.WriteBytes(baseAddr + 0xE64C, BitConverter.GetBytes(internalSSRParams.accurateThresholdHQ)); - } - } - - private void setHQMode(bool enable) - { - nint baseAddr = MemoryUtil.Read(0x1451C4368); - MemoryUtil.WriteBytes(baseAddr + 0xE9A3, enable ? [0x1] : [0x0]); - } - - private void RendererSetHook(nint unknownPtr, nint unknownPtr2, nint unknownPtr3) - { - if (disableMod) - { - rendererSetHook!.Original(unknownPtr, unknownPtr2, unknownPtr3); - return; - } - bool doSet = MemoryUtil.Read(unknownPtr + 0x530) == 0x0; - rendererSetHook!.Original(unknownPtr, unknownPtr2, unknownPtr3); - nint baseAddr = MemoryUtil.Read(0x1451C4368); - internalShadowSampleNumHQ = MemoryUtil.Read(baseAddr + 0xE5CC); - MemoryUtil.WriteBytes(baseAddr + 0xE5CC, BitConverter.GetBytes(16)); - internalSSAOParams.depthBias = MemoryUtil.Read(baseAddr + 0xB4B0); - internalSSAOParams.slopedDepthBias = MemoryUtil.Read(baseAddr + 0xB4B4); - internalSSAOParams.maxDepthBias = MemoryUtil.Read(baseAddr + 0xB4B8); - internalSSAOParams.dispersion = MemoryUtil.Read(baseAddr + 0xB4BC); - internalSSAOParams.effect = MemoryUtil.Read(baseAddr + 0xB430); - internalSSAOParams.effectGI = MemoryUtil.Read(baseAddr + 0xB434); - internalSSAOParams.depthDifference = MemoryUtil.Read(baseAddr + 0xB4C0); - internalSSAOParams.samplesPerPixel = MemoryUtil.Read(baseAddr + 0xB4C4); - internalSSAOParams.maxSampleNum = MemoryUtil.Read(baseAddr + 0xB4C8); - internalSSAOParams.maxSampleNumHQ = MemoryUtil.Read(baseAddr + 0xB4D0); - internalSSAOParams.radius = MemoryUtil.Read(baseAddr + 0xB4D4); - internalSSAOParams.bias = MemoryUtil.Read(baseAddr + 0xB4D8); - internalSSAOParams.intensity = MemoryUtil.Read(baseAddr + 0xB4E0); - internalSSAOParams.useHiZ = MemoryUtil.Read(baseAddr + 0xB4E5) == 0x1; - internalSSAOParams.edgeAttenRate = MemoryUtil.Read(baseAddr + 0xB4DC); - internalSSRParams.loopCount = MemoryUtil.Read(baseAddr + 0xE628); - internalSSRParams.loopCountFactorForCBR = MemoryUtil.Read(baseAddr + 0xE62C); - internalSSRParams.eliminateDepth = MemoryUtil.Read(baseAddr + 0xE630); - internalSSRParams.accurateThreshold = MemoryUtil.Read(baseAddr + 0xE644); - internalSSRParams.accurateThresholdHQ = MemoryUtil.Read(baseAddr + 0xE64C); - internalSSRParams.ditherRadius = MemoryUtil.Read(baseAddr + 0xE634); - internalSSRParams.importanceBias = MemoryUtil.Read(baseAddr + 0xE638); - internalSSRParams.mipScale = MemoryUtil.Read(baseAddr + 0xE63C); - internalSSRParams.mipBias = MemoryUtil.Read(baseAddr + 0xE640); - internalSSRParams.ditherResolve = MemoryUtil.Read(baseAddr + 0xB43F) == 0x1; - internalSSRParams.edgeAttenRate = MemoryUtil.Read(baseAddr + 0xB428); - internalSSRParams.mip0CountThreshold = MemoryUtil.Read(baseAddr + 0xB438); - internalSSRParams.depthEliminateRate = MemoryUtil.Read(baseAddr + 0xB42C); - internalSSRParams.useMipmap = MemoryUtil.Read(baseAddr + 0xE650) == 0x1; - internalSSRParams.gBufferJitter = MemoryUtil.Read(baseAddr + 0xB440) == 0x1; - internalSnowField4GlobalLODParam = MemoryUtil.Read(baseAddr + 0x5718); - if (doSet) - { - if (ssaoAdjustments) - { - setSSAOAdjustements(true, ssaoB); - } - if (ssrAdjustments) - { - setSSRAdjustements(true); - } - setHQMode(enableHQMode); - if (applyLODFactors) - { - setLODFactors(true); - } - } - } - private bool playerInMenu() { // https://github.com/HunterPie/HunterPie/blob/fa73f81ed0cdc921a6cf63f96c0fcff3688d88c2/HunterPie.Integrations/Datasources/MonsterHunterWorld/Entity/Game/MHWGame.cs#L74 @@ -2432,7 +1854,7 @@ namespace MHWNewCamera } #if HOOK_ORDER_ASSERTS - debugLog($"WritePadInputHook({unknownPtr:x}, {unknownPtr2:x}, {unknownPtr3:x}) @ {frameTick}"); + debugLog($"WritePadInputHook({unknownPtr:X}, {unknownPtr2:X}, {unknownPtr3:X}) @ {frameTick}"); #endif Button b1 = 0u, b2 = 0u; @@ -2581,34 +2003,6 @@ namespace MHWNewCamera bool blockInput = comboButton1Down || (enableFreeCamera && !unlockInputToggled); - /* - if (enableFreeCamera) - { - // Hold both buttons and release either. We have to block until - // release or it will get annoying to toggle input while on a menu. - if (buttonWasDown(Button.R2)) - { - if (buttonWasReleased(Button.R1)) - { - unlockInputToggled = !unlockInputToggled; - inputBlockedForToggle = false; - blockInput = true; - } - else if (buttonWasDown(Button.R1)) - { - inputBlockedForToggle = true; - blockInput = true; - } - } - else if (buttonWasReleased(Button.R2) && inputBlockedForToggle) - { - unlockInputToggled = !unlockInputToggled; - inputBlockedForToggle = false; - blockInput = true; - } - } - */ - if (blockInput) { if (!readInputsPostHook) @@ -2742,27 +2136,18 @@ namespace MHWNewCamera { if (buttonWasPressed(Button.Cross)) { - ssaoB = !ssaoB; - if (ssaoAdjustments) - { - setSSAOAdjustements(ssaoAdjustments, ssaoB); - } } - if (buttonWasPressed(Button.Circle)) { - dofParams.nearEnable = !dofParams.nearEnable; - /* - dofDisabled = !dofDisabled; - if (dofDisabled) + if (disableDofOverride != 0) { - jmpOverDof.Enable(); + tuningTool.RemoveOverride(disableDofOverride); + disableDofOverride = 0; } else { - jmpOverDof.Disable(); + disableDofOverride = tuningTool.AddOverride("Near Enable", new Vector4(), 0); } - */ } } else if (freeCameraFromViewMode && !unlockInputForMenu && buttonWasPressed(Button.Circle)) @@ -2818,7 +2203,7 @@ namespace MHWNewCamera } #if HOOK_ORDER_ASSERTS - debugLog($"CheckMovementHook({stickValue:x}, {alwaysZero}) @ {frameTick}"); + debugLog($"CheckMovementHook({stickValue:X}, {alwaysZero}) @ {frameTick}"); #endif if (freeCamera) @@ -2849,7 +2234,7 @@ namespace MHWNewCamera } #if HOOK_ORDER_ASSERTS - debugLog($"CollisionCheckHook({unknownPtr:x}, {unknownPtr2:x}) @ {frameTick}"); + debugLog($"CollisionCheckHook({unknownPtr:X}, {unknownPtr2:X}) @ {frameTick}"); #endif Player? player = Player.MainPlayer; @@ -2878,6 +2263,16 @@ namespace MHWNewCamera #if QUARANTINED_FEATURES private void SetZoneStateHook(nint player, int flags) { + if (disableMod) + { + setZoneStateHook!.Original(player, flags); + return; + } + +#if HOOK_ORDER_ASSERTS + debugLog($"SetZoneStateHook({player:X}, {flags:X}) @ {frameTick}"); +#endif + nint zoneStateAddr = MemoryUtil.Read(0x1451C42B8); ref byte zoneState = ref MemoryUtil.GetRef(zoneStateAddr + 0xD2EA); if (!zoneStateManualInvoke) @@ -2888,16 +2283,18 @@ namespace MHWNewCamera { zoneStateManualInvoke = false; } - ZoneState overrideZoneState = forceZoneState; - if (overrideZoneState == ZoneState.Unknown) - { - overrideZoneState = lastZoneState; - } + + ZoneState overrideZoneState = (forceZoneState == ZoneState.Unknown) ? lastZoneState : forceZoneState; if (overrideZoneState != ZoneState.Unknown) { - zoneState = byteFlag(overrideZoneState == ZoneState.Hub); + zoneState = ByteFlag(overrideZoneState == ZoneState.Hub); } + + Wetness wet = readCharacterWetness(player); + setZoneStateHook!.Original(player, flags); + + writeCharacterWetness(player, wet); } #endif @@ -2905,13 +2302,14 @@ namespace MHWNewCamera { refreshEntityParams!.Original(entity, unknownPtr2); - if (disableMod || playerOpacityOverride == 1.0f) + if (disableMod) { return; } Player? player = Player.MainPlayer; - if (player != null && entity == player.Instance) + bool entityIsPlayer = player != null && entity == player.Instance; + if (entityIsPlayer && playerOpacityOverride != 1.0f) { MemoryUtil.GetRef(player.Instance + 0x78E0) = playerOpacityOverride; } @@ -2922,135 +2320,27 @@ namespace MHWNewCamera freezeGame = !freezeGame; if (freezeGame) { - motionBlurWasDisabled = motionBlurDisabled; - motionBlurDisabled = true; decoupleDtFromGameTime = true; + if (forceOffMotionBlurOverride == 0) + { + forceOffMotionBlurOverride = tuningTool.AddOverride("Shutter Speed", new Vector4(0.0f), 0); + } } else { - motionBlurDisabled = motionBlurWasDisabled; decoupleDtFromGameTime = false; + if (forceOffMotionBlurOverride != 0) + { + tuningTool.RemoveOverride(forceOffMotionBlurOverride); + forceOffMotionBlurOverride = 0; + } } - MemoryUtil.WriteBytes(sMain.Instance + 0xA4, BitConverter.GetBytes(freezeGame ? 0.0f : 1.0f)); + MemoryUtil.GetRef(sMain.Instance + 0xA4) = freezeGame ? 0.0f : 1.0f; } - private void MotionBlurHook(nint unknownPtr, nint unknownPtr2) + private void UnderwaterCheckHook(nint unknownPtr) { - if (disableMod) - { - motionBlurHook!.Original(unknownPtr, unknownPtr2); - return; - } - -#if HOOK_ORDER_ASSERTS - debugLog($"MotionBlurHook({unknownPtr:x}, {unknownPtr2:x}) @ {frameTick}"); -#endif - - if (motionBlurDisabled) - { - MemoryUtil.WriteBytes(unknownPtr + 0x184, BitConverter.GetBytes(0.0f)); - } - - motionBlurHook!.Original(unknownPtr, unknownPtr2); - } - - private void DofHook(nint unknownPtr) - { - dofHook!.Original(unknownPtr); - - if (disableMod) - { - return; - } - -#if HOOK_ORDER_ASSERTS - debugLog($"DofHook({unknownPtr:x}) @ {frameTick}"); -#endif - - nint unknownObj = MemoryUtil.Read(unknownPtr + 0x230); - nint dofFilter = MemoryUtil.Read(unknownObj + 0x58); - if (dofFilter != 0x0) - { - ref byte dofEnabled = ref MemoryUtil.GetRef(dofFilter + 0x1DD); - ref byte newVersion = ref MemoryUtil.GetRef(dofFilter + 0x1DC); - ref float fNumber = ref MemoryUtil.GetRef(dofFilter + 0x1A0); - ref float sensorSize = ref MemoryUtil.GetRef(dofFilter + 0x1A4); - ref float focusDistance = ref MemoryUtil.GetRef(dofFilter + 0x1A8); - ref float nearCoef = ref MemoryUtil.GetRef(dofFilter + 0x1CC); - ref float farCoef = ref MemoryUtil.GetRef(dofFilter + 0x1C8); - ref byte nearEnable = ref MemoryUtil.GetRef(dofFilter + 0x1DE); - ref byte farEnable = ref MemoryUtil.GetRef(dofFilter + 0x1DF); - ref byte debugDraw = ref MemoryUtil.GetRef(dofFilter + 0x1E0); - ref float radius = ref MemoryUtil.GetRef(dofFilter + 0x1D0); - ref float depthScaleForeground = ref MemoryUtil.GetRef(dofFilter + 0x1D4); - ref float aspect = ref MemoryUtil.GetRef(dofFilter + 0x1D8); - ref byte vignettingEnabled = ref MemoryUtil.GetRef(dofFilter + 0x200); - ref byte vignettingEllipse = ref MemoryUtil.GetRef(dofFilter + 0x201); - ref float vignettingEllipticity = ref MemoryUtil.GetRef(dofFilter + 0x204); - ref float vignettingOffset = ref MemoryUtil.GetRef(dofFilter + 0x1F8); - ref float vignettingPow = ref MemoryUtil.GetRef(dofFilter + 0x1FC); - ref int vignettingColor = ref MemoryUtil.GetRef(dofFilter + 0x208); - if (fillOutDofParams) - { - dofParams.enabled = dofEnabled == 0x1; - dofParams.newVersion = newVersion == 0x1; - dofParams.fNumber = fNumber; - dofParams.sensorSize = sensorSize; - dofParams.focusDistance = focusDistance; - dofParams.nearCoef = nearCoef; - dofParams.farCoef = farCoef; - dofParams.nearEnable = nearEnable == 0x1; - dofParams.farEnable = farEnable == 0x1; - dofParams.debugDraw = debugDraw == 0x1; - dofParams.radius = radius; - dofParams.depthScaleForeground = depthScaleForeground; - dofParams.aspect = aspect; - fillOutDofParams = false; - } - if (fillOutVignettingParams) - { - dofParams.vignettingEnabled = vignettingEnabled == 0x1; - dofParams.vignettingEllipse = vignettingEllipse == 0x1; - dofParams.vignettingEllipticity = vignettingEllipticity; - dofParams.vignettingOffset = vignettingOffset; - dofParams.vignettingPow = vignettingPow; - dofParams.vignettingColor = vignettingColor; - fillOutVignettingParams = false; - } - /* - if ((dofEnabled == 0x0) != dofDisabled) - { - dofEnabled = byteFlag(!dofDisabled); - } - */ - dofEnabled = byteFlag(dofParams.enabled); - newVersion = byteFlag(dofParams.newVersion); - fNumber = dofParams.fNumber; - sensorSize = dofParams.sensorSize; - focusDistance = dofParams.focusDistance; - nearCoef = dofParams.nearCoef; - farCoef = dofParams.farCoef; - nearEnable = byteFlag(dofParams.nearEnable); - farEnable = byteFlag(dofParams.farEnable); - debugDraw = byteFlag(dofParams.debugDraw); - radius = dofParams.radius; - depthScaleForeground = dofParams.depthScaleForeground; - aspect = dofParams.aspect; - if (applyVignettingParams) - { - vignettingEnabled = byteFlag(dofParams.vignettingEnabled); - vignettingEllipse = byteFlag(dofParams.vignettingEllipse); - vignettingEllipticity = dofParams.vignettingEllipticity; - vignettingOffset = dofParams.vignettingOffset; - vignettingPow = dofParams.vignettingPow; - vignettingColor = dofParams.vignettingColor; - } - } - } - - private void UnderwaterCheckHook(nint unknownPtr) - { - underwaterCheckHook!.Original(unknownPtr); + underwaterCheck!.Original(unknownPtr); if (disableMod || !enableUnderwaterCamera) { @@ -3058,7 +2348,7 @@ namespace MHWNewCamera } #if HOOK_ORDER_ASSERTS - debugLog($"UnderwaterCheckHook({unknownPtr:x}) @ {frameTick}"); + debugLog($"UnderwaterCheckHook({unknownPtr:X}) @ {frameTick}"); #endif cameraIsUnderwater = MemoryUtil.Read(unknownPtr + 0x1E83) == 0x1; @@ -3073,7 +2363,7 @@ namespace MHWNewCamera } #if HOOK_ORDER_ASSERTS - debugLog($"CameraEffectHook({unknownPtr:x}, {unknownPtr2:x}, {unknownPtr3:x}) @ {frameTick}"); + debugLog($"CameraEffectHook({unknownPtr:X}, {unknownPtr2:X}, {unknownPtr3:X}) @ {frameTick}"); #endif byte[]? underwaterValues = null; @@ -3106,36 +2396,12 @@ namespace MHWNewCamera } } - private nint CreateLightingObjectHook(nint unknownPtr) - { - lightingObject = createLightingObject!.Original(unknownPtr); - return lightingObject; - } - - private nint DestroyLightingObjectHook(nint unknownPtr, nint unknownPtr2) - { - lightingObject = 0x0; - return destroyLightingObject!.Original(unknownPtr, unknownPtr2); - } - - private nint CreateFXAAObjectHook(nint unknownPtr, int unknownInt) - { - fxaaObject = createFXAAObject!.Original(unknownPtr, unknownInt); - return fxaaObject; - } - - private nint DestroyFXAAObjectHook(nint unknownPtr, int unknownInt) - { - fxaaObject = 0x0; - return destroyFXAAObject!.Original(unknownPtr, unknownInt); - } - private void drawViewportInfo(int i, float width, Config config, bool debug) { Viewport vp = CameraSystem.GetViewport(i); if (debug) { - ImGui.Text($"Address: {vp.Instance:x}"); + ImGui.Text($"Address: {vp.Instance:X}"); ImGui.Text($"Visible: {vp.Visible}"); ImGui.Text($"Region: {vp.Region.X} {vp.Region.Y} {vp.Region.Width} {vp.Region.Height}"); } @@ -3155,7 +2421,44 @@ namespace MHWNewCamera { Camera camera = vp.Camera; bool usedByFreeCamera = freeCamera && enableFreeCamera && camera == vCamera; - if (debug) ImGui.Text($"Camera Pointer: {camera.Instance:x}"); + if (debug) ImGui.Text($"Camera Pointer: {camera.Instance:X}"); + Player? player = checkPlayerChange(); + if (debug && player != null) + { + // MonsterHunterWorld.exe+12A9AEC - mov rcx,[rdi+00001E90] + // MonsterHunterWorld.exe+11A9AB9 - add rcx,00001410 + // MonsterHunterWorld.exe+12A9AE0 - mov rcx,[MonsterHunterWorld.exe+5013950] + nint playerCameraAddr = MemoryUtil.Read(player.Instance + 0x14F8); + playerCameraAddr = MemoryUtil.Read(playerCameraAddr + 0x1410 + 0x1E90); + nint baseSettingAddr = MemoryUtil.Read(0x145013950); + baseSettingAddr = calcOffsetSettingAddr.Invoke(baseSettingAddr); + ref byte settingB = ref MemoryUtil.GetRef(baseSettingAddr + 0x1403FD); + int settingI = settingB; + if (ImGui.RadioButton("Close", ref settingI, 0)) + { + settingB = (byte)settingI; + } + ImGui.SameLine(); + if (ImGui.RadioButton("Default", ref settingI, 1)) + { + settingB = (byte)settingI; + } + ImGui.SameLine(); + if (ImGui.RadioButton("Far", ref settingI, 2)) + { + settingB = (byte)settingI; + } + nint viewParamOffset = getViewParamOffset.Invoke(playerCameraAddr + 0x1380, 0, 0xC9); + if (viewParamOffset != 0x0) + { + ImGui.DragFloat3("Close", ref MemoryUtil.GetRef(viewParamOffset + 0x20), 0.1f); + } + viewParamOffset = getViewParamOffset.Invoke(playerCameraAddr + 0x1380, 0, 0xCA); + if (viewParamOffset != 0x0) + { + ImGui.DragFloat3("Far", ref MemoryUtil.GetRef(viewParamOffset + 0x20), 0.1f); + } + } if (ImGui.DragFloat("Field of View", ref camera.FieldOfView, 0.1f)) { if (usedByFreeCamera) @@ -3330,104 +2633,80 @@ namespace MHWNewCamera } } - private void drawAnimationInfo(Entity entity) + private void drawAnimationInfo(Entity entity, float width, bool debug) { - ActionInfo currentActionInfo = entity.ActionController.CurrentAction; + ActionController actionController = entity.ActionController; + ActionInfo currentActionInfo = actionController.CurrentAction; SharpPluginLoader.Core.Actions.Action? currentAction = null; if (currentActionInfo.ActionSet >= 0 && currentActionInfo.ActionSet <= 3) { - ActionList actionList = entity.ActionController.GetActionList(currentActionInfo.ActionSet); + ActionList actionList = actionController.GetActionList(currentActionInfo.ActionSet); if (currentActionInfo.ActionId >= 0 && currentActionInfo.ActionId < actionList.Count) { currentAction = actionList[currentActionInfo.ActionId]; } } - AnimationId currentAnimation = entity.CurrentAnimation; - ImGui.Text("Action/Animation:"); - ImGui.Text($"ActionController: {entity.ActionController.Instance:x}"); - ImGui.Text($" Current: {currentAction} {currentActionInfo}, {currentAnimation}"); - if (currentAction != null) + if (debug) { - ImGui.Text($" Active Time: {currentAction.ActiveTime}"); - ImGui.Text($" Delta Sec: {currentAction.DeltaSec}"); + ImGui.Text($"ActionController: {actionController.Instance:X}"); + ImGui.Text($" Current: {currentAction} {currentActionInfo}"); + if (currentAction != null) + { + + ImGui.Text($" Active Time: {currentAction.ActiveTime}"); + ImGui.Text($" Delta Sec: {currentAction.DeltaSec}"); + } } + AnimationId currentAnimation = entity.CurrentAnimation; AnimationLayerComponent? animationLayer = entity.AnimationLayer; if (animationLayer != null) { - ImGui.Text($"AnimationLayer: {animationLayer.Instance:x}"); - ImGui.Text($" Speed: {animationLayer.Speed:0.000}"); - ImGui.Text($" Frame: {animationLayer.CurrentFrame:0.000}/{animationLayer.MaxFrame:0.000}"); - } - } - - private static T drawRenderParameter(string name, nint baseAddr = 0x0, nint offset = 0x0, bool zeroToOne = false, float step = 0.0f) where T : unmanaged - { - nint addr = baseAddr + offset; - T? currentValue = null; - if (currentValue == null) - { - currentValue = MemoryUtil.Read(addr); - } - if (typeof(T) == typeof(float)) - { - float valueF = Convert.ToSingle(currentValue); - if (zeroToOne) + ImGui.Text(debug ? $"AnimationLayer: {animationLayer.Instance:X}" : "Animation:"); + ImGui.Text($" Current: {currentAnimation}"); + if (debug) { - if (ImGui.DragFloat(name, ref valueF, 0.01f, 0.0f, 1.0f, "%.6f")) - { - MemoryUtil.WriteBytes(addr, BitConverter.GetBytes(valueF)); - } + ImGui.Text($" Frame: {animationLayer.CurrentFrame:0.000}/{animationLayer.MaxFrame:0.000}"); + return; } else { - if (ImGui.InputFloat(name, ref valueF, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags.EnterReturnsTrue)) + ImGui.SliderFloat("Frame", ref animationLayer.CurrentFrame, 0.0f, animationLayer.MaxFrame, "%.3f"); + } + ImGui.PushItemWidth(width * 0.35f); + bool animationPaused = animationLayer.Paused; + if (ImGui.Checkbox("Paused", ref animationPaused)) + { + animationLayer.Paused = animationPaused; + } + ImGui.SameLine(); + float? lockedSpeed = animationLayer.LockedSpeed; + bool animationLocked = lockedSpeed != null; + if (ImGui.Checkbox("Set", ref animationLocked)) + { + if (animationLocked) + { + lockedSpeed = animationLayer.Speed; + animationLayer.LockSpeed((float)lockedSpeed); + } + else { - MemoryUtil.WriteBytes(addr, BitConverter.GetBytes(valueF)); + animationLayer.UnlockSpeed(); } } - return (T)Convert.ChangeType(valueF, typeof(T)); - } - else if (typeof(T) == typeof(int)) - { - int valueI = Convert.ToInt32(currentValue); - int stepI = (int)Math.Round(step); - if (ImGui.InputInt(name, ref valueI, stepI, 0, ImGuiInputTextFlags.EnterReturnsTrue)) + ImGui.SameLine(); + if (animationLocked) { - MemoryUtil.WriteBytes(addr, BitConverter.GetBytes(valueI)); + float requestSpeed = (float)lockedSpeed; + if (ImGui.DragFloat($"Speed", ref requestSpeed, 0.01f, 0.0f, 0.0f, "%.3f")) + { + animationLayer.LockSpeed(requestSpeed); + } } - return (T)Convert.ChangeType(valueI, typeof(T)); - } - else if (typeof(T) == typeof(byte)) - { - bool valueSwitch = Convert.ToByte(currentValue) == 0x1; - if (ImGui.Checkbox(name, ref valueSwitch)) + else { - MemoryUtil.WriteBytes(addr, valueSwitch ? [0x1] : [0x0]); + ImGui.DragFloat($"Speed", ref animationLayer.Speed, 0.01f, 0.0f, 0.0f, "%.3f"); } - return (T)Convert.ChangeType(valueSwitch, typeof(T)); - } - return (T)currentValue; - } - - private static void inputSSAOParameters(SSAOParameters? parameters, nint baseAddr) - { - if (parameters == null) - { - drawRenderParameter("SSAO Depth Bias", baseAddr, 0xB4B0); - drawRenderParameter("SSAO Sloped Depth Bias", baseAddr, 0xB4B4); - drawRenderParameter("SSAO Max Depth Bias", baseAddr, 0xB4B8); - drawRenderParameter("SSAO Dispersion", baseAddr, 0xB4BC); - drawRenderParameter("SSAO Effect", baseAddr, 0xB430); - drawRenderParameter("SSAO Effect GI", baseAddr, 0xB434); - drawRenderParameter("SSAO Depth Difference", baseAddr, 0xB4C0); - drawRenderParameter("SSAO Samples Per Pixel", baseAddr, 0xB4C4); - drawRenderParameter("SSAO Max Sample Num", baseAddr, 0xB4C8); - drawRenderParameter("SSAO Max Sample Num HQ", baseAddr, 0xB4D0); - drawRenderParameter("SSAO Radius", baseAddr, 0xB4D4); - drawRenderParameter("SSAO Bias", baseAddr, 0xB4D8); - drawRenderParameter("SSAO Intensity", baseAddr, 0xB4E0); - drawRenderParameter("SSAO Use HiZ", baseAddr, 0xB4E5); - drawRenderParameter("SSAO Edge Atten Rate", baseAddr, 0xB4DC); + ImGui.PopItemWidth(); } } @@ -3476,47 +2755,10 @@ namespace MHWNewCamera player.Rotation.X = 0.0f; player.Rotation.Z = 0.0f; } - if (tripleShadowRes) - { - tripleShadowResDisable(); - } - if (ssaoAdjustments) - { - setSSAOAdjustements(false, ssaoB); - } - if (ssrAdjustments) - { - setSSRAdjustements(false); - } - if (enableHQMode) - { - setHQMode(false); - } - if (disableLODLimits) - { - disableLODLimitsDisable(); - } - if (areLODFactorsSet() && !areLODFactorsDefault()) - { - setLODFactors(false); - } - if (largerFoliageSwayRange) - { - addressHigherValueForFoliageSway.Disable(); - } - if (disableReducedRateAnimations) - { - zeroFrameSkip.Disable(); - } - // @TODO: Volume rendering. if (disableCharacterFade) { noopCharacterFade.Disable(); } - if (dofDisabled) - { - jmpOverDof.Disable(); - } if (enableUnderwaterCamera) { underwaterCameraDisable(); @@ -3533,38 +2775,6 @@ namespace MHWNewCamera private void tryToEnableMod() { - if (tripleShadowRes) - { - tripleShadowResEnable(); - } - if (ssaoAdjustments) - { - setSSAOAdjustements(true, ssaoB); - } - if (ssrAdjustments) - { - setSSRAdjustements(true); - } - if (enableHQMode) - { - setHQMode(true); - } - if (disableLODLimits) - { - disableLODLimitsEnable(); - } - if (applyLODFactors && !areLODFactorsDefault()) - { - setLODFactors(true); - } - if (largerFoliageSwayRange) - { - addressHigherValueForFoliageSway.Enable(); - } - if (disableReducedRateAnimations) - { - zeroFrameSkip.Enable(); - } if (pCameraViewportIndex >= 0) { setDisableFadingObjects(pCameraViewportIndex, disableFading); @@ -3573,10 +2783,6 @@ namespace MHWNewCamera { noopCharacterFade.Enable(); } - if (dofDisabled) - { - jmpOverDof.Enable(); - } if (enableUnderwaterCamera) { underwaterCameraEnable(); @@ -3591,87 +2797,582 @@ namespace MHWNewCamera } } -#if SHADER_FEATURES - private bool shadersLoadedOnce = false; - public unsafe void OnCreateShader(ShaderInfo *info) + private void drawPlayerInfo(Player player, float width) { - if (shadersLoadedOnce) + ImGui.Checkbox("Hide Weapon", ref hideWeapon); + + if (ImGui.CollapsingHeader("Armor Parts")) { - return; + nint bodyArmor = MemoryUtil.Read(player.Instance + 0x2A0); + if (bodyArmor != 0x0) + { + nint next = bodyArmor - 0x40; + nint head = next; + nint prev = MemoryUtil.Read(next + 0x10); + for (;next != 0x0;) + { + ImGui.PushID(next); + nint vtable = MemoryUtil.Read(next + 0x40); + if (vtable == 0x143507A18) + { + string partName = ""; + bool armorPart = false; + string fullString = Marshal.PtrToStringAnsi(next + 0x4C)!; + sbyte[] n = new sbyte[4]; + for (int i = 0; i < 3; i++) + { + n[i] = MemoryUtil.Read(next + 0x4C + i); + } + if (n[0] == 'n' && n[1] == 'p' && n[2] == 'c') + { + partName = "npc"; + armorPart = true; + } + for (int i = 0; i < 4; i++) + { + n[i] = MemoryUtil.Read(next + 0x62 + i); + } + if (n[0] == 'h' && n[1] == 'e' && n[2] == 'l' && n[3] == 'm') // '/helm/mod' + { + for (int i = 0; i < 4; i++) + { + n[i] = MemoryUtil.Read(next + 0x62 + 0xB + i); + } + partName = "helmet"; + armorPart = (n[0] == 'h' && n[1] == 'e' && n[2] == 'l' && n[3] == 'm'); // 'f_helm' + } + else if (n[0] == 'b' && n[1] == 'o' && n[2] == 'd' && n[3] == 'y') // 'body/mod' + { + for (int i = 0; i < 4; i++) + { + n[i] = MemoryUtil.Read(next + 0x62 + 0xB + i); + } + partName = "body"; + armorPart = (n[0] == 'b' && n[1] == 'o' && n[2] == 'd' && n[3] == 'y'); // 'f_body' + } + else if (n[0] == 'a' && n[1] == 'r' && n[2] == 'm') // '/arm/mod' + { + for (int i = 0; i < 3; i++) + { + n[i] = MemoryUtil.Read(next + 0x62 + 0xA + i); + } + partName = "arm"; + armorPart = (n[0] == 'a' && n[1] == 'r' && n[2] == 'm'); // 'f_arm' + } + else if (n[0] == 'w' && n[1] == 's' && n[2] == 't') // '/wst/mod' + { + for (int i = 0; i < 3; i++) + { + n[i] = MemoryUtil.Read(next + 0x62 + 0xA + i); + } + partName = "waist"; + armorPart = (n[0] == 'w' && n[1] == 's' && n[2] == 't'); // 'f_wst' + } + else if (n[0] == 'l' && n[1] == 'e' && n[2] == 'g') // '/leg/mod' + { + for (int i = 0; i < 3; i++) + { + n[i] = MemoryUtil.Read(next + 0x62 + 0xA + i); + } + partName = "leg"; + armorPart = (n[0] == 'l' && n[1] == 'e' && n[2] == 'g'); // 'f_leg' + } + for (int i = 0; i < 3; i++) + { + n[i] = MemoryUtil.Read(next + 0x4F + i); + } + if (n[0] == 's' && n[1] == 'l' && n[2] == 'g') // 'wp/slg' + { + for (int i = 0; i < 3; i++) + { + n[i] = MemoryUtil.Read(next + 0x53 + i); + } + partName = "slinger"; + armorPart = (n[0] == 's' && n[1] == 'l' && n[2] == 'g'); // 'slgXXX_XXXX' + } + if (armorPart) + { + ImGui.Text($"{partName} ({fullString} @ {next:X}):"); + bool toggleAll = ImGui.Button("Toggle All"); + int parts = MemoryUtil.Read(next + 0x58C); + nint baseInner = MemoryUtil.Read(next + 0x108); + nint offset = MemoryUtil.Read(next + 0x448); + for (int i = 0; i < parts; i++) + { + nint baseOffset = offset + (i * 0x4) + (parts * 0x4); + ref byte bIndex = ref MemoryUtil.GetRef(baseOffset); + ref byte bEnabled = ref MemoryUtil.GetRef(baseInner + ((bIndex + (bIndex * 4)) << 4)); + ref byte bSub = ref MemoryUtil.GetRef(baseInner + ((bIndex + (bIndex * 4)) << 4) + 0xB); + if (toggleAll) + { + (bEnabled, bSub) = (bSub, bEnabled); + } + bool isVisible = bEnabled != 0x0; + if (ImGui.Checkbox($"Part #{i}", ref isVisible)) + { + (bEnabled, bSub) = (bSub, bEnabled); + } + } + ImGui.Separator(); + } + } + ImGui.PopID(); + if (head == prev) + { + next = MemoryUtil.Read(next + 0x10); + } + else + { + next = MemoryUtil.Read(next + 0x18); + if (next == 0x0) + { + head = prev; + next = prev; + } + } + } + } } - string hash = new string(info->DxbcHash); - if (hash == "2e4e18fd-6ea5eeae-2de3d65c-26ab36dd") + + nint controlsAddr = MemoryUtil.Read(player.Instance + 0x12608); + nint zoneStateAddr = MemoryUtil.Read(0x1451C42B8); + ZoneState zoneState = ZoneState.Unknown; + if (controlsAddr != 0x0 && zoneStateAddr != 0x0) { - byte[] shaderData; - try + ref byte passiveFlag = ref MemoryUtil.GetRef(player.Instance + 0x7626); + ref byte passiveFlag2 = ref MemoryUtil.GetRef(MemoryUtil.Read(player.Instance + 0x7D20) + 0x9B8); + bool passive = passiveFlag == 0x1 && passiveFlag2 == 0x1; + if (ImGui.Checkbox("Passive", ref passive)) { - shaderData = System.IO.File.ReadAllBytes("./volume_upsample_edit.shdr"); + passiveFlag = ByteFlag(passive); + passiveFlag2 = ByteFlag(passive); } - catch (Exception) + if (ImGui.BeginItemTooltip()) { - return; + ImGui.Text("Passive: Calm camera and your hunter looks neutral/smiles.\nCombat: Intense camera and your hunter looks angry.\nIf you have Passive set and Combat Controls on, or vice versa, expect glitchy behavior."); + ImGui.EndTooltip(); } - info->NewSourceType = SourceType.BINARY; - info->NewSourceLength = shaderData.Length; - info->NewSource = (byte *)Marshal.UnsafeAddrOfPinnedArrayElement(shaderData, 0); - Log.Info("Replaced volume upsample shader 1."); - } - else if (hash == "e2c8c13e-45bc99b2-4c3d7699-3d66188e") - { - byte[] shaderData; - try + bool combatControls = MemoryUtil.Read(controlsAddr + 0xB18) == 0x80; + zoneState = combatControls ? ZoneState.Combat : ZoneState.Hub; +#if QUARANTINED_FEATURES + if (ImGui.Checkbox("Combat Controls", ref combatControls)) + { + passiveFlag = ByteFlag(!combatControls); + passiveFlag2 = ByteFlag(!combatControls); + setPlayerController1.Invoke(player.Instance); + setPlayerController5.Invoke(controlsAddr); + } + int zoneStateInt = (int)forceZoneState; + Vector2 pos = ImGui.GetCursorPos(); + pos.Y += 6; + ImGui.SetCursorPos(pos); + ImGui.Text($"Force Zone State (Current: {((MemoryUtil.GetRef(zoneStateAddr + 0xD2EA) == 0x1) ? "Hub" : "Combat")})"); + if (ImGui.BeginItemTooltip()) { - shaderData = System.IO.File.ReadAllBytes("./volume_upsample2_edit.shdr"); + ImGui.Text("This will apply when moving to a different area."); + ImGui.EndTooltip(); } - catch (Exception) + ImGui.SameLine(); + pos = ImGui.GetCursorPos(); + pos.Y -= 6; + ImGui.SetCursorPos(pos); + ImGui.RadioButton("Off", ref zoneStateInt, 0); + ImGui.SameLine(); + pos = ImGui.GetCursorPos(); + pos.Y -= 6; + ImGui.SetCursorPos(pos); + ImGui.RadioButton("Hub", ref zoneStateInt, 1); + ImGui.SameLine(); + pos = ImGui.GetCursorPos(); + pos.Y -= 6; + ImGui.SetCursorPos(pos); + ImGui.RadioButton("Combat", ref zoneStateInt, 2); + forceZoneState = (ZoneState)zoneStateInt; + if (ImGui.Button("Run Change Zone State")) { - return; + zoneStateManualInvoke = true; + setZoneState.Invoke(player.Instance, 0x000106C0); // or 0x00010780. } - info->NewSourceType = SourceType.BINARY; - info->NewSourceLength = shaderData.Length; - info->NewSource = (byte *)Marshal.UnsafeAddrOfPinnedArrayElement(shaderData, 0); - Log.Info("Replaced volume upsample shader 2."); - // This interestingly allows us to A/B using the volume rendering value 2 switch. - shadersLoadedOnce = true; - } - } -#endif - - public void OnImGuiRender() - { -#if HOOK_ORDER_ASSERTS - debugLog($"OnImGuiRender() @ {frameTick}"); -#endif - - Config config = ConfigManager.GetConfig(this); - float width = ImGui.GetWindowWidth(); - - // If we use vCamera or pCamera here, we need to ensure they're not invalid. - Player? player = checkPlayerChange(); - checkCurrentVisibleCamera(player); - - if (ImGui.Checkbox("Disable Mod", ref disableMod)) - { - if (disableMod) + if (ImGui.BeginItemTooltip()) { - tryToDisableMod(player); + ImGui.Text("You can use this to apply the value of Force Zone State.\nIf you're in a map and Force Zone State is set to Off or Combat, this will send you back to camp."); + ImGui.EndTooltip(); } - else + if (ImGui.Checkbox("Force Passive in Combat Zones", ref forcePassiveInCombatZone)) { - tryToEnableMod(); + if (forcePassiveInCombatZone) + { + zoneStateForcePassive1.Enable(); + zoneStateForcePassive2.Enable(); + } + else + { + zoneStateForcePassive1.Disable(); + zoneStateForcePassive2.Disable(); + } } - config.DisableMod = disableMod; - ConfigManager.SaveConfig(this); + if (ImGui.Checkbox("Force Combat in Passive Zones", ref forceCombatInPassiveZone)) + { + if (forceCombatInPassiveZone) + { + zoneStateForceCombat1.Enable(); + zoneStateForceCombat2.Enable(); + } + else + { + zoneStateForceCombat1.Disable(); + zoneStateForceCombat2.Disable(); + } + } +#endif } - if (ImGui.BeginItemTooltip()) + + if (zoneState != ZoneState.Combat) { - ImGui.Text("Try to disable as much as possible."); - ImGui.EndTooltip(); + ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); } - if (disableMod) + if (ImGui.Checkbox("Force Crawl", ref enableCrawl)) { - return; - } + if (enableCrawl) + { + MemoryUtil.GetRef(psuedoObject2 + 0x70) = player.Position.X + player.Forward.X; + MemoryUtil.GetRef(psuedoObject2 + 0x74) = player.Position.Y + player.Forward.Y; + MemoryUtil.GetRef(psuedoObject2 + 0x78) = player.Position.Z + player.Forward.Z; + + Quaternion playerRotation = new Quaternion(player.Forward.X, player.Forward.Y, player.Forward.Z, 0.0f); + Quaternion objectRotation = getRight(playerRotation); + + MemoryUtil.GetRef(psuedoObject2 + 0x40) = objectRotation.X; + MemoryUtil.GetRef(psuedoObject2 + 0x44) = objectRotation.Y; + MemoryUtil.GetRef(psuedoObject2 + 0x48) = objectRotation.Z; + MemoryUtil.GetRef(psuedoObject2 + 0x4C) = objectRotation.W; + + MemoryUtil.GetRef(psuedoObject2 + 0x50) = 0.0f; + MemoryUtil.GetRef(psuedoObject2 + 0x54) = 1.0f; + MemoryUtil.GetRef(psuedoObject2 + 0x58) = 0.0f; + MemoryUtil.GetRef(psuedoObject2 + 0x5C) = 0.0f; + + MemoryUtil.GetRef(psuedoObject2 + 0x60) = playerRotation.X; + MemoryUtil.GetRef(psuedoObject2 + 0x64) = playerRotation.Y; + MemoryUtil.GetRef(psuedoObject2 + 0x68) = playerRotation.Z; + MemoryUtil.GetRef(psuedoObject2 + 0x6C) = playerRotation.W; + } + } + if (zoneState != ZoneState.Combat) + { + ImGui.PopItemFlag(); + ImGui.PopStyleVar(); + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("You have to be out in a map to use this."); + ImGui.EndTooltip(); + } + } + else + { + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Simulate crawling under an object in the direction your character was facing when enabled."); + ImGui.EndTooltip(); + } + } + + if (zoneState != ZoneState.Hub) + { + ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); + } + if (ImGui.Button("Sit in Hot Springs")) + { + // Run sit in hot springs action (top of function): + // MonsterHunterWorld.exe+17601F0 - mov [rsp+08],rbx + MemoryUtil.WriteBytes(player.ActionController.Instance + 0xC0, [0x65, 0x00, 0x00, 0x00]); + MemoryUtil.WriteBytes(player.ActionController.Instance + 0xBC, [0x01, 0x00, 0x00, 0x00]); + } + if (zoneState != ZoneState.Hub) + { + ImGui.PopItemFlag(); + ImGui.PopStyleVar(); + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("You have to be in a hub area to use this."); + ImGui.EndTooltip(); + } + } + + if (ImGui.Checkbox("Allow Hot Springs Anywhere", ref allowHotSpringsAnywhere)) + { + if (allowHotSpringsAnywhere) + { + jmpOverHotSpringsEval.Enable(); + } + else + { + jmpOverHotSpringsEval.Disable(); + } + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Disable check for being about halfway submerged in water to stay sitting."); + ImGui.EndTooltip(); + } + + if (ImGui.Checkbox("Disable Hot Springs Steam", ref disableHotSpringsSteam)) + { + if (disableHotSpringsSteam) + { + jmpOverHotSpringsSteam.Enable(); + } + else + { + jmpOverHotSpringsSteam.Disable(); + } + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("It will take a couple of seconds to fade away."); + ImGui.EndTooltip(); + } + + ImGui.PushItemWidth(width * 0.35f); + ref float playerOpacity = ref MemoryUtil.GetRef(player.Instance + 0x78E0); + if (ImGui.DragFloat("Opacity", ref playerOpacity, 0.01f, 0.0f, Single.MaxValue)) + { + playerOpacityOverride = playerOpacity; + } + ImGui.PopItemWidth(); + + if (ImGui.CollapsingHeader("Wetness")) + { + Wetness wet = readCharacterWetness(player.Instance); + nint wetnessAddr = player.Instance + 0x13BD0; + ImGui.PushItemWidth(width * 0.25f); + if (ImGui.DragFloat("Head", ref wet.head, 0.005f)) + { + MemoryUtil.GetRef(wetnessAddr) = wet.head; + } + if (ImGui.DragFloat("Body", ref wet.body, 0.005f)) + { + MemoryUtil.GetRef(wetnessAddr + 0x28) = wet.body; + } + if (ImGui.DragFloat("Waist", ref wet.waist, 0.005f)) + { + MemoryUtil.GetRef(wetnessAddr + 0x50) = wet.waist; + } + if (ImGui.DragFloat("Legs", ref wet.legs, 0.005f)) + { + MemoryUtil.GetRef(wetnessAddr + 0x78) = wet.legs; + } + if (ImGui.DragFloat("Whole Body", ref wholeBodyWetness, 0.005f)) + { + if (overrideCharacterWetness) + { + MemoryUtil.GetRef(wetnessAddr) = wholeBodyWetness; + MemoryUtil.GetRef(wetnessAddr + 0x28) = wholeBodyWetness; + MemoryUtil.GetRef(wetnessAddr + 0x50) = wholeBodyWetness; + MemoryUtil.GetRef(wetnessAddr + 0x78) = wholeBodyWetness; + } + } + ImGui.PopItemWidth(); + if (ImGui.Checkbox("Override Player Wetness", ref overrideCharacterWetness)) + { + if (overrideCharacterWetness) + { + overrideCharacterWetnessEnable(); + MemoryUtil.GetRef(wetnessAddr) = wholeBodyWetness; + MemoryUtil.GetRef(wetnessAddr + 0x28) = wholeBodyWetness; + MemoryUtil.GetRef(wetnessAddr + 0x50) = wholeBodyWetness; + MemoryUtil.GetRef(wetnessAddr + 0x78) = wholeBodyWetness; + } + else + { + overrideCharacterWetnessDisable(); + } + } + } + + ImGui.DragFloat3("Position", ref player.Position, 0.5f); + Vector3 forward; + forward.X = player.Forward.X; + forward.Y = player.Forward.Y; + forward.Z = player.Forward.Z; + ImGui.DragFloat3("Forward", ref forward, 0.0f); + Vector4 rotation; + rotation.X = player.Rotation.X; + rotation.Y = player.Rotation.Y; + rotation.Z = player.Rotation.Z; + rotation.W = player.Rotation.W; + if (ImGui.SliderFloat4("Rotation", ref rotation, -1.0f, 1.0f)) + { + player.Rotation.X = rotation.X; + player.Rotation.Y = rotation.Y; + player.Rotation.Z = rotation.Z; + player.Rotation.W = rotation.W; + } + if (ImGui.Button("Reset")) + { + player.Rotation.X = 0.0f; + player.Rotation.Z = 0.0f; + } + if (ImGui.Checkbox("Disable Collision", ref disableCollision)) + { + if (disableCollision) + { + disableCollisionEnable(); + } + else + { + if (disableExtraGravity) + { + disableExtraGravity = false; + disableExtraGravityDisable(); + } + if (disableGravity) + { + disableGravity = false; + disableGravityDisable(); + } + if (disableExtraCollision) + { + disableExtraCollision = false; + disableExtraCollisionDisable(); + } + disableCollisionDisable(); + } + } + if (!disableCollision) + { + ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); + } + if (ImGui.Checkbox("Disable Another Y Collision", ref disableExtraCollision)) + { + if (disableExtraCollision) + { + disableExtraCollisionEnable(); + } + else + { + if (disableExtraGravity) + { + disableExtraGravity = false; + disableExtraGravityDisable(); + } + if (disableGravity) + { + disableGravity = false; + disableGravityDisable(); + } + disableExtraCollisionDisable(); + } + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("This will make your legs goofy, but is needed to get on top of some things."); + ImGui.EndTooltip(); + } + if (!disableCollision) + { + ImGui.PopItemFlag(); + ImGui.PopStyleVar(); + } + if (!disableExtraCollision) + { + ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); + } + if (ImGui.Checkbox("Disable Y Gravity", ref disableGravity)) + { + if (disableGravity) + { + disableGravityEnable(); + } + else + { + if (disableExtraGravity) + { + disableExtraGravity = false; + disableExtraGravityDisable(); + } + disableGravityDisable(); + } + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Avoid falling when going too high (Y axis)."); + ImGui.EndTooltip(); + } + if (!disableExtraCollision) + { + ImGui.PopItemFlag(); + ImGui.PopStyleVar(); + } + if (!disableGravity) + { + ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); + ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); + } + if (ImGui.Checkbox("Disable More Gravity", ref disableExtraGravity)) + { + if (disableExtraGravity) + { + disableExtraGravityEnable(); + } + else + { + disableExtraGravityDisable(); + } + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("This can stop you from falling when going out of bounds and/or rotating."); + ImGui.EndTooltip(); + } + if (!disableGravity) + { + ImGui.PopItemFlag(); + ImGui.PopStyleVar(); + } + + drawAnimationInfo(player, width, false); + } + + public void OnImGuiRender() + { +#if HOOK_ORDER_ASSERTS + debugLog($"OnImGuiRender() @ {frameTick}"); +#endif + + Config config = ConfigManager.GetConfig(this); + float width = ImGui.GetWindowWidth(); + + // If we use vCamera or pCamera here, we need to ensure they're not invalid. + Player? player = checkPlayerChange(); + checkCurrentVisibleCamera(player); + + if (ImGui.Checkbox("Disable Mod", ref disableMod)) + { + if (disableMod) + { + tryToDisableMod(player); + } + else + { + tryToEnableMod(); + } + config.DisableMod = disableMod; + ConfigManager.SaveConfig(this); + } + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Try to disable as much as possible."); + ImGui.EndTooltip(); + } + if (disableMod) + { + return; + } ImGui.Separator(); @@ -3926,101 +3627,47 @@ namespace MHWNewCamera { ImGui.PopStyleVar(); } - - if (ImGui.Checkbox("Disable Depth of Field", ref dofDisabled)) + if (vCamera != null) { - if (dofDisabled) + ImGui.PushItemWidth(width * 0.12f); + bool altNearClipSet = guessAltNearClipSet(vCamera); + if (ImGui.Checkbox("Alternate Near Clip", ref altNearClipSet)) { - jmpOverDof.Enable(); + setNearClip(vCamera, altNearClipSet); } - else + if (ImGui.BeginItemTooltip()) + { + ImGui.Text("Changing the near clip will subtly break rendering of various effects.\nTemporarily lowering the near clip can allow you to get the camera closer to things without clipping."); + ImGui.EndTooltip(); + } + ImGui.SameLine(); + if (ImGui.DragFloat("##Alternate Near Clip", ref alternateNearClip, 0.05f, 0.001f, 0.0f)) + { + if (altNearClipSet) + { + vCamera.NearClip = alternateNearClip; + } + } + ImGui.SameLine(); + if (ImGui.Button("Save")) { - jmpOverDof.Disable(); + Config.Settings camera = config.Camera; + camera.AlternateNearClip = alternateNearClip; + config.Camera = camera; + ConfigManager.SaveConfig(this); } + ImGui.PopItemWidth(); } + + ImGui.Separator(); + + ImGui.Text("When Close to the Camera"); if (ImGui.BeginItemTooltip()) { - ImGui.Text("Works to disable depth of field in cutscenes."); + ImGui.Text("Set Disable Fading in the camera preset above for these to persist."); ImGui.EndTooltip(); } - ImGui.SameLine(); - float alignCursorX = ImGui.GetCursorPosX(); - ImGui.Checkbox("Disable Motion Blur", ref motionBlurDisabled); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Motion blur completely breaks when freezing the game."); - ImGui.EndTooltip(); - } - if (!ssaoAdjustments) - { - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); - } - if (ImGui.Checkbox("Disable SSAO", ref ssaoB)) - { - if (ssaoAdjustments) - { - setSSAOAdjustements(ssaoAdjustments, ssaoB); - } - } - if (!ssaoAdjustments) - { - ImGui.PopStyleVar(); - } - if (ImGui.BeginItemTooltip()) - { - if (!ssaoAdjustments) - { - ImGui.Text("Enable SSAO Adjustments under Graphical Tweaks for this to apply."); - } - else - { - ImGui.Text("Currently doesn't work in cutscenes."); - } - ImGui.EndTooltip(); - } - if (vCamera != null) - { - ImGui.SameLine(); - ImGui.SetCursorPosX(alignCursorX); - ImGui.PushItemWidth(width * 0.12f); - bool altNearClipSet = guessAltNearClipSet(vCamera); - if (ImGui.Checkbox("Alternate Near Clip", ref altNearClipSet)) - { - setNearClip(vCamera, altNearClipSet); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Changing the near clip will subtly break rendering of various effects.\nTemporarily lowering the near clip can allow you to get the camera closer to things without clipping."); - ImGui.EndTooltip(); - } - ImGui.SameLine(); - if (ImGui.DragFloat("##Alternate Near Clip", ref alternateNearClip, 0.05f, 0.001f, 0.0f)) - { - if (altNearClipSet) - { - vCamera.NearClip = alternateNearClip; - } - } - ImGui.SameLine(); - if (ImGui.Button("Save")) - { - Config.Settings camera = config.Camera; - camera.AlternateNearClip = alternateNearClip; - config.Camera = camera; - ConfigManager.SaveConfig(this); - } - ImGui.PopItemWidth(); - } - - ImGui.Separator(); - - ImGui.Text("When Close to the Camera"); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Set Disable Fading in the camera preset above for these to persist."); - ImGui.EndTooltip(); - } - if (vCameraViewportIndex >= 0) + if (vCameraViewportIndex >= 0) { bool disableFadingObjects = getDisableFadingObjects(vCameraViewportIndex); if (ImGui.Checkbox("Disable Fading Objects", ref disableFadingObjects)) @@ -4366,534 +4013,51 @@ namespace MHWNewCamera } ImGui.PopID(); - ImGui.PushID("Player"); - if (ImGui.CollapsingHeader("Player") && player != null) + bool playerFallback = player == null; + if (!playerFallback) { - ImGui.Checkbox("Hide Weapon", ref hideWeapon); - - if (ImGui.CollapsingHeader("Armor Parts")) - { - nint bodyArmor = MemoryUtil.Read(player.Instance + 0x2A0); - if (bodyArmor != 0x0) - { - nint next = bodyArmor - 0x40; - nint head = next; - nint prev = MemoryUtil.Read(next + 0x10); - for (;next != 0x0;) - { - ImGui.PushID(next); - nint vtable = MemoryUtil.Read(next + 0x40); - if (vtable == 0x143507A18) - { - sbyte[] n = new sbyte[4]; - for (int i = 0; i < 4; i++) - { - n[i] = MemoryUtil.Read(next + 0x62 + i); - } - string partName = ""; - bool armorPart = false; - if (n[0] == 'h' && n[1] == 'e' && n[2] == 'l' && n[3] == 'm') // '/helm/mod' - { - for (int i = 0; i < 4; i++) - { - n[i] = MemoryUtil.Read(next + 0x62 + 0xB + i); - } - partName = "helmet"; - armorPart = (n[0] == 'h' && n[1] == 'e' && n[2] == 'l' && n[3] == 'm'); // 'f_helm' - } - else if (n[0] == 'b' && n[1] == 'o' && n[2] == 'd' && n[3] == 'y') // 'body/mod' - { - for (int i = 0; i < 4; i++) - { - n[i] = MemoryUtil.Read(next + 0x62 + 0xB + i); - } - partName = "body"; - armorPart = (n[0] == 'b' && n[1] == 'o' && n[2] == 'd' && n[3] == 'y'); // 'f_body' - } - else if (n[0] == 'a' && n[1] == 'r' && n[2] == 'm') // '/arm/mod' - { - for (int i = 0; i < 3; i++) - { - n[i] = MemoryUtil.Read(next + 0x62 + 0xA + i); - } - partName = "arm"; - armorPart = (n[0] == 'a' && n[1] == 'r' && n[2] == 'm'); // 'f_arm' - } - else if (n[0] == 'w' && n[1] == 's' && n[2] == 't') // '/wst/mod' - { - for (int i = 0; i < 3; i++) - { - n[i] = MemoryUtil.Read(next + 0x62 + 0xA + i); - } - partName = "waist"; - armorPart = (n[0] == 'w' && n[1] == 's' && n[2] == 't'); // 'f_wst' - } - else if (n[0] == 'l' && n[1] == 'e' && n[2] == 'g') // '/leg/mod' - { - for (int i = 0; i < 3; i++) - { - n[i] = MemoryUtil.Read(next + 0x62 + 0xA + i); - } - partName = "leg"; - armorPart = (n[0] == 'l' && n[1] == 'e' && n[2] == 'g'); // 'f_leg' - } - for (int i = 0; i < 3; i++) - { - n[i] = MemoryUtil.Read(next + 0x4F + i); - } - if (n[0] == 's' && n[1] == 'l' && n[2] == 'g') // 'wp/slg' - { - for (int i = 0; i < 3; i++) - { - n[i] = MemoryUtil.Read(next + 0x53 + i); - } - partName = "slinger"; - armorPart = (n[0] == 's' && n[1] == 'l' && n[2] == 'g'); // 'slgXXX_XXXX' - } - if (armorPart) - { - ImGui.Text($"{partName}({next:x}):"); - int parts = MemoryUtil.Read(next + 0x58C); - nint baseInner = MemoryUtil.Read(next + 0x108); - nint offset = MemoryUtil.Read(next + 0x448); - for (int i = 0; i < parts; i++) - { - nint baseOffset = offset + (i * 0x4) + (parts * 0x4); - ref byte bIndex = ref MemoryUtil.GetRef(baseOffset); - ref byte bEnabled = ref MemoryUtil.GetRef(baseInner + ((bIndex + (bIndex * 4)) << 4)); - ref byte bSub = ref MemoryUtil.GetRef(baseInner + ((bIndex + (bIndex * 4)) << 4) + 0xB); - bool isVisible = bEnabled != 0x0; - if (ImGui.Checkbox($"Part #{i}", ref isVisible)) - { - (bEnabled, bSub) = (bSub, bEnabled); - } - } - ImGui.Separator(); - } - } - ImGui.PopID(); - if (head == prev) - { - next = MemoryUtil.Read(next + 0x10); - } - else - { - next = MemoryUtil.Read(next + 0x18); - if (next == 0x0) - { - head = prev; - next = prev; - } - } - } - } - } - - nint controlsAddr = MemoryUtil.Read(player.Instance + 0x12608); - nint zoneStateAddr = MemoryUtil.Read(0x1451C42B8); - ZoneState zoneState = ZoneState.Unknown; - if (controlsAddr != 0x0 && zoneStateAddr != 0x0) - { - ref byte passiveFlag = ref MemoryUtil.GetRef(player.Instance + 0x7626); - ref byte passiveFlag2 = ref MemoryUtil.GetRef(MemoryUtil.Read(player.Instance + 0x7D20) + 0x9B8); - bool passive = passiveFlag == 0x1 && passiveFlag2 == 0x1; - if (ImGui.Checkbox("Passive", ref passive)) - { - passiveFlag = byteFlag(passive); - passiveFlag2 = byteFlag(passive); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Passive: Calm camera and your hunter looks neutral/smiles.\nCombat: Intense camera and your hunter looks angry.\nIf you have Passive set and Combat Controls on, or vice versa, expect glitchy behavior."); - ImGui.EndTooltip(); - } - bool combatControls = MemoryUtil.Read(controlsAddr + 0xB18) == 0x80; - zoneState = combatControls ? ZoneState.Combat : ZoneState.Hub; -#if QUARANTINED_FEATURES - if (ImGui.Checkbox("Combat Controls", ref combatControls)) - { - passiveFlag = byteFlag(!combatControls); - passiveFlag2 = byteFlag(!combatControls); - setPlayerController1.Invoke(player.Instance); - setPlayerController5.Invoke(controlsAddr); - } - int zoneStateInt = (int)forceZoneState; - Vector2 pos = ImGui.GetCursorPos(); - pos.Y += 6; - ImGui.SetCursorPos(pos); - ImGui.Text($"Force Zone State (Current: {((MemoryUtil.GetRef(zoneStateAddr + 0xD2EA) == 0x1) ? "Hub" : "Combat")})"); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("This will apply when moving to a different area."); - ImGui.EndTooltip(); - } - ImGui.SameLine(); - pos = ImGui.GetCursorPos(); - pos.Y -= 6; - ImGui.SetCursorPos(pos); - ImGui.RadioButton("Off", ref zoneStateInt, 0); - ImGui.SameLine(); - pos = ImGui.GetCursorPos(); - pos.Y -= 6; - ImGui.SetCursorPos(pos); - ImGui.RadioButton("Hub", ref zoneStateInt, 1); - ImGui.SameLine(); - pos = ImGui.GetCursorPos(); - pos.Y -= 6; - ImGui.SetCursorPos(pos); - ImGui.RadioButton("Combat", ref zoneStateInt, 2); - forceZoneState = (ZoneState)zoneStateInt; - if (ImGui.Button("Run Change Zone State")) - { - zoneStateManualInvoke = true; - setZoneState.Invoke(player.Instance, 0x000106C0); // or 0x00010780. - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("You can use this to apply the value of Force Zone State.\nIf you're in a map and Force Zone State is set to Off or Combat, this will send you back to camp."); - ImGui.EndTooltip(); - } - if (ImGui.Checkbox("Force Passive in Combat Zones", ref forcePassiveInCombatZone)) - { - if (forcePassiveInCombatZone) - { - zoneStateForcePassive1.Enable(); - zoneStateForcePassive2.Enable(); - } - else - { - zoneStateForcePassive1.Disable(); - zoneStateForcePassive2.Disable(); - } - } - if (ImGui.Checkbox("Force Combat in Passive Zones", ref forceCombatInPassiveZone)) - { - if (forceCombatInPassiveZone) - { - zoneStateForceCombat1.Enable(); - zoneStateForceCombat2.Enable(); - } - else - { - zoneStateForceCombat1.Disable(); - zoneStateForceCombat2.Disable(); - } - } -#endif - } - - if (zoneState != ZoneState.Combat) - { - ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); - } - if (ImGui.Checkbox("Force Crawl", ref enableCrawl)) - { - if (enableCrawl) - { - MemoryUtil.GetRef(psuedoObject2 + 0x70) = player.Position.X + player.Forward.X; - MemoryUtil.GetRef(psuedoObject2 + 0x74) = player.Position.Y + player.Forward.Y; - MemoryUtil.GetRef(psuedoObject2 + 0x78) = player.Position.Z + player.Forward.Z; - - Quaternion playerRotation = new Quaternion(player.Forward.X, player.Forward.Y, player.Forward.Z, 0.0f); - Quaternion objectRotation = getReverse(playerRotation); - - MemoryUtil.GetRef(psuedoObject2 + 0x40) = objectRotation.X; - MemoryUtil.GetRef(psuedoObject2 + 0x44) = objectRotation.Y; - MemoryUtil.GetRef(psuedoObject2 + 0x48) = objectRotation.Z; - MemoryUtil.GetRef(psuedoObject2 + 0x4C) = objectRotation.W; - - MemoryUtil.GetRef(psuedoObject2 + 0x50) = 0.0f; - MemoryUtil.GetRef(psuedoObject2 + 0x54) = 1.0f; - MemoryUtil.GetRef(psuedoObject2 + 0x58) = 0.0f; - MemoryUtil.GetRef(psuedoObject2 + 0x5C) = 0.0f; - - MemoryUtil.GetRef(psuedoObject2 + 0x60) = playerRotation.X; - MemoryUtil.GetRef(psuedoObject2 + 0x64) = playerRotation.Y; - MemoryUtil.GetRef(psuedoObject2 + 0x68) = playerRotation.Z; - MemoryUtil.GetRef(psuedoObject2 + 0x6C) = playerRotation.W; - } - } - if (zoneState != ZoneState.Combat) - { - ImGui.PopItemFlag(); - ImGui.PopStyleVar(); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("You have to be out in a map to use this."); - ImGui.EndTooltip(); - } - } - else - { - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Simulate crawling under an object in the direction your character was facing when enabled."); - ImGui.EndTooltip(); - } - } - - if (zoneState != ZoneState.Hub) - { - ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); - } - if (ImGui.Button("Sit in Hot Springs")) - { - // Run sit in hot springs action (top of function): - // MonsterHunterWorld.exe+17601F0 - mov [rsp+08],rbx - MemoryUtil.WriteBytes(player.ActionController.Instance + 0xC0, [0x65, 0x00, 0x00, 0x00]); - MemoryUtil.WriteBytes(player.ActionController.Instance + 0xBC, [0x01, 0x00, 0x00, 0x00]); - } - if (zoneState != ZoneState.Hub) - { - ImGui.PopItemFlag(); - ImGui.PopStyleVar(); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("You have to be in a hub area to use this."); - ImGui.EndTooltip(); - } - } - - if (ImGui.Checkbox("Allow Hot Springs Anywhere", ref allowHotSpringsAnywhere)) - { - if (allowHotSpringsAnywhere) - { - jmpOverHotSpringsEval.Enable(); - } - else - { - jmpOverHotSpringsEval.Disable(); - } - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Disable check for being about halfway submerged in water to stay sitting."); - ImGui.EndTooltip(); - } - - if (ImGui.Checkbox("Disable Hot Springs Steam", ref disableHotSpringsSteam)) - { - if (disableHotSpringsSteam) - { - jmpOverHotSpringsSteam.Enable(); - } - else - { - jmpOverHotSpringsSteam.Disable(); - } - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("It will take a couple of seconds to fade away."); - ImGui.EndTooltip(); - } - - ImGui.PushItemWidth(width * 0.35f); - ref float playerOpacity = ref MemoryUtil.GetRef(player.Instance + 0x78E0); - if (ImGui.DragFloat("Opacity", ref playerOpacity, 0.01f, 0.0f, Single.MaxValue)) - { - playerOpacityOverride = playerOpacity; - } - ImGui.PopItemWidth(); + saveSlotFallback = false; + } + else if (saveSlotFallback) + { + player = getPlayerFromSaveSlot(saveSlotIndex); + } - if (ImGui.CollapsingHeader("Wetness")) + ImGui.PushID("Player"); + if (ImGui.CollapsingHeader("Player")) + { + if (playerFallback) { - nint wetnessAddr = player.Instance + 0x13BD0; - ImGui.PushItemWidth(width * 0.3f); - float headWetness = MemoryUtil.Read(wetnessAddr); - if (ImGui.DragFloat("Head", ref headWetness, 0.005f)) - { - MemoryUtil.WriteBytes(wetnessAddr, BitConverter.GetBytes(headWetness)); - } - float bodyWetness = MemoryUtil.Read(wetnessAddr + 0x28); - if (ImGui.DragFloat("Body", ref bodyWetness, 0.005f)) - { - MemoryUtil.WriteBytes(wetnessAddr + 0x28, BitConverter.GetBytes(bodyWetness)); - } - float waistWetness = MemoryUtil.Read(wetnessAddr + 0x50); - if (ImGui.DragFloat("Waist", ref waistWetness, 0.005f)) + bool updateFallback = ImGui.Checkbox("Save Slot Fallback", ref saveSlotFallback); + if (saveSlotFallback) { - MemoryUtil.WriteBytes(wetnessAddr + 0x50, BitConverter.GetBytes(waistWetness)); - } - float legsWetness = MemoryUtil.Read(wetnessAddr + 0x78); - if (ImGui.DragFloat("Legs", ref legsWetness, 0.005f)) - { - MemoryUtil.WriteBytes(wetnessAddr + 0x78, BitConverter.GetBytes(legsWetness)); - } - if (ImGui.DragFloat("Whole Body", ref wholeBodyWetness, 0.005f)) - { - if (applyCharacterWetness) + int saveSlot = saveSlotIndex; + ImGui.SetNextItemWidth(width * 0.2f); + if (ImGui.InputInt("Save Slot Index", ref saveSlot, 1, 0, ImGuiInputTextFlags.EnterReturnsTrue)) { - MemoryUtil.WriteBytes(wetnessAddr, BitConverter.GetBytes(wholeBodyWetness)); - MemoryUtil.WriteBytes(wetnessAddr + 0x28, BitConverter.GetBytes(wholeBodyWetness)); - MemoryUtil.WriteBytes(wetnessAddr + 0x50, BitConverter.GetBytes(wholeBodyWetness)); - MemoryUtil.WriteBytes(wetnessAddr + 0x78, BitConverter.GetBytes(wholeBodyWetness)); + saveSlotIndex = Math.Clamp(saveSlot, 0, 2); } } - ImGui.PopItemWidth(); - if (ImGui.Checkbox("Override Player Wetness", ref applyCharacterWetness)) + if (updateFallback) { - if (applyCharacterWetness) + if (saveSlotFallback) { - noopCharacterWetnessUpdate.Enable(); + if (player == null) + { + player = getPlayerFromSaveSlot(saveSlotIndex); + } } else { - noopCharacterWetnessUpdate.Disable(); - } - MemoryUtil.WriteBytes(wetnessAddr, BitConverter.GetBytes(wholeBodyWetness)); - MemoryUtil.WriteBytes(wetnessAddr + 0x28, BitConverter.GetBytes(wholeBodyWetness)); - MemoryUtil.WriteBytes(wetnessAddr + 0x50, BitConverter.GetBytes(wholeBodyWetness)); - MemoryUtil.WriteBytes(wetnessAddr + 0x78, BitConverter.GetBytes(wholeBodyWetness)); - } - } - - ImGui.DragFloat3("Position", ref player.Position, 0.5f); - Vector3 forward; - forward.X = player.Forward.X; - forward.Y = player.Forward.Y; - forward.Z = player.Forward.Z; - ImGui.DragFloat3("Forward", ref forward, 0.0f); - Vector4 rotation; - rotation.X = player.Rotation.X; - rotation.Y = player.Rotation.Y; - rotation.Z = player.Rotation.Z; - rotation.W = player.Rotation.W; - if (ImGui.SliderFloat4("Rotation", ref rotation, -1.0f, 1.0f)) - { - player.Rotation.X = rotation.X; - player.Rotation.Y = rotation.Y; - player.Rotation.Z = rotation.Z; - player.Rotation.W = rotation.W; - } - if (ImGui.Button("Reset")) - { - player.Rotation.X = 0.0f; - player.Rotation.Z = 0.0f; - } - if (ImGui.Checkbox("Disable Collision", ref disableCollision)) - { - if (disableCollision) - { - disableCollisionEnable(); - } - else - { - if (disableExtraGravity) - { - disableExtraGravity = false; - disableExtraGravityDisable(); - } - if (disableGravity) - { - disableGravity = false; - disableGravityDisable(); - } - if (disableExtraCollision) - { - disableExtraCollision = false; - disableExtraCollisionDisable(); - } - disableCollisionDisable(); - } - } - if (!disableCollision) - { - ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); - } - if (ImGui.Checkbox("Disable Another Y Collision", ref disableExtraCollision)) - { - if (disableExtraCollision) - { - disableExtraCollisionEnable(); - } - else - { - if (disableExtraGravity) - { - disableExtraGravity = false; - disableExtraGravityDisable(); - } - if (disableGravity) - { - disableGravity = false; - disableGravityDisable(); - } - disableExtraCollisionDisable(); - } - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("This will make your legs goofy, but is needed to get on top of some things."); - ImGui.EndTooltip(); - } - if (!disableCollision) - { - ImGui.PopItemFlag(); - ImGui.PopStyleVar(); - } - if (!disableExtraCollision) - { - ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); - } - if (ImGui.Checkbox("Disable Y Gravity", ref disableGravity)) - { - if (disableGravity) - { - disableGravityEnable(); - } - else - { - if (disableExtraGravity) - { - disableExtraGravity = false; - disableExtraGravityDisable(); + player = checkPlayerChange(); } - disableGravityDisable(); - } - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Avoid falling when going too high (Y axis)."); - ImGui.EndTooltip(); - } - if (!disableExtraCollision) - { - ImGui.PopItemFlag(); - ImGui.PopStyleVar(); - } - if (!disableGravity) - { - ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); - } - if (ImGui.Checkbox("Disable More Gravity", ref disableExtraGravity)) - { - if (disableExtraGravity) - { - disableExtraGravityEnable(); - } - else - { - disableExtraGravityDisable(); } } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("This can stop you from falling when going out of bounds and/or rotating."); - ImGui.EndTooltip(); - } - if (!disableGravity) + if (player != null) { - ImGui.PopItemFlag(); - ImGui.PopStyleVar(); + drawPlayerInfo(player, width); + ImGui.Separator(); } - - ImGui.Separator(); } ImGui.PopID(); @@ -4969,470 +4133,6 @@ namespace MHWNewCamera } ImGui.PopID(); - ImGui.PushID("Graphics"); - if (ImGui.CollapsingHeader("Graphical Tweaks")) - { - if (ImGui.Checkbox("3x Shadow Resolution (Requires Reload)", ref tripleShadowRes)) - { - if (tripleShadowRes) - { - tripleShadowResEnable(); - } - else - { - tripleShadowResDisable(); - } - Config.GraphicalTweaks graphics = config.Graphics; - graphics.TripleShadowResolution = tripleShadowRes; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("In-Game Settings:\n - High: 1.0 -> 3.0\n - Mid: 0.7 -> 2.1\n - Low: 0.5 -> 1.5\nReload shadows by toggling Shadow Quality in Options -> Display -> Advanced Graphics Settings."); - ImGui.EndTooltip(); - } - - ImGui.PushItemWidth(width * 0.145f); - if (ImGui.Checkbox("##Apply Larger Shadow Range", ref applyShadowBias)) - { - Config.GraphicalTweaks graphics = config.Graphics; - graphics.ApplyShadowRange = applyShadowBias; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - ImGui.SameLine(); - if (ImGui.InputFloat("Shadow Range", ref shadowBiasOffset, 0.0f, 0.0f, null, ImGuiInputTextFlags.EnterReturnsTrue)) - { - Config.GraphicalTweaks graphics = config.Graphics; - graphics.ShadowRangeOffset = shadowBiasOffset; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("This will inversely reduce the detail of shadows closer to the camera (like the player shadow), so it's a trade-off.\nValue is an offset. Recommended: 0.5."); - ImGui.EndTooltip(); - } - ImGui.SameLine(); - if (ImGui.Checkbox("##Apply Radius", ref applyShadowRadius)) - { - Config.GraphicalTweaks graphics = config.Graphics; - graphics.ApplyShadowRadius = applyShadowRadius; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - ImGui.SameLine(); - if (ImGui.InputFloat("Shadow Radius", ref shadowRadiusOffset, 0.0f, 0.0f, "%.5f", ImGuiInputTextFlags.EnterReturnsTrue)) - { - Config.GraphicalTweaks graphics = config.Graphics; - graphics.ShadowRadiusOffset = shadowRadiusOffset; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Size of a shadows border (to be softened if HQ Mode is enabled).\nValue is an offset. Recommended: -0.0001 (if Shadow Range = 0.5)."); - ImGui.EndTooltip(); - } - ImGui.PopItemWidth(); - - /* - if (ImGui.Checkbox("Higher Shadow Detail in Hoarfrost Reach/Seliana Gathering Hub", ref lowShadowDetailOverride)) - { - Config.GraphicalTweaks graphics = config.Graphics; - graphics.HigherShadowDetailInHoarfrost = lowShadowDetailOverride; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Disable reduced detail/range shadows in Hoarfrost Reach and Seliana Gathering Hub.\nAlso doubles the Shadow Range offset in those areas."); - ImGui.EndTooltip(); - } - */ - - if (ImGui.Checkbox("Enable \"HQ Mode\"", ref enableHQMode)) - { - ssaoAdjustments = enableHQMode; - setSSAOAdjustements(ssaoAdjustments, ssaoB); - ssrAdjustments = enableHQMode; - setSSRAdjustements(ssrAdjustments); - setHQMode(enableHQMode); - Config.GraphicalTweaks graphics = config.Graphics; - graphics.EnableHQMode = enableHQMode; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Enable the game's built-in \"HQ Mode\" and associated tweaks to not tank performance.\nBy default, HQ Mode jacks up various rendering parameters and enables HQ Shadows.\nSome of the values are put too high to work for general gameplay.\nThis tweak adjusts the following parameters:\n SSAO Max Sample Num HQ: 64 -> 16\n SSLR Accurate Threshold HQ: 0.5 -> 0.2\nAs well as SSAO Dispersion: 10.0 -> 1.75 to mitigate a grid artifact in the SSAO rendering."); - ImGui.EndTooltip(); - } - - if (ImGui.Checkbox("Volume Rendering Full Resolution Blur Pass (Requires Area Change)", ref disableVolumeDownsample)) - { - if (disableVolumeDownsample) - { - volumeSars1.Enable(); - volumeSars2.Enable(); - volumeSars3.Enable(); - volumeSars4.Enable(); - volumeSars5.Enable(); - volumeSars6.Enable(); - volumeSars7.Enable(); - volumeSars8.Enable(); - volumeSars9.Enable(); - } - else - { - volumeSars1.Disable(); - volumeSars2.Disable(); - volumeSars3.Disable(); - volumeSars4.Disable(); - volumeSars5.Disable(); - volumeSars6.Disable(); - volumeSars7.Disable(); - volumeSars8.Disable(); - volumeSars9.Disable(); - } - Config.GraphicalTweaks graphics = config.Graphics; - graphics.FullResolutionVolumeBlur = disableVolumeDownsample; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("This can get rid of excessive aliasing when an object is in front of a volumetric effect.\nYou have to move to a different area one time for this to apply. It will remain applied after that."); - ImGui.EndTooltip(); - } - - if (ImGui.Checkbox("Higher Than \"Highest\" Volume Rendering Quality", ref higherVolumeQuality)) - { - if (higherVolumeQuality) - { - value2ForVolumeQuality.Enable(); - } - else - { - value2ForVolumeQuality.Disable(); - } - Config.GraphicalTweaks graphics = config.Graphics; - graphics.HigherThanHighestVolumeRendering = higherVolumeQuality; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("*Extremely Resource Intensive* Only noticeable effect is likely in areas that had visible breakup with Volume Rendering Quality: Highest.\nThis takes mostly the same path as Highest, so expect the same visual artifacts."); - ImGui.EndTooltip(); - } - - if (ImGui.Checkbox("Disable Player/Palico/NPC LOD Limit in Gameplay", ref disableLODLimits)) - { - if (disableLODLimits) - { - disableLODLimitsEnable(); - } - else - { - disableLODLimitsDisable(); - } - Config.GraphicalTweaks graphics = config.Graphics; - graphics.DisableLODLimits = disableLODLimits; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("This will make the default (gameplay) LOD limits equivalent to View Mode. Disabling the limit on:\n - Player Models & Shadows\n - Palico Models & Shadows\n - NPC Models & Shadows\n - Simple NPC Models & Shadows\nAlso equivalent to the settings applied in your room with the addition of disabled Simple NPC limits."); - ImGui.EndTooltip(); - } - - ImGui.PushItemWidth(width * 0.1f); - ImGui.InputFloat("##Foliage LOD Bias", ref foliageLODBias, 0.0f, 0.0f, "%.2f"); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("In-Game Settings:\n - High: 3.0\n - Mid: 1.0\n - Low: 0.9\n - Variable: -1.0\nHigher value = Farther distance before plants switch to a lower LOD."); - ImGui.EndTooltip(); - } - ImGui.SameLine(); - ImGui.InputFloat("##Foliage LOD Factor", ref foliageLODFactor, 0.0f, 0.0f, "%.2f"); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Controls the distance at which the game decides to no longer render some plants.\nCan be effectively overridden by a high first value.\nDefault: 1.0, Best Quality: 0.0."); - ImGui.EndTooltip(); - } - ImGui.SameLine(); - ImGui.Text("Foliage LOD Bias"); - - ImGui.InputFloat("##Terrain/Object LOD Bias", ref terrainLODBias, 0.0f, 0.0f, "%.2f"); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("In-Game Settings:\n - High: 3.0\n - Mid: 1.0\n - Low: 0.9\n - Variable: -1.0\nHigher value = Farther distance before objects switch to a lower LOD."); - ImGui.EndTooltip(); - } - ImGui.SameLine(); - ImGui.InputFloat("##Terrain/Object LOD Factor", ref terrainLODFactor, 0.0f, 0.0f, "%.2f"); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Controls the distance at which the game decides to no longer render some objects.\nCan be effectively overridden by a high first value.\nDefault: 1.0, Best Quality: 0.0."); - ImGui.EndTooltip(); - } - ImGui.SameLine(); - ImGui.Text("Terrain/Object LOD Bias"); - - ImGui.InputFloat("Snow LOD Bias", ref snowField4GlobalLODParam, 0.0f, 0.0f, "%.2f", ImGuiInputTextFlags.EnterReturnsTrue); - ImGui.PopItemWidth(); - - bool lodsSet = areLODFactorsSet(); - bool disableLODButton = lodsSet && areLODFactorsDefault(); - if (disableLODButton) - { - ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); - lodsSet = false; - } - if (ImGui.Checkbox("Apply LOD Biases", ref lodsSet)) - { - setLODFactors(lodsSet); - applyLODFactors = lodsSet && !areLODFactorsDefault(); - Config.GraphicalTweaks graphics = config.Graphics; - if (lodsSet) - { - graphics.FoliageLODBias = foliageLODBias; - graphics.TerrainLODBias = terrainLODBias; - graphics.FoliageLODFactor = foliageLODFactor; - graphics.TerrainLODFactor = terrainLODFactor; - graphics.SnowLODBias = snowField4GlobalLODParam; - } - graphics.ApplyLODFactors = applyLODFactors; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - if (disableLODButton) - { - ImGui.PopItemFlag(); - ImGui.PopStyleVar(); - } - - if (ImGui.Checkbox("Larger Foliage Sway Range", ref largerFoliageSwayRange)) - { - if (largerFoliageSwayRange) - { - addressHigherValueForFoliageSway.Enable(); - } - else - { - addressHigherValueForFoliageSway.Disable(); - } - Config.GraphicalTweaks graphics = config.Graphics; - graphics.LargerFoliageSwayRange = largerFoliageSwayRange; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Increase the distance at which Foliage Sway is still applied to lower priority plants."); - ImGui.EndTooltip(); - } - - if (ImGui.Checkbox("Disable Reduced Rate Animations", ref disableReducedRateAnimations)) - { - if (disableReducedRateAnimations) - { - zeroFrameSkip.Enable(); - } - else - { - zeroFrameSkip.Disable(); - } - Config.GraphicalTweaks graphics = config.Graphics; - graphics.DisableReducedRateAnimations = disableReducedRateAnimations; - config.Graphics = graphics; - ConfigManager.SaveConfig(this); - } - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Ignore the frame skip set on an animal's animation when they get farther from the camera."); - ImGui.EndTooltip(); - } - - if (ImGui.CollapsingHeader("Depth of Field Parameters")) - { - ImGui.Checkbox("Enabled", ref dofParams.enabled); - ImGui.Checkbox("New Version", ref dofParams.newVersion); - ImGui.DragFloat("FNumber", ref dofParams.fNumber, 0.001f, 0.0f, 0.0f, "%.5f"); - ImGui.DragFloat("Sensor Size", ref dofParams.sensorSize, 0.001f, 0.0f, 0.0f, "%.5f"); - ImGui.DragFloat("Focus Distance", ref dofParams.focusDistance, 0.2f); - ImGui.DragFloat("Near Coef", ref dofParams.nearCoef, 0.001f, 0.0f, 0.0f, "%.5f"); - ImGui.DragFloat("Far Coef", ref dofParams.farCoef, 0.001f, 0.0f, 0.0f, "%.5f"); - ImGui.Checkbox("Near Enabled", ref dofParams.nearEnable); - ImGui.Checkbox("Far Enabled", ref dofParams.farEnable); - ImGui.Checkbox("Debug Draw", ref dofParams.debugDraw); - if (!dofParams.newVersion) - { - ImGui.PushStyleVar(ImGuiStyleVar.Alpha, ImGui.GetStyle().Alpha * 0.5f); - } - ImGui.Text("New Version Parameters:"); - ImGui.DragFloat("Radius", ref dofParams.radius, 0.001f, 0.0f, 0.0f, "%.6f"); - ImGui.DragFloat("Depth Scale Foreground", ref dofParams.depthScaleForeground, 0.0001f, 0.0f, 0.0f, "%.6f"); - ImGui.DragFloat("Aspect", ref dofParams.aspect, 0.001f, 0.0f, 0.0f, "%.6f"); - if (!dofParams.newVersion) - { - ImGui.PopStyleVar(); - } - if (ImGui.Button("Reset Per-frame Parameters")) - { - fillOutDofParams = true; - } - } - - if (ImGui.CollapsingHeader("Vignetting Parameters")) - { - ImGui.Checkbox("Apply Adjustments", ref applyVignettingParams); - ImGui.Checkbox("Enabled", ref dofParams.vignettingEnabled); - ImGui.Checkbox("Ellipse", ref dofParams.vignettingEllipse); - ImGui.DragFloat("Ellipticity", ref dofParams.vignettingEllipticity, 0.05f); - ImGui.DragFloat("Offset", ref dofParams.vignettingOffset, 0.05f); - ImGui.DragFloat("Power", ref dofParams.vignettingPow, 0.05f); - ImGui.InputInt("Color", ref dofParams.vignettingColor, 0, 0, ImGuiInputTextFlags.CharsHexadecimal); - if (ImGui.Button("Reset Per-frame Parameters")) - { - fillOutVignettingParams = true; - } - } - - if (ImGui.CollapsingHeader("Shadow Distance Parameters")) - { - ImGui.PushItemWidth(width * 0.2f); - ImGui.Text($"sUmbra: {sUmbra.Instance:x}"); - nint obj = MemoryUtil.Read(sUmbra.Instance + 0x00149740); - ImGui.Text($"Object Address: {obj:x}"); - ImGui.Checkbox("Apply Adjustments", ref applyShadowAdjust); - ImGui.InputFloat("Shadow Backforward Distance", ref shadowBackforwardDistance); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("Try increasing this if it looks like objects are being culled out of the shadow map at certain angles.\nThese values probably neeed to be entirely retuned per-area after increasing shadow range."); - ImGui.EndTooltip(); - } - ImGui.Text($"Original: {lastShadowBackforwardDistance}"); - ImGui.InputFloat("Shadow Distance", ref shadowDistance); - ImGui.Text($"Original: {lastShadowDistance}"); - ImGui.InputFloat("Shadow Distribution", ref shadowDistribution); - ImGui.Text($"Original: {lastShadowDistribution}"); - /* - ImGui.InputFloat("Broad Area Shadow Range", ref broadAreaShadowRange); - ImGui.Text($"Original: {lastBroadAreaShadowRange}"); - ImGui.InputFloat("Shadow FOV", ref shadowFov); - ImGui.Text($"Original: {lastShadowFov}"); - */ - ImGui.PopItemWidth(); - } - - if (ImGui.CollapsingHeader("Lighting Parameters")) - { - ImGui.Text($"Address: {lightingObject:x}"); - if (lightingObject != 0x0) - { - ImGui.PushItemWidth(width * 0.2f); - drawRenderParameter("Tone Map Type", lightingObject, 0x16C, false, 1.0f); - drawRenderParameter("Compute Luminance", lightingObject, 0x170); - //drawRenderParameter("Luminance Version", lightingObject, 0x168); - drawRenderParameter("Shoulder Strength", lightingObject, 0x174); - drawRenderParameter("Linear Strength", lightingObject, 0x178); - drawRenderParameter("Linear Angle", lightingObject, 0x17C); - drawRenderParameter("Toe Strength", lightingObject, 0x180); - drawRenderParameter("Toe Num", lightingObject, 0x184); - drawRenderParameter("Toe Denum", lightingObject, 0x188); - drawRenderParameter("White Point", lightingObject, 0x18C); - //drawRenderParameter("LUT Blend", lightingObject, 0x1C8); - //drawRenderParameter("Vfx LUT Blend", lightingObject, 0x1D0); - drawRenderParameter("Enable Color Grading", lightingObject, 0x1D8); - drawRenderParameter("Input Color Linear to PQ", lightingObject, 0x1A1); - drawRenderParameter("Output Color PQ to Linear", lightingObject, 0x1A0); - drawRenderParameter("Dispersion", lightingObject, 0x19C); - drawRenderParameter("Edge Sharpness", lightingObject, 0x198); - drawRenderParameter("Downsample Volume", lightingObject, 0x210); - ImGui.PopItemWidth(); - } - } - - if (ImGui.CollapsingHeader("FXAA Parameters")) - { - ImGui.Text($"Address: {fxaaObject:x}"); - if (fxaaObject != 0x0) - { - ImGui.PushItemWidth(width * 0.2f); - drawRenderParameter("FXAA Subpix", fxaaObject, 0x178, true); - drawRenderParameter("FXAA Edge Threshold", fxaaObject, 0x17C, true); - drawRenderParameter("FXAA Edge Threshold Min", fxaaObject, 0x180, true); - ImGui.PopItemWidth(); - } - } - - if (ImGui.CollapsingHeader("Misc Parameters")) - { - nint baseAddr = MemoryUtil.Read(0x1451C4368); - ImGui.Text($"Address: {baseAddr:x}"); - ImGui.PushItemWidth(width * 0.2f); - drawRenderParameter("HQ Mode", baseAddr, 0xE9A3); - drawRenderParameter("Primary Shadow Sample Num", baseAddr, 0xE5C4); - drawRenderParameter("Primary Shadow Sample Num HQ", baseAddr, 0xE5CC); - drawRenderParameter("Primary Shadow HQ", baseAddr, 0xE5C0); - if (ImGui.BeginItemTooltip()) - { - ImGui.Text("This seems to refer to softening the edges of shadows."); - ImGui.EndTooltip(); - } - drawRenderParameter("Primary Shadow HQ HQ", baseAddr, 0xE5C2); - drawRenderParameter("LOD Length Bias HQ", baseAddr, 0x1FC); - drawRenderParameter("LOD Pixel Size Bias HQ", baseAddr, 0x1FC); - inputSSAOParameters(null, baseAddr); - drawRenderParameter("SSLR Loop Count", baseAddr, 0xE628); - drawRenderParameter("SSLR Loop Count Factor For CBR", baseAddr, 0xE62C); - drawRenderParameter("SSLR Eliminate Depth", baseAddr, 0xE630); - drawRenderParameter("SSLR Accurate Threshold", baseAddr, 0xE644); - drawRenderParameter("SSLR Accurate Threshold HQ", baseAddr, 0xE64C); - drawRenderParameter("SSLR Dither Radius", baseAddr, 0xE634); - drawRenderParameter("SSLR Importance Bias", baseAddr, 0xE638); - drawRenderParameter("SSLR Mip Scale", baseAddr, 0xE63C); - drawRenderParameter("SSLR Mip Bias", baseAddr, 0xE640); - drawRenderParameter("SSLR Dither Resolve", baseAddr, 0xB43F); - drawRenderParameter("SSLR Edge Atten Rate", baseAddr, 0xB428); - drawRenderParameter("SSLR Mip 0 Count Threshold", baseAddr, 0xB438); - drawRenderParameter("SSLR Depth Eliminate Rate", baseAddr, 0xB42C); - drawRenderParameter("SSLR Use Mipmap", baseAddr, 0xE650); - drawRenderParameter("SSLR GBuffer Jitter", baseAddr, 0xB440); - drawRenderParameter("Contact Shadows Enabled", baseAddr, 0xB4EC); - drawRenderParameter("Force Disable Contact Shadows", baseAddr, 0xB4ED); - drawRenderParameter("Facial Contact Shadows Enabled", baseAddr, 0xB4EE); - drawRenderParameter("Contact Shadows Enable Noise", baseAddr, 0xB500); - drawRenderParameter("Facial Contact Shadows Enable Noise", baseAddr, 0xB501); - drawRenderParameter("Contact Shadow Intensity", baseAddr, 0xB4F0); - drawRenderParameter("Contact Shadow Length", baseAddr, 0xB4F4); - drawRenderParameter("Contact Shadow Accept Maximum Length", baseAddr, 0xB4F8); - drawRenderParameter("Contact Shadow Accept Minimum Length", baseAddr, 0xB4FC); - /* - drawRenderParameter("Capsule AO Enabled", baseAddr, 0xB502); - drawRenderParameter("Force Disable Capsule AO", baseAddr, 0xB503); - drawRenderParameter("Checkerboard Alpha Unroll Near", baseAddr, 0xE964); - drawRenderParameter("Checkerboard Alpha Unroll Far", baseAddr, 0xE968); - drawRenderParameter("Checkerboard History Blend Rate", baseAddr, 0xE96C); - drawRenderParameter("Checkerboard Sanitize Color", baseAddr, 0xE972); - drawRenderParameter("Checkerboard Blend Dither", baseAddr, 0xE973); - drawRenderParameter("Checkerboard BBox Strength", baseAddr, 0xE974); - drawRenderParameter("Checkerboard Dither Passthru Weight", baseAddr, 0xE978); - drawRenderParameter("Checkerboard Dither Filtered Weight", baseAddr, 0xE97C); - drawRenderParameter("Checkerboard Continous History Reset", baseAddr, 0xE971); - */ - ImGui.PopItemWidth(); - } - - ImGui.Separator(); - } - ImGui.PopID(); - ImGui.PushID("Debug"); if (ImGui.CollapsingHeader("DEBUG")) { @@ -5441,13 +4141,13 @@ namespace MHWNewCamera ImGui.Text("Camera:"); if (vCamera != null) { - ImGui.Text($"Visible Camera: {vCamera.Instance:x}"); + ImGui.Text($"Visible Camera: {vCamera.Instance:X}"); ImGui.Text($"freeCameraFallback: {freeCameraFallback}"); - //ImGui.Text($"viewModeObject: {psuedoViewModeObject:x}"); + //ImGui.Text($"viewModeObject: {psuedoViewModeObject:X}"); } if (pCamera != null) { - ImGui.Text($"Player Camera: {pCamera.Instance:x}"); + ImGui.Text($"Player Camera: {pCamera.Instance:X}"); ImGui.Text($"Applying Offset: {applyPerspective}"); ImGui.Text($"previousCameraAnimState: {previousCameraAnimState}"); ImGui.PushItemFlag(ImGuiItemFlags.Disabled, true); @@ -5472,13 +4172,15 @@ namespace MHWNewCamera ImGui.Separator(); + ImGui.Text($"sMhPlayer: {Player.SingletonInstance}"); + if (player != null) { ImGui.PushID("Player"); ImGui.Text("Player:"); - ImGui.Text($"Address: {player.Instance:x}"); + ImGui.Text($"Address: {player.Instance:X}"); - drawAnimationInfo(player); + drawAnimationInfo(player, width, true); bool move = player.Move; if (ImGui.Checkbox("Move", ref move)) @@ -5497,7 +4199,7 @@ namespace MHWNewCamera ImGui.PushID("Palico"); ImGui.Text("Palico/Otomo"); - ImGui.Text($"Address: {sOtomo.Instance:x}"); + ImGui.Text($"Address: {sOtomo.Instance:X}"); ImGui.PopID(); ImGui.Separator(); @@ -5511,46 +4213,48 @@ namespace MHWNewCamera Monster monster = monsters[i]; ImGui.PushID(monster.Instance); ImGui.Text($"{monster.Name}:"); - ImGui.Text($" Address: {monster.Instance:x}"); + ImGui.Text($" Address: {monster.Instance:X}"); ImGui.DragFloat3("Position", ref monster.Position, 0.5f); - drawAnimationInfo(monster); + drawAnimationInfo(monster, width, true); ImGui.PopID(); ImGui.Separator(); } } - ImGui.Text("Graphics:"); - // Locations taken from MHW-DTI-Dumps/wip_dump_15_20_00.h. - ImGui.InputFloat("Simulation Fps", ref MemoryUtil.GetRef(sMain.Instance + 0x58)); - if (ImGui.BeginItemTooltip()) + Animal[] animals = Animal.GetAllAnimals(); + if (animals.Length != 0 && ImGui.CollapsingHeader("Animals")) { - ImGui.Text("This does not apply to jiggle physics."); - ImGui.EndTooltip(); + for (int i = animals.Length - 1; i >= 0; i--) + { + Animal animal = animals[i]; + ImGui.PushID(animal.Instance); + ImGui.Text($"{animal.Id:X} ({animal.OtherId:X}):"); + ImGui.Text($" Address: {animal.Instance:X}"); + ImGui.DragFloat3("Position", ref animal.Position, 0.5f); + // Freeze: +0x1AFC = 0xFFFFFFFC + if (ImGui.Button("Remove")) + { + MemoryUtil.GetRef(animal.Instance + 0x928) = 0xFFFFFFFF; + } + ImGui.PopID(); + ImGui.Separator(); + } } - ImGui.InputFloat("Max Fps", ref MemoryUtil.GetRef(sMain.Instance + 0x5C)); - ImGui.InputFloat("Fps", ref MemoryUtil.GetRef(sMain.Instance + 0x68)); - ImGui.Text($"Delta Time: {MemoryUtil.Read(sMain.Instance + 0x94)}"); - - ImGui.Text($"prevFoliageLODBias: {prevFoliageLODBias}"); - ImGui.Text($"prevTerrainLODBias: {prevTerrainLODBias}"); - ImGui.Text($"shadowCascadeValue: {lastShadowCascadeValue}"); - ImGui.Text($"shadowBias: {lastShadowBias}"); - ImGui.Text($"shadowRadius: {lastShadowRadius}"); ImGui.Separator(); #if MOUSE_AND_KEYBOARD_LAYER ImGui.PushID("Mouse/Keyboard"); ImGui.Text("Mouse:"); - ImGui.Text($"Address: {sMhMouse.Instance:x}"); + ImGui.Text($"Address: {sMhMouse.Instance:X}"); ImGui.Text("Keyboard:"); - ImGui.Text($"Address: {sMhKeyboard.Instance:x}"); + ImGui.Text($"Address: {sMhKeyboard.Instance:X}"); ImGui.PopID(); #endif ImGui.PushID("Pad"); ImGui.Text("Pad:"); - ImGui.Text($"Address: {controllerAddr():x}"); + ImGui.Text($"Address: {controllerAddr():X}"); int Rx = MemoryUtil.Read(controllerAddr() + 0x1B0); int Ry = MemoryUtil.Read(controllerAddr() + 0x1B4); int Lx = MemoryUtil.Read(controllerAddr() + 0x1B8); diff --git a/README.txt b/README.txt index 9d33fe6..c3bc6c1 100644 --- a/README.txt +++ b/README.txt @@ -1,4 +1,4 @@ -== MHWNewCamera +== New Camera https://www.nexusmods.com/monsterhunterworld/mods/8300 + https://www.nexusmods.com/monsterhunterworld/mods/8366 + diff --git a/Scripts/zip_from_gamedir.sh b/Scripts/zip_from_gamedir.sh new file mode 100755 index 0000000..ca37151 --- /dev/null +++ b/Scripts/zip_from_gamedir.sh @@ -0,0 +1,19 @@ +#! /usr/bin/env sh + +7z a -tzip "NewCamera_$1_incl_spl_linux.zip" \ + msvcrt.dll \ + nativePC/plugins/CSharp/Loader/Default.bin \ + nativePC/plugins/CSharp/Loader/SharpPluginLoader.Bootstrapper.dll \ + nativePC/plugins/CSharp/Loader/SharpPluginLoader.Core.dll \ + nativePC/plugins/CSharp/Loader/SharpPluginLoader.runtimeconfig.json \ + nativePC/plugins/CSharp/NewCamera.dll \ + nativePC/plugins/CSharp/NewCamera.json \ + nativePC/plugins/CSharp/Shaders/body_skin.shdr \ + nativePC/plugins/CSharp/Shaders/cube_only.shdr \ + nativePC/plugins/CSharp/Shaders/face.shdr \ + nativePC/plugins/CSharp/Shaders/fxaa_max_quality.hlsl \ + nativePC/plugins/CSharp/Shaders/sslr.shdr \ + nativePC/plugins/CSharp/Shaders/volume_upsample.shdr \ + nativePC/plugins/CSharp/Shaders/volume_upsample2.shdr \ + nativePC/plugins/CSharp/WorldTuningTool.dll \ + nativePC/plugins/CSharp/WorldTuningTool.json diff --git a/changelog.txt b/changelog.txt index a56a8f6..18d025c 100644 --- a/changelog.txt +++ b/changelog.txt @@ -70,4 +70,4 @@ == Changelog * Release -// vim: set ft=asciidoc: +// vim: set syntax=asciidoc: -- cgit v1.2.3-101-g0448