Skip to content

Commit

Permalink
Merge pull request #487 from pas-de-2/manualreload
Browse files Browse the repository at this point in the history
Added DisableAutomaticReload option
  • Loading branch information
nipkownix committed Mar 17, 2023
2 parents 78f28f7 + 7ef0426 commit 674116a
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 0 deletions.
24 changes: 24 additions & 0 deletions dllmain/Gameplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,30 @@ void re4t::init::Gameplay()
InjectHook(injector::GetBranchDestination(pattern.count(1).get(0).get<uint32_t>(3)).as_int(), cPlayer__weaponInit_Hook, PATCH_JUMP);
}

// Disable Automatic Reload
{
auto pattern = hook::pattern("8B 86 D8 07 00 00 8B 48 34 8B 11 8B 42 4C FF D0");
struct DisableReloadCheck
{
void operator()(injector::reg_pack& regs)
{
if (PlayerPtr()->Wep_7D8->m_pWep_34->reloadable() && !re4t::cfg->bDisableAutomaticReload)
regs.ef &= ~(1 << regs.zero_flag);
else
regs.ef |= (1 << regs.zero_flag);
}
};
// for Handguns, Matilda, TMP, Shotguns
injector::MakeInline<DisableReloadCheck>(pattern.count(5).get(0).get<uint32_t>(0), pattern.count(5).get(0).get<uint32_t>(18));
injector::MakeInline<DisableReloadCheck>(pattern.count(5).get(1).get<uint32_t>(0), pattern.count(5).get(1).get<uint32_t>(18));
injector::MakeInline<DisableReloadCheck>(pattern.count(5).get(2).get<uint32_t>(0), pattern.count(5).get(2).get<uint32_t>(18));
injector::MakeInline<DisableReloadCheck>(pattern.count(5).get(4).get<uint32_t>(0), pattern.count(5).get(4).get<uint32_t>(18));
// for Rifles, Mine Thrower
pattern = hook::pattern("8B 8E D8 07 00 00 8B 49 34 8B 11 8B 42 4C FF");
injector::MakeInline<DisableReloadCheck>(pattern.count(3).get(1).get<uint32_t>(0), pattern.count(3).get(1).get<uint32_t>(18));
injector::MakeInline<DisableReloadCheck>(pattern.count(3).get(2).get<uint32_t>(0), pattern.count(3).get(2).get<uint32_t>(18));
}

