Skip to content

Commit

Permalink
9999: Log spilled items.
Browse files Browse the repository at this point in the history
  • Loading branch information
GraionDilach committed Jun 15, 2024
1 parent 5763cd2 commit b69baa3
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 8 deletions.
70 changes: 63 additions & 7 deletions zgtweaks/library/equipinventory.tpa
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ACTION_DEFINE_ASSOCIATIVE_ARRAY remap_itemcategories BEGIN
7 => 0 // Headgear (Helms, hats, and other head-wear)
9 => 18 // Potions
10 => 4 // Rings
11 => 18 // Scrolls
// 11 Scrolls, skipped
12 => 2 // Shields (not in IWD)
// 13 Food, skipped
14 => 13 // Bullets (for a sling)
Expand Down Expand Up @@ -75,11 +75,11 @@ ACTION_DEFINE_ASSOCIATIVE_ARRAY remap_itemcategories BEGIN
END

ACTION_DEFINE_ASSOCIATIVE_ARRAY remap_slotcount BEGIN
5 => 17 // quiver
5 => 16 // quiver
9 => 21 // quick item
10 => 6 // ring
11 => 21 // quick item
14 => 17 // quiver
14 => 16 // quiver
15 => 13 // weapon
16 => 13 // weapon
17 => 13 // weapon
Expand All @@ -103,15 +103,58 @@ ACTION_DEFINE_ASSOCIATIVE_ARRAY remap_slotcount BEGIN
69 => 13 // weapon
END

ACTION_DEFINE_ASSOCIATIVE_ARRAY itemslots BEGIN
0 => "HELMET"
1 => "ARMOR"
2 => "SHIELD"
3 => "GLOVES"
4 => "LRING"
5 => "RRING"
6 => "AMULET"
7 => "BELT"
8 => "BOOTS"
9 => "WEAPON1"
10 => "WEAPON2"
11 => "WEAPON3"
12 => "WEAPON4"
13 => "QUIVER1"
14 => "QUIVER2"
15 => "QUIVER3"
16 => "QUIVER4"
17 => "CLOAK"
18 => "QITEM1"
19 => "QITEM2"
20 => "QITEM3"
21 => "INV1"
22 => "INV2"
23 => "INV3"
24 => "INV4"
25 => "INV5"
26 => "INV6"
27 => "INV7"
28 => "INV8"
29 => "INV9"
30 => "INV10"
31 => "INV11"
32 => "INV12"
33 => "INV13"
34 => "INV14"
35 => "INV15"
36 => "INV16"
END

DEFINE_PATCH_FUNCTION TRY_EQUIPPING_ALL_ITEMS
BEGIN
READ_LONG 0x2b8 slot_off ELSE 0
READ_LONG 0x2bc itm_off ELSE 0
READ_LONG 0x2c0 itm_num ELSE 0
SPRINT cre_name ~%SOURCE_RES%~

FOR (index = 0; index < itm_num; ++index) BEGIN
SET found = 0
SET category = (0 - 1)
SET currentitem = itm_off + index * 0x14
READ_ASCII currentitem currentitem_name (8) NULL

// CHECK IF ITEM IS EQUIPPED ALREADY

Expand All @@ -132,9 +175,6 @@ BEGIN
PATCH_IF found = 0 BEGIN

// READ ITEM CATEGORY

SET currentitem = itm_off + index * 0x14
READ_ASCII currentitem currentitem_name (8) NULL
INNER_ACTION BEGIN
ACTION_IF FILE_EXISTS_IN_GAME ~%currentitem_name%.itm~ BEGIN
COPY_EXISTING ~%currentitem_name%.itm~ ~override~
Expand Down Expand Up @@ -165,13 +205,18 @@ BEGIN
READ_SHORT (slot_off + (index3 * 0x02)) ref
PATCH_IF ref = 0xFFFF BEGIN
WRITE_SHORT (slot_off + (index3 * 0x02)) index
SPRINT slot_text $itemslots(~%index3%~)
PATCH_PRINT ~%cre_name%: Equipped item %currentitem_name% to slot %slot_text%~
found = 2
END
END
END ELSE BEGIN
READ_SHORT (slot_off + ($remap_itemcategories(~%category%~) * 0x02)) ref
PATCH_IF ref = 0xFFFF BEGIN
WRITE_SHORT (slot_off + ($remap_itemcategories(~%category%~) * 0x02)) index
SET slot = $remap_itemcategories(~%category%~)
SPRINT slot_text $itemslots(~%slot%~)
PATCH_PRINT ~%cre_name%: Equipped item %currentitem_name% to slot %slot_text%~
found = 2
END
END
Expand All @@ -185,6 +230,8 @@ BEGIN
READ_SHORT (slot_off + (index2 * 0x02)) ref
PATCH_IF ref = index BEGIN
WRITE_SHORT (slot_off + (index2 * 0x02)) 0xFFFF
SPRINT slot_text $itemslots(~%index2%~)
PATCH_PRINT ~ from slot %slot_text%.~
found = 1
END
END
Expand All @@ -208,10 +255,19 @@ BEGIN
READ_SHORT (slot_off + (index2 * 0x02)) ref
PATCH_IF ref = 0xFFFF BEGIN
WRITE_SHORT (slot_off + (index2 * 0x02)) index
found = 1
SPRINT slot_text $itemslots(~%index2%~)
PATCH_PRINT ~%cre_name%: Added item %currentitem_name% to slot %slot_text%~
found = 2
END
END
END

// LOG SPILLED ITEMS

PATCH_IF found = 2 BEGIN
PATCH_PRINT ~ from outside the inventory.~
found = 1
END
END
END

Expand Down
2 changes: 1 addition & 1 deletion zgtweaks/zgtweaks.tp2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
BACKUP ~weidu_external/zgtweaks/backup~ // location to store files for uninstall purposes
AUTHOR ~Graion Dilach~
VERSION ~1.13~
VERSION ~1.14~

ALWAYS
// do not convert Setup.tra files, those should be UTF8 already
Expand Down

0 comments on commit b69baa3

Please sign in to comment.