Author Topic: Fixes to store fixes  (Read 12021 times)

Offline jastey

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1524
  • Gender: Female
Re: Fixes to store fixes
« Reply #25 on: March 30, 2014, 04:00:53 PM »
Thank you very much for the corrections. I will change it accordingly.

I don't have a BGT-install, so any help is welcome. I did scan the BGT v18, though, and I did not spot the Maltz, shop01, shop05, and Alyth references as they are for BG1. In Tutu they are not there, definitely.

Offline Salk

  • Planewalker
  • *****
  • Posts: 873
Re: Fixes to store fixes
« Reply #26 on: April 01, 2014, 12:56:57 AM »
If I had to hire someone for quality testing, it'd be Hurricane! :)

Hurricane

  • Guest
Re: Fixes to store fixes
« Reply #27 on: April 01, 2014, 01:47:50 PM »
Hey, thank you so much, Salk. :) Yeah, you know me, I consider it my duty to scrutinize the code until I find something, so I can run off to the mod creators and pester them about it. :D

Looking into the Maltz situation in BGT now, will report shortly...

Offline jastey

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1524
  • Gender: Female
Re: Fixes to store fixes
« Reply #28 on: April 02, 2014, 12:10:54 PM »

Code: [Select]
COPY_EXISTING ~%EBaldursGate_KeexieTavern_L1%.ARE~ ~override~ // Assign correct bartender, Keexie Tavern downstairs
  PATCH_IF (SOURCE_SIZE > 0x11c) BEGIN
    READ_LONG 0x54 actOff
    FOR (READ_SHORT 0x58 numAct; numAct; numAct -= 0x1) BEGIN
      READ_ASCII actOff + 0x80 actor
      PATCH_IF !("%actor%" STRING_COMPARE_CASE "%tutu_var%BART13") BEGIN
        WRITE_EVALUATED_ASCII actOff + 0x80 ~%tutu_var%BART15~ #8
      END
      actOff += 0x110
    END
  END
BUT_ONLY_IF_IT_CHANGES

The BGT setup changes the bartender on the ground floor of the Keexie Tavern from BART13 to BART12. This is part of the Dudleyville Fixes incorporated by BGT. Therefore, the check for %actor% must be extended to accept BART12 as well.
I am not the right one to provide the code. I read: "if the present actor is NOT %tutu_var%BART13, THEN...",so it should patch - or not...

Quote

Code: [Select]
COPY_EXISTING ~%Nashkel%.ARE~ ~override~ // Nashkel
READ_LONG 0x5c trigOff ELSE 0x0
PATCH_IF (trigOff) BEGIN
  FOR (READ_SHORT 0x5a numTrig; numTrig; numTrig -= 0x1) BEGIN
    READ_ASCII trigOff name         // Trigger name
    READ_SHORT trigOff + 0x20 type  // Trigger type
    READ_LONG trigOff + 0x64 string // Info point StrRef
    PATCH_IF (!("%name%" STRING_COMPARE_CASE "INFO4801") &&
               (type == 0x1) && (string == 16266)) BEGIN
      SAY trigOff + 0x64 #11696 // Renames the area info trigger for the inn to say "The Northern Light"
    END
    trigOff += 0xc4
  END
END
BUT_ONLY_IF_IT_CHANGES

A similar case here. The changing of the info trigger string doesn't happen in BGT. This is because the StrRef for the trigger is not 16266 but 11683 on a BGT install.
Indeed. Using string references for BGT is optimistic. Are you sure the string in question is always the same for BGT? Because I am not sure, it depends on how many mods were installed on the BGIi game, for example, etcpp.?

Offline Mike1072

  • Planewalker
  • *****
  • Posts: 298
  • Gender: Male
Re: Fixes to store fixes
« Reply #29 on: April 02, 2014, 04:30:52 PM »

