Sector Creation

The place to discuss scripting and game modifications for X4: Foundations.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
Oganesson
Posts: 7
Joined: Fri, 11. Nov 22, 07:59

Sector Creation

Post by Oganesson » Sat, 12. Nov 22, 06:10

Hello, I've recently been following this <https://github.com/enenra/x4modding/wik ... e-Creation> tutorial to create a new sector, and it seems to work fine to create a custom start in a brand new sector, but it's not quite a tutorial to add a sector into the game for other game starts. I've looked through the New Horizons / Old Lands mod a bit to see what I can reverse engineer but it's quite a complex mod, so I was wondering if before I start that if there's any very simple mods that add a sector I might work from instead (can't seem to find one myself), or whether anybody's already done this that can give me some tips on turning what you get from enenra's tutorial into a mod that'll work for any game start. Thanks.

Dr Reed
Posts: 76
Joined: Fri, 30. Nov 18, 00:05
x4

Re: Sector Creation

Post by Dr Reed » Sat, 12. Nov 22, 17:51

That tutorial seem to be all that exists at the moment as far as I am aware.
As for other mods that you can pull apart to learn from, have a look on Nexus Mods for XPANed Sectors Advanced. It only adds new sectors to the game so it might be easier to learn from as there aren't other things which could add confusion to the process. e.g. new factions.


For each sector to work on a basic level you will need:

A naming convention that you will use throughout the mod. e.g. yourmod_
A basic sector file in the assets/environments/cluster folder. This will give the lighting data and sun, planet and set dressing. You can just copy and rename existing sectors for starters but make sure you also change a few settings in the files to work with your new names.
macro.xml and component.xml files are also needed in the Index folder.
A mapdefaults.xml file is needed in the Library folder. This holds the name, music, sunlight level and security details of the sector.

In the maps/xu_ep2_universe folder you will need :
galaxy.xml which gives the map co-ords of you sector and it also has the details of the gate connections.
yourmod_clusters.xml file gives the spawn positions of mineral, gas and audio regions from the Regions.xml file.
yourmod_sectors.xml file gives the co-ords of the zones in a system
yourmod_zones.xml contains the gates and their positions in the zones.
sectors.xml to add the co-ords in an existing sector for a new zone for your connecting gate.
zones.xml to add the gate into your new zone in the existing map.
You will also need a text file in the t folder for the name of your new sector and other things you add.

Also a small MD file is needed to activate the new gate connection.


I think I covered the basic files needed to get a new sector working.

Oganesson
Posts: 7
Joined: Fri, 11. Nov 22, 07:59

Re: Sector Creation

Post by Oganesson » Sun, 13. Nov 22, 11:46

Thanks, I'm working from that mod now, still a lot of files, but I'll see what I can strip out to simplify it down to one sector, I'll try and update this thread with what I learn in case anybody else is looking to do something similar.

Realspace
Posts: 1342
Joined: Wed, 15. Nov 06, 10:21
x4

Re: Sector Creation

Post by Realspace » Sun, 13. Nov 22, 12:02

I suggest you use New Horizons mod as base for learning. It is more strictly build on the x/z axis and has notes everywhere. My XRSGE mod also has many notes but it'd be too big to learn, use the above instead, it is quite self-explicatory

Oganesson
Posts: 7
Joined: Fri, 11. Nov 22, 07:59

Re: Sector Creation

Post by Oganesson » Sun, 13. Nov 22, 22:38

That's a good idea, I'll give it another look now I've got a bare bones extension working that adds a new sector and links it to an existing sector, I think I'll tidy up what I've got so far and upload it soonish in case anybody else wants a really simple example to start with too.

EDIT: I deleted the example mod, use this tutorial instead - https://pastebin.com/5VdtWMLb
Last edited by Oganesson on Mon, 28. Nov 22, 15:18, edited 2 times in total.

Oganesson
Posts: 7
Joined: Fri, 11. Nov 22, 07:59

Re: Sector Creation

Post by Oganesson » Tue, 15. Nov 22, 11:57

