The Black Wyrm Lair Forums
The Black Wyrm's Lair Terms of Use Help Search Members Calendar

Welcome Guest ( Log In | Register )

> Has anyone seen the worldmap tutorial of SpellholdStudios?, I need to learn quickly how to add areas to the wmp
balduran
post Aug 27 2006, 02:47 PM
Post #1


Supremacy of the Metal Kingdom
Group Icon

Mod Developer
Posts: 223
Joined: 1-September 05
From: Bulgaria




I saw several familiar topics, both here and on other forums, which pointed to this tutorial:
http://forums.spellholdstudios.net/index.p...=17269&st=0

The problem is that for some reason it's I'm forbidden from opening the html, so I can't see what's inside.
I also checked the tp2 of G3Anniversary mod, but so far I cannot figure what does what.

Anyway, what I need to achieve is to patch my town into the world map without making it incompatible with other mods which change the WMP, and I have no idea how to. I also need to find out what other files i need to edit - 2da, bam, etc... And I'm somewhat in a hurry to make it work, cause I need to finish the SofA portion of Azure NPC in a few days time, since I'll be going on a trip next week, and then again to the "back to work" routine.


--------------------
Blessed be the one who has nothing to say, and yet remains silent.

Too many chieftan, too little indian.

http://balduran.blackwyrmlair.net

-- Azure NPC Romance
-- BG2 Improvements
-- IWD Improvements
Go to the top of the page
 
Quote Post
 
Start new topic
Replies
Baronius
post Aug 31 2006, 03:05 AM
Post #2


Master of energies
Group Icon

Council Member
Posts: 3324
Joined: 9-July 04
From: Magyarország




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:

CODE
/* 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:

CODE
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:

CODE
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):

CODE
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:

CODE
// 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:

CODE
// 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.
Attached File(s)
Attached File  patchWMP.zip ( 3.16k ) Number of downloads: 38
 


--------------------
Mental harmony dispels the darkness.
Go to the top of the page
 
Quote Post

Posts in this topic
balduran   Has anyone seen the worldmap tutorial of SpellholdStudios?   Aug 27 2006, 02:47 PM
Rabain   SHS was giving me errors this morning saying I do ...   Aug 27 2006, 03:23 PM
CamDawg   SHS was a temporary outage; it appears to be back ...   Aug 27 2006, 03:31 PM
balduran   SHS was a temporary outage; it appears to be back...   Aug 27 2006, 03:35 PM
balduran   I'm totally and completely lost in this code. ...   Aug 28 2006, 11:08 AM
Baronius   To sum up, once it has been revealed, should it be...   Aug 29 2006, 01:15 AM
balduran   The links you've mentioned do sound like the m...   Aug 29 2006, 12:21 PM
Baronius   So the earliest chapter you can visit that area is...   Aug 30 2006, 02:39 AM
balduran   So the earliest chapter you can visit that area i...   Aug 30 2006, 10:44 AM
Baronius   I've written the code. I made only a short try...   Aug 31 2006, 03:05 AM
Vlad   Also, it's possible to add areas dynamically, ...   Sep 1 2006, 11:21 PM
Baronius   That only works if ToB is installed. If Azure requ...   Sep 2 2006, 12:15 AM
balduran   Azure will require ToB, since I don't want to ...   Sep 2 2006, 08:58 AM
Baronius   Yes, that string will be written to the worldmap f...   Sep 2 2006, 07:24 PM
balduran   Thanks about that. I'll be sure to download it...   Sep 8 2006, 09:09 AM
Baronius   No need to apologise, it's your mod ;) And sin...   Sep 8 2006, 01:40 PM
balduran   It took a while to test this one, but the code is ...   Sep 12 2006, 02:45 PM
jastey   I would appreciate very much if the knowledge coll...   Sep 18 2006, 09:06 AM
Baronius   I plan to make one, I plan. :) (Though no idea exa...   Sep 18 2006, 04:17 PM
balduran   I think Baronius should have the final word on tha...   Sep 19 2006, 06:41 AM
Baronius   It's now available: http://www.blackwyrmlair.n...   Oct 24 2006, 03:09 PM


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:



- Lo-Fi Version Time is now: 10th August 2025 - 05:47 PM