RWR Map Format

From Running With Rifles Wiki
Jump to: navigation, search

This page will present known information about the RWR map format. Modders may find this useful for creating mapping-related tools for RWR. A sufficiently masochistic person could hand-craft a map with the information on this page - don't do this, just use Inkscape.

Note: Most of this information was gathered by reverse-engineering the format. There are probably a fair few mistakes. This page is a work in progress!

Folder Structure[edit | edit source]

All RWR maps are stored as collections of files within folders.

Mandatory files[edit | edit source]

The following files are absolutely necessary - without these RWR will crash:

  • objects.svg - Most important. Spawnpoints, hints for texture splatting, the works.
  • map_config.xml - Configuration file.
  • terrain5_alpha_asphalt.png
  • terrain5_alpha_grass.png
  • terrain5_alpha_road.png
  • terrain5_alpha_rocky_mountain.png
  • terrain5_alpha_sand.png
  • terrain5_combined_alpha.png - Holds 4 terrain layers in one file to save space. The game prefers to use this instead of the above individual splat textures.
  • terrain5_heightmap.png - Lighter is higher, darker is lower. Sea level is 20.
  • green.xml/neutral.xml - Faction file for the greenbelts and some neutral stuff. The game needs sufficient information about things like primary/secondary weapons present in a faction file or the game will most likely crash when a player spawns. You could replace this with one large file if you like.
  • init_match.xml - Contains commands which are executed when a game is started. Can be used to create objects (just use objects.svg) store things in the player's inventory on start (lobby does this) and there are also a few more useful parameters (such as XP multipliers). If you leave this file out the game won't actually crash, but it will ignore the no_ai command-line parameter. Just leave the default in.

The terrain5_* files are related to texture splatting. Lighter (more white) means a given texture (say sand) will be expressed more strongly in that area. Everything is covered in dirt initially, with sand/grass/etc drawn on top of that.

All texture splats and the heightmap should be saved in 8-bit PNG format with no gamma or palette information and in grayscale. Paint.NET is capable of this when used in tandem with TweakPNG, and GIMP may be capable of this as well. Forgetting to do this with the heightmap will stop the map from loading. Forgetting to do this with a terrain splat will make the terrain appear all over the map.

Optional files[edit | edit source]

The following files are optional - useful, but RWR will not crash without them provided they aren't referenced anywhere:

  • common.resources - Lists resources e.g. weapons, vehicles which are used in this map. You almost certainly want this file, and want it referenced by map_config.xml.
  • map.png - Drawn when you view the map in-game. Just looks transparent if you omit it.
  • mapview_frame.png - Drawn over the top of the in-game map. A reasonable default frame will draw if you omit this file.
  • asphalt.png, grass.png, dirtroad.png, etc - Some default maps override the default terrain textures. Generally these are named thus but you can rename them - this is all specified in objects.svg

Mystery files[edit | edit source]

The following files behave strangely or their purpose is otherwise unknown:

  • effect_alpha_dirtroad.png - Theoretically should govern the lobby map's 'inner' dirt tracks, however when edited the tracks do not change.
  • effect_combined_alpha.png - A combined set of effect splats(?). The lobby map's 'inner' dirt tracks disappear if this file is removed and will not change to effect_alpha_dirtroad.png's.

Resources[edit | edit source]

A sample 'bare bones' map can be found here. This includes a custom heightmap and terrain splats, as well as the bare minimum required for an objects.svg/map config/etc.

objects.svg[edit | edit source]

RWR maps are extensions of the SVG image format which is generated by Inkscape. Because this file is automatically generated by Inkscape the format is actually quite hard to read for humans, despite being essentially XML. There is a very large amount of redundant information stored in each map due to the choice of Inkscape as the map editor. If you wish to write a program which can read RWR maps then you will need to learn which parts of this file can be safely ignored. If you wish to save Inkscape-compatible maps you will need to save this formatting back into the map.

Preamble[edit | edit source]

objects.svg begins with the XML version and SVG tags:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   width="2048"    - Width of the map, in units.
   height="2048"   - Height of the map, in units.
   version="1.1">  - Required.
    <defs id="defs4"></defs> - Required, even if empty.

It makes sense to match the size of your terrain5_* splats to the width/height given here, unless you are looking to achieve an exceptional amount of terrain detail. The default maps in RWR are 2048x2048, with a 513x513 heightmap.

