Skip to content

Adding items to containers in Areas?

GreenerGreener Member Posts: 430
edited November 2017 in General Modding
This adds an item to a creature
COPY_EXISTING_REGEXP GLOB ~^_?hlkoshi\.cre$~ ~override~ 
REPLACE_CRE_ITEM ~katana4~ #0 #0 #0 ~NONE~ ~SHIELD~ EQUIP
This adds an item to a store
COPY_EXISTING ~wmart1.sto~ ~override/wmart1.sto~                  
ADD_STORE_ITEM ~Katana3~   AFTER  ~wastaff~ #1 #0 #0 ~IDENTIFIED~ #1 
I'm trying to add an item to the container (pool 1) of area AR0310.ARE in BG2EE, how would I script this via a .tp2 file?
Post edited by Greener on

Comments

  • PaulaMigratePaulaMigrate Member Posts: 1,201
    edited November 2017
    There is not such an equivalent. You would use the area script
    ar 0310.bcs
    IF
    Global("IntoPool","ar0310",0)
    THEN
    RESPONSE #100
    SetGlobal("IntoPool",ar0310",1)
    ActionOverride("Pool 1",CreateItem("MyItem",0,0,0))
    END
  • GreenerGreener Member Posts: 430

    There is not such an equivalent. You would use the area script
    ar 0310.bcs

    IF
    Global("IntoPool","ar0310",0)
    THEN
    RESPONSE #100
    SetGlobal("IntoPool",ar0310",1)
    ActionOverride("Pool 1",CreateItem("MyItem",0,0,0))
    END
    Thank you
  • GwendolyneGwendolyne Member Posts: 461
    Or you can use the WeiDU fj_are_structure function. :)
  • GreenerGreener Member Posts: 430
    edited November 2017

    Or you can use the WeiDU fj_are_structure function. :)

    I may need a little more help with that if possible...

    Currently, I've written this (but it's not working)

    //Added to my .tp2 file
    COMPILE ~Odachi/Scripts/AR0310.baf~
    EXTEND_TOP ~AR0310.bcs~ ~Odachi/Scripts/AR0310.baf~ // Add item to container (pool 1)
    //AR0310.baf
    IF
    Global("IntoPool","ar0310",0)
    THEN
    RESPONSE #100
    SetGlobal("IntoPool","ar0310",1)
    ActionOverride("Pool 1",CreateItem("odachi",0,0,0)) //Odachi
    Continue()
    END
  • GreenerGreener Member Posts: 430
    edited November 2017
    I've figured it out...
    COPY_EXISTING AR0310.are override 
      LPF fj_are_structure
        INT_VAR
    	  fj_con_itm_idx = 0 
        STR_VAR
    	  fj_structure_type = itm
    	  fj_name = odachi 
      END
    BUT_ONLY
    Thank you for all of your help!
  • CamDawgCamDawg Member, Developer Posts: 3,438
    Glad you got it working! In case you were wondering, though:
    COMPILE ~Odachi/Scripts/AR0310.baf~
    EXTEND_TOP ~AR0310.bcs~ ~Odachi/Scripts/AR0310.baf~ // Add item to container (pool 1)
    Compiling scripts also moves them to the override, so what this code essentially does is compile Odachi/Scripts/AR0310.baf into override/AR0310.bcs (deleting the previous AR0310.bcs, if it exists) and then extends itself with another copy of itself--you can drop the COMPILE outright here. Also, in general you should use EXTEND_BOTTOM instead of EXTEND_TOP, even with the Continue().
    IF
    Global("IntoPool","ar0310",0)
    THEN
    RESPONSE #100
    SetGlobal("IntoPool","ar0310",1)
    ActionOverride("Pool 1",CreateItem("odachi",0,0,0)) //Odachi
    Continue()
    END
    One other tricky thing that happens with containers as objects in scripts is that they ignore spaces. So that ActionOverride should be directed at "Pool1" instead of "Pool 1".

    However, the big reason why you couldn't get this to work is that AR0310 is one of those very rare areas that doesn't have its area script assigned. You'd need to also add this to your tp2:
    COPY_EXISTING ~ar0310.are~ ~override~
      WRITE_ASCII 0x94 ~ar0310~ #8
      BUT_ONLY


  • GreenerGreener Member Posts: 430
    edited November 2017
    CamDawg said:

    Glad you got it working! In case you were wondering, though:

    COMPILE ~Odachi/Scripts/AR0310.baf~
    EXTEND_TOP ~AR0310.bcs~ ~Odachi/Scripts/AR0310.baf~ // Add item to container (pool 1)
    Compiling scripts also moves them to the override, so what this code essentially does is compile Odachi/Scripts/AR0310.baf into override/AR0310.bcs (deleting the previous AR0310.bcs, if it exists) and then extends itself with another copy of itself--you can drop the COMPILE outright here. Also, in general you should use EXTEND_BOTTOM instead of EXTEND_TOP, even with the Continue().
    IF
    Global("IntoPool","ar0310",0)
    THEN
    RESPONSE #100
    SetGlobal("IntoPool","ar0310",1)
    ActionOverride("Pool 1",CreateItem("odachi",0,0,0)) //Odachi
    Continue()
    END
    One other tricky thing that happens with containers as objects in scripts is that they ignore spaces. So that ActionOverride should be directed at "Pool1" instead of "Pool 1".

    However, the big reason why you couldn't get this to work is that AR0310 is one of those very rare areas that doesn't have its area script assigned. You'd need to also add this to your tp2:
    COPY_EXISTING ~ar0310.are~ ~override~
      WRITE_ASCII 0x94 ~ar0310~ #8
      BUT_ONLY
    Thank you for your assistance! I did manage to utilize the WeiDU fj_are_structure function instead of using an area script.
  • PaulaMigratePaulaMigrate Member Posts: 1,201
    Greener said:

    I've figured it out...

    COPY_EXISTING AR0310.are override 
      LPF fj_are_structure
        INT_VAR
    	  fj_con_itm_idx = 0 
        STR_VAR
    	  fj_structure_type = itm
    	  fj_name = odachi 
      END
    BUT_ONLY
    Thank you for all of your help!
    Just my curiosity - in the case of ar0310 there is just a single container, so if i want to address one in an area with multiple conrainers, what would I use.
  • GreenerGreener Member Posts: 430

    Greener said:

    I've figured it out...

    COPY_EXISTING AR0310.are override 
      LPF fj_are_structure
        INT_VAR
    	  fj_con_itm_idx = 0 
        STR_VAR
    	  fj_structure_type = itm
    	  fj_name = odachi 
      END
    BUT_ONLY
    Thank you for all of your help!
    Just my curiosity - in the case of ar0310 there is just a single container, so if i want to address one in an area with multiple conrainers, what would I use.
    Adjust "0" fj_con_itm_idx = 0 to the specific container you want. I found each container identified in NI
  • PaulaMigratePaulaMigrate Member Posts: 1,201
    Greener said:

    Greener said:

    I've figured it out...

    COPY_EXISTING AR0310.are override 
      LPF fj_are_structure
        INT_VAR
    	  fj_con_itm_idx = 0 
        STR_VAR
    	  fj_structure_type = itm
    	  fj_name = odachi 
      END
    BUT_ONLY
    Thank you for all of your help!
    Just my curiosity - in the case of ar0310 there is just a single container, so if i want to address one in an area with multiple conrainers, what would I use.
    Adjust "0" fj_con_itm_idx = 0 to the specific container you want. I found each container identified in NI
    Ah, thanks.
    And sorry, the area script didn't work for you. I have an EET install and therefore every area in the game has a script assigned.
  • argent77argent77 Member Posts: 3,434
    Another option for adding items to area containers would be the patch function ADD_AREA_ITEM.
  • GreenerGreener Member Posts: 430
    argent77 said:

    Another option for adding items to area containers would be the patch function ADD_AREA_ITEM.

    Thank you for the comment, I've been searching around for an example using the ADD_AREA_ITEM patch function and so far haven't found one, would you be able to assist me?
  • argent77argent77 Member Posts: 3,434
    I'm currently using it in my Chaos Sorcerer Kit mod for a number of items (examples 1, 2, 3 and 4). Important: Container index starts at 1 for this function!

    More info can be found in the WeiDU docs.
  • GreenerGreener Member Posts: 430
    edited November 2017
    @argent77

    Thank you, for the examples I must admit I tried look in the WeiDU docs but got a little lost...

    In you opinion is this better (or cleaner) than:
    COPY_EXISTING AR0310.are override 
      LPF fj_are_structure
        INT_VAR
    	  fj_con_itm_idx = 0 
        STR_VAR
    	  fj_structure_type = itm
    	  fj_name = odachi 
      END
    BUT_ONLY
  • argent77argent77 Member Posts: 3,434
    Both functions are equally valid. You can choose one or the other.
  • GreenerGreener Member Posts: 430
    argent77 said:

    Both functions are equally valid. You can choose one or the other.

    Thank you, I appreciate your time and advice!
Sign In or Register to comment.