Code: [Select]
COPY_EXISTING ~%EBaldursGate_KeexieTavern_L1%.ARE~ ~override~ // Assign correct bartender, Keexie Tavern downstairs
  PATCH_IF (SOURCE_SIZE > 0x11c) BEGIN
    READ_LONG 0x54 actOff
    FOR (READ_SHORT 0x58 numAct; numAct; numAct -= 0x1) BEGIN
      READ_ASCII actOff + 0x80 actor
      PATCH_IF !("%actor%" STRING_COMPARE_CASE "%tutu_var%BART13") BEGIN
        WRITE_EVALUATED_ASCII actOff + 0x80 ~%tutu_var%BART15~ #8
      END
      actOff += 0x110
    END
  END
BUT_ONLY_IF_IT_CHANGES

The BGT setup changes the bartender on the ground floor of the Keexie Tavern from BART13 to BART12. This is part of the Dudleyville Fixes incorporated by BGT. Therefore, the check for %actor% must be extended to accept BART12 as well.
I am not the right one to provide the code. I read: "if the present actor is NOT %tutu_var%BART13, THEN...",so it should patch - or not...

That code is a bit misleading.  STRING_COMPARE_CASE returns 0 if the terms match, -1 if the first term should be sorted before the second, and 1 if the first term should be sorted after the second.

So, !("%actor%" STRING_COMPARE_CASE "%tutu_var%BART13") will be true if the terms match.

I prefer using STRING_EQUAL instead (since it behaves the way you'd expect), but I still have to deal with the STRING_COMPARE return syntax when dealing with regular expressions (STRING_CONTAINS_REGEXP).

In those situations, I like to write it out as ("%actor%" STRING_COMPARE_CASE "%tutu_var%BART13") == 0 or ("%actor%" STRING_COMPARE_CASE "%tutu_var%BART13") != 0, to remind myself that the return value is unusual.

Hurricane

  • Guest
Re: Fixes to store fixes
« Reply #30 on: April 02, 2014, 07:20:06 PM »
Concerning the Keexie Tavern bartender: What Mike said. :) There is no harm in modernizing the code a bit and using the more intuitive STRING_EQUAL, as Miloch also did in his additions. Try this:

Code: [Select]
COPY_EXISTING ~%EBaldursGate_KeexieTavern_L1%.ARE~ ~override~ // Assign correct bartender, Keexie Tavern downstairs
  PATCH_IF (SOURCE_SIZE > 0x11c) BEGIN
    READ_LONG 0x54 actOff
    FOR (READ_SHORT 0x58 numAct; numAct; numAct -= 0x1) BEGIN
      READ_ASCII actOff + 0x80 actor
      PATCH_IF ("%actor%" STRING_EQUAL_CASE "%tutu_var%BART13") OR // in vanilla BG
               ("%actor%" STRING_EQUAL_CASE "%tutu_var%BART12") BEGIN // in DudleyFix'd games
        WRITE_EVALUATED_ASCII actOff + 0x80 ~%tutu_var%BART15~ #8
      END
      actOff += 0x110
    END
  END
BUT_ONLY_IF_IT_CHANGES


Regarding the Nashkel info trigger:

Quote
The changing of the info trigger string doesn't happen in BGT. This is because the StrRef for the trigger is not 16266 but 11683 on a BGT install.
Indeed. Using string references for BGT is optimistic.

Yupp, so optimistic you could call it naïve. :D However, the good news is I can guarantee that BGT always uses StrRef #11683 for that particular info trigger, because this is hardcoded into the Nashkel area file that BGT brings along. The StrRef was changed because in BG2's dialog.tlk, #16266 no longer says "Nashkel Inn" (it's an empty string), but #11683 still does. Therefore:

Code: [Select]
COPY_EXISTING ~%Nashkel%.ARE~ ~override~ // Nashkel
READ_LONG 0x5c trigOff ELSE 0x0
PATCH_IF (trigOff) BEGIN
  FOR (READ_SHORT 0x5a numTrig; numTrig; numTrig -= 0x1) BEGIN
    READ_ASCII trigOff name         // Trigger name
    READ_SHORT trigOff + 0x20 type  // Trigger type
    READ_LONG trigOff + 0x64 string // Info point StrRef
    PATCH_IF ("%name%" STRING_EQUAL_CASE "INFO4801") && (type == 0x1) &&
             ((string == 16266) OR (string == 11683)) BEGIN
      SAY trigOff + 0x64 #11696 // Renames the area info trigger for the inn to say "The Northern Light"
    END
    trigOff += 0xc4
  END
