Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TarnishedTool/Memory/AobScanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public void QueueFallbackPatterns()
Queue(nameof(Pattern.NoRuneLossOnDeath), Pattern.NoRuneLossOnDeath,
addr => Patches.NoRuneLossOnDeath = addr);
Queue(nameof(Pattern.IsWorldPaused), Pattern.IsWorldPaused, addr => Patches.IsWorldPaused = addr);
Queue(nameof(Pattern.ShouldPauseWorld), Pattern.ShouldPauseWorld, addr => Patches.ShouldPauseWorld = addr);
Queue(nameof(Pattern.GetItemChance), Pattern.GetItemChance, addr => Patches.GetItemChance = addr);
Queue(nameof(Pattern.OpenMap), Pattern.OpenMap, addr => Patches.OpenMap = addr);
Queue(nameof(Pattern.CloseMap), Pattern.CloseMap, addr => Patches.CloseMap = addr);
Expand Down
8 changes: 8 additions & 0 deletions TarnishedTool/Memory/Offsets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,7 @@ public static class Patches
public static nint IsTorrentDisabledInUnderworld;
public static nint IsWhistleDisabled;
public static nint IsWorldPaused;
public static nint ShouldPauseWorld;
public static nint GetItemChance;
public static nint FpsCap;
public static nint MenuDelay;
Expand Down Expand Up @@ -3229,6 +3230,12 @@ Version2_2_0 or Version2_2_3 or Version2_3_0 or Version2_4_0 or Version2_5_0
_ => 0
};

Patches.ShouldPauseWorld = moduleBase + Version switch
{
Version2_7_2 => 0xAF9F45,
_ => 0
};

Patches.GetItemChance = moduleBase + Version switch
{
Version1_2_0 => 0xCC9E0E,
Expand Down Expand Up @@ -3505,6 +3512,7 @@ public static void Print(nint moduleBase)
PrintOffset("IsTorrentDisabledInUnderworld",Patches.IsTorrentDisabledInUnderworld);
PrintOffset("IsWhistleDisabled", Patches.IsWhistleDisabled);
PrintOffset("IsWorldPaused", Patches.IsWorldPaused);
PrintOffset("ShouldPauseWorld", Patches.ShouldPauseWorld);
PrintOffset("GetItemChance", Patches.GetItemChance);
PrintOffset("GetShopEvent", Patches.GetShopEvent);
PrintOffset("FpsCap", Patches.FpsCap);
Expand Down
7 changes: 7 additions & 0 deletions TarnishedTool/Memory/Pattern.cs
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,13 @@ public class Pattern(
anchorOffset: 1
);

public static readonly Pattern ShouldPauseWorld = new Pattern(
[0x84, 0xC0, 0x74, 0x09, 0x66, 0xC7, 0x83, 0xB8, 0x04, 0x00, 0x00, 0x00, 0x01],
"xxxxxxxxxxxxx",
2,
AddressingMode.Absolute
);

public static readonly Pattern IsTorrentDisabledInUnderworld = new Pattern(
[0x80, 0x78, 0x36, 0x00, 0x0F],
"xxxxx",
Expand Down
42 changes: 40 additions & 2 deletions TarnishedTool/Services/UtilityService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Numerics;
using System.Threading;
using TarnishedTool.Enums;
using TarnishedTool.Interfaces;
using TarnishedTool.Memory;
Expand All @@ -12,6 +13,9 @@ public class UtilityService(IMemoryService memoryService, HookManager hookManage
: IUtilityService
{
public const float DefaultNoClipSpeedScale = 0.2f;

private const float FreezeWorldSettleSpeed = 0.0001f;
private const int FreezeWorldSettleFrames = 3;

public void Quitout() =>
memoryService.Write(memoryService.Read<nint>(GameMan.Base) + GameMan.ShouldQuitout, (byte)1);
Expand Down Expand Up @@ -239,8 +243,42 @@ public void MovePlayerToCam()
}
}

public void ToggleFreezeWorld(bool isEnabled) =>
memoryService.WriteBytes(Patches.IsWorldPaused, isEnabled ? [0x0F, 0x85] : [0x0F, 0x84]);
public void ToggleFreezeWorld(bool isEnabled)
{
if (isEnabled)
{
// Zero out bone motion first so TAA doesn't smear frozen characters
var speed = GetSpeed();
SetSpeed(FreezeWorldSettleSpeed);
WaitFrames(FreezeWorldSettleFrames);
WriteFreezeWorldPatch(true);
WaitFrames(FreezeWorldSettleFrames);
SetSpeed(speed);
}
else
{
WriteFreezeWorldPatch(false);
WaitFrames(FreezeWorldSettleFrames);
}
}

private void WriteFreezeWorldPatch(bool isEnabled)
{
if (Patches.ShouldPauseWorld <= memoryService.BaseAddress)
{
memoryService.WriteBytes(Patches.IsWorldPaused, isEnabled ? [0x0F, 0x85] : [0x0F, 0x84]);
return;
}

memoryService.WriteBytes(Patches.ShouldPauseWorld, isEnabled ? [0x90, 0x90] : [0x74, 0x09]);
}

private void WaitFrames(int frames)
{
var frameTime = memoryService.Read<float>(Patches.FpsCap + 0x3);
frameTime = Math.Min(Math.Max(frameTime, 1f / 60), 1f / 15);
Thread.Sleep((int)(frameTime * 1000 * frames));
}

public void ToggleDrawHitbox(bool isDrawHitboxEnabled) =>
memoryService.Write(memoryService.Read<nint>(DamageManager.Base) + DamageManager.HitboxView,
Expand Down
1 change: 1 addition & 0 deletions TarnishedTool/ViewModels/UtilityViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,7 @@ private void OnGameNotLoaded()
{
AreOptionsEnabled = false;
IsFreeCamEnabled = false;
IsFreezeWorldEnabled = false;
if (IsDrawLowHitEnabled)
{
_utilityService.ToggleDrawLowHit(false);
Expand Down