Jump to content

Editing existing areas for a mod


Recommended Posts

I'm currently doing a mod where I'd like to add in some new areas but link them to existing ones in game. I wasn't able to really find too many tutorials or walk-throughs on area editing, so this is all a bit of trial and error on my part, but is the only way to add a new travel point in an existing area to edit the .are file directly and export that into the override folder? I feel like that's just a big no-no and wouldn't play well with other mods at all, but I just can't for the life of me think of another way to do it. 

Thanks!

Link to comment

1. You can add travel regions (and exitpoints for the opposite direction of travel) into areas easily by using the weidu funktion "fj_are_structure". Have a look into the WeiDU readme how to use it, also several mods use it, e.g. bg1re for the component "Necromancer's Trouble" which adds and entrance to one of the houses in N Baldur's Gate. Note: if you want a door with animated open/closed status, things get a lot more complicated. This example gives just a field where the cursor changes and the group travels upon clicking on it:

Spoiler

COPY_EXISTING ~%NBaldursGate%.are~ ~override~ //all changes are done to this area

/* add travel region that links to other area */
  LAUNCH_PATCH_FUNCTION  ~fj_are_structure~
    INT_VAR
    fj_type         = 2    //travel - kind of trigger area
    fj_box_left     = 4183  //highes x coordinate
    fj_box_top      = 2588 //highes y coordinate
    fj_box_right    = 4309 //lowest x coordinate
    fj_box_bottom   = 2662 //lowest y coordinate
    fj_cursor_idx   = 30   //door - mouse cursor symbol
    fj_vertex_0     = 4183 + (2588 << 16) //start with the lowest point: x coodinate - y coordinate
    fj_vertex_1     = 4309 + (2588 << 16)
    fj_vertex_2     = 4309 + (2662 << 16)
    fj_vertex_3     = 4183 + (2662 << 16)
    STR_VAR
    fj_structure_type   = region
    fj_name             = Tranc#q1 //name of this travel region so you can address it via script etc.
    fj_destination_area = c#q111 //name of the destination area
    fj_destination_name = c#Exq111 //name of exitpoint in destination area
  END

/* add exitpoint for backwards travel */
  LAUNCH_PATCH_FUNCTION  ~fj_are_structure~
    INT_VAR
    fj_loc_x       = 4213 //x coordinate where the group will spawn
    fj_loc_y       = 2638 //y coordinate where the group will spawn
    fj_orientation = 4   //W - face direction in which group is looking after coming through
    STR_VAR
    fj_structure_type = entrance
    fj_name           = c#Exitq1 //name of this new exitpoint so it can be referenced for the travel region of the other area
  END
BUT_ONLY

2. You can add areas to the worldmap. Those areas need a "world travel" region at the corners of their search maps - it's just a special color but I don't know which one.

Adding to the worldmap is done by patching accordingly (if the original game's worldmap is big enough) or patching files for the Wolrldmap Mod (if your area is outside the game's worldmap), or both (preferable, as many mods need the Worldmap mod so this should be always taken into account). Worldmap patching is done in several mods as well. For example, in Ascalon's Breagar I do it in all possible ways: I'm patching all (BGII) areas directly, as well as provide info for the Worldmap mod so the mod's area will be added there, too. The listed files give info about the area code and name, coordinates, whether it is supposed to be available from the start or only after being revealed, and from which other areas etc. This is how the tp2 looks, for an example of the needed files please refer to the mod package-

Note: this example also works independent on install order for the Worldmap mod. However, there is still an oversight in the ADD_WORLDMAP_TBL which leads to the icons being misplaced if the mod is installed after the Worldmap mod.

Spoiler

//Worldmap
MKDIR ~Worldmap~

/* this is only because the worldmap icons numbers do not match for the different games, so I'm workin with the variable %icon_index% inside the files */

ACTION_IF GAME_IS ~bgt eet~ BEGIN
    COPY ~ACBre/Worldmap/BP/areas.tbl~  ~ACBre/Worldmap/areas.tbl~
        REPLACE_TEXTUALLY ~icon_index~ ~79~
END
ACTION_IF (GAME_IS ~tob bg2ee~ AND NOT GAME_IS ~bgt~) BEGIN
    COPY ~ACBre/Worldmap/BP/areas.tbl~  ~ACBre/Worldmap/areas.tbl~
        REPLACE_TEXTUALLY ~icon_index~ ~11~
END

/* this is the code needed for the Worldmap mod */
ACTION_IF FILE_EXISTS ~Worldmap/map_mods_areas.tbl~ THEN BEGIN
  COPY ~Worldmap/map_mods_areas.tbl~  ~Worldmap~
  APPEND_FILE ~ACBre/Worldmap/areas.tbl~
