[HELP] How to modify Prices (Shields + Engines)

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

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

PSCO1
Posts: 1087
Joined: Thu, 4. Jun 09, 17:08
x4

[HELP] How to modify Prices (Shields + Engines)

Post by PSCO1 » Tue, 17. Oct 23, 01:36

First I would like to thanks Egosoft for their products ) and thanks for those awesome cockpits :)

So I started to play ~10 hours without mod.. until I bought a Chimera
What ? Chimera has better speed than a Mako ? Unaceptable ! :D Time to mod this

By learning how to extract files, using X4 Editor etc ... I decide to do my first mod on X4, something """"easy"""" for now

My first mod is about change ARGON S SHIELDS stats, so there are my new stats:

Code: Select all

--SIZE-- ---MAX--- ---RATE--- ---DELAY--- ---HULL--- ---THR--- ---PRICE---
S Mk1    1075       82        6.5            0         0        19228
S Mk2    1409       200       9.2            169       0        35480
S Mk3    1552       141       11.1           194       0        42643
By default, X4 Editor dont allow to modify Prices "on the fly"
So exploring files, I decide to modify "WARES.xml"
And I add a new path to my mod folder (for a modified "wares.xml")

X4 Editor show my new prices, instead of "0" values by default, so thats look good, lets start the game...
In game, I have the new values all works...... except prices, prices are still vanilla
I tried to start a new game, same problem.

If someone can tell me whats wrong in my code
some lines added In "wares.xml" to try to setup new prices:

Exemple for MK1:

Code: Select all

<ware id="shield_arg_s_standard_01_mk1" name="{20106,1004}" description="{20106,1002}" group="shields" transport="equipment" volume="1" tags="equipment shield">
  <price min="14790" average="19228" max="24996" />
  <production time="7" amount="1" method="default" name="{20206,101}">
    <primary>
      <ware ware="energycells" amount="5" />
      <ware ware="shieldcomponents" amount="1" />
    </primary>
  </production>
  <component ref="shield_arg_s_standard_01_mk1_macro" />
    <owner faction="argon" />
    <owner faction="yaki" />
</ware>
By comparing Vanilla "wares.xml" and Modified "wares.xml", X4 Editor works fine, I have my 3 lines added at end of "wares.xml" (MK1, MK2, MK3)

My structure:

Code: Select all

X4 Foundations > extensions > PSC01_X4RebStats > ...
    assets > props > SurfaceElements  > macros > ...
        "shield_arg_s_standard_01_mk1_macro.xml"
        "shield_arg_s_standard_01_mk2_macro.xml"
        "shield_arg_s_standard_01_mk3_macro.xml"
    libraries > ...
        "wares.xml"
    "content.xml"
Work without ext_01.cat.dat
Apparently my "wares.xml" look like in a wrong path
My code in "wares.xml" look good because X4 Editor recognize it
Wrong version of X3 Editor for my game version ? :?

sprIder
Posts: 96
Joined: Sat, 3. Jul 10, 23:23
x4

Re: [HELP] How to modify Prices (Shields + Engines)

Post by sprIder » Tue, 17. Oct 23, 19:24

Hi PSC01,

first: since you already got to know, how to unpack X4, this is obsolete? Getting Started: Tools, Scripting and Modding
Apart from the fact, that I never used the X4 Editor, you should find a

Code: Select all

<diff>
in the beginning and a

Code: Select all

</diff>
at the end of your *_macro.xml files.
This indicates, that these file contains stuff, which changes existing stuff.
More about that: [TUTORIAL] XML Patch Guide

That's something You need for the wares.xml as well.
And: if you only want to change the prices of these wares, you should only change the prices. Who knows, maybe Egosoft will change the other parameters in the future.
If you want to overwrite it completely, please don't forget half of it. Currently, you are missing

Code: Select all

    <restriction licence="generaluseequipment" />
    <use threshold="0.25" />
if i see it correct.

The short way, your wares.xml:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff>
	<replace sel="/wares/ware[@id='shield_arg_s_standard_01_mk1']/price">
		<price min="14790" average="19228" max="24996" />
	</replace>
