Vectorial1024 / v1024_civilian_fleets

Create civilian fleets to help manage your traders and miners.
https://www.nexusmods.com/x4foundations/mods/335
MIT License
18 stars 10 forks source link

Legacy mode accidentally blocks Random* mods #62

Closed frank-leitner closed 2 years ago

frank-leitner commented 2 years ago

I'm using the Random* family of mods in my game, which provide their own mass assignment feature. On the nexus page of civilian fleets it is mentioned that for this reason this mod will never support these mods.

I tried to use both random* mods for mining/supplying fleets are well as this mod for my salvagers (traders I rarely use nowadays, so both worlds would be fine)

What I encountered is that use of civilian fleets and the random family of mods are mutually exclusive. When civilian fleets is installed, mass assignment via the random*-method (defend) is broken (after one action all subordinates switch to mimic and stop working).

In civilianfleets_signals.xml I saw that there are special cases for random* orders.

Now I wonder whether

Vectorial1024 commented 2 years ago

Hi there! Gonna answer the first round of questions first, and then answer more later.

In civilianfleets_signals.xml I saw that there are special cases for random* orders.

Indeed. However at the same time, they are annotated with a chance="0" tag. This means that they will never be executed. I was simply being lazy and decided to keep those code segments for decoration purposes.


Anyway, before there was Mimic, I noticed that the Random family had their own order syncing mechanism (as I have written, and as you have read), so the intention was this: no interference. Whatever stuff the Random family wants to do, I will not block them, and I try not to accidentally block them.

This is supposed to extend to the Mimicry Extension part since X4 4.0. Default behaviors unrelated to this mod will not be touched by the Mimic modification logic of this mod.


I checked again that Cradle of Humality was released on Mar 2021 (ie X4 v4.0 + Mimic was out at the same time), however it seems that the Random* family's last update date was 2020. This meant that they likely did not make use of the Mimic command introduced in X4 4.0. Update: it seems they updated the Steam version in Mar 2021 but did not update the Nexus version; the Nexus version stayed at "last update 2020". This adds to the confusion, will need to be investigated later.

The way vanilla Mimic works behind the scenes is that external scripts must add themselves to the Mimic logic chain, which looks very similar to the logic chain of this mod that you have found. If scripts did not add themselves to the Mimic logic chain, the default behavior (I think) is to follow the commander, which can break things.


And then I will have to investigate deeper to answer the remaining questions.

Hope that so far it helps clear things a bit!

frank-leitner commented 2 years ago

Anyway, before there was Mimic, I noticed that the Random family had their own order syncing mechanism (as I have written, and as you have read), so the intention was this: no interference. Whatever stuff the Random family wants to do, I will not block them, and I try not to accidentally block them.

This is supposed to extend to the Mimicry Extension part since X4 4.0. Default behaviors unrelated to this mod will not be touched by the Mimic modification logic of this mod.

The sync mechanism of the Random* mods is as follows:

  1. Assign the commands to the fleet commander as usual.
  2. Assign the subordinates as "Defend commander" image
  3. The fleet commander then updates the subordinates accordingly. While this is done, the subordinate role in the fleet overview changes to "Trader". In the ship information screen, the role changes to --- and the default behaviour to "Random*". image image
  4. Changes to the fleet commander propagate at some intervals to the subordinates, or can be force-propagated.

The "Mimic" command was never supported by random mods (as it did not exist back then), so using it for subordinates breaks random commands completely. You wrote that follow is the default behaviour if Mimic is not supported, that is consistent with what I'm seeing.

The issue come from 'something' causing the subordinates to use mimic after the first action. The behaviour listed above changes as soon as the civilian fleets mod is installed:

  1. OK: Assigning fleet commander
  2. OK: Assigning subordinates as "Defend"
  3. OK: Subordinates get their commands and start working
  4. NOK: As soon as the first action is completed (trade or mining), the subordinates switch to (the unsupported) Mimic and just follow the commander. So basically the full subordinate group goes from "Trader" to "Mimic" and defaulting to "follow"

If I reapply the "Defend", it works again for a single action. As soon as I uninstall civilian fleets and reassign the subordinates as "Defend", they work properly again

So the not to accidentally block them part appears to not work currently. I noticed a comment on the RandomSupply modpage on Steam from summer 2021 that describes this behaviour, so it is nothing new in any recent update of civilian fleets.

My gut feeling is that is might be something with the switch to "Trade" during the mass assignment of Random mods, perhaps in conjunction with some changed default in v4.0 that is just never used in the random mods.

I checked again that Cradle of Humality was released on Mar 2021 (ie X4 v4.0 + Mimic was out at the same time), ~however it seems that the Random* family's last update date was 2020. This meant that they likely did not make use of the Mimic command introduced in X4 4.0.~ Update: it seems they updated the Steam version in Mar 2021 but did not update the Nexus version; the Nexus version stayed at "last update 2020". This adds to the confusion, will need to be investigated later.

Indeed, I use the Steam version of the Random* family of mods. I did not (yet) test whether the nexus version behaves differently.

Vectorial1024 commented 2 years ago

Haven't yet started any investigation (busy/lazy), but after reading your description of how the order sync of Random* works, I know why it happened.

So the not to accidentally block them part appears to not work currently

And you got it!

It is exactly as you have extensively documented. The missing link at "Step 4 NOK" is that the Legacy Mode of this mod got triggered.

Legacy Mode was supposed to provide a smooth transition from the pre-Mimic style to the post-Mimic style. I omit some irrelevant details, but it is triggered on ships that:

Those ships will then be order-synced with the new Mimic order-sync script. And the rest is history.


It's just... idk, but a long time ago this mod supported/was planning to support Random, but right at the time of release I read about Random implementing their own version of order sync, so I kept my distance and cancelled my side; and it turned out that the Random* family were/are using basically-the-same logic as on this side... And then they updated their mod after 4.0+COH came out just to add the Terran/Segaris to the list... no update on order sync... ok...


Anyways, thanks for the report! The fix is easy.

Vectorial1024 commented 2 years ago

Provides a fix at 351c00ca62aaaf8cb77d406a2cb62f427de55d1e

If you wish, you may download a copy of this mod from GitHub to test whether the above fix works

frank-leitner commented 2 years ago

For a longish test I need to wait for the weekend. In a quick test now I saw multiple times ships performing their cycles without issues: starting again with 'defend' mass assignment the ships went mining, then selling and continued mining with RandomMine still as default behaviour.

So as a first assessment I'd say the fix works 👍 Thank you for the quick solution.

Vectorial1024 commented 2 years ago

That's good news!

If the limited test passes, then I am quite confident that the full test will also pass.

I will push this to public sometime later, been getting busy IRL. Keeping this open until then.

Vectorial1024 commented 2 years ago

Released; therefore closed.