Changes to Resources (Spawns, Spawntime, Yields, etc.)

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

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

desertforce
Posts: 6
Joined: Tue, 15. Feb 22, 16:16
x4

Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by desertforce »

Hi @all :D ...

Within the last few weeks I started to play X4 again after a longer break from the game. Now I reached a point in the game where the different factions have grown quiet a bit and are mining resources without end. One of those resources is the all known and most famous *Methane-u-won't-be-able-to-find-enough-from-it* :P . My problem with that now is that Methane is depleting faster than its respawing :cry: . For example 6h of gameplay ago the Eighteen Billion Sector had around 550k of Methane in it and now - 6h later - it only has around 150k left, dropping faster than it'll respawn :evil:.!

Since I do not want to get to a point where the whole economy will start to crumble because of depleted resources and therefore make my savegame/game unplayable/boring to play, I thought about how to counter this Problem. In this regard I do have some questions now and I am hoping that someone will be able to help me with some answers.
  1. I do know that you can change spawns, spawntimes, yields and so on by changing the region_definitions.xml and other .xml files related to it. But do those changes also effect already existing savegames? I am asking because I've read that since the 4.0 update this is not the case anymore and because I do NOT want to start over from scratch again :x ...
  2. If those changes do effect existing savegames, how should I apply them? For example with a small mod which will introduce changes to the general spawntimes?
  3. If those changes do not effect existing savegames, is there a way to apply those changes to them? For example by editing the savegame entries regarding the spawntimes and current amounts of specific resources (I've seen entries listing those for discovered sectors inside of my savegame files.)?

Many thanks in advance for the help :mrgreen: !
DeadAirRT
Posts: 1124
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by DeadAirRT »

There is no way to change existing resource fields from what I gathered from devs around 4.0.

You can try adding resource regions though. It's been a long time since I messed with it so I don't remember if the ai actually recognizes it or not.
User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13485
Joined: Sun, 15. Feb 04, 20:12
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by euclid »

Welcome desertforce :-)

I take you have unpacked the game files already (if not please do so). Look into the libraries folder and check the region_definitions.xml file. I also recommend to look into the definitions of the commands and parameter used there. You'll find them in the xsd file. In particular check (and test) the parameters 'yield' and 'replenishtime' of 'resourcefield'. Hope that helps.

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786
desertforce
Posts: 6
Joined: Tue, 15. Feb 22, 16:16
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by desertforce »

DeadAirRT wrote: Wed, 16. Feb 22, 00:34 There is no way to change existing resource fields from what I gathered from devs around 4.0.

You can try adding resource regions though. It's been a long time since I messed with it so I don't remember if the ai actually recognizes it or not.
Hi DeadAirRT. Thank you for the fast answer :mrgreen: .! I feared that what I read was correct :cry: . But still. Does this apply to all values regarding resources or only specific ones? For example. Can you - perhaps - change the respaw timer for certain resources like *Methane - high yield* in already existing games/savegames?
euclid wrote: Wed, 16. Feb 22, 02:01 Welcome desertforce :-)

I take you have unpacked the game files already (if not please do so). Look into the libraries folder and check the region_definitions.xml file. I also recommend to look into the definitions of the commands and parameter used there. You'll find them in the xsd file. In particular check (and test) the parameters 'yield' and 'replenishtime' of 'resourcefield'. Hope that helps.

Cheers Euclid
Hi Euclid. Thanky you too for the fast answer :mrgreen: .! I didn't unpack them, but I'll do so later today (its now way past bedtime for me, 3:00am in the morning :D ). Then I'll also check the files. What I already did yesterday was checking some Mods and the Code used in them, as well as some posts and threads here in the Forum. From them I got some understanding which .xml files and code lines I'll need to look out for.

As you can see DeadAirRT wrote that according to what he heared from the devs changes to existing fields aren't possible. Nevertheless, I also want to ask you the same question as I asked him. Can you - perhaps - change the respaw timer for certain resources like *Methane - high yield* in already existing games/savegames? I think - if I am not mistaken - it should be something along those lines, if done via a Mod that is.

Code: Select all

<replace sel="/regionyields/resource[@ware='methane']/yield[@name='veryhigh']/@replenishtime">300</replace>

Many thanks again you two 8) !
DeadAirRT
Posts: 1124
Joined: Fri, 25. Jan 19, 03:26
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by DeadAirRT »

This is from a discord conversation in the modding channel from March 2021

Me-
@DocAce sorry to bug you, are changes to regionyields.xml (specifically replenish time) applicable to an existing game? Is there is a minimum amount of time for replenish?

Docace-
I'm afraid not automatically. Changing things requires a pretty costly rebuilding of data, so we don't do it on every load. There is currently no mod-available method of triggering this rebuild, sorry.
desertforce
Posts: 6
Joined: Tue, 15. Feb 22, 16:16
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by desertforce »

Thank you very, very much for digging out the conversation you had DeadAirRT :) :!: :!:

