[TEST] War experiment galaxy

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

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

celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

[TEST] War experiment galaxy

Post by celludriel »

I made this galaxy to test how the AI actually plays out when we just let it run. It's not really meant to be played but if anyone else likes to write his own War logic mod or create some kind of 4X game out of X4. Maybe you can use this galaxy as a test ground.

GitHub

War Test Galaxy

I tried to make it as balanced as possible, for the four major factions and the xenon. I stuck with the vanilla game jobs.xml and god.xml where possible so it's as if the original game was playing out in another galaxy. This time however a symmetrical one.

https://steamuserimages-a.akamaihd.net/ ... C4D3B7C70/

Hope it has a use for some people
Last edited by celludriel on Sat, 29. Dec 18, 12:51, edited 1 time in total.
Tyrant597
Posts: 299
Joined: Wed, 9. Apr 08, 05:52
x4

Re: [TEST] War experiment galaxy

Post by Tyrant597 »

celludriel wrote: Wed, 26. Dec 18, 23:53 or create some kind of 4X game out of X4.
omg... yes
You don't talks about X:Rebirth...
X4 Mods: Collect Inventory Wares Stations Supply Build Storage Mass Move Marines
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [TEST] War experiment galaxy

Post by celludriel »

Tyrant597 wrote: Thu, 27. Dec 18, 00:34
celludriel wrote: Wed, 26. Dec 18, 23:53 or create some kind of 4X game out of X4.
omg... yes
... remember I did not say this IS a 4X mod ... but could be turned into a 4X mod ... if someone feels the itch to do so ...
Tyrant597
Posts: 299
Joined: Wed, 9. Apr 08, 05:52
x4

Re: [TEST] War experiment galaxy

Post by Tyrant597 »

I know, I just got a semi at the thought..
You don't talks about X:Rebirth...
X4 Mods: Collect Inventory Wares Stations Supply Build Storage Mass Move Marines
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [TEST] War experiment galaxy

Post by celludriel »

Well after over 7 hours of full SETA run, the AI did not expand into any sector. Whats even worse was when I woke up and checked what was happening , argon was fighting amongst themself. A swarm of small ships where shooting eachother and the argon wharf.

So conclusion, if we make custom galaxies chances are nothing of the war logic is working and we have to write it ourselves. Another conclusion could be that the war logic doesn't even work in vanilla or only works if there is a bordering faction and empty sectors won't be taken.

Anyone willing on figuring out with me why this isn't working. What we need to let the AI expand into new territory
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [TEST] War experiment galaxy

Post by celludriel »

- I had to add the minor factions and give them factionHQ's otherwise the FactionLogic.xml kept putting out errors on startup.
- Fixed some miner jobs that had wrong values
- Fixed some misc stuff , minor but at least it's clean now

I've uploaded this new version to the drive v4 atm. I'll start a test with this new version let seta run for a few hours
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [TEST] War experiment galaxy

Post by celludriel »

So guys we have a problem and it's rather a big one when it concerns any custom galaxy.

So the current FactionLogic is very tied into the original galaxy and mission system. The wars are hardcoded, the behavior is hardcoded, a faction will not take over an empty sector for example, it will only "invade" as far as you can call it bordering sectors of a factor there is a "war" with. I could go on with the gaps there are.

So the only way we will ever get custom galaxies to work is if we create our own logic to handle wars. This is of course not that easy. I'm trying to get feet wet with md script but it will take several weeks for me to get proficient since it took me yesterday three hours to figure out how I could compose a cue name out of loose variables ... and I'm a dev btw ... so it's a matter of syntax not skill. Whatever we come up with needs to work for any galaxy. Now the good part is , that we don't have to rewrite everything. The economy part of egosoft is fine and doesn't have to be touched, as well as the part where they build lasertowers, minefields and sattelites around the galaxy. Only any and everything that has to do with invasion, sector takeover and sector defense.

For now I'll try and start out with something simple ... I'm gonna try to let the ai go out and build a defense station on a neighboring sector (one defense station in an empty system will transfer ownership of that sector). After that maybe with some community effort we can build further ?
Leeroy223
Posts: 5
Joined: Thu, 13. Dec 18, 16:55
x4

Re: [TEST] War experiment galaxy

