Jump to content

item dupe


Ardanis

Recommended Posts

Well... Honestly, I didn't really get what the few lines here were about, but what this code does is it puts lovely RNDTRE05 into all inventory slots

// number of creatures with dupe entries for rndtre05
COPY_EXISTING ~drush.cre~	~override~
		  ~ogrema01.cre~ ~override~
		  ~ogrmag01.cre~ ~override~
		  ~plshom01.cre~ ~override~
 READ_LONG  0x2b8 "slot_off" ELSE 0
 READ_LONG  0x2bc "itm_off" ELSE 0
 READ_LONG  0x2c0 "itm_num" ELSE 0
 FOR (index = 0; index < itm_num; index = index + 1) BEGIN
READ_ASCII ("%itm_off%" + (0x14 * "%index%")) "item"
PATCH_IF ("%item%" STRING_COMPARE_CASE "rndtre05" = 0) BEGIN
  SET "exists" = 0
  SET "insert" = 0
  FOR (index2 = 18; index2 < 36; index2 = index2 + 1) BEGIN // search through quick slots & inventory
	READ_SHORT ("%slot_off%" + ("%index2%" * 0x02)) "ref"
	PATCH_IF ("%index%" = "%ref%") BEGIN
	  SET "exists" = 1
	  SET "index2" = 36 // kills loop
	END ELSE
	PATCH_IF (("%insert%" = 0) AND ("%ref%" = 0xffff)) BEGIN // if null entry, set insert point
	  SET "insert" = "%index2%"
	END
  END
  PATCH_IF ("%exists%" = 0) BEGIN
	FOR (index3 = 21; index3 < 36; index3 = index3 + 1) BEGIN // search through weapon slots
	  READ_SHORT ("%slot_off%" + ("%index3%" * 0x02)) "ref"
	  PATCH_IF ("%ref%" = 0xffff) BEGIN
		WRITE_SHORT ("%slot_off%" + ("%index3%" * 0x02)) "%index%" // adds reference
	  END
	END
  END
END
 END
 BUT_ONLY_IF_IT_CHANGES

Link to comment

The problem was that these creatures have 4 randtre05, but only 3 of them were referenced by an item slot.

The fix intends to add a reference for the 4th randtre05, but it does not kill the FOR loop after having added it once, so it adds a reference for every inventory slot (since they are all -1).

 

This should fix it:

 

		FOR (index3 = 21; index3 < 36; index3 = index3 + 1) BEGIN // search through weapon slots
	  READ_SHORT ("%slot_off%" + ("%index3%" * 0x02)) "ref"
	  PATCH_IF ("%ref%" = 0xffff) BEGIN
		WRITE_SHORT ("%slot_off%" + ("%index3%" * 0x02)) "%index%" // adds reference
		SET "index3" = 36 // kills loop
	  END
	END

Link to comment
Guest temujin_
We can confirm this bug and should be fixed with the next BG2 Fixpack version. Meanwhile we will include Wisp's fix in the BiG World Fixpack.

 

your BWP fixpack is applying this fix in the wrong place to the wrong creature. right now, instead of drush.cre, ogrema01.cre, ogrmag01.cre, plshom01.cre, this (Wisp's) fix is being incorrectly applied to rskel03.cre, which doesn't have this problem.

 

i think this part in setup-bg2fixpack.tp2.patch,

 

@@ -8597,6 +8597,7 @@
		 READ_SHORT ("%slot_off%" + ("%index3%" * 0x02)) "ref"
		 PATCH_IF ("%ref%" = 0xffff) BEGIN
		   WRITE_SHORT ("%slot_off%" + ("%index3%" * 0x02)) "%index%" // adds reference
+			  SET "index3" = 36 // kills loop
		 END
	   END
	 END ELSE BEGIN

 

should be changed to

 

@@ -8656,6 +8656,7 @@
		 READ_SHORT ("%slot_off%" + ("%index3%" * 0x02)) "ref"
		 PATCH_IF ("%ref%" = 0xffff) BEGIN
		   WRITE_SHORT ("%slot_off%" + ("%index3%" * 0x02)) "%index%" // adds reference
+			  SET "index3" = 36 // kills loop
		 END
	   END
	 END

 

but you might want to double check anyway.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...