Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

For X4 (will largely also work for XR)

Preparation

Download the X-tools XR/X4 catalogue extraction tool from either steam (it’s available in ‘tools’) or the egosoft website

Have a text editor on hand, my personal favourites are notepad++ and vscode

Get familiar with the file structure of the base game, particularly everything within libraries and maps.

With all the necessary files it is now prudent to setup a file structure which should be as follows

your_highway_mod

libraries

maps

extensions

content.xml

  highwayconfigurations.xml

  xu_ep2_universe

  <mod/dlc_file_name>


  material_library.xml

    zonehighways.xml

    maps



    sectors.xml

      Sectors.xml


Note: extensions is only required if modifying the sectors of a DLC or mod, be sure to follow the way sectors.xml is named in the original. For example for cradle of humanity its actually named dlc_terran_sectors.xml

The inclusion of the libraries directory and its contents is optional and only relevant if the appearance of the highway is to be changed.

Getting Started

To get started open up zonehighways.xml with your editor and add the following:

<?xml version="1.0" encoding="utf-8"?>
<diff>
  <add sel="/macros">
    <!--We'll put highway macros here-->
  </add>
</diff>

For those unfamiliar with the usage of <diff/> and <add/> it is well worth looking at the XML Patch Guide but in this guide most operations should be fairly self explanatory.

We now want to add a highway macro, to do that we need the following information:

  • Highway name, I recommend keeping it consistent with the vanilla naming scheme
    • Highwayxx_Clusteryyy_Sectorzzz_macro
  • Entry and exit points
  • Intermediate points with optional (but recommended) tangents
  • Configuration is optional and is for aesthetic purposes
  • All other nodes can remain empty

This information is to be added to the following template to the double quotes, e.g. <position x="" y="" z="" /> may be <position x="7000" y="-500" z="36.57" />

<macro name="Highway01_Cluster_113_Sector001_macro" class="highway">
    <component ref="standardzonehighway" />
    <connections>
      <connection ref="entrypoint">
        <offset>
          <position x="" y="" z="" />
        </offset>
      </connection>
      <connection ref="exitpoint">
        <offset>
          <position x="" y="" z="" />
        </offset>
      </connection>
    </connections>
    <properties>
      <boundaries>
        <boundary class="splinetube">
          <splineposition x="" y="" z="" tx="" ty="" tz="" weight="" inlength="0" outlength="" />
		  <splineposition x="" y="" z="" tx="" ty="" tz="" weight="" inlength="" outlength="" />
		  <splineposition x="" y="" z="" tx="" ty="" tz="" weight="" inlength="" outlength="" />
		  <splineposition x="" y="" z="" tx="" ty="" tz="" weight="" inlength="" outlength="0" />
          <size r="200" />
        </boundary>
      </boundaries>
      <controls>
        <linear>
          <time />
        </linear>
        <angular>
          <roll />
        </angular>
      </controls>
      <configuration ref="configuration_name" ring="0" />
    </properties>
  </macro>

Splines

The central section of zonehighways.xml denotes the shape of the highway and is contained within the boundary node, the boundary class is explicitly defined as a splinetube because a number of other elements like resource regions use the boundary node. Within the boundary node there are splineposition nodes which store the following information on each explicitly defined point on the spline curve:

splineposition noderole
x="" y="" z=""Denotes the co-ordinates of the point measured in metres from the origin (the centre of the sector unless changed in sectors.xml). In X4 the XZ plane is the "horizontal" plane that most objects are located on within sectors.
tx="" ty="" tz=""The tangent to the spline at the point (x,y,z) expressed as the vector (tx,ty,tz) measured in metres. I recommend making the vector a unit vector to make working with in and outlengths much easier.
weight=""Affects the speed of the highway at the point (x,y,z)
inlength="" & outlength=""Inlength scales the side of the tangent vector that is "before" the point itself, this makes the curve closer to the tangent. Outlength does the same to the side that is "after" the point. In and outlength also has the affect of setting the speed gradent, longer in and outlengths make for smoother changes in speed. The initial inlength and final outlength must both be 0 to prevent issues.

Diagrammatic representation of the splineposition node and its attributes

Adding Highways to Sectors

A lot of fiddling with highways comes down to selecting an appropriate placement for the highway in regards to the infrastructure already there, it may be desirable to have a highway go to a higher density resource region and back or perhaps have it go directly between jumpgates or even dip down below the ecliptic plane to give you a different perspective on a sector there are a lot of options, the trick comes from getting the co-ordinates of the features the highway should start nearby or pass by. Luckily Roguey's website features an interactive map that has the co-ordinates of certain objects available when hovering over them, it is important to note, however, that his website uses km and X4 uses metres so be sure to apply the scale factor in your splines. For plotting highways to resource regions either resourcedefinitions.xml may be used to get the exact co-ordinates for a given sector or guesswork and estimation may be used with jumpgates as a reference.


To actually get a highway into the game we take the highway macro in zonehighways.xml and reference it in sectors.xml (or equivalent DLC or mod xml). This is done in the following format

<add sel="//macro[@name='Cluster_xxx_Sectoryyy_macro']/connections">
	<connection name="Highwaynn_Cluster_xxx_Sectoryyy_connection" ref="zonehighways">
    <offset>
      <position x="" y="" z="" />
    </offset>
    <macro ref="Highwaynn_Cluster_xxx_Sectoryyy_macro" connection="sector">
      <connections>
        <connection ref="exitpoint">
          <macro path="../../Zonezzz_Cluster_xxx_Sectoryyy_connection" connection="HighwaynnConnection02_gate" />
        </connection>
        <connection ref="entrypoint">
          <macro path="../../Zonezzz_Cluster_xxx_Sectoryyy_connection" connection="HighwaynnConnection01_gate" />
        </connection>
      </connections>
    </macro>
  </connection>
</add>
</diff>

Cluster_xxx_Sectoryyy refers to the cluster (big hexagon) and sector (smaller hexagon) that the highway is to be placed in, for clusters with no smaller hexagons set "Sectorxxx" to "Sector001". The relation between the internal identification of the sector ID and the name is in libraries/map_defaults.xml for the basegame, DLC versions perform a diff patch on this library file so they are indentically named in their respective DLC directory.

The final trick with adding the defined highway to a sector is that the entrance and exit of a given highway must be in a zone, in vanilla zones are usually named Zone001 through to Zone006, check the co-ordinates of the existing vanilla, dlc or mod zones in the original sectors.xml to ensure the right zone is selected, choosing the wrong zone can cause debug log errors or the highway not to appear at all.

At this stage provided everything references everything else properly this should work as a mod if it is dropped in the extensions folder and has a proper content.xml, other resources can help with packing the mod correctly like euclid's Getting Started: Tools, Scripts and Modding.

Customising Highways

This section isn't a requirement for making highways but it goes through a bit of how they can be customised.

Navigation

  • No labels