mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed ReloadWeaponKey for using any non-weapon item (#84)
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
;sfall configuration settings
|
||||
;v4.2.4
|
||||
;v4.2.5
|
||||
|
||||
[Main]
|
||||
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
|
||||
@@ -193,7 +193,7 @@ SpeedKey9=0x00
|
||||
;Set to -1 for either ctrl key, -2 for either alt key or -3 for either shift key
|
||||
WindowScrollKey=0
|
||||
|
||||
;A key to press to reload your currently equipped weapon
|
||||
;A key to press to reload your currently equipped weapon or use the active item
|
||||
;Set to 0 if you don't want a reload key, or a DX scancode otherwise
|
||||
ReloadWeaponKey=0
|
||||
|
||||
|
||||
+17
-14
@@ -40,23 +40,26 @@ static DWORD skipFromContainer = 0;
|
||||
|
||||
void InventoryKeyPressedHook(DWORD dxKey, bool pressed) {
|
||||
if (pressed && reloadWeaponKey && dxKey == reloadWeaponKey && IsGameLoaded() && (GetLoopFlags() & ~(COMBAT | PCOMBAT)) == 0) {
|
||||
DWORD maxAmmo, curAmmo;
|
||||
fo::GameObject* item = fo::GetActiveItem();
|
||||
maxAmmo = fo::func::item_w_max_ammo(item);
|
||||
curAmmo = fo::func::item_w_curr_ammo(item);
|
||||
if (maxAmmo != curAmmo) {
|
||||
long ¤tMode = fo::GetActiveItemMode();
|
||||
long previusMode = currentMode;
|
||||
currentMode = 5; // reload mode
|
||||
fo::func::intface_use_item();
|
||||
if (previusMode != 5) {
|
||||
// return to previous active item mode (if it wasn't "reload")
|
||||
currentMode = previusMode - 1;
|
||||
if (currentMode < 0) {
|
||||
currentMode = 4;
|
||||
if (!item) return;
|
||||
|
||||
if (fo::func::item_get_type(item) == fo::ItemType::item_type_weapon) {
|
||||
long maxAmmo = fo::func::item_w_max_ammo(item);
|
||||
long curAmmo = fo::func::item_w_curr_ammo(item);
|
||||
if (maxAmmo != curAmmo) {
|
||||
long ¤tMode = fo::GetActiveItemMode();
|
||||
long previusMode = currentMode;
|
||||
currentMode = 5; // reload mode
|
||||
fo::func::intface_use_item();
|
||||
if (previusMode != 5) {
|
||||
// return to previous active item mode (if it wasn't "reload")
|
||||
currentMode = previusMode - 1;
|
||||
if (currentMode < 0) currentMode = 4;
|
||||
fo::func::intface_toggle_item_state();
|
||||
}
|
||||
fo::func::intface_toggle_item_state();
|
||||
}
|
||||
} else {
|
||||
fo::func::intface_use_item();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user