Post reply

The message has the following error or errors that must be corrected before continuing:
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.
Other options
Shortcuts: ALT+S post or ALT+P preview

Topic summary

Posted by Baronius
 - October 24, 2006, 03:09:52 PM
Posted by balduran
 - September 19, 2006, 06:41:24 AM
I think Baronius should have the final word on that one, because the code is his, and I still have little idea what does what.
Posted by Baronius
 - September 18, 2006, 04:17:07 PM
I plan to make one, I plan. :) (Though no idea exactly when. :()
Posted by jastey
 - September 18, 2006, 09:06:12 AM
I would appreciate very much if the knowledge collected in this thread would be turned into some general template / tutorial for the tutorial section. Baronius? balduran?  :)

(If you think this thread gives all needed information maybe some link could be given to it from the tutorial section.)
Posted by balduran
 - September 12, 2006, 02:45:17 PM
It took a while to test this one, but the code is working just fine. Three times cheers for Baronius' great work. :beer:  :beer:  :beer:

Of course, as in any other mod, there's still some minor/major (plus one critical problem with the game not displaying a tis file propperly) issues to be resolved, but I guess it's nothing to be worried about.
Posted by Baronius
 - September 08, 2006, 01:40:56 PM
No need to apologise, it's your mod ;) And since you say it requires ToB, Vlad's suggestion appears to be a shorter solution code-wise. (I haven't been thinking on its realisation though.) However, I appreciate a lot that you test my code, because it will confirm that it works. (This is universal code, which can be made working with BG1, SoA, ToB and can deal with any number of area links.)
Posted by balduran
 - September 08, 2006, 09:09:55 AM
Thanks about that. I'll be sure to download it again. Though I still haven't test the code, sorry about that. Right now I'm "redecorating" my mother's house, and I didn't even have time to install my harddisk inside the computer (although I specifically brought it with me). I should be ready by Sunday and probably'll post results on Monday or Tuesday.
Once again appologies ofr the delay. :(
Posted by Baronius
 - September 02, 2006, 07:24:41 PM
Yes, that string will be written to the worldmap file, and when you click on the area icon in the game, it will search for an entrance of the same name in Kula's .ARE file.

By the way, please download the file again, because I've fixed a problem in the original code. I'm 100% sure it wouldn't have caused any anomaly for Azure, but I recommend that you download it again, as the fix might be important for future developments.
Posted by balduran
 - September 02, 2006, 08:58:22 AM
Azure will require ToB, since I don't want to make two separate downloads for SofA and ToB.

Thanks for all the hard work on the code, Baronius :) I'll try to make it work tonight and will post back with results.

Just one last question - the worldmap will use the name of the entrance, with which I replace ExitSE, right?
Posted by Baronius
 - September 02, 2006, 12:15:24 AM
That only works if ToB is installed. If Azure requires Throne of Bhaal, the best solution is obviously the one you've told. :)
Posted by Vlad
 - September 01, 2006, 11:21:09 PM
Also, it's possible to add areas dynamically, the same way Watcher's Keep is added to the map. The only drawback of this approach is that the game should be started a new in order to update the map with a new area. If you wish the area being invisible you may hide area on the map in any initial script of the game and later on to reveal it via script or dialogue. So, take a look at two files XNEWAREA.2DA and XL3000.2DA. You'll need to APPEND XNEWAREA.2DA with your area entry, to APPEND MASTAREA.2DA, and to create your new file XL****.2DA. That is basically all.
Posted by Baronius
 - August 31, 2006, 03:05:17 AM
I've written the code. I made only a short try in BG2, it seemed to work properly. This code will make your TP2 fatter, that's sure, but I think it's not hard to customize or extend it. I've attached it to this post.

Single-line comments such as // this in the code usually  indicate lines where you can set attributes. The code is divided into several sections. I'll paste here the most important lines that you should change when you want to modify the code.

I've tried to add all those features we've discussed in the above posts, so the area names, coordinates, initial map icon etc. are already specified in the code.

These variables (from section 4) are very important, they're used in several calculations:

/* ALL area links, including the ones FROM the new area as well as all links you want to add from other areas */
SET "my-northlink"  = 0        // How many north links you'll add from your NEW area
SET "my-westlink"   = 2        // How many west links you'll add from your NEW area
SET "my-southlink"  = 2        // How many south links you'll add from your NEW area
SET "my-eastlink"   = 2        // How many east links you'll add from your NEW area
SET "ext-northlink" = 2        // How many total north links you'll add from other EXISTING areas
SET "ext-westlink"  = 1        // How many total west links you'll add from other EXISTING areas
SET "ext-southlink" = 2        // How many total south links you'll add from other EXISTING areas
SET "ext-eastlink"  = 2        // How many total east links you'll add from other EXISTING areas


I'm sure this part (from section 5) is obvious, so no explanation is needed:

WRITE_ASCII "%area-section-end%" ~AZ1000~            // Your area's filename
WRITE_ASCII "%area-section-end%" + 0x8 ~AZ1000~
WRITE_ASCII "%area-section-end%" + 0x10 ~AZ1000~
WRITE_LONG "%area-section-end%" + 0x34 10            // Icon index
WRITE_LONG "%area-section-end%" + 0x38 1292        // X coordinate on the worldmap
WRITE_LONG "%area-section-end%" + 0x3C 402        // Y coordinate on the worldmap
SAY "%area-section-end%" + 0x40 ~Kula~            // Worldmap caption of your area


If you want it to detect an existing game area, and add a link from it to your new area, you have to change the code at three points, basically. The first are the already mentioned variables in section 5, the second is pasted directly below, and the third (section 9) will be quoted in a later part of this post. The following code is from section 7:

PATCH_IF(
/* Specify the list of EXISTING areas you want links FROM */
// You can use the commented template below to include a new area. Substitute ARXXXX with the area filename.
/* ("%area-resref%" STRING_EQUAL "ARXXXX") OR    */
("%area-resref%" STRING_EQUAL "AR0020") OR     /* City Gates    */
("%area-resref%" STRING_EQUAL "AR2000")        /* Trademeet    */)
BEGIN
...
END


Though you probably won't have to modify it directly, it's important to mention the following code block. This is a typical statement inside the body of PATCH_IF (also in section 7):

READ_LONG ("%northlink-offset%" + 4) "north-count"  
WRITE_LONG ("%northlink-offset%" + 4) ("%north-count%" + 1)
"north-position" = "%link-offset%" + 216 * ("%north-current%" + "%north-count%")
INNER_PATCH_SAVE str "%str%" BEGIN
  FOR (j=8 * "%north-current%" + 2; j<=8*("%link-count%" - "%new-link-count%") + 6; j+=2) BEGIN
    READ_SHORT j "temp"
    WRITE_SHORT j ("%temp%" + 1)
  END
END
"actual-north" = "%actual-north%" + 1


So the above code creates (or rather just starts to create) one north link FROM an existing game area to your new area. It is applied on each detected area from those you've listed. If you don't want an area to have a north link to yours, exclude it. The following code snipeet, also from section 7, ensures that no west link will be added from City Gates to your area:

// You can specify conditions if you want. Here we won't add west link from City Gates to the new area.
  PATCH_IF !("%area-resref%" STRING_EQUAL "AR0020") BEGIN
   READ_LONG ("%northlink-offset%" + 12) "west-count"
   WRITE_LONG ("%northlink-offset%" + 12) ("%west-count%" + 1)
   "west-position" = "%link-offset%" + 216 * ("%west-current%" + "%west-count%")
   INNER_PATCH_SAVE str "%str%" BEGIN
    FOR (j=8 * "%west-current%" + 8; j<=8*("%link-count%" - "%new-link-count%") + 6; j+=2) BEGIN
     READ_SHORT j "temp"
     WRITE_SHORT j ("%temp%" + 1)
    END
   END
  "actual-west" = "%actual-west%" + 1
  END ELSE "west-position" = 0


The below lines are from section 9. Important: all area resrefs on your first list of existing game areas must also be added here:

// This is where you specify the structure of inserted links that come from EXISTING areas to your new area
/* In this example, we only have City Gates and Trademeet */
PATCH_IF (("%area-resref%" STRING_EQUAL "AR0020") OR
             ("%area-resref%" STRING_EQUAL "AR2000"))
BEGIN    
  // Travel time factor. You don't need PATCH_IF if you use the same time multiplier for all areas.
  PATCH_IF ("%area-resref%" STRING_EQUAL "AR2000") BEGIN
   SET "travel" = 1    // Journey (or a trip?) takes 4 hours to Trademeet from your new area
  END ELSE BEGIN
   SET "travel" = 5    // Otherwise 20 hours
  END
  // North link
  PATCH_IF ("north-position") BEGIN
   INNER_PATCH "%str%" BEGIN READ_SHORT (8 * "%north-current%") "shift" END
   SET "new-position" = "%north-position%" + (216 * shift)
   INSERT_BYTES "%new-position%" 216
   WRITE_LONG "%new-position%" ("%area-count%" - 1)
   WRITE_ASCII ("%new-position%" + 4) ~ExitSE~        // Entrance in new area. Non-existing entrance causes the game to crash.    
   WRITE_LONG ("%new-position%"+ 0x24) travel        // Travel time factor
   WRITE_LONG ("%new-position%"+ 0x28) 4
   /* WRITE_ASCII ("%new-position%"+ 0x2C) ~ARXXXX~ */    // Filename of random encounter area
   /* WRITE_LONG ("%new-position%"+ 0x54) 50        */    // Probability of random encounter
   "actual-north" = "%actual-north%" + 1
  END
  // East link
  ...
  // South link
  ...
  // West link


Very important: as the only direct connection between the ARE file and the worldmap is the entrance, make sure to specify an existing entrance name here. (I've added ExitSE, the entrance of the test area I quickly made.)

The only section that has a bigger chance to be modified by you in the future and I didn't mention it yet is section 12, which adds links FROM YOUR area to other existing game areas.

If you browse the code, you might notice three short sections, with "Check code consistency" as a title comment. It is recommended that you never remove these (unlike most of the comments and commented code), because they make the installation fail if anything is wrong. The installation won't fail in its current state, but if you modify it in the future, it is possible that you accidently make some mistakes in the code. In the latter case, without these lines, it is possible that WeiDU would happily inform the user about a successful install while the worldmap would become totally messed up, causing a crash in the game.

The player has to start a new game, or the worldmap change will not take effect. (The worldmap is stored in the savegame.)

The code is quite long, as I've already written. This is because it must be capable of adding links from theoretically any number of areas, not just from one. (And you needed Trademeet and City Gates.) Though since I've optimized it for your needs, you probably won't have to change anything except the bam icon stuff. Tell me how it works for you.
Posted by balduran
 - August 30, 2006, 10:44:26 AM
Quote from: Baronius on August 30, 2006, 02:39:26 AM
So the earliest chapter you can visit that area is the 6th. That time, the player will have visited most wilderness areas, so there is no reason to add links from all those areas I listed. Trademeet and City Gates should have a link to Kula, but it would be illogical to provide a direct path from every wilderness area, as the adventurers reach many areas by passing already explored places. To sum up, the player will still be able to visit Kula practically from any other area, while you won't have redundant code in your TP2.

Exactly. There's no need to link every single area if the game uses such a method of travelling.

Quote
Anything that needs to be changed on this?

Not really. Everything sound right. Although I think I can make a new mapicons.bam with a special graphic for Kula, but the change in the animation number I can fix by myself later. That's about the only thing I know how to do about that code.
Posted by Baronius
 - August 30, 2006, 02:39:26 AM
So the earliest chapter you can visit that area is the 6th. That time, the player will have visited most wilderness areas, so there is no reason to add links from all those areas I listed. Trademeet and City Gates should have a link to Kula, but it would be illogical to provide a direct path from every wilderness area, as the adventurers reach many areas by passing already explored places. To sum up, the player will still be able to visit Kula practically from any other area, while you won't have redundant code in your TP2.

Anything that needs to be changed on this?
Posted by balduran
 - August 29, 2006, 12:21:00 PM
The links you've mentioned do sound like the most logical choice. :)

As far as the map revealing goes, I added a few interjections to chief Brega's dialogue, so that he reveals the area after you talk to him with a Reputation higher than 13 and some other prerequisites, like Global("Chapter","GLOBAL",6) and a few other variables.