END
BUT_ONLY_IF_IT_CHANGES

Tested locally with success.

Hurricane

  • Guest
Re: Fixes to store fixes
« Reply #31 on: April 03, 2014, 03:03:17 AM »
Continuing now with Maltz et al. I have gathered the resources and adjusted the setup so that it all works for BGT as well. Here it is.

First, we need 5 new files to be delivered with UB which are missing on a BGT install. I uploaded them here: http://1drv.ms/1j39O5p
Those are the .cre and .d file for shop05 plus three .sto files. What these files are and where they go:

bg1ub\BGT\cre\bgshop05.cre -- This is shop05.cre extracted from BG/TotSC. Renamed for compatibility with BG2. Also changed its dialogue reference from shop05.dlg to bgshop05.dlg.

bg1ub\BGT\d\bgshop05.d -- Decompiled from shop05.dlg from BG/TotSC. Renamed for compatibility with BG2. Changed its three dialog StrRefs to new translation strings starting at @40158. See the addition to extra_tmp.tra below for the new strings.

bg1ub\BGT\sto\sto1116.sto -- Extracted from BG/TotSC. No alterations.
bg1ub\BGT\sto\tav0809.sto -- Extracted from BG/TotSC. No alterations.
bg1ub\BGT\sto\tav0810.sto -- Extracted from BG/TotSC. No alterations.


The .sto files are imported automatically thanks to COPY ~bg1ub/%tutuorbgt%/STO~ ~override~.
The .d file is imported/compiled automatically thanks to COMPILE ~bg1ub/%tutuorbgt%/D~.
The .cre file must be imported explicitly. I added the following code to the list of creature imports for BGT/Tutu at the beginning of the UB setup:

Code: [Select]
    ACTION_IF ("%tutuorbgt%" STRING_EQUAL "BGT") THEN BEGIN //only BGT for now
      COPY ~bg1ub/%tutuorbgt%/CRE/%tutu_scriptbg%SHOP05.CRE~ ~override~
       SAY NAME1 @10179
       SAY NAME2 @10179
       SAY INITIAL_MEETING @10180
       SAY DAMAGE @10181
       SAY DYING @10182
       SAY SELECT_COMMON1 @10183
       SAY SELECT_COMMON2 @10184
       SAY SELECT_COMMON3 @10185
    END

Once this is made to work for Tutu as well, the first and last line can be removed if _shop05.cre is provided in bg1ub\Tutu\cre.
The new translation strings are added to extra_tmp.tra again, starting at @10179. See the addition to extra_tmp.tra below.


Now all the necessary resources are available in BGT. Next, the code for the Restoration component needs to be adjusted:

Code: [Select]
ACTION_IF GAME_IS ~bg1 totsc bgt~ THEN BEGIN
COPY_EXISTING ~%tutu_var%tav0810.sto~ ~override~ //Maltz' Weapon Shop
  SAY NAME2 #11782 //Maltz' Weapon Shop
BUT_ONLY

COPY_EXISTING ~%tutu_var%tav0809.sto~ ~override~ //unused General Store
  SAY NAME2 #11685
BUT_ONLY

COPY_EXISTING ~%SWBaldursGate_WeaponsStore2%.are~ ~override~ //Fix duplicate weapon store
  PATCH_IF SOURCE_SIZE > 0x11c BEGIN
    READ_LONG 0x54 actOff
    FOR (READ_SHORT 0x58 numAct; numAct; numAct -= 1) BEGIN
          READ_ASCII actOff + 0x80 actor
          PATCH_IF (~%actor%~ STRING_EQUAL_CASE ~%tutu_scriptbg%SHOP03~ = 1) BEGIN
            WRITE_EVALUATED_ASCII actOff + 0x80 ~%tutu_scriptbg%SHOP05~ #8
          END
          actOff += 0x110
    END
  END
