mirror of
https://github.com/uberhalit/SekiroFpsUnlockAndMore.git
synced 2026-06-13 09:57:55 +00:00
Added an option to output player death counter and kill counter to files. Useful for display on twitch stream.
This commit is contained in:
parent
f0ad1e49fa
commit
8ffe1615e4
1 changed files with 98 additions and 13 deletions
|
|
@ -11,6 +11,8 @@ using System.Windows.Threading;
|
|||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Timers;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
namespace SekiroFpsUnlockAndMore
|
||||
{
|
||||
|
|
@ -26,11 +28,20 @@ namespace SekiroFpsUnlockAndMore
|
|||
internal long _offset_resolution_default = 0x0;
|
||||
internal long _offset_resolution_scaling_fix = 0x0;
|
||||
internal long _offset_fovsetting = 0x0;
|
||||
//game stat offsets
|
||||
internal long _offset_player_deaths = 0x0;
|
||||
internal long _pointer_player_deaths = 0x0;
|
||||
internal long _offset_timescale = 0x0;
|
||||
internal long _offset_timescale_player = 0x0;
|
||||
internal bool _use_resolution_720 = false;
|
||||
internal long _offset_total_kills = 0x0;
|
||||
internal long _pointer_total_kills = 0x0;
|
||||
|
||||
internal const string deathCounterFilename = "DeathCouner.txt";
|
||||
internal SettingsService _settingsService;
|
||||
internal const string totalKillsFilename = "TotalKillsCounter.txt";
|
||||
|
||||
internal readonly Timer _statRecordTimer = new Timer();
|
||||
internal readonly DispatcherTimer _dispatcherTimerCheck = new DispatcherTimer();
|
||||
internal bool _running = false;
|
||||
internal string _logPath;
|
||||
|
|
@ -75,6 +86,9 @@ namespace SekiroFpsUnlockAndMore
|
|||
});
|
||||
_dispatcherTimerCheck.Interval = new TimeSpan(0, 0, 0, 2);
|
||||
_dispatcherTimerCheck.Start();
|
||||
|
||||
_statRecordTimer.Elapsed += new ElapsedEventHandler(StatReadTimer);
|
||||
_statRecordTimer.Interval = 1500;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -88,6 +102,8 @@ namespace SekiroFpsUnlockAndMore
|
|||
UnregisterHotKey(hWnd, 9009);
|
||||
if (_gameAccessHwnd != IntPtr.Zero)
|
||||
CloseHandle(_gameAccessHwnd);
|
||||
|
||||
_statRecordTimer.Stop();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -288,6 +304,29 @@ namespace SekiroFpsUnlockAndMore
|
|||
this.cbFov.IsEnabled = false;
|
||||
}
|
||||
|
||||
//Game stats
|
||||
_offset_player_deaths = patternScan.FindPatternInternal(_gameAccessHwndStatic, procList[gameIndex].MainModule, GameData.PATTERN_PLAYER_DEATHS, GameData.PATTERN_PLAYER_DEATHS_MASK, ' ');
|
||||
Debug.WriteLine("Player Deaths found at: 0x" + _offset_player_deaths.ToString("X"));
|
||||
if (!IsValidAddress(_offset_player_deaths))
|
||||
{
|
||||
LogToFile("Player death counter not found...");
|
||||
}
|
||||
else
|
||||
{
|
||||
_pointer_player_deaths = Read<Int64>(_gameAccessHwndStatic, DereferenceStaticX64Pointer(_gameAccessHwndStatic, _offset_player_deaths, 0)) + 0x90;
|
||||
}
|
||||
|
||||
_offset_total_kills = patternScan.FindPatternInternal(_gameProc, procList[gameIndex].MainModule, GameData.PATTERN_TOTAL_KILLS, GameData.PATTERN_TOTAL_KILLS_MASK, ' ') + GameData.PATTERN_TOTAL_KILLS_OFFSET;
|
||||
Debug.WriteLine("Total kills found at: 0x" + _offset_total_kills.ToString("X"));
|
||||
if (!IsValidAddress(_offset_total_kills))
|
||||
{
|
||||
LogToFile("Total kills counter not found...");
|
||||
}
|
||||
else
|
||||
{
|
||||
_pointer_total_kills = DereferenceStaticX64Pointer(_gameAccessHwndStatic, _offset_total_kills, 0);
|
||||
}
|
||||
|
||||
this.cbBorderless.IsEnabled = true;
|
||||
|
||||
long offset_pTimeRelated = patternScan.FindPatternInternal(GameData.PATTERN_TIMESCALE, GameData.PATTERN_TIMESCALE_MASK, ' ');
|
||||
|
|
@ -655,6 +694,27 @@ namespace SekiroFpsUnlockAndMore
|
|||
UpdateStatus(DateTime.Now.ToString("HH:mm:ss") + " Game unpatched!", Brushes.White);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads some hidden stats and outputs them to text files. Use to display counters on Twitch stream or just look at them and get disspointed
|
||||
/// </summary
|
||||
private void StatReadTimer(object sender, EventArgs e)
|
||||
{
|
||||
if (IsValidAddress(_pointer_player_deaths))
|
||||
{
|
||||
int playerDeaths = Read<Int32>(_gameAccessHwndStatic, _pointer_player_deaths);
|
||||
//Debug.WriteLine("[STAT]Player deaths: " + playerDeaths);
|
||||
LogStatFile(deathCounterFilename, playerDeaths.ToString());
|
||||
|
||||
if (IsValidAddress(_pointer_total_kills))
|
||||
{
|
||||
int totalKills = Read<Int32>(_gameAccessHwndStatic, _pointer_total_kills);
|
||||
totalKills -= playerDeaths; //Since this value seems to track every death, including the player
|
||||
//Debug.WriteLine("[STAT]Enemies killed: " + totalKills);
|
||||
LogStatFile(totalKillsFilename, totalKills.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the hexadecimal representation of an IEEE-754 floating point number
|
||||
/// </summary>
|
||||
|
|
@ -848,6 +908,26 @@ namespace SekiroFpsUnlockAndMore
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Logs stat values to separate files for the use in OBS
|
||||
/// </summary>
|
||||
/// <param name="filename">File name</param>
|
||||
/// <param name="msg">Just a single stat value</param>
|
||||
private void LogStatFile(string filename, string value)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (StreamWriter writer = new StreamWriter(filename, false))
|
||||
{
|
||||
writer.Write(value);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show("Failed writing stat file: " + ex.Message, "Sekiro Fps Unlock And More");
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateStatus(string text, Brush color)
|
||||
{
|
||||
this.tbStatus.Background = color;
|
||||
|
|
@ -985,6 +1065,11 @@ namespace SekiroFpsUnlockAndMore
|
|||
if (this.cbPlayerSpeed.IsChecked == true) PatchPlayerSpeed();
|
||||
}
|
||||
|
||||
private void CbStatChanged(object sender, RoutedEventArgs e)
|
||||
{
|
||||
_statRecordTimer.Enabled = (bool)cbLogStats.IsChecked;
|
||||
}
|
||||
|
||||
private void BPatch_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
PatchGame();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue