[Tool] X4 Editor

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

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

Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

[Tool] X4 Editor

Post by Max Bain » Fri, 3. Jan 20, 23:00

https://staticdelivery.nexusmods.com/mo ... 508367.png

X4 Editor

Main purpose of this tool
To make modding and especially balancing easier. So maybe even Egosoft might benefit from this tool by discovering some hidden balance issues. But apart from that I believe that X4 will become an epic game, especially because of the moddability this game offers. So the more modders we can get into X4, the faster X4 will evolve and we all will profit.

Short description:
The X4 Editor shows many values of different items and entities in game. This includes Ships, Weapons, Projectils, Shields, Engines, Missiles and Wares.
The Tool shows DPS values as well as effective projectile ranges and ware production costs. It can also export changes made to the items into a separate mod.


WARNING:
Rule number 1: Before you use this tool, be sure to have a BACKUP of your mods you want to open in the Editor. I am not responsible for any data loss due to bugs or wrong usage of the tool.


Precondition:
Extract all X4 and Mod Data you want to use so the X4 Editor can read the files.

How to use:
  • 1. Set the vanilla folder path to the folder where you extracted the X4 vanilla data into. Then click on Read Vanilla. This will show you all vanilla data for the specified tables.
  • 2. Set Mod folders. The tool supports an optional base mod and an active mod to be loaded into the editor. First enter the base mod path if needed and then your active mod path. Both is optional, but the base mod path can not be the export path.
  • 3. Edit or just compare the values in the tables.
  • 4. If you want to export your changes, set the export path the folder of your mod. This must be the active mod folder or a totally new folder.
Features:

  • The X4 Editor shows most (not all) values for Ships, Weapons, Projectiles, Missiles, Shields, Engines and Wares in a compact and simply to compare view
  • Additionally the tool shows calculated values like DPS, DPS to shield, effective projectile range, production costs and margin of wares
  • For ships it shows the number of shields, turrets and weapons slots mountable on the ship
  • The tool makes it simple to find the values of a specific item by showing in game names if accessible (the 0001.xml file will be parsed and needs to be inside the "t" folder)
  • It offers several filter options to search specific items including item size or the option to filter for words in the name or ID of the items
  • The separate wares window can be set to show only the wares related to the filtered items of the main window
  • Mass edition/calculation over multiple selected cells is possible
  • Right click opens the related xml file in the oposite order of the loaded mods. So if the item you right click on was edited by the Active Mod, then this item xml file will be opened. If Active Mod has not changed the item at all but the BAse Mod did, then the file of Base Mod will be opened. If neither of these mods has edited the item, then the vanilla file will be opened.
  • Double Click on a weapon/turret filters the related projectil
  • Double Click on a projectile filters the related Turret/weapon
  • The X4 Editor saves your path and filter settings in a config file to make it as easy as possible to use
  • If no content.xml file in your export folder exists, the tool will generate a default one


If you only want to compare and check different values of several items of vanilla X4 and mods, there is no danger in using this mod. It is the perfect tool for you!
You can skip the next part.
If you want to create a mod based on other mods or vanilla X4 and this mod does not exist yet, there should not be any problem. Simply put a new export folder path and thats it.
You can also skip the next part.

If you have a mod with new content as active mod or export folder, then you should read the next section carefully!



Known Problems/Dangers

The mod will only create diff files with changed parameters of the file in that session. Only changes compared to the VANILLA and BASE MOD files will be written. For example I changed the rotationspeed and rotationacceleration of the shotgun in the editor. This will result in the creation of the xml file turret_arg_m_shotgun_01_mk1_macro.xml including following lines.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff> 
<replace sel="//macros/macro/properties/rotationspeed/@max">200.00</replace>
<replace sel="//macros/macro/properties/rotationacceleration/@max">2.00</replace>
</diff> 
When I close and open the editor again and just change reloadtime to 2, the export will create the following xml:

Code: Select all

 <?xml version="1.0" encoding="utf-8"?>
<diff> 
	<replace sel="//macros/macro/properties/rotationspeed/@max">200.00</replace>
	<replace sel="//macros/macro/properties/rotationacceleration/@max">2.00</replace>
	<replace sel="//macros/macro/properties/reload/@time">2.00</replace>
</diff> 
Export path same as active mod path problem!
If you have already created a mod that adds new content like weapons, shields or ships and you set the export path to this mod because you want to edit your mod, the X4 editor will not check that the new content is new. Lets say you added a ship file for a new ship and load the mod in X4 Editor. If you dont edit any property of the ship and export the mod, then you dont have any problems because the file will not be written. But if you edit a property like hull value of that new ship and export the mod this will result in a similar file as you see above with just the hull value changed. The old xml file including all other values is then totally overwritten and destroyed! Therefore...


=> Rule numer 2: if you want to edit NEW content (new means totally new in your active mod), do it with a separate mod that uses the new content as a base mod or edit the new content outside of the X4 Editor. Simply right click on the item and the xml file will be opened. Be careful to reload the mod after this if you want to see the changes made outside the tool because all other not exported changes are gone then.


Not 100% tested!
During the long developement of the tool, I found several hundreds of bugs that I all could fix, but that shows that there might be more hidden. So always keep a copy of you mod you are writing into, especially if you have a big one. Errors might appear to a later time, even when the mod seems to tun flawlessly.

Download link on Nexus:
https://www.nexusmods.com/x4foundations/mods/388/

Changelog:

1.0.1
  • Fixed typos in content.xml
  • Changed default version output for content.xml to 001 instead of 100
  • Subfolders will now only be created if necessary
  • Subfolders for base mod files will now be created as well, so changes made on new content of base mod will be applied into the game
  • Changed defaul mod name in content xml to "ZZ_" + mod folder name so the mod should be loaded as last mod
Bugs reports and feedback welcome!

And now.. happy modding!

====================== Pictures below ======================

https://staticdelivery.nexusmods.com/mo ... 222533.png

https://staticdelivery.nexusmods.com/mo ... 088655.png

https://staticdelivery.nexusmods.com/mo ... 271383.png

https://staticdelivery.nexusmods.com/mo ... 464484.png

https://staticdelivery.nexusmods.com/mo ... 523624.png

https://staticdelivery.nexusmods.com/mo ... 437998.png
Last edited by Terre on Thu, 25. Mar 21, 09:29, edited 2 times in total.
Reason: Images posted directly to the forums should not be greater than 640x480 or 100kb, oversize image now linked
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

werit
Werit Gaming
Posts: 39
Joined: Mon, 8. Jul 19, 14:45
x4

Re: [Tool] X4 Editor

Post by werit » Sat, 4. Jan 20, 01:54

Very neat, could it work with jobs as well?

User avatar
alexalsp
Posts: 1820
Joined: Fri, 18. Jul 14, 05:28
x4

Re: [Tool] X4 Editor

Post by alexalsp » Sat, 4. Jan 20, 09:54

Program creates content.xml with

Code: Select all

encoding="utf - 8"
Correct format

Code: Select all

encoding="utf-8"

Code: Select all

version="100"
I think it's better

Code: Select all

version="001"
and

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff> 
<replace sel="//macros/macro/properties/rotationspeed/@max">200.00</replace>
<replace sel="//macros/macro/properties/rotationacceleration/@max">2.00</replace>
</diff> 
to

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff> 
<replace sel="//properties/rotationspeed/@max">200.00</replace>
<replace sel="//properties/rotationacceleration/@max">2.00</replace>
</diff>

Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [Tool] X4 Editor

Post by Max Bain » Sat, 4. Jan 20, 11:51

werit wrote:
Sat, 4. Jan 20, 01:54
Very neat, could it work with jobs as well?
I think it could, but not sure if/when I will add this. Jobs are normally a thing you create once and then you are done. You dont need to tweak them very often. Therefore the work to involved such a feature will be big compared to the benefit. But when I am bored one day I will think about it.
But you know, I have several other projects running at the time :D.

alexalsp wrote:
Sat, 4. Jan 20, 09:54
Program creates content.xml with

Code: Select all

encoding="utf - 8"
Correct format

Code: Select all

encoding="utf-8"

Code: Select all

version="100"
I think it's better

Code: Select all

