Changes

Jump to navigation Jump to search
6,672 bytes added ,  02:41, 6 September 2023
add info on real-time positioning
Line 7: Line 7:  
'''To edit location maps, see [[Modding:Maps]]. See also [[Modding:Index#Creating mods|an intro to making mods]].'''
 
'''To edit location maps, see [[Modding:Maps]]. See also [[Modding:Index#Creating mods|an intro to making mods]].'''
   −
==Overview==
+
==Data==
 +
===Overview===
 
You can change the world map by editing the <samp>Data/WorldMap</samp> asset. You can add custom maps for certain locations, apply texture overlays, add/edit tooltips, set player marker positioning, etc.
 
You can change the world map by editing the <samp>Data/WorldMap</samp> asset. You can add custom maps for certain locations, apply texture overlays, add/edit tooltips, set player marker positioning, etc.
   −
===Basic concepts===
   
[[File:Modding map area.png|thumb|The default world map. The entire map is the Valley region, and the highlighted portion is an area with its own texture, tooltip/name, and player marker positioning.]]
 
[[File:Modding map area.png|thumb|The default world map. The entire map is the Valley region, and the highlighted portion is an area with its own texture, tooltip/name, and player marker positioning.]]
   Line 26: Line 26:  
The game will find the first <samp>WorldPositions</samp> entry which matches the current location, and assume you're in the region and map area which contains it. If there's none found, it defaults to the farm.
 
The game will find the first <samp>WorldPositions</samp> entry which matches the current location, and assume you're in the region and map area which contains it. If there's none found, it defaults to the farm.
   −
===Real-time positioning===
  −
The world map generally shows players' actual positions within the world in real-time. If the location drawn on the map closely matches the in-game location, this happens automatically based on the <samp>PixelArea</samp> and <samp>LocationName</samp> fields in <samp>Data/WorldMap</samp>. For complex locations whose tile layout doesn't match the drawn map, you can specify pixel + tile areas in the <samp>WorldLocations</samp> field to allow real-time positions.
  −
  −
==Data==
   
===Format===
 
===Format===
 
The <samp>Data/WorldMap</samp> data asset consists of a string → model lookup, where...
 
The <samp>Data/WorldMap</samp> data asset consists of a string → model lookup, where...
Line 283: Line 279:  
     ]
 
     ]
 
}</nowiki>|lang=javascript}}
 
}</nowiki>|lang=javascript}}
 +
 +
==Real-time positioning==
 +
The world map generally shows players' positions in real-time. There are three main approaches to do this for a custom location.
 +
 +
===Automatic positioning (recommended)===
 +
If the drawn map area closely matches the in-game location, the game can determine positions automatically based on the <samp>PixelArea</samp> and <samp>LocationName</samp> fields in <samp>Data/WorldMap</samp>. For example, a player in the exact center of the in-game location will be drawn in the center of the drawn map area.
 +
 +
To do that:
 +
 +
# [[Options#Screenshots|Take a screenshot]] of the full in-game location.
 +
# Open the screenshot in an image editor like [https://www.getpaint.net/ Paint.NET] or [https://www.gimp.org/ GIMP].
 +
# Crop as needed, then rescale it to the size you want on the world map. Make sure you use 'nearest neighbor' as the scale algorithm.
 +
# Redraw parts if needed to clean it up.
 +
 +
That's it! If you use that as the map area's texture in <samp>Data/WorldMap</samp>, the game will be able to determine positions automatically. You can omit the <samp>WorldPositions</samp> field with this approach.
 +
 +
===Manual positioning===
 +
