added feature to automatically loot enemies

This commit is contained in:
uberhalit 2019-05-04 21:22:52 +02:00
parent 6898302974
commit f485974b6b
6 changed files with 83 additions and 12 deletions

View file

@ -22,6 +22,7 @@ Patches games memory while running, does not modify any game files. Works with e
* disable camera auto rotate adjustment on movement (intended for mouse users)
* disable centering of camera (cam reset) on lock-on if there is no target
* display hidden death/kill counters and optionally log them to file to display in OBS on stream
* automatically loot enemies
* game modifications
* prevent dragonrot from increasing upon death
* disable death penalties like losing Sen or experience
@ -147,6 +148,9 @@ This will completely disable the automatic camera rotation adjustments when you
### On 'Disable camera reset on lock-on':
If you press your target lock-on key and no target is in sight the game will reset and center the camera position and disable your input while it's doing so. Ticking this checkbox will remove this behaviour of the game.
### On 'Automatically loot enemies':
Enabling this will pick up all loot an enemy drops automatically as long as you are in pick-up range.
### On 'Prevent dragonrot increase on death':
This option will remove the effect dragonrot has on NPCs, if an NPC already got dragonrot then it will ensure that their condition won't worsen when you die. The internal dragonrot counter will however keep increasing, nobody will be affected by it though. Keep in mind that there are certain thresholds regarding amount of deaths between dragonrot levels, if you enable this feature and die a level might get skipped so even when you disable it afterwards the dragonrot level for all NPCs will only increase after you have hit the **next** threshold.
@ -236,6 +240,8 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
## Version History
* v1.2.5.0 (2019-05-04)
* added feature to automatically loot enemies
* v1.2.4.0 (2019-05-02)
* added feature to increase spirit emblem capacity on prosthetic upgrades
* changed way to obtain player kills, fixes slow stats updates

View file

