Jump to content

Request for recheck on modifying BG2:EE AR0700 (WeiDU)


cmorgan

Recommended Posts

Folks who have made the full crossover to BG2:EE modding of areas - I have a question that I hope is just me being boneheaded...

 

I have the following code (tested, works perfectly on BG2):

 

 

PRINT @30038
/* steal Abandon06 info point and turn it into a travel region, add entrance point for c-ar01 to use to send party to AR0700    */
COPY_EXISTING ar0700.are override
    LPF ALTER_AREA_REGION
    INT_VAR
    type = ~2~
    cursor = ~30~
    STR_VAR
    region_name = ~Abandon06~
    destination_area = ~c-ar01~
    entrance_name = ~Trancar01~
    END
    LPF fj_are_structure
    INT_VAR
        fj_loc_x         = 2391
        fj_loc_y         = 1484
        fj_orientation = 4     // w
    STR_VAR
        fj_structure_type = entrance
        fj_name    = Exitc-ar01
    END
    ADD_MAP_NOTE #2254 #1342 ~blue~ @13144

 

On BG2:EE using this code works as well, except that the original tooltip still plays when the "hijacked" area is clicked on for transition.

 

I tried to load up the BG2:EE area in DLTCEP using WeiDU v38, but that just crashed DLTCEP.

Is there a different set of structures in place in BG2:EE that I need to work with differently?

Even more importantly, what tool are modern modders using to investigate and recheck BG2:EE areas?

Link to comment

