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
|
||||
;v3.8.24
|
||||
;v3.8.25
|
||||
|
||||
[Main]
|
||||
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
|
||||
@@ -185,7 +185,7 @@ HighlightCorpses=1
|
||||
;64 - purple
|
||||
OutlineColor=16
|
||||
|
||||
;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
|
||||
|
||||
|
||||
+36
-20
@@ -851,14 +851,6 @@ long __stdcall ItemGetType(TGameObj* item) {
|
||||
WRAP_WATCOM_CALL1(item_get_type_, item)
|
||||
}
|
||||
|
||||
long __stdcall ItemSize(TGameObj* item) {
|
||||
WRAP_WATCOM_CALL1(item_size_, item)
|
||||
}
|
||||
|
||||
long __stdcall ItemWeight(TGameObj* item) {
|
||||
WRAP_WATCOM_CALL1(item_weight_, item)
|
||||
}
|
||||
|
||||
long __stdcall IsPartyMember(TGameObj* obj) {
|
||||
WRAP_WATCOM_CALL1(isPartyMember_, obj)
|
||||
}
|
||||
@@ -1484,6 +1476,26 @@ long __stdcall TileDir(long scrTile, long dstTile) {
|
||||
WRAP_WATCOM_CALL2(tile_dir_, scrTile, dstTile)
|
||||
}
|
||||
|
||||
long __stdcall ItemCCurrSize(TGameObj* critter) {
|
||||
WRAP_WATCOM_CALL1(item_c_curr_size_, critter)
|
||||
}
|
||||
|
||||
long __stdcall ItemCapsTotal(TGameObj* object) {
|
||||
WRAP_WATCOM_CALL1(item_caps_total_, object)
|
||||
}
|
||||
|
||||
long __stdcall ItemSize(TGameObj* item) {
|
||||
WRAP_WATCOM_CALL1(item_size_, item)
|
||||
}
|
||||
|
||||
long __stdcall ItemTotalCost(TGameObj* object) {
|
||||
WRAP_WATCOM_CALL1(item_total_cost_, object)
|
||||
}
|
||||
|
||||
long __stdcall ItemTotalWeight(TGameObj* object) {
|
||||
WRAP_WATCOM_CALL1(item_total_weight_, object)
|
||||
}
|
||||
|
||||
long __stdcall ItemWAnimWeap(TGameObj* item, DWORD hitMode) {
|
||||
WRAP_WATCOM_CALL2(item_w_anim_weap_, item, hitMode)
|
||||
}
|
||||
@@ -1496,6 +1508,10 @@ long __stdcall ItemWCurrAmmo(TGameObj* item) {
|
||||
WRAP_WATCOM_CALL1(item_w_curr_ammo_, item)
|
||||
}
|
||||
|
||||
long __stdcall ItemWMaxAmmo(TGameObj* item) {
|
||||
WRAP_WATCOM_CALL1(item_w_max_ammo_, item)
|
||||
}
|
||||
|
||||
long __stdcall ItemWReload(TGameObj* weapon, TGameObj* ammo) {
|
||||
WRAP_WATCOM_CALL2(item_w_reload_, weapon, ammo)
|
||||
}
|
||||
@@ -1504,26 +1520,22 @@ long __stdcall ItemWRounds(TGameObj* item) {
|
||||
WRAP_WATCOM_CALL1(item_w_rounds_, item)
|
||||
}
|
||||
|
||||
long __stdcall ItemWeight(TGameObj* item) {
|
||||
WRAP_WATCOM_CALL1(item_weight_, item)
|
||||
}
|
||||
|
||||
long __stdcall BarterComputeValue(TGameObj* source, TGameObj* target) {
|
||||
WRAP_WATCOM_CALL2(barter_compute_value_, source, target)
|
||||
}
|
||||
|
||||
long __stdcall ItemCapsTotal(TGameObj* object) {
|
||||
WRAP_WATCOM_CALL1(item_caps_total_, object)
|
||||
}
|
||||
|
||||
long __stdcall ItemTotalCost(TGameObj* object) {
|
||||
WRAP_WATCOM_CALL1(item_total_cost_, object)
|
||||
}
|
||||
|
||||
long __stdcall ItemTotalWeight(TGameObj* object) {
|
||||
WRAP_WATCOM_CALL1(item_total_weight_, object)
|
||||
}
|
||||
|
||||
void __fastcall CorrectFidForRemovedItemFunc(TGameObj* critter, TGameObj* item, long slotFlag) {
|
||||
WRAP_WATCOM_FCALL3(correctFidForRemovedItem_, critter, item, slotFlag)
|
||||
}
|
||||
|
||||
void __stdcall IntfaceToggleItemState() {
|
||||
WRAP_WATCOM_CALL0(intface_toggle_item_state_)
|
||||
}
|
||||
|
||||
void __stdcall IntfaceUpdateAc(long animate) {
|
||||
WRAP_WATCOM_CALL1(intface_update_ac_, animate)
|
||||
}
|
||||
@@ -1532,6 +1544,10 @@ void __stdcall IntfaceUpdateMovePoints(long ap, long freeAP) {
|
||||
WRAP_WATCOM_CALL2(intface_update_move_points_, ap, freeAP)
|
||||
}
|
||||
|
||||
void __stdcall IntfaceUseItem() {
|
||||
WRAP_WATCOM_CALL0(intface_use_item_)
|
||||
}
|
||||
|
||||
void __fastcall IntfaceUpdateItems(long animate, long modeLeft, long modeRight) {
|
||||
WRAP_WATCOM_FCALL3(intface_update_items_, animate, modeLeft, modeRight)
|
||||
}
|
||||
|
||||
+11
-7
@@ -1061,8 +1061,6 @@ void DevPrintf(...);
|
||||
#endif
|
||||
|
||||
long __stdcall ItemGetType(TGameObj* item);
|
||||
long __stdcall ItemSize(TGameObj* item);
|
||||
long __stdcall ItemWeight(TGameObj* item);
|
||||
|
||||
long __stdcall IsPartyMember(TGameObj* obj);
|
||||
long __stdcall PartyMemberGetCurrentLevel(TGameObj* obj);
|
||||
@@ -1318,25 +1316,31 @@ long __stdcall TileDist(long scrTile, long dstTile);
|
||||
|
||||
long __stdcall TileDir(long scrTile, long dstTile);
|
||||
|
||||
// for the backported AmmoCostHook from 4.x
|
||||
long __stdcall ItemCCurrSize(TGameObj* critter);
|
||||
long __stdcall ItemCapsTotal(TGameObj* object);
|
||||
long __stdcall ItemSize(TGameObj* item);
|
||||
long __stdcall ItemTotalCost(TGameObj* object);
|
||||
long __stdcall ItemTotalWeight(TGameObj* object);
|
||||
long __stdcall ItemWAnimWeap(TGameObj* item, DWORD hitMode);
|
||||
long __stdcall ItemWComputeAmmoCost(TGameObj* item, DWORD* rounds);
|
||||
long __stdcall ItemWCurrAmmo(TGameObj* item);
|
||||
long __stdcall ItemWMaxAmmo(TGameObj* item);
|
||||
long __stdcall ItemWReload(TGameObj* weapon, TGameObj* ammo);
|
||||
long __stdcall ItemWRounds(TGameObj* item);
|
||||
long __stdcall ItemWeight(TGameObj* item);
|
||||
|
||||
// for the backported BarterPriceHook from 4.x
|
||||
long __stdcall BarterComputeValue(TGameObj* source, TGameObj* target);
|
||||
long __stdcall ItemCapsTotal(TGameObj* object);
|
||||
long __stdcall ItemTotalCost(TGameObj* object);
|
||||
long __stdcall ItemTotalWeight(TGameObj* object);
|
||||
|
||||
void __fastcall CorrectFidForRemovedItemFunc(TGameObj* critter, TGameObj* item, long slotFlag);
|
||||
|
||||
void __stdcall IntfaceToggleItemState();
|
||||
|
||||
void __stdcall IntfaceUpdateAc(long animate);
|
||||
|
||||
void __stdcall IntfaceUpdateMovePoints(long ap, long freeAP);
|
||||
|
||||
void __stdcall IntfaceUseItem();
|
||||
|
||||
void __fastcall IntfaceUpdateItems(long animate, long modeLeft, long modeRight);
|
||||
|
||||
TGameObj* __fastcall InvenFindType(TGameObj* critter, long itemType, DWORD* buf);
|
||||
|
||||
@@ -867,7 +867,7 @@ DWORD _stdcall KeyPressHook(DWORD dxKey, bool pressed, DWORD vKey) {
|
||||
args[2] = vKey;
|
||||
RunHookScript(HOOK_KEYPRESS);
|
||||
if (cRet != 0) dxKey = result = rets[0];
|
||||
InventoryKeyPressedHook(dxKey, pressed, vKey);
|
||||
InventoryKeyPressedHook(dxKey, pressed);
|
||||
EndHook();
|
||||
return result;
|
||||
}
|
||||
|
||||
+16
-27
@@ -31,42 +31,36 @@ static DWORD reloadWeaponKey = 0;
|
||||
static DWORD itemFastMoveKey = 0;
|
||||
static DWORD skipFromContainer = 0;
|
||||
|
||||
DWORD& GetActiveItemMode() {
|
||||
return ptr_itemButtonItems[(*ptr_itemCurrentItem * 6) + 4];
|
||||
long& GetActiveItemMode() {
|
||||
return (long&)ptr_itemButtonItems[(*ptr_itemCurrentItem * 6) + 4];
|
||||
}
|
||||
|
||||
TGameObj* GetActiveItem() {
|
||||
return (TGameObj*)ptr_itemButtonItems[*ptr_itemCurrentItem * 6];
|
||||
}
|
||||
|
||||
void InventoryKeyPressedHook(DWORD dxKey, bool pressed, DWORD vKey) {
|
||||
void InventoryKeyPressedHook(DWORD dxKey, bool pressed) {
|
||||
if (pressed && reloadWeaponKey && dxKey == reloadWeaponKey && IsGameLoaded() && (GetLoopFlags() & ~(COMBAT | PCOMBAT)) == 0) {
|
||||
DWORD maxAmmo, curAmmo;
|
||||
TGameObj* item = GetActiveItem();
|
||||
__asm {
|
||||
mov eax, item;
|
||||
call item_w_max_ammo_;
|
||||
mov maxAmmo, eax;
|
||||
mov eax, item;
|
||||
call item_w_curr_ammo_;
|
||||
mov curAmmo, eax;
|
||||
}
|
||||
if (!item) return;
|
||||
|
||||
if (ItemGetType(item) == item_type_weapon) {
|
||||
long maxAmmo = ItemWMaxAmmo(item);
|
||||
long curAmmo = ItemWCurrAmmo(item);
|
||||
if (maxAmmo != curAmmo) {
|
||||
DWORD ¤tMode = GetActiveItemMode();
|
||||
DWORD previusMode = currentMode;
|
||||
long ¤tMode = GetActiveItemMode();
|
||||
long previusMode = currentMode;
|
||||
currentMode = 5; // reload mode
|
||||
__asm {
|
||||
call intface_use_item_;
|
||||
}
|
||||
IntfaceUseItem();
|
||||
if (previusMode != 5) {
|
||||
// return to previous active item mode (if it wasn't "reload")
|
||||
currentMode = previusMode - 1;
|
||||
if (currentMode < 0)
|
||||
currentMode = 4;
|
||||
__asm {
|
||||
call intface_toggle_item_state_;
|
||||
if (currentMode < 0) currentMode = 4;
|
||||
IntfaceToggleItemState();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IntfaceUseItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,12 +68,7 @@ void InventoryKeyPressedHook(DWORD dxKey, bool pressed, DWORD vKey) {
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
DWORD __stdcall sf_item_total_size(TGameObj* critter) {
|
||||
int totalSize;
|
||||
__asm {
|
||||
mov eax, critter;
|
||||
call item_c_curr_size_;
|
||||
mov totalSize, eax;
|
||||
}
|
||||
int totalSize = ItemCCurrSize(critter);
|
||||
|
||||
if (((critter->artFid >> 24) & 0x0F) == OBJ_TYPE_CRITTER) {
|
||||
TGameObj* item = InvenRightHand(critter);
|
||||
|
||||
+1
-1
@@ -24,4 +24,4 @@ DWORD __stdcall sf_item_total_size(TGameObj* critter);
|
||||
|
||||
void InventoryInit();
|
||||
void InventoryReset();
|
||||
void InventoryKeyPressedHook(DWORD dxKey, bool pressed, DWORD vKey);
|
||||
void InventoryKeyPressedHook(DWORD dxKey, bool pressed);
|
||||
|
||||
Reference in New Issue
Block a user