Materials Layer[edit | edit source]

The materials layer is used to define things such as:

  • Metadata (map name, description, day/night colours, etc)
  • Surface configuration data (step sounds, surface friction etc. for each terrain type)
  • Terrain layer data (texture for each terrain type, alpha splat textures, texture scaling, outlining)
  • A couple of other things I've not written here yet.
    <g inkscape:label="materials">

General Settings[edit | edit source]

Metadata about the map.

- style is required for most objects in the materials layer, even if empty.
<rect inkscape:label="#general" style="">
    <desc>
        day_color = fill;  - fill=#ffffff. Governs what colour sunlight is. Can create a nice effect if made more reddish/bluish.
        night_color = #136395;
        flip = 1; - Rotates the user's view by 180 degrees. Used in some maps.
        name = My Map Name;
        description = Map Description;
        randomize_faction_index = 0;
        ambience_day_sound = ambient_daytime.wav;
        ambience_alert_day_sound = ambient_alert_daytime.wav;
        show_base_names_in_map_view = 0;
    </desc>
</rect>

Pvt. Surface Config[edit | edit source]

Defines some useful physical parameters related to terrain layers. Experiment with these!

<rect inkscape:label="#surface_config" style="">
    <desc>
        index = 0; - Dirt
        step_sound = 18; - Numeric IDs referencing step sounds
        step_sound = 19;
        step_sound = 20;
        step_sound = 21;
        step_sound = 22;
        step_sound_volume = 0.14;
        friction = 0.19;
        color = fill;
        step_dust_size = 0.4;
        drag = 0.1;
        tag = dirt; - Not 100% sure what this does.
    </desc>
</rect>

Col. Terrain Layer[edit | edit source]

Very important. Defines textures for each terrain layer, as well as alpha splats (for everything except dirt/0 and also handles things such as scaling and decoration.

- Here, the style="fill:COLOUR;" tints the outline colour. I'm not sure why outline_color is not used instead.
<rect inkscape:label="#terrain_layer" style="fill:#e7eeed;">
    <desc>
        index = 2; - Which terrain layer? Generally (may vary): 0=dirt, 1=mountain, 2=grass, 3=asphalt, 4=road
        texture = grass.png; - Obviously, the texture used by this terrain layer
        alpha = terrain5_alpha_grass.png; - Where will grass be drawn? Splat map.
        scale = 0.01 0.01; 
        auto_decoration_texture = ground_decoration.png; - Auto-decoration used to place tiny bushes, bits of grass all over grassy areas. Not required, but useful.
        auto_decoration_texture_atlas_cell = 0 0 2 2;
        auto_decoration_texture_atlas_cell = 1 0 2 2;
        auto_decoration_multiplier = 4;
        auto_decoration_size = 0.4;
        auto_decoration_density = 0.6;
        outline = 1; - Boundaries between two terrain layers are highlighted with an outline.
        outline_color = fill;
        tag = dirt;
    </desc>
</rect>

Bases[edit | edit source]

The bases group defines a series of rectangles along with names, which count as bases.

<g inkscape:label="bases">
    <rect
        inkscape:label="#rect11324_base" - Don't change this.
        x="512"
        y="700"
        width="100" - Width of the base rectangle.
        height="75"> - Height of the base rectangle.
        <desc>name=My Base Name;</desc> - Name of your base goes here!
    </rect>
</g>

Layer[edit | edit source]

"layer" is arguably one of the most important parts of the map. Here all objects, player spawnpoints and vehicle spawnpoints are defined.

Boundaries[edit | edit source]

Defines a series of bounds the player cannot pass. Pretty important; if the player gets close to leaving the map things start to act a bit strangely.

<g inkscape:label="boundaries" /> - Yeah, work in progress.

Other (Objects, spawns, etc)[edit | edit source]

This section in particular is very WIP The following shows an example of using the 'other' layer to define a single spawnpoint. Spawnpoints are not explicitly tied to bases; rather the game allows you to spawn at any spawnpoint which is in your territory and not considered dangerous.

<g inkscape:label="other">
    <rect
        inkscape:label="#spawnrect10748" - Do not change
        x="1024"     - X coordinate of spawn
        y="1024" />  - Y coordinate of spawn
</g>

Some more info needs to go here. It'll probably be a while. 26/04/2016