Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Neverwinter Nights: Enhanced Edition has been released! Visit nwn.beamdog.com to make an order. NWN:EE FAQ is available.
Soundtracks for BG:EE, SoD, BG2:EE, IWD:EE, PST:EE are now available in the Beamdog store.
Attention, new and old users! Please read the new rules of conduct for the forums, and we hope you enjoy your stay!

WeiDU Help With: How to alter items from an existing container and add an item to a creature?

Hello I am trying to change the container items within the chest in AR5405.ARE to be as this:

What command does one write in the .tp2 file to instigate this change to Container1 in AR5405.ARE (Mulahey's Lair)?

Also how does one add "OLRING06" to Mulahey ("MULAHE.CRE") without breaking him for other mods?

COPY_EXISTING ~MULAHE.CRE~ ~override~
ADD_CRE_ITEM ~OLRING06~ #0 #0 #0 ~NONE~ ~RRING~ ?

Source: https://www.weidu.org/~thebigg/README-WeiDU.html#sec34

This is for an Original Baldur's Gate Module 'Xan's New Groove':


I am none too good with operating WeiDU :-P. Any help would be great to get this to launch soon. @Arunsun

Comments

  • GwendolyneGwendolyne Member Posts: 174
    edited December 5
    For containers, use the following WeiDU function:
    ADD_AREA_ITEM: adds an item to a container of an area. This is a PATCH macro and function.
    
        SPRINT item_to_add to the item you want to add
        SET container_to_add_to to the number of the container the item should be added to. The count starts at 1.
        SPRINT flags to flags the item should have (usual weidu syntax: STOLEN, IDENTIFIEDSTOLEN, etc). Default - no flags.
        SET charges1 to amount in stock/number of charges of first magical ability (default 0)
        SET charges2 to number of charges of second magical ability (default 0)
        SET charges3 to number of charges of third magical ability (default 0) 

    To alter containers content, it is better to use homemade functions.

    Post edited by Gwendolyne on
    GusindaWithinAmnesia
  • WithinAmnesiaWithinAmnesia Member Posts: 799

    For containers, use the following WeiDU function:


    ADD_AREA_ITEM: adds an item to a container of an area. This is a PATCH macro and function.
    
        SPRINT item_to_add to the item you want to add
        SET container_to_add_to to the number of the container the item should be added to. The count starts at 1.
        SPRINT flags to flags the item should have (usual weidu syntax: STOLEN, IDENTIFIEDSTOLEN, etc). Default - no flags.
        SET charges1 to amount in stock/number of charges of first magical ability (default 0)
        SET charges2 to number of charges of second magical ability (default 0)
        SET charges3 to number of charges of third magical ability (default 0) 

    To alter containers content, it is better to use homemade functions.
    Okay I have read through the WeiDU document by I have no example of what this looks like in a .tp2 file. What would an example be to add an item to a container with these document commands?

  • WithinAmnesiaWithinAmnesia Member Posts: 799
    edited December 6
    I am looking through other mods .tp2 files where they add items and it is confusing myself as to how it all does not break down. A lot of work went into this but I do not understand it currently to replicate.

    From Unfinished Business
    COPY_EXISTING ~%WSewers%.ARE~ ~override~
    PATCH_IF (SOURCE_SIZE > 0xd4) BEGIN
    READ_LONG 0x70 contOff // Offset to containers
    READ_LONG 0x78 itmOff // Offset to item list
    FOR (READ_SHORT 0x74 numCont; numCont; numCont -= 0x1) BEGIN
    READ_ASCII contOff contName (11) // Container name
    READ_SHORT contOff + 0x20 contXloc // Container X location
    READ_SHORT contOff + 0x22 contYloc // Container Y location
    // Check by name and location, in case name is modified by FotD
    PATCH_IF (!("%contName%" STRING_COMPARE_CASE "CONTAINER 1") ||
    ((contXloc == 1924) && (contYloc == 1888))) BEGIN
    READ_LONG contOff + 0x40 itmIdx // Index of first item in list
    myItmOff = itmOff + (itmIdx * 0x14)
    FOR (READ_LONG contOff + 0x44 itmCnt; itmCnt; itmCnt -= 0x1) BEGIN
    READ_ASCII myItmOff itmRef // Item resource reference
    PATCH_IF !("%itmRef%" STRING_COMPARE_CASE "%tutu_var%MISC80") BEGIN
    WRITE_ASCIIE myItmOff ~%tutu_scriptbg%MISC79~ #8 // Female body
    END
    myItmOff += 0x14
    END
    END
    contOff += 0xc0
    END
    END
    BUT_ONLY

    I am at a loss as to what this means and how '%WSewers%.ARE' even works, I thought Area files had to be Something like '5405.ARE' to work. In the meantime I will try and get Mulahey that ring of Accurate Striking +1 for that task seems more straight forward.

  • WithinAmnesiaWithinAmnesia Member Posts: 799
    edited December 6
    I got Mulahey to equip the Ring of Accurate Striking +1 but I am still at a loss as to how to add and remove items in the Chest (Container1) in 5405.ARE any .tp2 suggestions?

    Also I forgot to mention earlier that all of Xan's items have proper item descriptions (if a bit lengthy; how Within Amnesia makes an item:-P): Moonblade +3, Buckler +2 'Buckler of Unexpected Might', Elven Chain Mail +1 'Mail of the Evereskan Tomb Guardian', Band of Protection +1 ' Band of the Missing Page'.

    Also I threw in some extra general items that I have already completed just for extra quality of value: Ring of Accurate Striking +1, Potion of Additional Healing and Potion of Remarkable Healing at the last second.

  • CamDawgCamDawg Member, Developer Posts: 3,216
    Honestly, I usually just script container inventory changes. Containers have unique DVs--it's the 'container name' from the area file, without the spaces--so you can manipulate them with the area script. Add something like this to the bottom of the area script, ar5405.bcs:
    IF
      Global("CD_do_this_once","MYAREA",0)
    THEN
      RESPONSE #100
        ActionOverride("Container1",DestroyItem("bar"))
        ActionOverride("Container1",CreateItem("foo",0,0,0))
        SetGlobal("CD_do_this_once","MYAREA",1)
    END
    This would add the item 'foo' to the container and remove the item 'bar'.

    AstroBryGuyWithinAmnesiaArunsun
  • AstroBryGuyAstroBryGuy Member Posts: 3,362
    edited December 6

    I am looking through other mods .tp2 files where they add items and it is confusing myself as to how it all does not break down. A lot of work went into this but I do not understand it currently to replicate.

    From Unfinished Business

    COPY_EXISTING ~%WSewers%.ARE~ ~override~ PATCH_IF (SOURCE_SIZE > 0xd4) BEGIN READ_LONG 0x70 contOff // Offset to containers READ_LONG 0x78 itmOff // Offset to item list FOR (READ_SHORT 0x74 numCont; numCont; numCont -= 0x1) BEGIN READ_ASCII contOff contName (11) // Container name READ_SHORT contOff + 0x20 contXloc // Container X location READ_SHORT contOff + 0x22 contYloc // Container Y location // Check by name and location, in case name is modified by FotD PATCH_IF (!("%contName%" STRING_COMPARE_CASE "CONTAINER 1") || ((contXloc == 1924) && (contYloc == 1888))) BEGIN READ_LONG contOff + 0x40 itmIdx // Index of first item in list myItmOff = itmOff + (itmIdx * 0x14) FOR (READ_LONG contOff + 0x44 itmCnt; itmCnt; itmCnt -= 0x1) BEGIN READ_ASCII myItmOff itmRef // Item resource reference PATCH_IF !("%itmRef%" STRING_COMPARE_CASE "%tutu_var%MISC80") BEGIN WRITE_ASCIIE myItmOff ~%tutu_scriptbg%MISC79~ #8 // Female body END myItmOff += 0x14 END END contOff += 0xc0 END END BUT_ONLY


    I am at a loss as to what this means and how '%WSewers%.ARE' even works, I thought Area files had to be Something like '5405.ARE' to work. In the meantime I will try and get Mulahey that ring of Accurate Striking +1 for that task seems more straight forward.

    The '%WSewers%.ARE' is using a variable for the area filename, since the filename will be different between BG1, BGT, Tutu, BGEE, and EET. So, to make a mod compatible across different platforms, you need to use variables for the area filenames. The variables are declared in the cpmvars.tpa files in the lib subdirectory of BG1UB.

    For example, in BG1, the variable declaration for the West Sewers area is:

    OUTER_SPRINT "WSewers" "AR0224"

    While for Tutu, it is:

    OUTER_SPRINT "WSewers" "FW0224"

    And for BGT:

    OUTER_SPRINT "WSewers" "AR7324"

    The rest of it is some advanced WeiDU hacking, but not too difficult to understand once you understand the .ARE file structure. Basically, it is looping over the containers in the ARE file, looking for "Container 1" (it is also checking the container location since another mod, Fields of the Dead, is known to alter the container name). When finds Container 1, it replaces the item MISC80 with MISC79.

    @CamDawg's method is definitely simpler, but you will still need to use variables for the script filenames if you want compatibility across BG1, Tutu, BGT, BGEE, and EET.

    WithinAmnesia
  • GwendolyneGwendolyne Member Posts: 174
    edited December 6

    I got Mulahey to equip the Ring of Accurate Striking +1 but I am still at a loss as to how to add and remove items in the Chest (Container1) in 5405.ARE any .tp2 suggestions?

    If there is only a single instance of the item you want to delete in a area, you can use this:
    // REMOVE ITEM USED BY TAZOK FROM ORIGINAL LOCATIONS
    
    COPY_EXISTING ~AR1301.are~ ~override~	// Removes Orc Leather +3
    	LPF DELETE_AREA_ITEM STR_VAR item_to_delete = "LEAT16" END 
    BUT_ONLY

    If there are many same items populated in several containers, it is a little bit complicated and must be written by hand (that's what I called a "homemade function").

    WithinAmnesia
  • WithinAmnesiaWithinAmnesia Member Posts: 799
    edited December 8
    CamDawg said:

    Honestly, I usually just script container inventory changes. Containers have unique DVs--it's the 'container name' from the area file, without the spaces--so you can manipulate them with the area script. Add something like this to the bottom of the area script, ar5405.bcs:

    IF
      Global("CD_do_this_once","MYAREA",0)
    THEN
      RESPONSE #100
        ActionOverride("Container1",DestroyItem("bar"))
        ActionOverride("Container1",CreateItem("foo",0,0,0))
        SetGlobal("CD_do_this_once","MYAREA",1)
    END
    This would add the item 'foo' to the container and remove the item 'bar'.

    @CamDawg Okay if I put the following in the .tp2 file for Xan's New Groove the extra content for the chest in Mulahey's Lair should work?

    Plan A: Okay so to make the default chest in AR5405.ARE become this (plus an extra new healing potion and some random treasure preserved from Classic Baldur's Gate) for what items it contains:


    I would have to remove all of the default items found in the base game and then add of the above items in descending order like this?
    IF
      Global("OL_Xans_New_Groove","AR5405",0)
    THEN
      RESPONSE #100
        ActionOverride("Container1",DestroyItem("POTN18"))
        ActionOverride("Container1",DestroyItem("POTN08"))
        ActionOverride("Container1",DestroyItem("POTN08"))
        ActionOverride("Container1",DestroyItem("SW1H08"))
        ActionOverride("Container1",DestroyItem("MISC07"))
        ActionOverride("Container1",DestroyItem("SCRL67"))
        ActionOverride("Container1",DestroyItem("SCRL76"))
        ActionOverride("Container1",DestroyItem("SCRL69"))
        ActionOverride("Container1",DestroyItem("SCRL81"))
        ActionOverride("Container1",DestroyItem("SCRL75"))
        ActionOverride("Container1",DestroyItem("SCRL99"))
        ActionOverride("Container1",DestroyItem("SW1H13"))
        ActionOverride("Container1",CreateItem("POTN18",0,0,0))
        ActionOverride("Container1",CreateItem("POTN08",0,0,0))
        ActionOverride("Container1",CreateItem("POTN08",0,0,0))
        ActionOverride("Container1",CreateItem("OLPOTN01",0,0,0))
        ActionOverride("Container1",CreateItem("OLPOTN02",0,0,0))
        ActionOverride("Container1",CreateItem("SW1H08",0,0,0))
        ActionOverride("Container1",CreateItem("DART01",80,0,0))
        ActionOverride("Container1",CreateItem("MISC07",790,0,0))
        ActionOverride("Container1",CreateItem("SCRL67",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL76",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL69",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL81",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL75",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL72",2,0,0))
        ActionOverride("Container1",CreateItem("SCRL84",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL99",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL95",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL98",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL1P",0,0,0))
        ActionOverride("Container1",CreateItem("OLSW1H13",1,1,1))
        ActionOverride("Container1",CreateItem("OLSHLD02",1,0,0))
        ActionOverride("Container1",CreateItem("OLCHAN01",0,0,0))
        ActionOverride("Container1",CreateItem("OLHELM21",3,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE01",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE01",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE02",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE02",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE03",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE03",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE04",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE04",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE05",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE05",0,0,0))
        SetGlobal("OL_Xans_New_Groove","AR5405",1)
    END

    Plan B: Push for the highest success rate and simplify the moving parts and just remove the basic Moonblade +3 (SW1H13) and add the remastered Moonblade +3 (OLSW1H13) and all of the extra items for Xan?
    IF
      Global("OL_Xans_New_Groove","AR5405",0)
    THEN
      RESPONSE #100
        ActionOverride("Container1",DestroyItem("SW1H13"))
        ActionOverride("Container1",CreateItem("OLPOTN01",0,0,0))
        ActionOverride("Container1",CreateItem("OLPOTN02",0,0,0))
        ActionOverride("Container1",CreateItem("DART01",80,0,0))
        ActionOverride("Container1",CreateItem("SCRL72",2,0,0))
        ActionOverride("Container1",CreateItem("SCRL84",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL95",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL98",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL1P",0,0,0))
        ActionOverride("Container1",CreateItem("OLSW1H13",1,0,0))
        ActionOverride("Container1",CreateItem("OLSHLD02",1,0,0))
        ActionOverride("Container1",CreateItem("OLCHAN01",0,0,0))
        ActionOverride("Container1",CreateItem("OLHELM21",3,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE01",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE01",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE02",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE02",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE03",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE03",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE04",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE04",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE05",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE05",0,0,0))
        SetGlobal("OL_Xans_New_Groove","AR5405",1)
    END


    Will these work? (P.S. It wants something more before [parse error at the start] so I am not exactly sure what the complete text will look like that works in the .tp2 file. I am not sure what to look for what makes a success verses a failure in this line of work; I am just roughly stumbling in the dark searching for a way forward).

    Post edited by WithinAmnesia on
  • AstroBryGuyAstroBryGuy Member Posts: 3,362
    @WithinAmnesia - If you want your mod to be compatible with BGT, Tutu, and EET, you should use "MYAREA" instead of "AR5405", as CamDawg did in his example. BG1 area filenames are changed in BGT, Tutu, and EET due to conflicts with BG2 area filenames.

    WithinAmnesia
  • WithinAmnesiaWithinAmnesia Member Posts: 799
    edited December 7

    @WithinAmnesia - If you want your mod to be compatible with BGT, Tutu, and EET, you should use "MYAREA" instead of "AR5405", as CamDawg did in his example. BG1 area filenames are changed in BGT, Tutu, and EET due to conflicts with BG2 area filenames.

    Okay, I am neutral on how it works so what ever works; I am after a path that leads to the highest chance of success across as many scenarios as possible.

    I am without experience in doing this operation so I am putting my thoughts in the open to be filtered, processed and reiterated and hopefully rebuilt into something that works.

    If I can get an example of what should be in the .tp2 file to be as useful to as many people as possible for this project I will gladly use it; again I am a bit in the dark and looking for brilliance.

    P.S. How does "MYAREA" work? As in what is required to implement the system for a successful install of the module for as many different set ups as possible? It is not that I disagree on what path to choose, I simply do not currently have a path and I am looking for a lead to solve this puzzle.

  • CamDawgCamDawg Member, Developer Posts: 3,216
    Variables have three degrees of 'scope'. A GLOBAL variable is exactly what it says on the package, a variable that can be checked any time by any object. A LOCALS variable is something unique to the object running the script, e.g. you see these used by NPCs to track their banters or by combat scripts to track what they've cast, etc. LOCALS are not accessible to other objects*, nor can every object store LOCALS variables, so these tend to get limited to creatures and their scripting. An area-scope variable is more like a GLOBAL, except that it's limited to objects in the area. Good coding practice is to try and limit the scope of your variables to the minimum needed. Since containers can't use LOCALS, area is the next-best thing.

    Using MYAREA in a script will get converted to the proper area variable by the engine, in this specific case, to AR5405. It's a good shorthand for scripts like this that may end up in multiple, differently-named areas (which is every area for mods that cover any combo of BGT-Tutu-BGEE; BG doesn't support MYAREA).

    I think otherwise the script you posted should work. Same it as a baf file, and then use

    EXTEND_BOTTOM ~ar5405.bcs~ ~mymod/myfile.baf~

    in the tp2. With the caveat that you'll eventually want to use the libraries that @AstroBryGuy has mentioned, in which case you'll end up replacing the 'ar5405' with the right variable for the area.

    * Technically, TriggerOverride lets you futz around this limitation but the broader point stands.

    WithinAmnesia
  • WithinAmnesiaWithinAmnesia Member Posts: 799
    Okay that was very educational @CamDawg yet I am still not 100% assured as of what the course of action should be; is this correct?


    1.) Save the following as a .baf file named OL5405.baf (OL being my registered moniker / prefix):
    IF
      Global("OL_Xans_New_Groove","MYAREA",0)
    THEN
      RESPONSE #100
        ActionOverride("Container1",DestroyItem("POTN18"))
        ActionOverride("Container1",DestroyItem("POTN08"))
        ActionOverride("Container1",DestroyItem("POTN08"))
        ActionOverride("Container1",DestroyItem("SW1H08"))
        ActionOverride("Container1",DestroyItem("MISC07"))
        ActionOverride("Container1",DestroyItem("SCRL67"))
        ActionOverride("Container1",DestroyItem("SCRL76"))
        ActionOverride("Container1",DestroyItem("SCRL69"))
        ActionOverride("Container1",DestroyItem("SCRL81"))
        ActionOverride("Container1",DestroyItem("SCRL75"))
        ActionOverride("Container1",DestroyItem("SCRL99"))
        ActionOverride("Container1",DestroyItem("SW1H13"))
        ActionOverride("Container1",CreateItem("POTN18",0,0,0))
        ActionOverride("Container1",CreateItem("POTN08",0,0,0))
        ActionOverride("Container1",CreateItem("POTN08",0,0,0))
        ActionOverride("Container1",CreateItem("OLPOTN01",0,0,0))
        ActionOverride("Container1",CreateItem("OLPOTN02",0,0,0))
        ActionOverride("Container1",CreateItem("SW1H08",0,0,0))
        ActionOverride("Container1",CreateItem("DART01",80,0,0))
        ActionOverride("Container1",CreateItem("MISC07",790,0,0))
        ActionOverride("Container1",CreateItem("SCRL67",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL76",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL69",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL81",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL75",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL72",2,0,0))
        ActionOverride("Container1",CreateItem("SCRL84",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL99",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL95",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL98",0,0,0))
        ActionOverride("Container1",CreateItem("SCRL1P",0,0,0))
        ActionOverride("Container1",CreateItem("OLSW1H13",1,0,0))
        ActionOverride("Container1",CreateItem("OLSHLD02",1,0,0))
        ActionOverride("Container1",CreateItem("OLCHAN01",0,0,0))
        ActionOverride("Container1",CreateItem("OLHELM21",3,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE01",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE01",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE02",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE02",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE03",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE03",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE04",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE04",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE05",0,0,0))
        ActionOverride("Container1",CreateItem("RNDTRE05",0,0,0))
        SetGlobal("OL_Xans_New_Groove","MYAREA",1)
    END

    Step 2.) In the XansNewGroove file add the OL5405.baf file and in .tp2 file write the following line:

    EXTEND_BOTTOM ~AR5405.bcs~ ~XansNewGroove/OL5405.baf~


    Step 3.) ???

    Profit?


    P.S. I hope that people will enjoy this module and I wish to be cooperative and helpful (as I can) with the community if there is a desire to find a way to make this as compatible as possible.



    *One hour later* I did some tests and iterations and I got the first feature complete version to work, a bit weird how there is a WeiDU translation option 'artifact' left over from my other larger scale module Baldur's Gate Arms and Armour Emporium but it works on with Baldur's Gate: Siege of Dragonspear! Here it is on an early release! please do tell if you find a bud / error?:-)

Sign In or Register to comment.