version="001"
Thx. Visual Studio adds some blanks when you copy and paste xml.. dont know why -.-. The version number idea is good too.
alexalsp wrote:
Sat, 4. Jan 20, 09:54

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff> 
<replace sel="//macros/macro/properties/rotationspeed/@max">200.00</replace>
<replace sel="//macros/macro/properties/rotationacceleration/@max">2.00</replace>
</diff> 
to

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff> 
<replace sel="//properties/rotationspeed/@max">200.00</replace>
<replace sel="//properties/rotationacceleration/@max">2.00</replace>
</diff>
No I dont think so. I just tested it with some ship values I changed (I changed units to 999) and the changes were made to the game. The xml generated by the tool was:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff> 
	<replace sel="//macros/macro/properties/storage/@unit">999</replace>
</diff> 
But I found a bug. When you edit an item that the base mod has added to the game and which was not part of vanilla, the tool will not create the "extension/modname/" folder, so the changes made to the new added item wont ba applied into the game. Need to fix that.

Thank you!
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [Tool] X4 Editor

Post by Max Bain » Sat, 4. Jan 20, 14:56

Uploaded a fixed version.
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

djrygar
Posts: 1841
Joined: Mon, 10. Aug 09, 02:09
x3ap

Re: [Tool] X4 Editor

Post by djrygar » Sun, 3. May 20, 14:12

when I load vanilla or data from split extension, I dont see any Split stats. Tool has been released before dlc, is that a reason?

Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [Tool] X4 Editor

Post by Max Bain » Sun, 3. May 20, 14:24

djrygar wrote:
Sun, 3. May 20, 14:12
when I load vanilla or data from split extension, I dont see any Split stats. Tool has been released before dlc, is that a reason?
Split is handled like a normal mod. You need to extract split dlc and set it as base mod in the Editor then it should show up.
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

djrygar
Posts: 1841
Joined: Mon, 10. Aug 09, 02:09
x3ap

Re: [Tool] X4 Editor

Post by djrygar » Sun, 3. May 20, 16:07

it worked, something was wrong with unpacked split extension before, so i was working on bad data

still, Split extension should be treated like part of base game or (equally) there it could be another 'slot' for things (vro, xrshippack etc) beside split (because I'm using 3rd for my mod, so I can tweak what I already did before).

StopBanningMe7_III
Posts: 47
Joined: Wed, 24. Feb 16, 05:23
x4

Re: [Tool] X4 Editor

Post by StopBanningMe7_III » Sun, 12. Jul 20, 20:48

Is the source code available anywhere?

User avatar
alexalsp
Posts: 1820
Joined: Fri, 18. Jul 14, 05:28
x4

Re: [Tool] X4 Editor

Post by alexalsp » Mon, 13. Jul 20, 08:27

Make a language file for the program, if possible. Thank. :roll:

Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [Tool] X4 Editor

Post by Max Bain » Mon, 13. Jul 20, 13:25

StopBanningMe7_III wrote:
Sun, 12. Jul 20, 20:48
Is the source code available anywhere?
I have agit repository online but its not public. Code is written in C# and UI in WPF.
Actually I am not working on the Tool. I can send you a link to the repository if you are really interested in the code and want to improve it.
alexalsp wrote:
Mon, 13. Jul 20, 08:27
Make a language file for the program, if possible. Thank. :roll:
Sorry but I made the tool in english to make it readable by as many people as possible (I am german btw). The columns have nearly the same names as the attributes in the XML files - so you need a little english anyway if you want to make a mod. Just a few texts are not from the XML files but should be very simple english texts.
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

StopBanningMe7_III
Posts: 47
Joined: Wed, 24. Feb 16, 05:23
x4

Re: [Tool] X4 Editor

Post by StopBanningMe7_III » Thu, 13. Aug 20, 10:12

Max Bain wrote:
Mon, 13. Jul 20, 13:25
StopBanningMe7_III wrote:
Sun, 12. Jul 20, 20:48
Is the source code available anywhere?
I have agit repository online but its not public. Code is written in C# and UI in WPF.
Actually I am not working on the Tool. I can send you a link to the repository if you are really interested in the code and want to improve it.
alexalsp wrote:
Mon, 13. Jul 20, 08:27
Make a language file for the program, if possible. Thank. :roll:
Sorry but I made the tool in english to make it readable by as many people as possible (I am german btw). The columns have nearly the same names as the attributes in the XML files - so you need a little english anyway if you want to make a mod. Just a few texts are not from the XML files but should be very simple english texts.
I'd appreciate it if you did send a link, but I probably won't actually work on it directly. I was hoping you had it available under some open source license so I could see how you approached dealing with the XML and maybe ̶s̶t̶e̶a̶l̶ borrow a few things. Up to you I guess.

User avatar
apricotslice
Posts: 14129
Joined: Sun, 16. May 04, 13:01
x4

Re: [Tool] X4 Editor

Post by apricotslice » Fri, 13. Nov 20, 07:04

Thanks for this.

I finally came back to this largely unplayable game (for me) after the last update, and even trying to mod has been driving me crazy.

I'd been about to bin the game forever, when I did one last look through the threads in the modding forum, and realized I hadn't looked for any new tools. And since the last time I looked was back in 2019 sometime, I hadn't even known this tool existed.

Within half an hour, I'd finally achieved what I'd failed to do since the game first came out. My own ship customized to what I had in my X3 mods, albeit with some interesting side effects in certain sectors now. :D

If you ever get the chance, or desire, it would be nice to have a 'copy ship' function, which copies a vanilla ship, or fitting, and creates a new custom one. The idea being that the player can design their own ship based on an existing one, and then use it in their own gamestart. Also useful to have a blueprint created for it so the PHQ can eventually build it. (Which might be more useful to non-modders.)

But for now, I'd post the big clap smilie, but alas, there isn't one here. The best I can do is....

:thumb_up: :thumb_up: :thumb_up: :thumb_up: :thumb_up: :thumb_up:

PetitViet
Posts: 32
Joined: Sat, 4. Jul 20, 00:56
x4

Re: [Tool] X4 Editor

Post by PetitViet » Fri, 13. Nov 20, 09:39

Bonjour l'ami et merci, j'utilise ta version 1.1.1.. mais lorsque j'essaye d'indiquer le répertoire de vanilla (étape 1) et que je clique sur le bouton "Read Vanilla" il me dit "no found " à chaque fois...

j'ai bien le répertoire X4 / common / ... (j'utilise la version jeu X4 Foundation 3.30 hotfit 1)

mais rien ne marche, sais tu quel répertoire je dois indiquer s'il te plait ?

P.S. : je les ai tous essayé (tous les répertoires) et j'ai à chaque fois "not found"

Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [Tool] X4 Editor

Post by Max Bain » Fri, 13. Nov 20, 10:57

If you ever get the chance, or desire, it would be nice to have a 'copy ship' function, which copies a vanilla ship, or fitting, and creates a new custom one. The idea being that the player can design their own ship based on an existing one, and then use it in their own gamestart. Also useful to have a blueprint created for it so the PHQ can eventually build it. (Which might be more useful to non-modders.)
I am sorry, but this is not on my todo list for the near future. Just copying some files wont be enough to make a copy ship work. IDs need to be changed, links adjusted, wares added, macros and components added.
PetitViet wrote:
Fri, 13. Nov 20, 09:39
Bonjour l'ami et merci, j'utilise ta version 1.1.1.. mais lorsque j'essaye d'indiquer le répertoire de vanilla (étape 1) et que je clique sur le bouton "Read Vanilla" il me dit "no found " à chaque fois...

j'ai bien le répertoire X4 / common / ... (j'utilise la version jeu X4 Foundation 3.30 hotfit 1)

mais rien ne marche, sais tu quel répertoire je dois indiquer s'il te plait ?

P.S. : je les ai tous essayé (tous les répertoires) et j'ai à chaque fois "not found"
Have you extracted the game files with the xr extractor from egosoft?
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

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

Re: [Tool] X4 Editor

Post by Realspace » Fri, 15. Jan 21, 22:05

Any chance you add the inertia/strafe values?

I've not looked into the files yet, last time I edited those was in Rebirth.

It was easier since you could add inertia to player's ship only to avoid AI going crazy.

Does it use a direct parameter as strafe (Rebirth) or indirect such as mass (Freelancer)? Thank you! :wink:

Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [Tool] X4 Editor

Post by Max Bain » Fri, 15. Jan 21, 22:10

Realspace wrote:
Fri, 15. Jan 21, 22:05
Any chance you add the inertia/strafe values?

I've not looked into the files yet, last time I edited those was in Rebirth.

It was easier since you could add inertia to player's ship only to avoid AI going crazy.

Does it use a direct parameter as strafe (Rebirth) or indirect such as mass (Freelancer)? Thank you! :wink:
I think X4 uses mass and that is in the X4 Editor as well as strafe values for horizontal/vertical direction. Or what are you missing?
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

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

Re: [Tool] X4 Editor

Post by Realspace » Fri, 15. Jan 21, 22:27

Max Bain wrote:
Fri, 15. Jan 21, 22:10
Realspace wrote:
Fri, 15. Jan 21, 22:05
Any chance you add the inertia/strafe values?

I've not looked into the files yet, last time I edited those was in Rebirth.

It was easier since you could add inertia to player's ship only to avoid AI going crazy.

Does it use a direct parameter as strafe (Rebirth) or indirect such as mass (Freelancer)? Thank you! :wink:
I think X4 uses mass and that is in the X4 Editor as well as strafe values for horizontal/vertical direction. Or what are you missing?
Great, must take a look and try. I don't aim at 100% newtonian but so as are now ships seem to travel inside a glue :D

Osbot
Posts: 108
Joined: Sun, 10. Jan 10, 19:49
x4

Re: [Tool] X4 Editor

Post by Osbot » Tue, 26. Jan 21, 20:50

Max Bain wrote:
Fri, 15. Jan 21, 22:10
Realspace wrote:
Fri, 15. Jan 21, 22:05
Any chance you add the inertia/strafe values?

I've not looked into the files yet, last time I edited those was in Rebirth.

It was easier since you could add inertia to player's ship only to avoid AI going crazy.

Does it use a direct parameter as strafe (Rebirth) or indirect such as mass (Freelancer)? Thank you! :wink:
I think X4 uses mass and that is in the X4 Editor as well as strafe values for horizontal/vertical direction. Or what are you missing?
I believe there are horizontal, vertical, forward and reverse drag values.

Max Bain
Posts: 1458
Joined: Wed, 27. Jun 18, 19:05
x3ap

Re: [Tool] X4 Editor

Post by Max Bain » Tue, 26. Jan 21, 21:14

Osbot wrote:
Tue, 26. Jan 21, 20:50
Max Bain wrote:
Fri, 15. Jan 21, 22:10
Realspace wrote:
Fri, 15. Jan 21, 22:05
Any chance you add the inertia/strafe values?

I've not looked into the files yet, last time I edited those was in Rebirth.

It was easier since you could add inertia to player's ship only to avoid AI going crazy.

Does it use a direct parameter as strafe (Rebirth) or indirect such as mass (Freelancer)? Thank you! :wink:
I think X4 uses mass and that is in the X4 Editor as well as strafe values for horizontal/vertical direction. Or what are you missing?
I believe there are horizontal, vertical, forward and reverse drag values.
I just checked the Editor (havent played with the values you are talking about much yet). You can find some innertia values in the ship files and these are all represented in the Editor.
For example:

Code: Select all

      
      <physics mass="32.5">
        <inertia pitch="12.6" yaw="12.6" roll="12.6" />
        <drag forward="4.9" reverse="21.8" horizontal="18" vertical="18" pitch="14.4" yaw="14.4" roll="14.4" />
      </physics>
These are for each ship InPitch, InYaw, inRoll and Pitch, Yaw, Roll, Forward, Reverse, Horizontal, vertical.
Additionally the engines/thrusters have their forward, reverse, strafe, yaw, pitch and roll values and some more.

But dont ask me in detail what each value is for. I hope that helps.
XR Ship Pack (adds several ships from XR) Link
Weapon Pack (adds several new weapons) Link
Economy Overhaul (expands the X4 economy with many new buildings) Link
X4 Editor (view stats of objects and make your own mod within a few clicks) Link

Post Reply

Return to “X4: Foundations - Scripts and Modding”