END ELSE BEGIN
  COPY ~ACBre/Worldmap/areas.tbl~ ~Worldmap/map_mods_areas.tbl~
END
ACTION_IF FILE_EXISTS ~Worldmap/map_mods_links.tbl~ BEGIN
  COPY ~Worldmap/map_mods_links.tbl~  ~Worldmap~
  APPEND_FILE ~ACBre/Worldmap/links.tbl~
END ELSE BEGIN
  COPY ~ACBre/Worldmap/links.tbl~ ~Worldmap/map_mods_links.tbl~
END
ACTION_IF FILE_EXISTS ~Worldmap/map_mods_trans.tra~ BEGIN
  COPY ~Worldmap/map_mods_trans.tra~  ~Worldmap~
  APPEND_FILE_EVALUATE ~ACBre/TRA/%LANGUAGE%/worldmap.tra~
END ELSE BEGIN
  COPY ~ACBre/TRA/%LANGUAGE%/worldmap.tra~ ~Worldmap/map_mods_trans.tra~
END

/* direct Worldmap-patching for EET */
ACTION_IF GAME_IS ~eet~ BEGIN
    INCLUDE ~ACBre/lib/add_worldmap_tbl.tpa~
    LAF ADD_WORLDMAP_TBL
        INT_VAR
        verbose = 1
        inclSv = 0
        STR_VAR
        path_to_areas = EVAL ~ACBre/Worldmap/EET/areas.tbl~
        path_to_areas_bp = EVAL ~ACBre/Worldmap/areas.tbl~
        path_to_links = EVAL ~ACBre/Worldmap/links.tbl~
        path_to_trans = EVAL ~ACBre/TRA/%LANGUAGE%/worldmap.tra~
    END
END

/* direct Worldmap-patching for BGT */
ACTION_IF GAME_IS ~bgt~ BEGIN
    INCLUDE ~ACBre/lib/add_worldmap_tbl.tpa~
    LAF ADD_WORLDMAP_TBL
        INT_VAR
        verbose = 1
        inclSv = 0
        STR_VAR
        path_to_areas = EVAL ~ACBre/Worldmap/BGT/areas.tbl~
        path_to_areas_bp = EVAL ~ACBre/Worldmap/areas.tbl~
        path_to_links = EVAL ~ACBre/Worldmap/links.tbl~
        path_to_trans = EVAL ~ACBre/TRA/%LANGUAGE%/worldmap.tra~
    END
END

/* direct Worldmap-patching for BGII(:EE) */
ACTION_IF (GAME_IS ~tob bg2ee~ AND NOT GAME_IS ~bgt~) BEGIN
    INCLUDE ~ACBre/lib/add_worldmap_tbl.tpa~
    LAF ADD_WORLDMAP_TBL
        INT_VAR
        verbose = 1
        inclSv = 0
        STR_VAR
        path_to_areas = EVAL ~ACBre/Worldmap/BG2/areas.tbl~
        path_to_areas_bp = EVAL ~ACBre/Worldmap/areas.tbl~
        path_to_links = EVAL ~ACBre/Worldmap/links.tbl~
        path_to_trans = EVAL ~ACBre/TRA/%LANGUAGE%/worldmap.tra~
    END
END

 

Link to comment

First of all, thank you so much for the help. 

Since you're copying an existing area into override though, would that still possibly cause conflict with other mods (say, if they both tried to add a new travel point to that same area)?

Edited by AWizardDidIt
Link to comment
On 4/18/2021 at 1:52 PM, AWizardDidIt said:

First of all, thank you so much for the help. 

Since you're copying an existing area into override though, would that still possibly cause conflict with other mods (say, if they both tried to add a new travel point to that same area)?

I don't know much about area editing, but in section 1 of jastey's response, she posted a patch function which is not quite the same as copying a file over to the override (which would definitely conflict with any mod that changed that area).

Basically, it takes an existing file and changes only the relevant 'parts' of that file as determined by the modder. This can still lead to conflicts--if your mod and another mod changed the exact same 'parts'-- but it is much less likely to cause conflicts.

For example, I could patch all spells to increase their range to 100, say, and another louder could change all spells to have a casting time of 6 and all spells would have a casting time of 6 and a range of 100. No conflict except possibly conceptual.

Link to comment
On 4/18/2021 at 7:52 PM, AWizardDidIt said:

Since you're copying an existing area into override though, would that still possibly cause conflict with other mods (say, if they both tried to add a new travel point to that same area)?