There are some things I do find interesting about his answer. For example, he only said that changes won't be implemented automatically. So, it should be possible to do it manual in some way but with a lot of work required. Its also interesting that he wrote *..., so we don't do it on every load.*. That would suggest that there is perhaps a certain load cycle during which the game will load/rebuild/check all the data. Maybe during each update and or new DLC download perhaps? Or perhaps every X times of loading the game / a savegame?

With that I now know what options I do have - sadly :( .
  1. I can start a New Game with a Mod changing resources already installed. This would be the fastest solution, but it would mean that I have wasted a few 100h of playtime :evil: !
  2. I can try to change the resource values saved in the savegame(s) and see if that will do any good. It will be a big load of data entries I'll need to change and see *if* it will work or not :| . This may take for ever, without knowing if it will work or not.
  3. I can try to load the game / a savegame over and over and over .... and over again, until the changes may or may not apply.
  4. I can leave it as it is and play until the whole economy comes down or until the devs will change something or a modder will find a solution for it.
Manawydn
Posts: 306
Joined: Sun, 26. Jan 20, 06:54
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by Manawydn »

desertforce wrote: Wed, 16. Feb 22, 15:58
I can start a New Game with a Mod changing resources already installed. This would be the fastest solution, but it would mean that I have wasted a few 100h of playtime :evil: !
Recreate your empire in a custom start. It will take about an hour or so, but it will mean that those 100 or so hours are not wasted. If it's any consolation, I've abandoned like 5 or 6 200+hr games.
User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 13485
Joined: Sun, 15. Feb 04, 20:12
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by euclid »

desertforce wrote: Wed, 16. Feb 22, 15:58 .....
With that I now know what options I do have - sadly :( .
.....
As DeadAirRT pointed out, you could just add a new resource with high yield and short replenish time. Of course you need to trigger it only once. Backup your saved game, make a short MD script that triggers on game load and adds a new resource and then check it the resource is there. If so, save the game, exit, remove the script and then continue playing ;-)

Cheers Euclid
"In any special doctrine of nature there can be only as much proper science as there is mathematics therein.”
- Immanuel Kant (1724-1804), Metaphysical Foundations of the Science of Nature, 4:470, 1786
desertforce
Posts: 6
Joined: Tue, 15. Feb 22, 16:16
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by desertforce »

Thanks for the answers... Will try those things out :) ...
desertforce
Posts: 6
Joined: Tue, 15. Feb 22, 16:16
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by desertforce »

Hi...

Just wanted to give a short Update :) ...

Yesterday I did play around with a Savegame file chaning things here and there. The result was, that I did find a way to reduce the respawn time for resources :mrgreen: ... I am not sure, if that change will be permanent or not and if this change did break anything or not... For the moment its working and I do have a nearly instant respawn time for resources in the Eighteen Billion Sector 8) ...
DarthKroolik
Posts: 7
Joined: Sat, 19. Nov 22, 12:34
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by DarthKroolik »

Could you share what you changed actually? At least some key words I should search for and file names to modify?
I got over 400hrs in game and I really don't want to start from the scratch before gaining an endgame phase.
Thank you for any helpful suggestion!
mingl0280
Posts: 2
Joined: Sat, 25. Jan 25, 21:55
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by mingl0280 »

DarthKroolik wrote: Mon, 1. Jul 24, 23:51 Could you share what you changed actually? At least some key words I should search for and file names to modify?
I got over 400hrs in game and I really don't want to start from the scratch before gaining an endgame phase.
Thank you for any helpful suggestion!
I navigated through some items in the save... Looks like there are sections like this:

Code: Select all

<area x="1024000" y="-128000" z="192000">
<wares>
<ware ware="hydrogen">
<recharge max="6600" time="18000"/>
</ware>
<ware ware="ice">
<recharge max="39321" time="10800"/>
</ware>
<ware ware="nividium">
<recharge max="25" current="14" time="302400"/>
</ware>
<ware ware="ore">
<recharge max="6814" time="36000"/>
</ware>
<ware ware="silicon">
<recharge max="6813" time="36000"/>
</ware>
</wares>
<yields>
<ware ware="hydrogen">
<yield name="low"/>
</ware>
<ware ware="ice">
<yield name="verylow"/>
</ware>
<ware ware="nividium">
<yield name="low"/>
</ware>
<ware ware="ore">
<yield name="lowest"/>
</ware>
<ware ware="silicon">
<yield name="lowest"/>
</ware>
</yields>
</area>
And if you change them... It should make a high yield and respawn quicker.
Realspace
Posts: 1637
Joined: Wed, 15. Nov 06, 10:21
x4

Re: Changes to Resources (Spawns, Spawntime, Yields, etc.)

Post by Realspace »

As DeadAir wrote the easiest way is adding some more resources on the map (cluster) on slightly different location. This can easily double the res and yes, at game load the game recognizes the new regions. You can even move or remove the old regions but they will be (re)moved only in space not in the resource mapping which is written in the save. So better not to mess with that.

Return to “X4: Foundations - Scripts and Modding”