// Limit the Matilda to one three round burst per trigger pull
{
auto pattern = hook::pattern("E8 ? ? ? ? 85 C0 74 ? 8B 96 D8 07 00 00 8B 4A 34 E8");
Expand Down
3 changes: 3 additions & 0 deletions dllmain/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ void ReadSettingsIni(std::wstring ini_path)
re4t::cfg->bAllowSellingHandgunSilencer = ini.getBool("GAMEPLAY", "AllowSellingHandgunSilencer", re4t::cfg->bAllowSellingHandgunSilencer);
re4t::cfg->bBalancedChicagoTypewriter = ini.getBool("GAMEPLAY", "BalancedChicagoTypewriter", re4t::cfg->bBalancedChicagoTypewriter);
re4t::cfg->bUseSprintToggle = ini.getBool("GAMEPLAY", "UseSprintToggle", re4t::cfg->bUseSprintToggle);
re4t::cfg->bDisableAutomaticReload = ini.getBool("GAMEPLAY", "DisableAutomaticReload", re4t::cfg->bDisableAutomaticReload);
re4t::cfg->bRifleScreenShake = ini.getBool("GAMEPLAY", "RifleScreenShake", re4t::cfg->bRifleScreenShake);
re4t::cfg->bDisableQTE = ini.getBool("GAMEPLAY", "DisableQTE", re4t::cfg->bDisableQTE);
re4t::cfg->bAutomaticMashingQTE = ini.getBool("GAMEPLAY", "AutomaticMashingQTE", re4t::cfg->bAutomaticMashingQTE);
Expand Down Expand Up @@ -703,6 +704,7 @@ void re4t_cfg::WriteSettings(bool trainerOnly)
ini.setBool("GAMEPLAY", "AllowSellingHandgunSilencer", re4t::cfg->bAllowSellingHandgunSilencer);
ini.setBool("GAMEPLAY", "BalancedChicagoTypewriter", re4t::cfg->bBalancedChicagoTypewriter);
ini.setBool("GAMEPLAY", "UseSprintToggle", re4t::cfg->bUseSprintToggle);
ini.setBool("GAMEPLAY", "DisableAutomaticReload", re4t::cfg->bDisableAutomaticReload);
ini.setBool("GAMEPLAY", "RifleScreenShake", re4t::cfg->bRifleScreenShake);
ini.setBool("GAMEPLAY", "DisableQTE", re4t::cfg->bDisableQTE);
ini.setBool("GAMEPLAY", "AutomaticMashingQTE", re4t::cfg->bAutomaticMashingQTE);
Expand Down Expand Up @@ -1054,6 +1056,7 @@ void re4t_cfg::LogSettings()
spd::log()->info("| {:<30} | {:>15} |", "AllowSellingHandgunSilencer", re4t::cfg->bAllowSellingHandgunSilencer ? "true" : "false");
spd::log()->info("| {:<30} | {:>15} |", "BalancedChicagoTypewriter", re4t::cfg->bBalancedChicagoTypewriter ? "true" : "false");
spd::log()->info("| {:<30} | {:>15} |", "UseSprintToggle", re4t::cfg->bUseSprintToggle ? "true" : "false");
spd::log()->info("| {:<30} | {:>15} |", "DisableAutomaticReload", re4t::cfg->bDisableAutomaticReload ? "true" : "false");
spd::log()->info("| {:<30} | {:>15} |", "RifleScreenShake", re4t::cfg->bRifleScreenShake ? "true" : "false");
spd::log()->info("| {:<30} | {:>15} |", "DisableQTE", re4t::cfg->bDisableQTE ? "true" : "false");
spd::log()->info("| {:<30} | {:>15} |", "AutomaticMashingQTE", re4t::cfg->bAutomaticMashingQTE ? "true" : "false");
Expand Down
1 change: 1 addition & 0 deletions dllmain/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class re4t_cfg
bool bAllowSellingHandgunSilencer = true;
bool bBalancedChicagoTypewriter = false;
bool bUseSprintToggle = false;
bool bDisableAutomaticReload = false;
bool bRifleScreenShake = false;
bool bDisableQTE = false;
bool bAutomaticMashingQTE = false;
Expand Down
13 changes: 13 additions & 0 deletions dllmain/cfgMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1581,6 +1581,19 @@ void cfgMenuRender()
ImGui::TextWrapped("Changes sprint key to act like a toggle instead of needing to be held.");
}

// DisableAutomaticReload
if ((OptionsFilter.PassFilter("DisableAutomaticReload") && OptionsFilter.IsActive()) || !OptionsFilter.IsActive())
{
ImGui_ColumnSwitch();

re4t::cfg->HasUnsavedChanges |= ImGui::Checkbox("DisableAutomaticReload", &re4t::cfg->bDisableAutomaticReload);

ImGui_ItemSeparator();

ImGui::Dummy(ImVec2(10, 10 * esHook._cur_monitor_dpi));
ImGui::TextWrapped("Disables automatic reload when firing a weapon that's out of ammo.");
}

// RifleScreenShake
if ((OptionsFilter.PassFilter("RifleScreenShake") && OptionsFilter.IsActive()) || !OptionsFilter.IsActive())
{
Expand Down
3 changes: 3 additions & 0 deletions settings/settings.ini
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,9 @@ BalancedChicagoTypewriter = false
; Changes sprint key to act like a toggle instead of needing to be held.
UseSprintToggle = false

; Disables automatic reload when firing a weapon that's out of ammo.
DisableAutomaticReload = false

; Adds a screen shake effect when firing a rifle.
RifleScreenShake = false

Expand Down

0 comments on commit 674116a

Please sign in to comment.