[Docn] Start game with Custom PHQ

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

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

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

[Docn] Start game with Custom PHQ

Post by apricotslice » Mon, 10. May 21, 07:05

Believe it or not, you can start the game with a Custom PHQ.

I was on day 2 of building a mega-PHQ in a new game for terraforming purposes, since my old game PHQ was a dog's breakfast not worth salvaging, and I suddenly had one of those thoughts that usually lead to hours of frustration.

What if the game could build your PHQ design at the start?

It did take hours, and a lot of help from Unitrader on the X4 Modding Discord chat server, but the serious OMFG! moment when I started a new game and there it was, was truly worth the experimentation and frustration that went with it.

Now, before anyone says this is a cheat, well of course it is. But I've played the game building my own closed loop shipyard and hull parts and claytronics complex, and I've done all the building and all the gathering, and I'm done with it.

Terraforming is a whole new endgame. And what I had wasn't what was needed. After a week and 2 attempts to build what I needed, and only getting half way on the second attempt, I had this epiphany.

So this is for those like me who have been there, done that, got the t-shirt, and are only now interested in playing the new endgame that came with v4. Or anyone who just wants to start with a functioning PHQ for whatever reason and self-justification you have.

So, how do you do it?

Step 1. Build your dream PHQ inside the game. Save the construction plan. Export the construction plan.

Step 2. In Documents-Egosoft-X4-*Your game number*-constructionplan, you'll find your construction plan. Open it in Notepad++ or some other xml editor.

Step 3. Open a new xml document. Copy the code below to create a diff file, so we can replace the PHQ's plan with another one.

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<diff>
<replace sel="/plans/plan[@id='x4ep1_playerheadquarters']"> 
  <plan id="x4ep1_playerheadquarters" name="{20102,2011}">
####
   </plan>
</replace>
</diff>
Step 4. Where there is ####, replace that with everything from your custom construction plan after the plan id line, and before the /plan line. If that code includes a patch for Cradle set of lines, remove those, or avoid copying them. They won't work.

Step 5. [If you have a mod already, ignore this.] Create a folder in X4 Foundations-extensions called something like Custom PHQ. In there create a folder called libraries. Save constructionplans.xml to this folder.

Step 6. [If you have a mod already, ignore this.] Create a new xml file and put this code in it:

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<content id="CustomPHQ" name="CustomPHQ" description="CustomPHQ"  author="apricotslice" version="001" date="2021-05-10" save="0">
  <text language="7" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="33" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="34" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="39" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="44" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="49" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="86" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="88" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
</content>
Save this to your Custom PHQ folder as content.xml.

Step 6. Start X4, check to see your new mod is listed and ON in the extensions section of settings , and start a new game. When the PHQ is created for the first time, it will use your plan, and contain every module you specified.

If the game start you used gives you the PHQ immediately, you should see it from your ship. Otherwise you need to do the PHQ plot to find out if it works. Once you have it, you need to give it a Manager, and if it contains a shipyard, a Ship Dealer. Then you need to talk to the Boron about research.

If you went like I did for the closed loop Shipyard with an insane amount of firepower protecting it, all you need do now is feed it resources and wait for the production cycles to build enough of everything to finally build a ship. This will still take a while, but at least you didn't have to build the station first.

Warning : This does Mod your game, and removes some of the online options.

Someone tell me if I missed anything.

Go to it, good luck.

ETA: Don't forget when building mega complexes, you can highlight a section of what you've already done, copy it, and place that copy wherever you want. For example, if you build storage all in a single level, you can copy the entire level, and place it on an up post above where the first level is. Or below. The only downside is graphics power once you start moving hundreds of modules at once. But it is worth trying to do.
Last edited by apricotslice on Mon, 10. May 21, 15:21, edited 1 time in total.

User avatar
Baconnaise
Posts: 619
Joined: Sat, 23. Nov 13, 15:50
x4

Re: [Docn] Start game with Custom PHQ

Post by Baconnaise » Mon, 10. May 21, 13:46

Neat! I'm definitely trying this out when I have time today or tomorrow. Thank you.

daBeschi
Posts: 76
Joined: Mon, 28. Jan 19, 14:04
x4

Re: [Docn] Start game with Custom PHQ

Post by daBeschi » Tue, 11. May 21, 10:08

Hello,

I tried it and it works! Great to prove ideas without spending days of waiting for construction completion. I like it! Thank you very much for figuring this out for us all.

Greetings

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

Re: [Docn] Start game with Custom PHQ

Post by apricotslice » Tue, 11. May 21, 11:31

daBeschi wrote:
Tue, 11. May 21, 10:08
Great to prove ideas without spending days of waiting for construction completion.
I found that too.

When I got the first build finally working, I found I'd seriously underestimated how much storage I needed.

I simply copied the whole storage arm, added a support strut, and pasted the entire arm back on, doubling storage in one go. Then cut and paste the new section into the phq definition.

Instant double storage, and then start again. :D

arshiba
Posts: 48
Joined: Thu, 1. Jul 04, 15:30
x4

Re: [Docn] Start game with Custom PHQ

Post by arshiba » Tue, 11. May 21, 19:15

apricotslice wrote:
Mon, 10. May 21, 07:05
Step 4. Where there is ####, replace that with everything from your custom construction plan after the plan id line, and before the /plan line. If that code includes a patch for Cradle set of lines, remove those, or avoid copying them. They won't work.

Code: Select all

<?xml version="1.0" encoding="iso-8859-1"?>
<content id="CustomPHQ" name="CustomPHQ" description="CustomPHQ"  author="apricotslice" version="001" date="2021-05-10" save="0">
  <text language="7" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="33" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="34" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="39" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="44" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="49" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="86" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
  <text language="88" name="CustomPHQ" description="CustomPHQ" author="apricotslice" />
</content>
There is no need to provide translation tags without actually translating the name and description.
It is better to add a dependency tag instead of the removed patch tag.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<content id="CustomPHQ" name="CustomPHQ" description="CustomPHQ" author="apricotslice" version="001" date="2021-05-10" save="0">
  <dependency version="400" />
  <dependency id="ego_dlc_split" version="100" />
  <dependency id="ego_dlc_terran" version="100" />
</content>
apricotslice wrote:
Mon, 10. May 21, 07:05
If the game start you used gives you the PHQ immediately, you should see it from your ship.
There is another plan for a scientist start: "x4ep1_playerheadquarters_with_dock".

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

Re: [Docn] Start game with Custom PHQ

Post by apricotslice » Wed, 12. May 21, 03:56

arshiba wrote:
Tue, 11. May 21, 19:15
There is another plan for a scientist start: "x4ep1_playerheadquarters_with_dock".
Someone mentioned that on discord, but there is no mention of this in the construction file.

If you use it, you get nothing but the bog standard PHQ.

That was part of the frustration time getting this to work, until we went back to the original we could actually find in the file itself.

Personally, I use a custom start, so what other starts do was never important in doing this.

Post Reply

Return to “X4: Foundations - Scripts and Modding”