Post by Leeroy223 »

Would it be possible to create an "Empty" neutral faction? Since then it would trick the major factions to invade the sectors and take them over. Each neutral system controlled by this Empty faction would have at least 1 station within the system. I might experiment with this by using one of the major factions and just spread them out across the map. And just set their job values to almost zero.

Also i created a modified version of the god.xml file. It gets rid of the Teladi, Paranid, and Holy Order factions. Leaving only the Argon. But now they border Xenon-controlled space. I thought this would help people who are developing Xenon-based mods or are experimenting with War/Conflict mechanics and faction mechanics when it comes to warfare. Currently, it's helping a bunch with developing my Technocide mod.

https://drive.google.com/open?id=1yK1vD ... tJO_bYqJsx
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [TEST] War experiment galaxy

Post by celludriel »

Leeroy223 wrote: Sat, 29. Dec 18, 12:30 Would it be possible to create an "Empty" neutral faction? Since then it would trick the major factions to invade the sectors and take them over. Each neutral system controlled by this Empty faction would have at least 1 station within the system. I might experiment with this by using one of the major factions and just spread them out across the map. And just set their job values to almost zero.

Also i created a modified version of the god.xml file. It gets rid of the Teladi, Paranid, and Holy Order factions. Leaving only the Argon. But now they border Xenon-controlled space. I thought this would help people who are developing Xenon-based mods or are experimenting with War/Conflict mechanics and faction mechanics when it comes to warfare. Currently, it's helping a bunch with developing my Technocide mod.

https://drive.google.com/open?id=1yK1vD ... tJO_bYqJsx
Creating a neutral faction would take a bit of work but is certainly possible. I'm currently experimenting with my own custom expansion logic. So in order to not loose any work and make things more comfortable I moved this project to github. The OP has been changed to reflect that. I suggest people that want to experiment, to just take a fork of the github and have fun with it.
Leeroy223
Posts: 5
Joined: Thu, 13. Dec 18, 16:55
x4

Re: [TEST] War experiment galaxy

Post by Leeroy223 »

Oh and also getting rid of the other major factions gave the game a huge performance boost. So if you want crazy battles without the game lagging crazy, there ya go.
leecarter
Posts: 379
Joined: Sat, 9. Sep 06, 22:35
x3tc

Re: [TEST] War experiment galaxy

Post by leecarter »

Wow this looks amazing. Great idea!
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [TEST] War experiment galaxy

Post by celludriel »

I wrote a simple basic script to let factions expand it's nothing special

Look at neighbouring clusters if it's not owned and no defense station is there or one is building then build a defense station

This is the result from about an hour of full SETA

https://steamuserimages-a.akamaihd.net/ ... 5459FAAE2/

Sometimes the build of the defense station stalls, either the traders get better offers elsewere or something. I tried to increase the buy offer prices on the defense station but Egosoft must have protected them cause I can't change them and if I add a new order with higher prices, the order gets filled but the buildstorage doesn't increase so nothing gets build. I'll keep on it but it's annoying.

This is all just exploratory work and nothing final. Deciding where to expand will need to be a lot smarter for a good implementation :)
vulgari
Posts: 1
Joined: Mon, 31. Dec 18, 01:18

Re: [TEST] War experiment galaxy

Post by vulgari »

celludriel wrote: Sun, 30. Dec 18, 20:04 I wrote a simple basic script to let factions expand it's nothing special
Possible to get a look at it?
I haven't looked into modding X but your thread has piqued my interest, I assume if the behaviour you describe is possible to mod in then it is also possible to mod the AI to check if a surrounding sector is owned by an enemy and trigger some form of fleet preparation to x number of ships or strength and then -> invade -> attack enemy defence station -> build own defence station?
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [TEST] War experiment galaxy

Post by celludriel »

vulgari wrote: Mon, 31. Dec 18, 01:28
celludriel wrote: Sun, 30. Dec 18, 20:04 I wrote a simple basic script to let factions expand it's nothing special
Possible to get a look at it?
I haven't looked into modding X but your thread has piqued my interest, I assume if the behaviour you describe is possible to mod in then it is also possible to mod the AI to check if a surrounding sector is owned by an enemy and trigger some form of fleet preparation to x number of ships or strength and then -> invade -> attack enemy defence station -> build own defence station?
That is entirely possible, just download the zip and have a look at FactionWarManager.xml , it receives the neighbouring sectors and the currently claimed sectors. What you are proposing is on my todo list as well
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [TEST] War experiment galaxy

