World Map Tutorial - Part 1  

Well, I know we already have a Map Tutorial on the Bioware wiki (which will be updated shortly by yours truly) but as far as I know, no one has been successful in getting a custom map to work in a stand-alone module. Or, if someone did, no one has come forth on the forums to help those who've had problems. So, here is a step-by-step tutorial on getting custom maps to work.

Step 1: Map Image

The map can either be in .tga or .dds formats.
TGA: You can use a freeware image editor like Irfanview or Gimp to convert a .jpg/.jpeg file to the .tga format.
DDS: You can use nvdxt.exe present in the <Dragon Age Install folder>\tools\ResourceBuild\Processors folder to generate a DDS file. nvdxt.exe is a batch utility and to use it you need to open a command prompt (Start -> Run -> cmd) and enter your command. An example to convert x.tga to x.dds is:

nvdxt.exe -file x.tga -output x.dds -nomipmap -8 u8888 -prescale length width

-prescale length width lets you put in the size (should be multiple of 4) to which the x.tga should be scaled before conversion

If you are using Photoshop, you first need the Nvidia Photoshop plug-ins and if you are using Gimp, you need the Gimp DDS plug-ins. In Photoshop, I saved my DDS as DXT5 ARGB 8bpp with Interpolated Alpha and No MipMaps.

The game requires the image to be with the client's localized name but the toolset reads the actual image so you need both <image_name> and <image_name_en-us> (for English clients). You have to place both images in your addin's module\override folder.

The game's world map (both OC and Awakening) is 912 x 687 pixels - this is the canvas size. The images have a 24 pixel transparent border which would make the actual image 864 x 639 (640 if you are using your own map)

Why is this important?
The map is anchored at the top-left corner of the book image and this corner is actually slightly above the book border. Without this transparent section, your map will never be aligned exactly in the center of the book.

Sample map in add-in module with DDS extension
There are ways to work around this but I will cover them in Part 2 if I am unable to figure out the transparent border.

Step 2: Building the m2DAs

You need to extend two 2DAs for the worldmap to function correctly in-game and create as many worksheets as you need based on the TargetWpTable entries (see below). All these 2das go into your module\override folder.

worldmaps from worldmaps.xls: A few things to note here:

worldmaps_tut 2da
  • The ID has to be between 0 and 255. Anything over that and the map will not work in-game and you will see the infamous grey square at the top left.
  • Bioware uses 1-5 for the OC and 10 for Awakening. I doubt the other DLCs use different world maps - if anyone has played them and has seen a different map, let me know.
  • The TargetWpTableID should match the IDs used to extend the m2da_base 2DA
  • The TargetWpTable entries should match the different worksheets containing the Source/Target waypoint information. I have yet to test whether this is actually used.
  • The MAP column contains the names of your map images
  • The Label column is the one used by the Toolset
  • As far as I can determine, the NameStrRef is not used anywhere so you can keep that at 0
m2da_base from 2da_base.xls: Create a new entry for each of the TargetWpTableID used in the worldmaps 2da extension. Keep in mind that the m2da_base is, in itself, a m2da so you need to only have a worksheet with the new rows.

source-target waypoint 2das: You can copy the existing target_wps_* worksheets and edit them if you so wish. It is basically a table with source and target areas on the rows and columns respectively. Their intersection contains the waypoint tag you will be transitioned to when traveling from the source to the target area.
test_map_1_wp 2da

Step 3: Setting up the map in the toolset

This is probably the easiest part. Fire up the toolset, navigate to the Maps tab, right-click and select New -> Map.

TIP: If you didn't know, going to the appropriate tab (Maps, Scripts, etc) and then selecting the New option by right-clicking there automatically positions the corresponding resource at the top of the menu. Selecting a folder and doing this creates the resource within that folder.

If you've done the previous 2 steps, you should see the map name (Label) in the drop down list for the Map within the toolset and the image should appear correctly.

To test what you've done till now in-game, just create a couple of map pins, save and export without dependent resources. Create a placeable using one of the Area Transition type placeables and set the PLC_AT_DEST_AREA_TAG to world_map (this is a hard-coded value inside the utility_h script). You can use any placeable for a transition but it is not as simple as this and I want to keep things simple till I start Part 2 of this tutorial :)

Fire up your module script and add the following lines of code:
#include "events_h"
#include "global_objects_h"
#include "sys_chargen_h"
#include "sys_rewards_h"
#include "world_maps_h"

void main()
{
    int nEventHandled = FALSE;
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);

    switch(nEvent)
    {
         case EVENT_TYPE_MODULE_START:
         {
            object oWorldMap = GetObjectByTag("<Tag of the placeable>");
            WR_SetWorldMapPrimary(oWorldMap);
            break;
         }

         case EVENT_TYPE_TRANSITION_TO_WORLD_MAP:
         {
            SetWorldMapGuiStatus(WM_GUI_STATUS_USE);
            OpenPrimaryWorldMap();
            break;
         }
    }

    // if this event wasn't handled by this script fall through to the core script
    if(!nEventHandled)
    {
        HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
    }
}

Export the resources for your module, start Dragon Age and launch your module. Once you click the Area Transition placeable, your map should be displayed.

Lastly, to show that this works with more than one custom map in the same add-in, another image. This one uses a .tga file as the world map and is bigger than the other one - just to show that there is no limitation on the size of the image - but you can notice the icons inside the map area -> the underlying book size is hard-coded.
Sample map in add-in module with .TGA extension
Part 2 of the tutorial will cover the scripting behind transitions, how to bypass/override certain events, customizations possible within the existing event framework and an explanation (or workaround) of the 24-pixel border. Stay tuned!

I did my testing as part of my module so if any of you who read this run into issues or find something inadequately explained, let me know and I will see what I can do.

1 comments

  • Anonymous  

    April 13, 2011 at 4:39 PM

    Are there any specifications for the TGAs to show up in-game? I created a custom map, and it would only show up once I converted it to DDS (using the options in this post).

Post a Comment