BUT_ONLY

END

I made the following changes here: The GAME_IS check now includes BGT. tav0809.sto now gets assigned a name ("General Store" via #11685), which was actually missed by Miloch. And the changing of shop03 to shop05 didn't work because it used WRITE_ASCII instead of WRITE_EVALUATED_ASCII. Plus, I changed the variables from %tutu_var% to %tutu_scriptbg% to account for the BG prefix in BGT.


Next, I extended bg1ub\stores\cpm\ubstores.d:

Code: [Select]
REPLACE_ACTION_TEXT %tutu_var%maltz
  ~StartStore("\(%tutu_var%[Ss][Tt][Oo]1112\)",LastTalkedToBy(\(Myself\)?))~
  ~StartStore("%tutu_var%tav0810",LastTalkedToBy())~

REPLACE_ACTION_TEXT %tutu_scriptbg%shop01
  ~StartStore("\(%tutu_var%[Ss][Tt][Oo]1112\)",LastTalkedToBy(\(Myself\)?))~
  ~StartStore("%tutu_var%tav0809",LastTalkedToBy())~

REPLACE_ACTION_TEXT %tutu_scriptbg%shop05
  ~StartStore("\(%tutu_var%[Ss][Tt][Oo]1115\)",LastTalkedToBy(\(Myself\)?))~
  ~StartStore("%tutu_var%sto1116",LastTalkedToBy())~

REPLACE_ACTION_TEXT %tutu_var%alyth
  ~StartStore("%tutu_var%tav0721",LastTalkedToBy(\(Myself\)?))~
  ~StartStore("%tutu_var%tav0705",LastTalkedToBy())~


And finally, the following new translation strings are added to extra_tmp.tra:

For (bg)shop05.cre:
Code: [Select]
//#9408
@10179 = ~Storekeep~

//#4881
@10180 = ~Welcome to my humble establishment.~ [%tutu_var%STORE01]

//#12558
@10181 = ~~ [%tutu_var%STORE05]

//#12559
@10182 = ~~ [%tutu_var%STORE06]

//#4882
@10183 = ~Business has been poor, what with the iron shortage and all.~ [%tutu_var%STORE02]

//#4883
@10184 = ~The customer is always right.~ [%tutu_var%STORE03]

//#4884
@10185 = ~My prices are the best south of Waterdeep.~ [%tutu_var%STORE04]

For (bg)shop05.d:
Code: [Select]
//#15383
@40158 = ~Welcome to my shop.  You are free to look about as you wish, but do try not to break anything.~

//#15384
@40159 = ~I shall proceed with due care and attention.  What do you have to show me?~

//#15385
@40160 = ~You need not worry about your merchandise, as I was just leaving.~

jastey, can you make the official announcement for these translations?
Btw, as always in extra_tmp.tra, this is not really a translation job, because people only need to look up the strings in their version of BG/TotSC and copy them.

I've already done the German strings. To speed things up, I'm providing them right here:

Code: [Select]
//#9408
@10179 = ~Ladenbesitzer~

//#4881
@10180 = ~Willkommen in meinem bescheidenen Reich.~ [%tutu_var%STORE01]

//#12558
@10181 = ~~ [%tutu_var%STORE05]

//#12559
@10182 = ~~ [%tutu_var%STORE06]

//#4882
@10183 = ~Die Geschäfte laufen schlecht. Kein Wunder, bei der Eisenknappheit.~ [%tutu_var%STORE02]

//#4883
@10184 = ~Der Kunde hat immer recht.~ [%tutu_var%STORE03]

//#4884
@10185 = ~Meine Preise sind die besten südlich von Tiefwasser.~ [%tutu_var%STORE04]

Code: [Select]
//#15383
@40158 = ~Willkommen in meinem Laden. Seht Euch ruhig um, aber macht mir bitte nichts kaputt.~

//#15384
@40159 = ~Ich werde mit der entsprechenden Vorsicht und Sorgfalt vorgehen. Was könnt Ihr mir zeigen?~

//#15385
@40160 = ~Ihr braucht Euch keine Sorgen um Eure Ware zu machen. Ich wollte gerade gehen.~

That's it for BGT. :)

Offline CamDawg

  • Infidel
  • Planewalker
  • *****
  • Posts: 859
  • Dreaming of a red Xmas
    • The Gibberlings Three
Re: Fixes to store fixes
« Reply #32 on: April 03, 2014, 09:25:31 AM »
Concerning the Keexie Tavern bartender: What Mike said. :) There is no harm in modernizing the code a bit and using the more intuitive STRING_EQUAL, as Miloch also did in his additions.
If you wanted modern code, you'd just use something like

