Jump to content

WeiDU's "fj_are_structure" deletes too many items


argent77

Recommended Posts

I'm trying to get to the bottom of an unexpected result using fj_are_structure to delete an item from a container.

The code is pretty straightforward:

// Attempts to determine the index of an ARE container item structure.
DEFINE_PATCH_FUNCTION are_index_of_container_item
STR_VAR
  resource = ~~
RET
  index
BEGIN
  SET index = "-1"
  PATCH_IF (NOT ~%resource%~ STRING_EQUAL ~~) BEGIN
    READ_SHORT 0x76 numItems
    READ_LONG 0x78 ofsItems
    FOR (idx = 0; idx < numItems; ++idx) BEGIN
      SET curOfs = ofsItems + (idx * 0x14)
      READ_ASCII curOfs curRes ( 8 ) NULL
      PATCH_IF (~%curRes%~ STRING_EQUAL_CASE ~%resource%~) BEGIN
        SET index = idx
        SET idx = numItems
      END
    END
  END
END

// Removing Clay Golem Page
COPY_EXISTING ~ar3017.are~ ~override~
  LPF are_index_of_container_item STR_VAR resource = "tome02a" RET index END
  PATCH_IF (index >= 0) BEGIN
    LPF fj_are_structure
    INT_VAR
      fj_delete         = 1
      fj_delete_mode    = index
    STR_VAR
      fj_structure_type = "itm"
    END
  END
BUT_ONLY

The code is supposed to find the item index of TOME02A.ITM in AR3017.ARE (Watcher's Keep, Level 4) and delete it via fj_are_structure. However, it not only removes the desired item, but also removes the following item which is referenced by another container and happens to be the quest item "Crystal Mallet" (PLOT04D.ITM) in my case.

I'm getting the same results in original BG2, BG2:EE and EET. Any idea what went wrong?

I have attached a small test mod containing the above code.

A7TestItemDelete.zip

Link to comment

Just a question

Do you intend to delete the item just from that area or completely from the game?

 

No idea how to do it with that method - I would just use the area script (if scroll is in container then actionoverride destroyitem + whatever conditions).

Link to comment

Just from the container in the area. It's part of a mod component that removes certain items from several maps and replaces them with other mod-added items (not necessarily into the same containers). This issue occurred only for the specific item/map combination mentioned in my first post. I'm using similar constructs in three more instances, for different items on different maps. These items are correctly removed.

It might be a bug in the fj_are_structure function. I have already posted a bug report. Maybe Wisp can tell me more.

Luckily WeiDU provides the patch function DELETE_AREA_ITEM which does a similar job.

Link to comment

 

...to delete an item from a container.

Do you intend to delete the item just from that area or completely from the game?

I don't know how you could ask such question... particularly if you read the post above yours. Yes, ahh that requires reading. That's where I must have overlook your capabilities.

 

My bet is that you (argent77) can't delete just one item using that function. Aka it deletes all of them... yeah, better use the DAI .

If you notice, the fj_delete = 1 is there to add debug/feedback info, not how many items to delete.

Link to comment

My bet is that you (argent77) can't delete just one item using that function. Aka it deletes all of them... yeah, better use the DAI .

If you notice, the fj_delete = 1 is there to add debug/feedback info, not how many items to delete.

Nope, now you're confusing the functionality of fj_are_structure with DELETE_AREA_ITEM. DELETE_AREA_ITEM removes every instance of the specified item resource from the current map. fj_are_structure requires the specific item index from the current ARE file that should be removed. It doesn't even care for the resource name.

 

In my case it doesn't really matter. The items in question are unique and don't appear multiple times on the same map (or anywhere else in the game).

 

Link to comment
Just from the container in the area.

Sorry, it is not only I cannot read - I cannot write either.

What I wanted to ask was, if you remove TOME02A.ITM in AR3017.ARE (the only place the item appears in the whole game), do you place it somewhere else or is it no longer to be found?

Link to comment

...

... are you sure, cause to me, it seems to, how ever you trigger the deletation, is that it targets all of the given type, aka in this case the .itm -references cause you gave that in the variable you set:
STR_VAR
      fj_structure_type = "itm"
    END
Link to comment

 

Just from the container in the area.

Sorry, it is not only I cannot read - I cannot write either.

What I wanted to ask was, if you remove TOME02A.ITM in AR3017.ARE (the only place the item appears in the whole game), do you place it somewhere else or is it no longer to be found?

 

It is no longer available in the game without using cheats. The golem tomes become redundant when you install my Golem Construction mod. That's why I provide an optional tweak component that replaces the original tome with similar items from my mod.

 

 

 

...

... are you sure, cause to me, it seems to, how ever you trigger the deletation, is that it targets all of the given type, aka in this case the .itm -references cause you gave that in the variable you set.

 

I can only tell you what the WeiDU docs told me.

 

DELETE_AREA_ITEM: deletes all matching items from an area. Regexp allowed. This is a PATCH macro and function.

 

INT_VAR fj_delete_mode to the index of the structure to be deleted (if deleting rather than adding a new structure);

Link to comment

Thank you for clarification

I assume it is related to Golem Construction mod tweak option 1 Replace original Golem Manual: Replaces the now obsolete original Golem Manual with items related to this mod.

and it would affect original items tome01, 02, 02a, 03, 03a, 04, 04a to become unavailable in the game.

Link to comment

Thank you for clarification

I assume it is related to Golem Construction mod tweak option 1 Replace original Golem Manual: Replaces the now obsolete original Golem Manual with items related to this mod.

and it would affect original items tome01, 02, 02a, 03, 03a, 04, 04a to become unavailable in the game.

Yes, that's the one. It removes TOME01, 02A, 03A and 04A from the their respective maps.

 

Looks like deleting the last item in container will also delete the first one in the next container.

Ah, so it's indeed a bug.

Link to comment

Archived

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

×
×
  • Create New...