OK, did some more research, and it looks like I have my own answers.

  • The above code works fine on both bg2 and bg2:ee, but in niether case does it deal with the embedded strref (In this case, Trigger 27, offset 0x470c, sttref #24486 on BG2:EE)
  • ALTER_AREA_REGION has no documented way to address the offset of the strref when dealing with an info trigger.
  • Luckily, for the millionth time, my darned good friend Yovaneth has found a way around the problem - http://www.simpilot.net/~sc/dltcep/infotriggers/main.htm and the long and short of it is you use NI to get the hex offset of the infopoint text, then use SAY and your .tra reference to write what you want in there.
  • Looking through BamDog forums. the latest NI is here: https://github.com/Argent77/NearInfinity/releases where Argent77 has kept things rolling; Avenger_teambg has the latest files for DLTCEP here: http://sourceforge.net/projects/gemrb/files/Utilities/DLTCEP%207.7/

TEMPORARY SOLUTION:

 

Manually find the hex offset and reassign the sttref (dynamically, using a .tra reference) ONLY DO THIS ON YOUR OWN AREA WHEN BUILDING IT FROM SCRATCH!!!

 

Got this code to do what I wanted on BG2:EE:

PRINT @30038
/* steal Abandon06 info point and turn it into a ravel region, add entrance point for c-ar01 to use to send party to AR0700    */
COPY_EXISTING ar0700.are override
    /* Turn Abandon06 into an entry point for C-AR01, The Broken Sword */
    LPF ALTER_AREA_REGION
        INT_VAR
            type = ~2~
            cursor = ~30~
        STR_VAR
            region_name = ~Abandon06~
            destination_area = ~c-ar01~
            entrance_name = ~Trancar01~
    END
    SAY 0x470c @13144 // Hex offset of trigger 27 in NI on BG2:EE AR0700 | @13144 = The Broken Sword
    /* give an exit point for C-AR01, The Broken Sword */
    LPF fj_are_structure
        INT_VAR
            fj_loc_x         = 2391
            fj_loc_y         = 1484
            fj_orientation = 4     // west
        STR_VAR
            fj_structure_type = entrance
            fj_name    = Exitc-ar01
    END
    ADD_MAP_NOTE #2254 #1342 ~blue~ @13144

Now I just need to make sure the hex offfset is the same on AR0700 on BG2. I believe everyone worked hard to avoid strange reorderings, so... I am pretty sure it will be the same. I will refrain from throwing it up as a fix on GitHub until i have confirmation.

 

Test install worked, looked fine in NI, and most importantly worked ingame without crashing AR0700 or C-AR01

Gurus, my hope is that someone will add the parameter to STR_VAR in the ALTER_AREA_REGION - I'd hope that weidu could find the offset even if something messed with it, whereas I can't get my head around the code necessary to identify the trigger, find the identifier, cont through the structure, and put my values in :(

Link to comment

This option is indeed missing in ALTER_AREA_REGION. You can easily add it though, by taking the original function from here and adding the required variable, such as this (I've named it "info_strref"):

 

DEFINE_PATCH_FUNCTION ALTER_AREA_REGION
  INT_VAR type        = "-1" // region type at 0x20; negative values mean no change
          cursor      = "-1" // cursor type at 0x34; negative values mean no change
          trap_detect = "-1" // difficulty of trap detection at 0x68; negative values mean no change
          trap_remove = "-1" // difficulty of trap removal at 0x6a; negative values mean no change
          trapped     = "-1" // is trapped? at 0x6c; negative values mean no change
          detected    = "-1" // is detected? at 0x6e; negative values mean no change
          info_strref = "-2" // info text at 0x64; negative values < -1 mean no change
          // flag_ vars affect flags starting at 0x60; 0 means remove flag, 1 means add flag, -1 no change
          flag_locked           = "-1" // locked, bit0
          flag_resets           = "-1" // trap resets, bit1
          flag_party_required   = "-1" // party required, bit2
          flag_trap_detectable  = "-1" // trap can be detected, bit3
          flag_trap_enemies     = "-1" // trap can be set off by enemies, bit4
          flag_tutorial         = "-1" // tutorial trigger, bit5
          flag_trap_npcs        = "-1" // trap can be set off by npcs, bit6
          flag_silent           = "-1" // silent trigger, bit7
          flag_deactivated      = "-1" // deactivated, bit8
          flag_impassable_npc   = "-1" // can not be passed by npcs, bit9
          flag_activation_point = "-1" // use activation point, bit10
          flag_connect_to_door  = "-1" // connected to door, bit11
  STR_VAR region_name = ""     // required, at 0x00, used to match region
          destination_area    = "same" // changes destination area at 0x38; "same" means no change
          entrance_name     = "same" // changes entrance name at 0x40; "same" means no change
          door_key     = "same" // resref of key to unlock at 0x74; "same" means no change
          door_script  = "same" // resref of region script at 0x7c; "same" means no change
BEGIN

  READ_SHORT 0x5a trig_num
  READ_LONG  0x5c trig_off
  FOR (index = 0 ; index < trig_num ; ++index) BEGIN
    READ_ASCII (trig_off + (index * 0xc4)) trig_name_file (32) NULL
    PATCH_IF ("%region_name%" STRING_COMPARE_CASE  "%trig_name_file%" = 0) BEGIN
      PATCH_IF (type >= 0)                 BEGIN WRITE_SHORT (trig_off + 0x20 + (index * 0xc4)) type        END
      PATCH_IF (cursor >= 0)               BEGIN WRITE_LONG  (trig_off + 0x34 + (index * 0xc4)) cursor      END
      PATCH_IF (info_strref >= "-1")       BEGIN WRITE_LONG  (trig_off + 0x64 + (index * 0xc4)) info_strref END
      PATCH_IF (trap_detect >= 0)          BEGIN WRITE_SHORT (trig_off + 0x68 + (index * 0xc4)) trap_detect END
      PATCH_IF (trap_remove >= 0)          BEGIN WRITE_SHORT (trig_off + 0x6a + (index * 0xc4)) trap_remove END
      PATCH_IF (trapped >= 0)              BEGIN WRITE_SHORT (trig_off + 0x6c + (index * 0xc4)) trapped     END
      PATCH_IF (detected >= 0)             BEGIN WRITE_SHORT (trig_off + 0x6e + (index * 0xc4)) detected    END
      PATCH_IF (flag_locked = 0)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11111110) END
      PATCH_IF (flag_resets = 0)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11111101) END
      PATCH_IF (flag_party_required = 0)   BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11111011) END
      PATCH_IF (flag_trap_detectable = 0)  BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11110111) END
      PATCH_IF (flag_trap_enemies = 0)     BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11101111) END
      PATCH_IF (flag_tutorial = 0)         BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b11011111) END
      PATCH_IF (flag_trap_npcs = 0)        BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b10111111) END
      PATCH_IF (flag_silent = 0)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BAND 0b01111111) END
      PATCH_IF (flag_deactivated = 0)      BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BAND 0b11111110) END
      PATCH_IF (flag_impassable_npc = 0)   BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BAND 0b11111101) END
      PATCH_IF (flag_activation_point = 0) BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BAND 0b11111011) END
      PATCH_IF (flag_connect_to_door = 0)  BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BAND 0b11110111) END
      PATCH_IF (flag_locked = 1)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT0) END
      PATCH_IF (flag_resets = 1)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT1) END
      PATCH_IF (flag_party_required = 1)   BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT2) END
      PATCH_IF (flag_trap_detectable = 1)  BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT3) END
      PATCH_IF (flag_trap_enemies = 1)     BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT4) END
      PATCH_IF (flag_tutorial = 1)         BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT5) END
      PATCH_IF (flag_trap_npcs = 1)        BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT6) END
      PATCH_IF (flag_silent = 1)           BEGIN WRITE_BYTE  (trig_off + 0x60 + (index * 0xc4)) (THIS BOR BIT7) END
      PATCH_IF (flag_deactivated = 1)      BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BOR BIT0) END
      PATCH_IF (flag_impassable_npc = 1)   BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BOR BIT1) END
      PATCH_IF (flag_activation_point = 1) BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BOR BIT2) END
      PATCH_IF (flag_connect_to_door = 1)  BEGIN WRITE_BYTE  (trig_off + 0x61 + (index * 0xc4)) (THIS BOR BIT3) END
      PATCH_IF ("%destination_area%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (trig_off + 0x38 + (index * 0xc4)) "%destination_area%" #8
      END
      PATCH_IF ("%entrance_name%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (trig_off + 0x40 + (index * 0xc4)) "%entrance_name%" #32
      END
      PATCH_IF ("%door_key%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (trig_off + 0x74 + (index * 0xc4)) "%door_key%" #8
      END
      PATCH_IF ("%door_script%" STRING_COMPARE_CASE "same") BEGIN
        WRITE_ASCIIE (trig_off + 0x7c + (index * 0xc4)) "%door_script%" #8
      END
    END
  END

END

// ############# Your TP2 code #############

COPY_EXISTING ar0700.are override
  /* Turn Abandon06 into an entry point for C-AR01, The Broken Sword */
  LPF ALTER_AREA_REGION
    INT_VAR
      type = ~2~
      cursor = ~30~
      info_strref = RESOLVE_STR_REF(@13144) // The Broken Sword
    STR_VAR
      region_name = ~Abandon06~
      destination_area = ~c-ar01~
      entrance_name = ~Trancar01~
  END
  // ...

 



Another option is to write a small function by yourself which updates the information text of a specific region structure. You should avoid using hardcoded offsets, however, because you'll be in big trouble as soon as any mod adds or removes an actor structure to/from the area file.

Link to comment

Way cool - thanks!

 

Forgot the freedom to remove was there - yes, hardcoded and a major area is definitely a bad thing!!!

 

To doublecheck, with ALTER_AREA_REGION already rolled into WeiDU, and my .tp2 using the same patch function name, I should probably do a

ARGENT_ALTER_AREA_REGION tag, at least until I can ask to add the information to the regular function, right?

 

And on RESOLVE_STR_REF(@13144) - since the .tra files are loaded by weidu first, I am pretty sure the strrefs are available for this before any .d is compiled, right?

Link to comment

Heh. If I read first THEN asked it would be better...

RESOLVE_STR_REF Resolves the given text (adding it to the tlk), and returns its TLK index (so you can pass the result of this command to a function which then uses WRITE_LONG rather than SAY.

 

I changed the name to ARGENTALTER_AREA_REGION, tested it out on BG2EE, and everything rocks. Thank you!

Link to comment

Archived

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

×
×
  • Create New...