@ -286,6 +286,20 @@ namespace SekiroFpsUnlockAndMore
internal static readonly byte[] PATCH_CAMRESET_LOCKON_ENABLE = new byte[1] { 0x01 }; // true
/**
Picking up enemy loot can be automated by setting key press indicator to 1.
0000000140910D14 | C685 30010000 01 | mov byte ptr ss:[rbp+130],1 |
0000000140910D1B | B0 01 | mov al,1 | triggers loot pickup
0000000140910D1D | EB 09 | jmp sekiro.140910D28 |
0000000140910D1F | C685 30010000 00 | mov byte ptr ss:[rbp+130],0 |
0000000140910D26 | 32C0 | xor al,al | resets loot pickup
*/
internal const string PATTERN_AUTOLOOT = "C6 85 ?? ?? ?? ?? ?? B0 01 EB ?? C6 85 ?? ?? ?? ?? ?? 32 C0";
internal const int PATTERN_AUTOLOOT_OFFSET = 18;
internal static readonly byte[] PATCH_AUTOLOOT_ENABLE = new byte[2] { 0xB0, 0x01}; // mov al,1
internal static readonly byte[] PATCH_AUTOLOOT_DISABLE = new byte[2] { 0x32, 0xC0 }; // xor al,al
/**
Whole dragonrot routine upon death is guarded by a conditional jump, there may be some events in the game where a true death shall not increase the disease so it's skippable as a whole.
We replace conditional jump with non-conditional one.

View file

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:SekiroFpsUnlockAndMore"
mc:Ignorable="d"
Title="Sekiro FPS Unlocker and more v1.2.4" Width="Auto" Height="Auto" SizeToContent="WidthAndHeight" ResizeMode="CanMinimize" Loaded="Window_Loaded" Closing="Window_Closing">
Title="Sekiro FPS Unlocker and more v1.2.5" Width="Auto" Height="Auto" SizeToContent="WidthAndHeight" ResizeMode="CanMinimize" Loaded="Window_Loaded" Closing="Window_Closing">
<Grid Background="#FFF9F9F9">
<DockPanel>
@ -37,23 +37,24 @@
<StackPanel Width="Auto" Height="Auto">
<CheckBox x:Name="cbCamAdjust" Margin="0,5,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Disable camera auto rotate on movement" ToolTip="Disables the annoying automatic camera adjustment on movement. Intended for mouse users" Checked="CbCamAdjust_Check_Handler" Unchecked="CbCamAdjust_Check_Handler" TabIndex="12" />
<CheckBox x:Name="cbCamReset" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Disable camera reset on lock-on" ToolTip="Disables the annoying camera centering on lock-on when there is no target" Checked="CbCamReset_Check_Handler" Unchecked="CbCamReset_Check_Handler" TabIndex="13" />
<CheckBox x:Name="cbDragonrot" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Prevent dragonrot increase on death" ToolTip="NPCs won't get the disease and/or their condition won't get worse" Checked="CbDragonrot_Check_Handler" Unchecked="CbDragonrot_Check_Handler" TabIndex="14" />
<CheckBox x:Name="cbDeathPenalty" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Disable death penalties (except dragonrot)" ToolTip="Disables Sen and Experience loss upon death" Checked="CbDeathPenalty_Check_Handler" Unchecked="CbDeathPenalty_Check_Handler" TabIndex="15" />
<CheckBox x:Name="cbAutoLoot" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Automatically loot enemies" ToolTip="Automatically pickup and collect all enemy loot/items" TabIndex="14" Checked="CbAutoLoot_Check_Handler" Unchecked="CbAutoLoot_Check_Handler" />
<CheckBox x:Name="cbDragonrot" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Prevent dragonrot increase on death" ToolTip="NPCs won't get the disease and/or their condition won't get worse" Checked="CbDragonrot_Check_Handler" Unchecked="CbDragonrot_Check_Handler" TabIndex="15" />
<CheckBox x:Name="cbDeathPenalty" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Disable death penalties (except dragonrot)" ToolTip="Disables Sen and Experience loss upon death" Checked="CbDeathPenalty_Check_Handler" Unchecked="CbDeathPenalty_Check_Handler" TabIndex="16" />
<CheckBox x:Name="cbDeathPenaltyHidden" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="(DEBUG) Disable hidden death penalties" ToolTip="DEBUG ONLY" Checked="CbDeathPenaltyHidden_Check_Handler" Unchecked="CbDeathPenaltyHidden_Check_Handler" IsTabStop="False" Visibility="Collapsed" />
<CheckBox x:Name="cbEmblemUpgrade" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Increase spirit emblem cap. on upgrades" ToolTip="Every prosthetic upgrade will increase maximum emblem capacity by 1. PERMANENT INCREASE!" Checked="CbEmblemUpgrade_Check_Handler" Unchecked="CbEmblemUpgrade_Check_Handler" TabIndex="16"/>
<CheckBox x:Name="cbEmblemUpgrade" Margin="0,3,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Increase spirit emblem cap. on upgrades" ToolTip="Every prosthetic upgrade will increase maximum emblem capacity by 1. PERMANENT INCREASE!" Checked="CbEmblemUpgrade_Check_Handler" Unchecked="CbEmblemUpgrade_Check_Handler" TabIndex="17"/>
<DockPanel Margin="0,3,0,0" LastChildFill="False">
<CheckBox x:Name="cbGameSpeed" DockPanel.Dock="Left" Margin="0,0,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Game speed (%):" ToolTip="Increase or decrease. Can potentially crash the game in cutscenes, use with caution" Checked="CbGameSpeed_Check_Handler" Unchecked="CbGameSpeed_Check_Handler" TabIndex="17" />
<CheckBox x:Name="cbGameSpeed" DockPanel.Dock="Left" Margin="0,0,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Game speed (%):" ToolTip="Increase or decrease. Can potentially crash the game in cutscenes, use with caution" Checked="CbGameSpeed_Check_Handler" Unchecked="CbGameSpeed_Check_Handler" TabIndex="18" />
<Button x:Name="bGs100" DockPanel.Dock="Right" Content="100" Margin="0,0,0,0" Width="30" Height="25" FontSize="14 px" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Focusable="False" Click="BGs100_Click" />
<Button x:Name="bGsHigher" DockPanel.Dock="Right" Content="&gt;" Margin="0,0,3,0" Width="25" Height="25" FontSize="14 px" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Focusable="False" Click="BGsHigher_Click" />
<TextBox x:Name="tbGameSpeed" DockPanel.Dock="Right" Margin="0,0,3,0" Width="30" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Text="100" TextAlignment="Center" MaxLength="3" PreviewTextInput="Numeric_PreviewTextInput" DataObject.Pasting="Numeric_PastingHandler" TabIndex="18" />
<TextBox x:Name="tbGameSpeed" DockPanel.Dock="Right" Margin="0,0,3,0" Width="30" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Text="100" TextAlignment="Center" MaxLength="3" PreviewTextInput="Numeric_PreviewTextInput" DataObject.Pasting="Numeric_PastingHandler" TabIndex="19" />
<Button x:Name="bGsLower" DockPanel.Dock="Right" Content="&lt;" Margin="0,0,3,0" Width="25" Height="25" FontSize="14 px" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Focusable="False" Click="BGsLower_Click" />
<Button x:Name="bGs0" DockPanel.Dock="Right" Content="0" Margin="0,0,3,0" Width="30" Height="25" FontSize="14 px" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Focusable="False" Click="BGs0_Click" />
</DockPanel>
<DockPanel Margin="0,5,0,0" LastChildFill="False">
<CheckBox x:Name="cbPlayerSpeed" DockPanel.Dock="Left" Margin="0,0,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Player speed (%):" ToolTip="Increase or decrease. To enable this start the game and load a save, then tick the checkbox. Can potentially crash the game in cutscenes, use with caution" Checked="CbPlayerSpeed_Check_Handler" Unchecked="CbPlayerSpeed_Check_Handler" TabIndex="19" />
<CheckBox x:Name="cbPlayerSpeed" DockPanel.Dock="Left" Margin="0,0,0,0" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Content="Player speed (%):" ToolTip="Increase or decrease. To enable this start the game and load a save, then tick the checkbox. Can potentially crash the game in cutscenes, use with caution" Checked="CbPlayerSpeed_Check_Handler" Unchecked="CbPlayerSpeed_Check_Handler" TabIndex="20" />
<Button x:Name="bPs100" DockPanel.Dock="Right" Content="100" Margin="0,0,0,0" Width="30" Height="25" FontSize="14 px" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Focusable="False" Click="BPs100_Click" />
<Button x:Name="bPsHigher" DockPanel.Dock="Right" Content="&gt;" Margin="0,0,3,0" Width="25" Height="25" FontSize="14 px" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Focusable="False" Click="BPsHigher_Click" />
<TextBox x:Name="tbPlayerSpeed" DockPanel.Dock="Right" Margin="0,0,3,0" Width="30" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Text="100" TextAlignment="Center" MaxLength="3" PreviewTextInput="Numeric_PreviewTextInput" DataObject.Pasting="Numeric_PastingHandler" TabIndex="20" />
<TextBox x:Name="tbPlayerSpeed" DockPanel.Dock="Right" Margin="0,0,3,0" Width="30" Height="25" FontSize="14 px" VerticalContentAlignment="Center" Text="100" TextAlignment="Center" MaxLength="3" PreviewTextInput="Numeric_PreviewTextInput" DataObject.Pasting="Numeric_PastingHandler" TabIndex="21" />
<Button x:Name="bPsLower" DockPanel.Dock="Right" Content="&lt;" Margin="0,0,3,0" Width="25" Height="25" FontSize="14 px" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Focusable="False" Click="BPsLower_Click" />
<Button x:Name="bPs0" DockPanel.Dock="Right" Content="0" Margin="0,0,3,0" Width="30" Height="25" FontSize="14 px" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" Focusable="False" Click="BPs0_Click" />
</DockPanel>
@ -63,7 +64,7 @@
<Button x:Name="bPatch" Margin="0,7,0,0" Width="300" Height="30" FontSize="14 px" IsEnabled="False" Content="Patch game (CTRL + P)" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
Focusable="False" Click="BPatch_Click" TabIndex="20" IsTabStop="False" />
<TextBox x:Name="tbStatus" Margin="0,5,0,0" Width="300" Height="25" FontSize="14 px" FontWeight="Bold" Text="waiting for game..." TextAlignment="Center" TextWrapping="NoWrap" IsEnabled="False" />
<Expander x:Name="exGuide" Margin="0,8,0,0" Height="Auto" FontSize="14 px" Header="ReadMe" IsExpanded="True" TabIndex="21">
<Expander x:Name="exGuide" Margin="0,8,0,0" Height="Auto" FontSize="14 px" Header="ReadMe" IsExpanded="True" TabIndex="22">
<TextBlock Margin="2,6,2,0" FontSize="11 px" TextWrapping="WrapWithOverflow" IsEnabled="False">
<TextBlock.Inlines>
<Run FontWeight="Bold" Foreground="#FF0046FF">This patcher does not modify game files, you have to start it every time.</Run>
@ -87,7 +88,7 @@
</Expander>
<Label HorizontalAlignment="Right" FontSize="12 px" TabIndex="22">
<Hyperlink NavigateUri="https://github.com/uberhalit/SekiroFpsUnlockAndMore" RequestNavigate="Hyperlink_RequestNavigate">
v1.2.4 - by uberhalit
v1.2.5 - by uberhalit
</Hyperlink>
</Label>
</StackPanel>

View file

@ -29,6 +29,7 @@ namespace SekiroFpsUnlockAndMore
internal long _offset_player_deaths = 0x0;
internal long _offset_total_kills = 0x0;
internal long _offset_camera_reset = 0x0;
internal long _offset_autoloot = 0x0;
internal long _offset_dragonrot_routine = 0x0;
internal long _offset_deathpenalties1 = 0x0;
internal long _offset_deathpenalties2 = 0x0;
@ -199,6 +200,7 @@ namespace SekiroFpsUnlockAndMore
this.exGameMods.IsExpanded = _settingsService.ApplicationSettings.exGameMods;
this.cbCamAdjust.IsChecked = _settingsService.ApplicationSettings.cbCamAdjust;
this.cbCamReset.IsChecked = _settingsService.ApplicationSettings.cbCamReset;
this.cbAutoLoot.IsChecked = _settingsService.ApplicationSettings.cbAutoLoot;
this.cbDragonrot.IsChecked = _settingsService.ApplicationSettings.cbDragonrot;
this.cbDeathPenalty.IsChecked = _settingsService.ApplicationSettings.cbDeathPenalty;
this.cbDeathPenaltyHidden.Visibility = _settingsService.ApplicationSettings.hiddenDPs == ZUH_HIDDEN_DP ? Visibility.Visible : Visibility.Collapsed;
@ -229,6 +231,7 @@ namespace SekiroFpsUnlockAndMore
_settingsService.ApplicationSettings.exGameMods = this.exGameMods.IsExpanded;
_settingsService.ApplicationSettings.cbCamAdjust = this.cbCamAdjust.IsChecked == true;
_settingsService.ApplicationSettings.cbCamReset = this.cbCamReset.IsChecked == true;
_settingsService.ApplicationSettings.cbAutoLoot = this.cbAutoLoot.IsChecked == true;
_settingsService.ApplicationSettings.cbDragonrot = this.cbDragonrot.IsChecked == true;
_settingsService.ApplicationSettings.cbDeathPenalty = this.cbDeathPenalty.IsChecked == true;
_settingsService.ApplicationSettings.cbEmblemUpgrade = this.cbEmblemUpgrade.IsChecked == true;
@ -258,9 +261,11 @@ namespace SekiroFpsUnlockAndMore
this.exGameMods.IsExpanded = true;
this.cbCamAdjust.IsChecked = false;
this.cbCamReset.IsChecked = false;
this.cbAutoLoot.IsChecked = false;
this.cbDragonrot.IsChecked = false;
this.cbDeathPenalty.IsChecked = false;
this.cbDeathPenaltyHidden.Visibility = Visibility.Collapsed;
this.cbEmblemUpgrade.IsChecked = false;
this.cbGameSpeed.IsChecked = false;
this.tbGameSpeed.Text = "100";
this.cbPlayerSpeed.IsChecked = false;
@ -446,6 +451,11 @@ namespace SekiroFpsUnlockAndMore
if (!IsValidAddress(_offset_total_kills))
_offset_total_kills = 0x0;
_offset_autoloot = patternScan.FindPattern(GameData.PATTERN_AUTOLOOT) + GameData.PATTERN_AUTOLOOT_OFFSET;
Debug.WriteLine("lpAutoLoot found at: 0x" + _offset_autoloot.ToString("X"));
if (!IsValidAddress(_offset_autoloot))
_offset_autoloot = 0x0;
long lpCamAdjustPitch = patternScan.FindPattern(GameData.PATTERN_CAMADJUST_PITCH);
long lpCamAdjustYawZ = patternScan.FindPattern(GameData.PATTERN_CAMADJUST_YAW_Z) + GameData.PATTERN_CAMADJUST_YAW_Z_OFFSET;
long lpCamAdjustPitchXY = patternScan.FindPattern(GameData.PATTERN_CAMADJUST_PITCH_XY);
@ -655,6 +665,13 @@ namespace SekiroFpsUnlockAndMore
this.cbCamReset.IsEnabled = false;
}
if (_offset_autoloot == 0x0)
{
UpdateStatus("auto loot not found...", Brushes.Red);
LogToFile("auto loot not found...");
this.cbAutoLoot.IsEnabled = false;
}
if (_offset_dragonrot_routine == 0x0)
{
UpdateStatus("dragonrot not found...", Brushes.Red);
@ -757,6 +774,7 @@ namespace SekiroFpsUnlockAndMore
_codeCave_camadjust = false;
_offset_camera_reset = 0x0;
_offset_dragonrot_routine = 0x0;
_offset_autoloot = 0x0;
_offset_deathpenalties1 = 0x0;
_offset_deathpenalties2 = 0x0;
_offset_deathscounter_routine = 0x0;
@ -991,6 +1009,29 @@ namespace SekiroFpsUnlockAndMore
return true;
}
/// <summary>
/// Patches the game's auto loot.
/// </summary>
/// <param name="showStatus">Determines if status should be updated from within method, default is true.</param>
private bool PatchAutoloot(bool showStatus = true)
{
if (!this.cbAutoLoot.IsEnabled || _offset_autoloot == 0x0 || !CanPatchGame()) return false;
if (this.cbAutoLoot.IsChecked == true)
{
WriteBytes(_gameAccessHwndStatic, _offset_autoloot, GameData.PATCH_AUTOLOOT_ENABLE);
}
else if (this.cbAutoLoot.IsChecked == false)
{
if (!_initialStartup)
WriteBytes(_gameAccessHwndStatic, _offset_autoloot, GameData.PATCH_AUTOLOOT_DISABLE);
if (showStatus) UpdateStatus(DateTime.Now.ToString("HH:mm:ss") + " Game unpatched!", Brushes.White);
return false;
}
if (showStatus) UpdateStatus(DateTime.Now.ToString("HH:mm:ss") + " Game patched!", Brushes.Green);
return true;
}
/// <summary>
/// Patches the game's dragonrot effect on NPCs.
/// </summary>
@ -1169,6 +1210,7 @@ namespace SekiroFpsUnlockAndMore
PatchFov(false),
PatchWindow(false),
PatchCamReset(false),
PatchAutoloot(false),
PatchDragonrot(false),
PatchDeathPenalty(false),
PatchGameSpeed(false),
@ -1693,6 +1735,12 @@ namespace SekiroFpsUnlockAndMore
PatchCamReset();
}
private void CbAutoLoot_Check_Handler(object sender, RoutedEventArgs e)
{
if (this.cbAutoLoot.IsEnabled == true)
PatchAutoloot();
}
private void CbDragonrot_Check_Handler(object sender, RoutedEventArgs e)
{
if (this.cbDragonrot.IsEnabled)

View file

@ -18,5 +18,5 @@ using System.Runtime.InteropServices;
ResourceDictionaryLocation.SourceAssembly
)]
[assembly: AssemblyVersion("1.2.4.0")]
[assembly: AssemblyFileVersion("1.2.4.0")]
[assembly: AssemblyVersion("1.2.5.0")]
[assembly: AssemblyFileVersion("1.2.5.0")]

View file

@ -45,6 +45,8 @@ namespace SekiroFpsUnlockAndMore
[XmlElement]
public bool cbCamReset { get; set; }
[XmlElement]
public bool cbAutoLoot { get; set; }
[XmlElement]
public bool cbDragonrot { get; set; }
[XmlElement]
public bool cbDeathPenalty { get; set; }