</diff>
  • replace: start of your action: replace the prices. Followed by the path where (sel="/wares/ware[@id='shield_arg_s_standard_01_mk1']) you want to change something (/price)
  • "> : End of path. Here starts your code which overrides the existing.
  • /replace: End of your action
  • At this point you can make your next change, removing a faction:

Code: Select all

	<remove sel="/wares/ware[@id='shield_arg_s_standard_01_mk1']/owner[@faction='alliance']"/>
All in all, and more:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff>
	<replace sel="/wares/ware[@id='shield_arg_s_standard_01_mk1']/price">
		<price min="14790" average="19228" max="24996" />
	</replace>
	<remove sel="/wares/ware[@id='shield_arg_s_standard_01_mk1']/owner[@faction='alliance']"/>
	<add sel="//wares/ware[@id='shield_arg_s_standard_01_mk1']">
		<owner faction="yaki" />
	</add>
</diff>
The path of your "wares.xml" is correct.

Does this help you?

PSCO1
Posts: 1087
Joined: Thu, 4. Jun 09, 17:08
x4

Re: [HELP] How to modify Prices (Shields + Engines)

Post by PSCO1 » Tue, 17. Oct 23, 20:48

Thanks for the help sprIder

I realized all my cat/dat wasnt extracted correctly ! (I extracted each cat/dat 1 by 1, 01 then 02 then 03 then 04 etc.... in hope of overwriting the previous cat/dat for each extract... )
I dont want to understand why but my extracted "wares.xml" wasnt the same than the original in 08.cat thats explain why I didnt able to see price in X4Editor

So i created a .bat to extract all cat/dat as you said in your post and ALL works now, this is a correct "wares.xml" in my "unpacked" folder, THATS OK !!


extensions\PSC01_X4RebStats\assets\props\SurfaceElements\macros\"shield_arg_s_standard_01_mk1_macro.xml"
is now:

Code: Select all

<diff> 
	<replace sel="//macros/macro/properties/recharge/@max">1075</replace>
	<replace sel="//macros/macro/properties/recharge/@delay">6.50</replace>
</diff> 
extensions\PSC01_X4RebStats\libraries\"wares.xml"
is now:

Code: Select all

<diff> 
	<replace sel="/wares/ware[@id='shield_arg_s_standard_01_mk1']/price">
		<price min="14790" average="19228" max="24996" />
	</replace>
</diff> 
Now thats works :)

I ll keep an eye at your reply :D

Edit:
After tests, it seems MIN and MAX values are ignored, the game show me values outside my min and max limits
It should be because of my high reputation with Argon (+18)

So I edited my "wares.xml" by

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff>
	<replace sel="/wares/ware[@id='shield_arg_s_standard_01_mk1']/price">
		<price average="19228" />
	</replace>
	<replace sel="/wares/ware[@id='shield_arg_s_standard_01_mk2']/price">
		<price average="35480" />
	</replace>
	<replace sel="/wares/ware[@id='shield_arg_s_standard_01_mk3']/price">
		<price average="42643" />
	</replace>
</diff>
Also works

sprIder
Posts: 96
Joined: Sat, 3. Jul 10, 23:23
x4

Re: [HELP] How to modify Prices (Shields + Engines)

Post by sprIder » Wed, 18. Oct 23, 18:21

You're welcome. Glad to see that it helps.

Please keep in mind that all your changes also apply to the entire game, respectively to the other factions and the economy, and not just to you. So it might make sense to adjust the min and max prices as well.

PSCO1
Posts: 1087
Joined: Thu, 4. Jun 09, 17:08
x4

Re: [HELP] How to modify Prices (Shields + Engines)

Post by PSCO1 » Thu, 19. Oct 23, 12:45

Good to know,, I have just started to play, and realy don't know how work the economy
I will restore min and max price in my mod
The goal was to take a quick look for a simple mod for me, i dont have in mind to change all values

Also I managed to reduce slightly speed of the Chimera and increased the speed of the Mako, I need to understand more how work the flight properties

By searching a little in the forum I found this

Code: Select all

speed        = ('engine: forward' * 'ship: slots engine') / 'ship: forward'
acceleration = ('engine: forward' * 'ship: slots engine') / 'ship: mass'
Iam just focused on S classes ships for now

Return to “X4: Foundations - Scripts and Modding”