Post by celludriel »

I believe the code is now stable and clean enough to start building for real. The expansion stuff although basic logic is working nicely. I pushed the changes to the develop branch. Logging is still enabled though and I log a shitton. So if you want to try it out expect log files in the 300mb after all the clusters have been taken by the factions. Takes about 1 to 2 hours full seta running. Xenon is currently disabled for testing cause they kill everything otherwise !
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [TEST] War experiment galaxy

Post by celludriel »

So I started on the next step. Once a cluster is taken it needs a defence force. So I started working on something to spawn defense jobs. It works ... in a way. I started with a single ship, so if a cluster is owned build one ship at a wharf and send it over.

This part works , ships get build and send over. However if I then seta for a while. Sometimes ... at random ... one or two of those five ships just ... dissapear ... gone without a trace, no reason, no destroyed message they just vanish. There is no indication why or how.

Code: Select all

<cue name="FMW_Evaluate_Cluster_Defence">
	<actions>
		<!-- find a way to count ships and establish a strength for each $ClaimedSectors -->
		<do_all exact="$ClaimedSectors.count" counter="$i">
			<find_requested_job_ship name="$PreviousRequested" requester="$ClaimedSectors.{$i}" multiple="true"/>
			<do_all exact="$PreviousRequested.count" counter="$j">
				<debug_text text="'Previous Request %1'.[$PreviousRequested.{$j}.idcode]" chance="$DebugChance"/>
			</do_all>
			<!-- do strength calculation here -->
			<do_if value="$PreviousRequested.count == 0 and not $ReinforcedClusters.indexof.{$ClaimedSectors.{$i}}">
				<!-- if strength < "a value to be determined" put cluster request a single reinforcement group for cluster -->
				<debug_text text="'Find Suitable jobs for cluster defence for %1'.[$Faction.id]" chance="$DebugChance"/>
				<get_suitable_job result="$ReinforcementList" multiple="true" faction="$Faction" tags="[tag.military]"/>
				<do_all exact="$ReinforcementList.count" counter="$k">
					<debug_text text="'Job found %1'.[$ReinforcementList.{$k}]" chance="$DebugChance"/>
				</do_all>
				<do_if value="$ReinforcementList.count gt 0">
					<signal_cue_instantly cue="Request_Job_Ship" param="[$ClaimedSectors.{$i},$ReinforcementList.{1}]"/>							
				</do_if>
			</do_if>
		</do_all>
		<!-- if strength >= "a value to be determined" and cluster in reinforcment mode remove it from that mode -->
	</actions>				
</cue>
<cue name="Request_Job_Ship" instantiate="true">
	<conditions>
		<event_cue_signalled/>
	</conditions>
	<actions>
		<find_zone name="$Startzone" space="event.param.{1}" normalzone="true"/>
		<request_job_ship name="$Requested_Job_Ship" job="event.param.{2}" requester="event.param.{1}" zone="$Startzone" />
		<debug_text text="'Requested_Job_Ship: %1'.[$Requested_Job_Ship.idcode]" chance="$DebugChance"/>
		<append_to_list name="$ReinforcedClusters" exact="event.param.{1}" />
	</actions>
	<cues>
		<cue name="Requested_Job_Ship_Destroyed">
			<conditions>
				<event_object_destroyed object="$Requested_Job_Ship" />
			</conditions>
			<actions>
				<set_value name="$DestroyedObject" exact="event.object"/>
				<set_value name="$Killer" exact="event.param"/>
				<set_value name="$Method" exact="event.param2"/>
				<debug_text text="'%1 has been destroyed by %2 due to %3'.[$DestroyedObject.idcode,$Killer.idcode,$Method]" chance="$DebugChance"/>
				<cancel_cue cue="Request_Job_Ship"/>
			</actions>
		</cue>
		<cue name="Requested_Job_Ship_Built">
		  <conditions>
			<event_build_finished object="$Requested_Job_Ship"/>
		  </conditions>
		  <actions>
			<set_requested_job_ship_timeout ship="$Requested_Job_Ship" timeout="player.age + 1h"/>
		  </actions>
		</cue>	
	</cues>
