Skip to content
Open
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 @@ -99,6 +99,7 @@ public void QueueFallbackPatterns()
Queue(nameof(Pattern.MapDebugFlags), Pattern.MapDebugFlags, addr => MapDebugFlags.Base = addr - 1);
Queue(nameof(Pattern.WorldAiManagerImp), Pattern.WorldAiManagerImp, addr => WorldAiManagerImp.Base = addr);
Queue(nameof(Pattern.CSSound), Pattern.CSSound, addr => CSSound.Base = addr);
Queue(nameof(Pattern.GxRenderer), Pattern.GxRenderer, addr => GxRenderer.Base = addr);

Queue(nameof(Pattern.GraceWarp), Pattern.GraceWarp, addr => Functions.GraceWarp = addr);
Queue(nameof(Pattern.SetEvent), Pattern.SetEvent, addr => Functions.SetEvent = addr);
Expand Down
16 changes: 16 additions & 0 deletions TarnishedTool/Memory/Offsets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -883,6 +883,15 @@ public static class CSSound
public static nint Base;
}

public static class GxRenderer
{
public static nint Base;

public const int AaConfig = 0x13A60;
public const int DisableTaa = 0x9;
public const int EnableMotionBlur = 0x20;
}

public static class Hooks
{
public static nint UpdateCoords;
Expand Down Expand Up @@ -1561,6 +1570,12 @@ Version2_2_0 or Version2_4_0 or Version2_5_0
_ => 0
};

GxRenderer.Base = moduleBase + Version switch
{
Version2_7_2 => 0x47F67C8,
_ => 0
};


// Functions
Functions.GraceWarp = moduleBase + Version switch
Expand Down Expand Up @@ -3432,6 +3447,7 @@ public static void Print(nint moduleBase)
PrintOffset("DrawPathing.Base", DrawPathing.Base);
PrintOffset("WorldAiManagerImp.Base", WorldAiManagerImp.Base);
PrintOffset("CSSound.Base", CSSound.Base);
PrintOffset("GxRenderer.Base", GxRenderer.Base);

Console.WriteLine("\n--- Functions ---");
PrintOffset("GraceWarp", Functions.GraceWarp);
Expand Down
11 changes: 11 additions & 0 deletions TarnishedTool/Memory/Pattern.cs
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,17 @@ public class Pattern(
7
);

public static readonly Pattern GxRenderer = new(
[
0x48, 0x8B, 0x15, 0x00, 0x00, 0x00, 0x00, 0x48, 0x85, 0xD2, 0x74, 0x28, 0x48, 0x8B, 0x82, 0x60, 0x3A, 0x01, 0x00
],
"xxx????xxxxxxxxxxxx",
0,
AddressingMode.Relative,
3,
7
);

//Hooks

public static readonly Pattern NoTimePassOnDeath = new Pattern(
Expand Down
34 changes: 33 additions & 1 deletion TarnishedTool/Services/UtilityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class UtilityService(IMemoryService memoryService, HookManager hookManage
: IUtilityService
{
public const float DefaultNoClipSpeedScale = 0.2f;
private readonly FreeCamInputController _freeCamInput = new(memoryService);
private byte? _savedMotionBlur;

public void Quitout() =>
memoryService.Write(memoryService.Read<nint>(GameMan.Base) + GameMan.ShouldQuitout, (byte)1);
Expand Down Expand Up @@ -203,9 +205,13 @@ public void ToggleFreeCam(bool isEnabled)
{
memoryService.WriteBytes(patchLoc, [0xB0, 0x01, 0xC3]);
memoryService.Write(camMode, (byte)1);
SetFreeCamActionBlock(true);
_freeCamInput.Start();
}
else
{
_freeCamInput.Stop();
SetFreeCamActionBlock(false);
memoryService.WriteBytes(patchLoc, [0xEB, 0x80, 0xCC]);
memoryService.Write(camMode, (byte)0);
}
Expand All @@ -215,6 +221,15 @@ public void TogglePlayerMovementForFreeCam(bool isEnabled)
{
var camMode = memoryService.FollowPointers(FieldArea.Base, [FieldArea.GameRend, FieldArea.CamMode], false);
memoryService.Write(camMode, isEnabled ? (byte)3 : (byte)1);
SetFreeCamActionBlock(!isEnabled);
}

private void SetFreeCamActionBlock(bool block)
{
if (Hooks.SetActionRequested <= memoryService.BaseAddress) return;
if (hookManager.IsHookInstalled(CodeCaveOffsets.Base + CodeCaveOffsets.ActionRequestIntercept)) return;
memoryService.WriteBytes(Hooks.SetActionRequested,
block ? [0x90, 0x90, 0x90, 0x90] : [0x49, 0x09, 0x41, 0x10]);
}

public void MoveCamToPlayer()
Expand All @@ -239,8 +254,25 @@ public void MovePlayerToCam()
}
}

public void ToggleFreezeWorld(bool isEnabled) =>
public void ToggleFreezeWorld(bool isEnabled)
{
memoryService.WriteBytes(Patches.IsWorldPaused, isEnabled ? [0x0F, 0x85] : [0x0F, 0x84]);
if (GxRenderer.Base <= memoryService.BaseAddress) return;
var aaConfig = memoryService.FollowPointers(GxRenderer.Base, [GxRenderer.AaConfig], true);
if (aaConfig == 0) return;

memoryService.Write(aaConfig + GxRenderer.DisableTaa, isEnabled);
if (isEnabled)
{
_savedMotionBlur ??= memoryService.Read<byte>(aaConfig + GxRenderer.EnableMotionBlur);
memoryService.Write(aaConfig + GxRenderer.EnableMotionBlur, (byte)0);
}
else if (_savedMotionBlur.HasValue)
{
memoryService.Write(aaConfig + GxRenderer.EnableMotionBlur, _savedMotionBlur.Value);
_savedMotionBlur = null;
}
}

public void ToggleDrawHitbox(bool isDrawHitboxEnabled) =>
memoryService.Write(memoryService.Read<nint>(DamageManager.Base) + DamageManager.HitboxView,
Expand Down
5 changes: 5 additions & 0 deletions TarnishedTool/TarnishedTool.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@
<Compile Include="Utilities\PositionUtils.cs" />
<Compile Include="Utilities\DataLoader.cs" />
<Compile Include="Utilities\ExeManager.cs" />
<Compile Include="Utilities\FreeCamInputController.cs" />
<Compile Include="Utilities\HotkeyManager.cs" />
<Compile Include="Utilities\MsgBox.cs" />
<Compile Include="Utilities\SearchExtensions.cs" />
Expand Down Expand Up @@ -495,6 +496,9 @@
<Compile Include="Views\Windows\EventLogWindow.xaml.cs">
<DependentUpon>EventLogWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Windows\FreeCamKeybindsWindow.xaml.cs">
<DependentUpon>FreeCamKeybindsWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\Windows\AiWindow.xaml.cs">
<DependentUpon>AiWindow.xaml</DependentUpon>
</Compile>
Expand Down Expand Up @@ -564,6 +568,7 @@
<Page Include="Views\Windows\CustomWarpImportSelectionWindow.xaml" />
<Page Include="Views\Windows\DefensesWindow.xaml" />
<Page Include="Views\Windows\EventLogWindow.xaml" />
<Page Include="Views\Windows\FreeCamKeybindsWindow.xaml" />
<Page Include="Views\Windows\AiWindow.xaml" />
<Page Include="Views\Windows\GestureSelectionWindow.xaml" />
<Page Include="Views\Windows\GraceImportPresentSelectionWindow.xaml" />
Expand Down
Loading