If the in-game layout doesn't match the drawn world map, you can use the <samp>WorldPositions</samp> field in <samp>Data/WorldMap</samp> to manually align positions between them. '''This can be tricky; usually [[#Automatic positioning (recommended)|automatic positioning]] is recommended instead.'''
 +
 +
For example, the mountain's map area is stylized (the mine and adventure guild are right next to each other, there are no islands, there's no water south of the guild, etc):
 +
[[File:Modding - manual world map positioning 1.png|thumb|500px|none|The [[mountain]]'s in-game location (top) and world map area (bottom).]]
 +
 +
With manual positioning, you add any number of ''world positions'' with a <samp>TileArea</samp> (where the player is standing in the actual location) and <samp>MapPixelArea</samp> (where that area is on the map). When the player is within the <samp>TileArea</samp>, they'll be mapped to the relative position within the matching <samp>MapPixelArea</samp>. For example, if they're in the exact center of the <samp>TileArea</samp>, they'll be drawn in the center of the <samp>MapPixelArea</samp>.
 +
 +
For example, you can divide the mountain into multiple areas like this (see the [[#Format|data format]] for info on each field):
 +
<syntaxhighlight lang="js">
 +
"WorldPositions": [
 +
    {
 +
        "Id": "Quarry",
 +
        "LocationName": "Mountain",
 +
        "TileArea": { "X": 95, "Y": 11, "Width": 36, "Height": 24 },
 +
        "ExtendedTileArea": { "X": 95, "Y": 0, "Width": 255, "Height": 255 },
 +
        "MapPixelArea": { "X": 236, "Y": 29, "Width": 28, "Height": 19 }
 +
    },
 +
    {
 +
        "Id": "Lake_Guild",
 +
        "LocationName": "Mountain",
 +
        "TileArea": { "X": 73, "Y": 5, "Width": 22, "Height": 30 },
 +
        "ExtendedTileArea": { "X": 73, "Y": 0, "Width": 22, "Height": 255 },
 +
        "MapPixelArea": { "X": 227, "Y": 29, "Width": 9, "Height": 19 }
 +
    },
 +
    {
 +
        "Id": "Lake_BetweenGuildAndMine",
 +
        "LocationName": "Mountain",
 +
        "TileArea": { "X": 57, "Y": 5, "Width": 16, "Height": 32 },
 +
        "ExtendedTileArea": { "X": 57, "Y": 0, "Width": 16, "Height": 255 },
 +
        "MapPixelArea": { "X": 224, "Y": 29, "Width": 3, "Height": 19 }
 +
    },
 +
    {
 +
        "Id": "Lake_Mine",
 +
        "LocationName": "Mountain",
 +
        "TileArea": { "X": 52, "Y": 5, "Width": 5, "Height": 30 },
 +
        "ExtendedTileArea": { "X": 52, "Y": 0, "Width": 5, "Height": 255 },
 +
        "MapPixelArea": { "X": 220, "Y": 29, "Width": 4, "Height": 19 }
 +
    },
 +
    {
 +
        "Id": "Lake_MineBridge",
 +
        "LocationName": "Mountain",
 +
        "TileArea": { "X": 44, "Y": 5, "Width": 8, "Height": 30 },
 +
        "ExtendedTileArea": { "X": 44, "Y": 0, "Width": 8, "Height": 255 },
 +
        "MapPixelArea": { "X": 210, "Y": 29, "Width": 10, "Height": 19 }
 +
    },
 +
    {
 +
        "Id": "West",
 +
        "LocationName": "Mountain",
 +
        "TileArea": { "X": 0, "Y": 5, "Width": 44, "Height": 30 },
 +
        "ExtendedTileArea": { "X": 0, "Y": 0, "Width": 44, "Height": 255 },
 +
        "MapPixelArea": { "X": 175, "Y": 29, "Width": 35, "Height": 19 }
 +
    },
 +
    {
 +
        "Id": "Default",
 +
        "LocationName": "Mountain"
 +
    }
 +
]
 +
</syntaxhighlight>
 +
 +
Here's a visual representation of those areas:
 +
[[File:Modding - manual world map positioning 2.png|thumb|none|500px|The [[mountain]]'s in-game location with highlighted <samp>TileArea</samp> positions (top) and world map with highlighted <samp>MapPixelArea</samp> positions (bottom).]]
 +
 +
Note how the area between the mine and adventurer's guild is wide in the location, but narrow on the drawn world map. When the player is walking across that part of the location, they'll be shown walking slowly across the equivalent location on the drawn map.
 +
 +
If the player is outside a <samp>TileArea</samp> but within the <samp>ExtendedTileArea</samp> (if set), their position is snapped to the nearest position within the <samp>TileArea</samp>. For example, notice how the bottom of the location south of the carpenter shop isn't part of the red area. It ''is'' part of that area's <samp>ExtendedTileArea</samp> though, so a player there will be snapped to the bottom of the red area on the world map.
 +
 +
===Fixed positions===
 +
For very complex locations, real-time positions on the world map may not be possible (e.g. because the drawn world map is very stylized). In that case you can set a fixed position (or multiple fixed positions) on the world map.
 +
 +
For example, this draws the player marker at one of five world map positions depending where they are in town. The <samp>TileArea</samp> indicates where the player is standing in the actual town, and <samp>MapPixelArea</samp> is where to draw them on the map. Note that the latter is always 1x1 pixel in the code below, which means that anywhere within the <samp>TileArea</samp> will be placed on that specific pixel on the world map. The last entry has no <samp>TileArea</samp>, which means it applies to all positions that didn't match a previous entry.
 +
<syntaxhighlight lang="js">
 +
"WorldPositions": [
 +
    {
 +
        "Id": "East_NearJojaMart",
 +
        "LocationName": "Town",
 +
        "TileArea": { "X": 85, "Y": 0, "Width": 255, "Height": 68 },
 +
        "MapPixelArea": { "X": 225, "Y": 81, "Width": 1, "Height": 1 }
 +
    },
 +
    {
 +
        "Id": "East_NearMuseum",
 +
        "LocationName": "Town",
 +
        "TileArea": { "X": 81, "Y": 68, "Width": 255, "Height": 255 },
 +
        "MapPixelArea": { "X": 220, "Y": 108, "Width": 1, "Height": 1 }
 +
    },
 +
    {
 +
        "Id": "West_North",
 +
        "LocationName": "Town",
 +
        "TileArea": { "X": 0, "Y": 0, "Width": 85, "Height": 43 },
 +
        "MapPixelArea": { "X": 178, "Y": 64, "Width": 1, "Height": 1 }
 +
    },
 +
    {
 +
        "Id": "West_Center",
 +
        "LocationName": "Town",
 +
        "TileArea": { "X": 0, "Y": 43, "Width": 85, "Height": 33 },
 +
        "MapPixelArea": { "X": 175, "Y": 88, "Width": 1, "Height": 1 }
 +
    },
 +
    {
 +
        "Id": "West_South",
 +
        "LocationName": "Town",
 +
        "MapPixelArea": { "X": 182, "Y": 109, "Width": 0, "Height": 0 }
 +
    }
 +
]
 +
</syntaxhighlight>
    
[[Category:Modding]]
 
[[Category:Modding]]
translators
8,446

edits

Navigation menu