</cue>
Fixing this will take time and some kind of miracle ...
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [TEST] War experiment galaxy

Post by celludriel »

Well here is a status update

Scenario

I eventually want to spawn defense fleets in each claimed sector of a faction. So I began working on some code to get this done and I banged on hundereds of roadblocks of sucky md script not working or other scripts interfering with stuff they shouldn't. So I have following experiment in the current build on develop

- Argon has no more military fleets at start of the map
- Each Argon claimed sector will get a Argon Fighter Leader build at the Wharf
- That leader will fly to his respective sector
- He will then realise he is all alone and doesn't want to be, he will fly back to the Wharf and build 4 wingman Argon Fighter Wingman
- Then he will fly back to his sector and patrol

Now all of this takes a lot of time, by the time every wingman is build and they are back in their patrol zones, several sectors will have been captured by all factions. I'm only talking here about 5 wings of 5 ships at the start of the game.

Also I noticed sometimes the wings just dissapear from the map if you cheat with a 400 km radar range in each cluster. If you look at the log, the ships are still there they aren't gone , but on the map and in the sector viewrange ... no more wing ...

There is a lot about this game that does not make sense at all and it's anyones guess what is going on

I'll try and work this scenario out now for each major faction and try to setup a decent defense fleet.

Todo:

- Set up decent defense fleets for each major faction
- Work on exploitation of a sector build economic stations
- Work on invasions, gather an invasion fleet and set them to target the defense station for invasion, if they destroy it build a station of their own.
celludriel
Posts: 163
Joined: Thu, 12. Sep 13, 11:29
x4

Re: [TEST] War experiment galaxy

Post by celludriel »

new update

I managed to write a new system that would decide a sector defensive strength based on it's location to an empty/neutral/enemy sector or it's security rating. However because you can't trust the game AT all for ships following orders it barely works. It boils down to the following


- Every x timeframe a sector checks if it needs defensive ships these would be jobs defined in job.xml with tags like tag.cruiser or tag.fighterwing
- If there is no job of the desired jobs currently present in the sector order a new ship of that tag and make it patrol the sector
- Ship gets ordered and flies to the sector, subordinates (wingmen) start building and fly over as well
- The ship should keep patrolling the sector until it gets killed by something

what happens is ... it decides on it's own to leave the sector with his subordinates emptying the sector and ... my order system kicks in ordering new ships ... I've been at this for three weeks now and I'm ready to throw in the towel. I can't rely on anything this game does. How can I as a programmer write code if nearly everything keeps interfering and doing it's own thing !!!!!

Keep in mind if I stop with this, new galaxies will be death or anyone making a new galaxy

- empty sectors will not be invaded
- no dynamic wars , only the hardcoded once for as far as they work

The one thing that does work in a new galaxy

- ai trade ships are flying from station to station trading
tomchk
Posts: 1294
Joined: Mon, 26. Jan 15, 19:55
x4

Re: [TEST] War experiment galaxy

Post by tomchk »

celludriel wrote: Sun, 13. Jan 19, 18:11 new update

I managed to write a new system that would decide a sector defensive strength based on it's location to an empty/neutral/enemy sector or it's security rating. However because you can't trust the game AT all for ships following orders it barely works. It boils down to the following
We all appreciate the work you are putting in with this frustrating code! The results sound amazing.
Care to see what I've been creating? https://www.youtube.com/user/ytubrute
Nerophos
Posts: 22
Joined: Fri, 4. Nov 11, 11:40
x3tc

Re: [TEST] War experiment galaxy

Post by Nerophos »

I am not a modder so this comes all from reading others posts.
First thx for the work.
Faction wars has missing scripts in vanilla and other modder tryed to fix them but still not fully working.
Same with Faction ships on patrol wandering to other sectors , vanilla bug.
I would wait until patch 2.0 and hopefully ego has fixed Faction Wars, patrolling and broken escorts.

Sry for my bad English

PS Missing scripts from Faction war have been reported but if I understood it correctly then the will NOT fix it with patch 1.51 but maybe before patch 2.0

Return to “X4: Foundations - Scripts and Modding”