Having a little trouble adding a sun, I've copied across:
assets\environments\cluster\Cluster_01_data\[all files]
assets\environments\cluster\Cluster_01.xml
assets\environments\cluster\CLUSTER_01_DATA.ANI
assets\environments\cluster\macros\Cluster_01_macro.xml
and also made a components.xml file in \index\ but I'm not sure exactly what to change to make it work, so far my tinkering hasn't worked, I'm guessing the urls need to point to the files in the mod by adding extensions\modname\, but I can't work out what goes in name, or how they connect to other files, do I need to add something in macros or another file?

This is components.xml :-

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!-- ?xml-stylesheet href="index.xsl" type="text/xsl" ? -->
<index>
	<entry name="Cluster_01" value="assets\environments\cluster\Cluster_01"/>
</index>
This is the top of Cluster_01.xml :-

Code: Select all

<?xml version="1.0"?>
<components>
	<component name="Cluster_01" class="celestialbody">
		<source geometry="assets\environments\cluster\Cluster_01_data"/>

Dr Reed
Posts: 76
Joined: Fri, 30. Nov 18, 00:05
x4

Re: Sector Creation

Post by Dr Reed » Tue, 15. Nov 22, 15:38

The entry in the components file should look like this

Code: Select all

<diff>
	<add sel="/index">	
		<entry name="Cluster_01" value="extensions\your_mod_name\assets\environments\cluster\Cluster_01" />
	</add>
</diff>
and the Cluster_01.xml file should also have the file path of your mod included as well

Code: Select all

	<source geometry="extensions\your_mod_name\assets\environments\cluster\Cluster_01_data"/>

Oganesson
Posts: 7
Joined: Fri, 11. Nov 22, 07:59

Re: Sector Creation

Post by Oganesson » Wed, 16. Nov 22, 13:34

Ah thank you I've got it working now.

I'm looking at adding regions for asteroids and gases now, does anybody know what noisescale means? I've played around with changing the number but I can't work out what it actually does, or what minnoisevalue and maxnoisevalue does, something to do with the distribution within the field as far as I can gather but I can't tell what actually does what.

Edit: I think noisescale does indeed influence where asteroids appear, bigger number clumps them together more, smaller number gives a more even distribution.

Edit2: Just found that the xsd files of the same name contain a load of info on what stuff is and does, whoops, didn't notice them before.

Edit3: Got custom asteroids working, just need to make sure you have everything in the rights folders, use diff/add for region_definitions, regionobjectgroup, and yieldvariation, then point regionobjectgroup to what the xml of your custom asteroid is called with a _macro suffix in extensions\mod\assets\environments\asteroids\macros which then points to the xml file without _macro in the folder above it which then points to the data folder, also you need an entry in components like you do with a cluster.

Oganesson
Posts: 7
Joined: Fri, 11. Nov 22, 07:59

Re: Sector Creation

Post by Oganesson » Sat, 26. Nov 22, 04:20

I've created a tutorial that combines everything I've learned, it's a bit long so I put it in a pastebin, it covers adding a cluster, a sector, a zone, gates, asteroids, gas, and debris.

https://pastebin.com/5VdtWMLb

Dr Reed
Posts: 76
Joined: Fri, 30. Nov 18, 00:05
x4

Re: Sector Creation

Post by Dr Reed » Sun, 27. Nov 22, 23:15

That's a nice bit of work.

I did not know the conversion site existed for converting between quaternions and Euler angles https://quaternions.online/
Thanks for this info. :)

Quirkz
Posts: 15
Joined: Sun, 24. May 20, 18:35
x4

Re: Sector Creation

Post by Quirkz » Sat, 2. Mar 24, 01:27

Oganesson wrote:
Sat, 26. Nov 22, 04:20
I've created a tutorial that combines everything I've learned, it's a bit long so I put it in a pastebin, it covers adding a cluster, a sector, a zone, gates, asteroids, gas, and debris.

https://pastebin.com/5VdtWMLb
This is actually really good. Maybe you can get it added to the official wiki modding section?

Post Reply

Return to “X4: Foundations - Scripts and Modding”