Code: [Select]
COPY_EXISTING ~%EBaldursGate_KeexieTavern_L1%.ARE~ ~override~ // Assign correct bartender, Keexie Tavern downstairs
  LPF ALTER_AREA_ACTOR STR_VAR actor_name ="Bartender" cre_file = EVAL "%tutu_var%BART15" END

Admittedly not tested, but this is the kind of stuff the macro was designed for.
« Last Edit: April 03, 2014, 09:26:03 AM by CamDawg »
The Gibberlings Three - Home of IE Mods

The BG2 Fixpack - All the fixes of Baldurdash, plus a few hundred more. Now available, with more fixes being added in every release.

Offline jastey

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1524
  • Gender: Female
Re: Fixes to store fixes
« Reply #33 on: April 03, 2014, 01:46:27 PM »
Thank you for the provided code, Hurricane!
Let me have a look at the strings for BG:EE. Maybe I can extract the corresponding text lines myself.

Hurricane

  • Guest
Re: Fixes to store fixes
« Reply #34 on: April 03, 2014, 02:00:26 PM »
@CamDawg: Absolutely. If those wonderful functions had been available when this code was written, I'm sure it would look very different now. :) Especially your AREA_ALTER_ functions make things so much easier nowadays.

@jastey: Great idea for the translations! I didn't even think of using BGEE for that!

Offline jastey

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1524
  • Gender: Female
Re: Fixes to store fixes
« Reply #35 on: April 04, 2014, 01:20:39 AM »
Hurricane: If you want me to include code that looks like CamDawg's I am afraid you'd have to provide it - I am not sure what I am doing there..

Hurricane

  • Guest
Re: Fixes to store fixes
« Reply #36 on: April 04, 2014, 04:40:01 PM »
No it's alright, just stay with the code I provided for this particular fix, you don't need to change it. I was just saying that CamDawg's suggestion will be useful for entirely new blocks of code added to UB in the future.

Hurricane

  • Guest
Re: Fixes to store fixes
« Reply #37 on: April 06, 2014, 04:36:26 AM »
Hurricane: Please check the BGT install whether I included the Fixes to the (Fixes to the) Store Fixes correctly!

Done and done. Result: Everything works as intended! Thank you for including it all. :)

One more thing: Good catch of you to split cpm\ubstores.d for the BGT-only changes, I hadn't accounted for that. However, the new change made to Alyth's dialog is valid for both BGT and Tutu, because tav0705.sto is already provided by UB for both games. ;) You can move that code over from ubstores_bgtadd.d to ubstores.d.

Offline jastey

  • Global Moderator
  • Planewalker
  • *****
  • Posts: 1524
  • Gender: Female
Re: Fixes to store fixes
« Reply #38 on: April 06, 2014, 05:28:52 AM »
Done locally. Thank you for checking!

Offline Cybersquirt

  • Socialist Evil-Doer
  • Planewalker
  • *****
  • Posts: 816
  • Gender: Female
Re: Fixes to store fixes
« Reply #39 on: April 18, 2014, 07:17:20 AM »
Thanks anon peoples! "hurricane", et al. And thank you Jastey for sorting/coding it.
« Last Edit: April 18, 2014, 07:21:47 AM by Cybersquirt »
Stupid is as stupid does.

 

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Name: Email:
Verification:
Type the letters shown in the picture
Listen to the letters / Request another image
Type the letters shown in the picture:
What color is grass?:
What is the seventh word in this sentence?:
What is five minus two (use the full word)?: