[WIP] [TC] X3 Galaxy

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

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

respaekt
Posts: 35
Joined: Wed, 10. Jun 09, 09:55

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by respaekt »

Great progress, watching this with great anticipation.
I am interested to see how this works performance wise, with 200 player ships or more, the map view is already getting laggy.
Lc4Hunter
XWiki Moderator
XWiki Moderator
Posts: 2188
Joined: Sun, 2. Apr 06, 16:15
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by Lc4Hunter »

Looks good so far.
But, and i hope you agree, the overwiew ist not very good with all these hexagons directly next to each other.

I would like to know if this grid is somekind of hardcoded or if it´s defined in a file we can change somehow.
It would be great to change the layout to something with a bit more overview :D

But for the first steps your progress is really great! :thumb_up:
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by celludriel »

Lc4Hunter wrote: Fri, 14. Dec 18, 10:17 Looks good so far.
But, and i hope you agree, the overwiew ist not very good with all these hexagons directly next to each other.

I would like to know if this grid is somekind of hardcoded or if it´s defined in a file we can change somehow.
It would be great to change the layout to something with a bit more overview :D

But for the first steps your progress is really great! :thumb_up:
I calculate the hex grid from a cartasian grid. The output is a galaxy.xml files with the center of the cluster coordinates in

Code: Select all

    
    public static final int SEMI_X_MOVEMENT = 15000000;
    public static final int FULL_X_MOVEMENT = 30000000;
    public static final int SEMI_Y_MOVEMENT = 8660000;
    public static final int FULL_Y_MOVEMENT = 17320000;
    
    @JsonIgnore
    public String getClusterX(){
        return Long.toString(x * SEMI_X_MOVEMENT);
    }

    @JsonIgnore
    public String getClusterZ() {
        if(x % 2 < 0 && y == 0){
            return Long.toString(y - SEMI_Y_MOVEMENT);
        } else if(x % 2 > 0 && y == 0){
            return Long.toString(y + SEMI_Y_MOVEMENT);
        } else if (x % 2 == 0 && y > 0){
            return Long.toString(y * FULL_Y_MOVEMENT);
        } else if (x % 2 == 0 && y < 0){
            return Long.toString(y * FULL_Y_MOVEMENT);
        } else if(y < 0) {
            int offset = x > 0 ? SEMI_Y_MOVEMENT : -SEMI_Y_MOVEMENT;
            return Long.toString(offset - (Math.abs(y) * FULL_Y_MOVEMENT));
        } else if(y > 0) {
            int offset = x > 0 ? SEMI_Y_MOVEMENT : -SEMI_Y_MOVEMENT;
            return Long.toString(offset + (Math.abs(y) * FULL_Y_MOVEMENT));
        }
        return "0";
    }
example output cluster30 for input json

Code: Select all

    {
      "id": "30",
      "name": "Duke's Domain",
      "description": "Duke's Domain",
      "music": "music_cluster_02",
      "sunlight": "1",
      "economy": "0.5",
      "security": "0.25",
      "x": 1,
      "y": -5,
      "backdrop": "empty_space",
      "connections": [
        {
          "targetClusterId": "26",
          "connectionType": "NE"
        }
      ]
    },

Code: Select all

      <!-- cluster setup 30 -->
      <connection name="x3g_cluster30_connection" ref="clusters">
        <offset>
          <position x="15000000" y="0" z="-77940000" />
        </offset>
        <macro ref="x3g_cluster30_macro" connection="galaxy" />
      </connection>
          <!-- gate connection setup 30 -->
          <connection name="x3g_gate_c30s001z003_c26s001z004" ref="destination" path="../x3g_cluster30_connection/x3g_cluster30_sector001_connection/x3g_zone003_cluster30_sector001_connection/x3g_gate_c30s001z003_c26s001z004_connection">
            <macro connection="destination" path="../../../../../x3g_cluster26_connection/x3g_cluster26_sector001_connection/x3g_zone004_cluster26_sector001_connection/x3g_gate_c26s001z004_c30s001z003_connection" />
          </connection>
Remember I feed an input json to my generator and get output I don't manually sculpt anything. If you can devise an algorithm that makes a nice clean layout I'm all ears :)
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by celludriel »

Small update

INPUT: https://github.com/Celludriel/X4_Univer ... alaxy.json

OUTPUT: https://steamuserimages-a.akamaihd.net/ ... 01F0CA46D/

there are still a few things that need to be done

- place shipyards and wharfs balanced and well for each race
- Ministry has to become part of the teladi empire since they can't own space
- ScalePlate needs to be defended by HatkiVah since they ALSO can't own space ... I won't understand why not but they can't
- Add all the jobs for all the races ... can't someone else do this for me ... pretty please ???????
TR0LL
Posts: 45
Joined: Tue, 6. Jan 04, 04:12
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by TR0LL »

I like that its a hex grid, the X4 map not adhering to a grid really annoyed me. If you wanted to add space between sectors, could you not just use more empty hexes?

Also for those that are worried about performance, this may not be a good mod for you, there is however a Trade Satellite mod that only gives you trade updates but doesn't display ships / view, that would make the performance not awful for you.
ApoxNM
Posts: 783
Joined: Wed, 5. Dec 18, 06:17
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by ApoxNM »

Looks damn great! With a working economy and wars and the ability to completely destroy stations, that would be a great playground!
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by celludriel »

Sooo another update

INPUT: https://github.com/Celludriel/X4_Univer ... alaxy.json

OUTPUT: https://steamuserimages-a.akamaihd.net/ ... 9D31A3D38/

the xenon have invaded, the xenon are here.

So I finished all the jobs, but left out the khaak, they had no place in the current setup and believe me look at the amount of lines in that json. You'll have plenty of stuff to shoot !
SpaceCadet11864
Posts: 476
Joined: Tue, 4. Dec 18, 02:14
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by SpaceCadet11864 »

Very cool.

I just might make an electron app that reads/writes this json format, once you get it all sorted out :D
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by celludriel »

SpaceCadet11864 wrote: Fri, 14. Dec 18, 23:50 Very cool.

I just might make an electron app that reads/writes this json format, once you get it all sorted out :D
try electron + react and rxdb ... very fun combination to get right ... webpack HELL !
User avatar
OneOfMany
Posts: 448
Joined: Thu, 15. May 14, 14:25
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by OneOfMany »

Will you be adding any highways or acelerators?
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by celludriel »

OneOfMany wrote: Sat, 15. Dec 18, 00:29 Will you be adding any highways or acelerators?
all gates are accelerators, highways will not be in, to frigging complicated with splices and splines and stuff .... So just gate travel (accelerator travel)
Tattoonation
Posts: 106
Joined: Sat, 11. Aug 07, 01:00
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by Tattoonation »

celludriel wrote: Sat, 15. Dec 18, 00:38
OneOfMany wrote: Sat, 15. Dec 18, 00:29 Will you be adding any highways or acelerators?
all gates are accelerators, highways will not be in, to frigging complicated with splices and splines and stuff .... So just gate travel (accelerator travel)
Perfect!!!!
X2-Illuminatus wrote: Fri, 14. Dec 18, 23:34 Wer enttäuscht vom Spiel ist, darf das hier äußern und muss sich nicht anhören (respektive lesen), welche Fehler oder Unzulänglichkeiten man aushalten soll. Solche Kommentare also bitte hier sein lassen.
SpaceCadet11864
Posts: 476
Joined: Tue, 4. Dec 18, 02:14
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by SpaceCadet11864 »

celludriel wrote: Fri, 14. Dec 18, 23:53
SpaceCadet11864 wrote: Fri, 14. Dec 18, 23:50 Very cool.

I just might make an electron app that reads/writes this json format, once you get it all sorted out :D
try electron + react and rxdb ... very fun combination to get right ... webpack HELL !

LOL I was just going to use typescript and stenciljs, no need to use webpack there XD
TR0LL
Posts: 45
Joined: Tue, 6. Jan 04, 04:12
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by TR0LL »

To further chime in on the topic of the map being in a grid, apparently each hex is not a defined location, and it expands as you explore, the space between the grid borders is not a defined distance, it represents light years.

Image
Lc4Hunter
XWiki Moderator
XWiki Moderator
Posts: 2188
Joined: Sun, 2. Apr 06, 16:15
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by Lc4Hunter »

celludriel wrote: Fri, 14. Dec 18, 11:26 ...
Remember I feed an input json to my generator and get output I don't manually sculpt anything. If you can devise an algorithm that makes a nice clean layout I'm all ears :)
Sorry, this is not my topic... i can basicaly understand what you´re doing but thats all :|
And it´s not "easy" possible to add a little bit more space between the hexes during the calculation or something like that?
Requiemfang
Posts: 3206
Joined: Thu, 16. Jul 09, 12:24
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by Requiemfang »