Sorry I didn't see this. As Grammarsalad pointed out, the "COPY_EXISTING" followed by the patch function means that the area in the game is taken and patched. The next mod takes the then current area version (with the changes from the first mod) and patches the new changes, and so forth. So, every mod patches its own travel regions to the same area and it's all compatible.

Also as Grammarsalad pointed out, the only thing that could happen is that, say, two mods add a travel region at the exact same spot. Then it might be that only one will be accessible in game. But that's easily fixed by one mod chaning the location of its travel region.

Link to comment
23 hours ago, AWizardDidIt said:

Ah! Thank you again for the clarification (and to you @Grammarsalad!). Still learning some of the ins and outs of weidu modding, but this explains it perfectly. 

:) glad to help (trust me: I've been there!)

Sometimes you will see "LPF" instead of "LAUNCH_PATCH_FUNCTION". It means the same thing. Patch functions presuppose a file that it will 'operate' on (in this case, an .are file). If you haven't copied one over, or copied an existing one as in this case, it will fail.

You will also see "LAF" or LAUNCH_ACTION_FUNCTION. They do a lot of the same things, but the main difference is that an action function does Not assume a file (often the function will copy an existing file and 'do stuff' to it like a patch function).

Link to comment
On 4/18/2021 at 3:15 AM, jastey said:

1. You can add travel regions (and exitpoints for the opposite direction of travel) into areas easily by using the weidu funktion "fj_are_structure". Have a look into the WeiDU readme how to use it, also several mods use it, e.g. bg1re for the component "Necromancer's Trouble" which adds and entrance to one of the houses in N Baldur's Gate. Note: if you want a door with animated open/closed status, things get a lot more complicated. This example gives just a field where the cursor changes and the group travels upon clicking on it:

  Hide contents

COPY_EXISTING ~%NBaldursGate%.are~ ~override~ //all changes are done to this area

/* add travel region that links to other area */
  LAUNCH_PATCH_FUNCTION  ~fj_are_structure~
    INT_VAR
    fj_type         = 2    //travel - kind of trigger area
    fj_box_left     = 4183  //highes x coordinate
    fj_box_top      = 2588 //highes y coordinate
    fj_box_right    = 4309 //lowest x coordinate
    fj_box_bottom   = 2662 //lowest y coordinate
    fj_cursor_idx   = 30   //door - mouse cursor symbol
    fj_vertex_0     = 4183 + (2588 << 16) //start with the lowest point: x coodinate - y coordinate
    fj_vertex_1     = 4309 + (2588 << 16)
    fj_vertex_2     = 4309 + (2662 << 16)
    fj_vertex_3     = 4183 + (2662 << 16)
    STR_VAR
    fj_structure_type   = region
    fj_name             = Tranc#q1 //name of this travel region so you can address it via script etc.
    fj_destination_area = c#q111 //name of the destination area
    fj_destination_name = c#Exq111 //name of exitpoint in destination area
  END

/* add exitpoint for backwards travel */
  LAUNCH_PATCH_FUNCTION  ~fj_are_structure~
    INT_VAR
    fj_loc_x       = 4213 //x coordinate where the group will spawn
    fj_loc_y       = 2638 //y coordinate where the group will spawn
    fj_orientation = 4   //W - face direction in which group is looking after coming through
    STR_VAR
    fj_structure_type = entrance
    fj_name           = c#Exitq1 //name of this new exitpoint so it can be referenced for the travel region of the other area
  END
BUT_ONLY

 

Do you know what the syntax is for the "INT_VAR fj_flags" variable for a region? I want to set the "Party Required" flag for a travel trigger.

Would it just be "4?"

Or "0b00000100?"
 

Edited by subtledoctor
Link to comment
On 4/18/2021 at 3:15 AM, jastey said:

STR_VAR
    fj_structure_type = entrance
    fj_name           = c#Exitq1 //name of this new exitpoint so it can be referenced for the travel region of the other area
  END

Another question: should these not be

fj_structure_type = ~entrance~
fj_name           = ~c#Exitq1~

I.e. with quotation marks or tildes? Since they are string variables?

Link to comment

The parser knows there's supposed to be a string there, so normally you don't need the tildes. The tildes won't break it either. You would need the tildes if your string had a delimiter character in it, to avoid ambiguity. For example (randomly picking an area), BG2's AR0408 has three barrels in the are art, two of which are containers "Barrel 1" and "Barrel 2". If you wanted to make the third one into a new container "Barrel 3", you'd call fj_are_structure using "fj_name = ~Barrel 3~". Using "fj_name = Barrel 3" would break things, as the parser would be wondering what the string variable "3" was doing in the function and why you weren't defining it properly.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...