Yup, a lot of people were decrying that this game's sectors are small. They are absoultely not, though it does beg the question is there a sector size limit? I mean at some point sectors have to have a max size right? wouldn't that just cause save size bloat? we all know that save file size already causes a longer time when saving the game.
TR0LL
Posts: 45
Joined: Tue, 6. Jan 04, 04:12
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by TR0LL »

Requiemfang wrote: Sat, 15. Dec 18, 06:50 Yup, a lot of people were decrying that this game's sectors are small. They are absoultely not, though it does beg the question is there a sector size limit? I mean at some point sectors have to have a max size right? wouldn't that just cause save size bloat? we all know that save file size already causes a longer time when saving the game.
Not at all, the physical size of a sector means nothing, each object has an X,Y,Z coordinate and that's all that matters, if each of those numbers its a double, it means that every object in space has 24 bytes assigned to it to track its location. however I would also be willing to bet that they are only using a float, and have a moving 0,0,0 origin, in this case each object only takes 12 bytes to track its location. and, this is runtime allocation in memory, in a save file its just 3 strings of coordinates that are at most 17 characters long.
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by celludriel »

Lc4Hunter wrote: Sat, 15. Dec 18, 06:46
celludriel wrote: Fri, 14. Dec 18, 11:26 ...
Remember I feed an input json to my generator and get output I don't manually sculpt anything. If you can devise an algorithm that makes a nice clean layout I'm all ears :)
Sorry, this is not my topic... i can basicaly understand what you´re doing but thats all :|
And it´s not "easy" possible to add a little bit more space between the hexes during the calculation or something like that?
Actually adding some space won't be that hard, but it looks really annoying then, I'll post a screenshot with it later one

We are hitting a rather big snag in the experiment though. We got none to blame then egosoft though. They hardcoded sectors in one of the most important files !!!!!
There is this file FactionLogic.xml, basically this runs the entire war control. Deciding if a faction wants to expand, go to war etc... However to decide the HQ of the factions, they deemed it neccesairy to hardcode it into the file

Code: Select all

        <!-- Find preferred Faction HQ at gamestart -->
        <cue name="FindFactionHeadquarters">
          <actions>
            <!-- Preferred Faction HQ depends on the faction -->
            <!-- Argon Federation -->
            <do_if value="$Faction" exact="faction.argon">
              <debug_text text="'Finding Faction HQ for Argon Federation'" chance="$DebugChance" />

              <find_cluster name="$ArgonPrime" macro="macro.cluster_14_macro" />
              <find_station name="$Shipyard" space="$ArgonPrime" owner="faction.argon" shipyard="true" />
              <do_if value="not $Shipyard">
                <debug_text text="'No shipyard owned by Argon Federation found in Argon Prime'" chance="$DebugChance" />
              </do_if>
              <do_else>
                <debug_text text="'$Shipyard set to ' + $Shipyard.knownname + ' ({' + $Shipyard + '}) in ' + $Shipyard.sector.knownname + ', ' + $Shipyard.cluster.knownname" chance="$DebugChance" />
                <set_value name="md.$FactionData.{$Faction}.$Headquarters" exact="$Shipyard" />
                <set_faction_headquarters faction="$Faction" station="md.$FactionData.{$Faction}.$Headquarters"/>
              </do_else>
            </do_if>
notice macro="macro.cluster_14_macro"
This is just a little extract, it goes on, there are 19 locations where they hardcoded a cluster name. If we want a living galaxy, we need to find a way to patch those out or we will have ships flying around trading and stuff but not going to war.
SpaceCadet11864
Posts: 476
Joined: Tue, 4. Dec 18, 02:14
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by SpaceCadet11864 »

Can you use xmlpatch remove?
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [WIP] [EXPERIMENT] X3 Galaxy

Post by celludriel »

SpaceCadet11864 wrote: Sat, 15. Dec 18, 09:58 Can you use xmlpatch remove?
thats what I'm planning on @UniTrader on discord is helping me a bit with the xpath stuff , mine is really rusty. This should do the trick

Code: Select all

<replace sel="//cue[@name='FindFactionHeadquarters']/actions/do_if[@exact='faction.argon']/find_cluster/@macro">macro.x3g_cluster01_macro</replace>
I just need to write it in freemarker to generate this diff file. Then find the egosoft dev that hardcoded this into the file and have a "chat"

Return to “X4: Foundations - Scripts and Modding”