mbleichner / x4-warehouse-fleets

X4 Foundations Mod - Warehouse Fleets
2 stars 3 forks source link

Trying to distribute raw ressources bricks the script #1

Closed HankSeesSharp closed 1 year ago

HankSeesSharp commented 1 year ago

Hi! Mod looks very promising. Sadly when trying to distribute solids or gas from the same station that distributes the final or intermediate products it bricks. Basically when setting up the default behaviour for a large container ship it tries to pick up silicon or ore and such. Gas and Solid Transporter aren't doing anything besides docking x)

Would it be possible to declare an individual warebasket per fleet? So that we could run one distribution fleet for container storage wares and one fleet for solids and one for gas.

Appreciate the work though! Having mules that run on cues instead of scripts should perform way better for my universe spanning trade empire! 100+ mules are way too much xD

mbleichner commented 1 year ago

I guess I forgot to mention this in the docs - in its current state, only container storage is being considered. I haven't even tested what happens when trying to distribute raw resources.

The reason for this is that the scheduling algorithm tries to mix multiple wares per trip to make the most of the ship capacity. Combining this with multiple cargo capacity types makes it a lot more complicated, so I ignored that for the time being. In fact, I never felt the need to transport raw materials, because it seemed relatively inefficient to me.

I'll check if there's a good solution for this as soon as I have time.

I'm not a fan of the warebasket idea though, it would force you to split up fleets and this gets extremely tedious once you have >10 fleets. Ideally, each ship should consider the different types if storage for itself and decide what's most efficient.

HankSeesSharp commented 1 year ago

Of course, if every ship could automatically only get the wares it can carry, that would be amazing!

My reason for wanting to distribute raw mats is that I don't want my miners to travel like 5 jumps every cycle. I'd rather streamline it so that they mine efficiently in one system and then have a fast ship with defense turrets and a travel drive distribute it from there. For example with the Donia.

I feel like that's more efficient than each miner travelling back to the system my factories are in. This way I can also focus on only mining in the highest yield areas around the map. Otherwise I would just pump all my economy in one good sector like Nopileos Fortune and never visit that one x)

I'll gonna look into it aswell, maybe I find something in the game files that would help.

mbleichner commented 1 year ago

Makes perfect sense :)

I'm not at home right now. If you want to have a look at the code for yourself, the relevant block is this one: https://github.com/mbleichner/x4-warehouse-fleets/blob/master/md/warehousefleets.xml#L702

Sorry for the german comments btw, I should probably translate them at some point 😅

mbleichner commented 1 year ago

Ok, so this was a lot easier to fix than I expected.

I made a new branch containing the changes: https://github.com/mbleichner/x4-warehouse-fleets/tree/feature/raw-resources You can download the files and put them into your /extensions/warehousefleets folder. If everything works for you, I'll release an update on Nexus.

If you have a little experience in X4 modding, feel free to have a look at the changes and give me feedback :)

HankSeesSharp commented 1 year ago

Awesome! I don't really have experience with X4 modding, but I was tinkering with the cargo.capacity.{$flags} and $ware.flags.{1} (which seems to be the storage type flag), but your solution is so much easier! First glance looks very promising. First test is positive. Large Miner does its thing. Trades are found.

Gonna set up the fleets and see how it's doing, but so far everything looks great! Gonna get back to you later today.

Thanks a bunch for your quick response and great work :D

HankSeesSharp commented 1 year ago

Yup works like a charm. Performance is amazing and all my stuff get's distributed between my warehouses even with mixed fleets. All of my 60ish M-size factory mules are now in their own warehouse fleet balancing all wares between my supply hub and the factories within my one production sector. I might even switch my trade mules to trade warehouse fleets... Gotta test which are more productive though ^^ My dude, you made my empire management and my overall X4 late game experience so much better :D Thanks again!!

P.s.: Ohh one thing. The minimum cargo usage could mayyyybe be improved. I had to get a bunch of S-sized ship for medical supplies and nostrop oil because the M-sized ships couldn't be bothered because those wares wouldnt amount to more than like 8% of the cargo space according to the scriptlogs. But I guess that might be by design since you wrote we have to put all sizes of ships into the fleets. But I want to start terraforming for SCP soon anyway so losing small ships wont be a problem for long.

mbleichner commented 1 year ago

Would it help if you could set minimum cargo usage lower than 10%? That's a relatively easy change :)

mbleichner commented 1 year ago

Update published on Nexus

HankSeesSharp commented 1 year ago

Would it help if you could set minimum cargo usage lower than 10%?

Actually yeah. I think that might be it! Is that a per ware setting or the overall cargo usage for the ship per trip? Like, is the script checking if at least 10% of the total cargo is used for each of the 3 wares it tries to put in there? So that, worst case, it would only fill up 30% of total cargo? Because if I can set it to 1% and the ship still fills up the whole cargo, if needed, but only 1% of that is used for medical supplies, that would be amazing.

mbleichner commented 1 year ago

Currently there are two rules:

The reason for the first rule is that loading/unloading takes a set amount of time, so it's inefficient to repeatedly carry very small amounts of stuff. Better wait until there is more to carry.

The reason for the second rule is somewhat obvious - you don't want to ships flying around that are mostly empty.

In your case, flying almost empty seems to be what you want to explicitly allow? Maybe there is a more clever way to identify situations like this without sacrificing the rules that try to optimize efficiency?

HankSeesSharp commented 1 year ago

No, I actually want all ships to be efficient. But I want small wares with low amounts like food stuff to be carried as well.

I actually would propose another slide bar for the hard coded value like "min. cargo % per ware". So that I can set that wares with a lower % cargo usage should be also considered alongside with the min. (total) cargo usage parameter.

And maybe even a setting for the amount of wares to be transported would make sense then. Because when one ware only makes up say 1% of the total cargo, having 2 other wares in big enough amounts to be transported might become inefficient. But 4 toal wares, 1 in low amounts and 3 with normal amounts might make it efficient again. With these 2 additional settings I could set up my in-sector supply fleet for my production sectors to carry food stuff as well as fill up their cargo and for all other fleets I would leave it at default so I don't carry inefficient amounts on long hauls between warehouses.

Or maybe it would make more sense to just have a overwrite setting, that enables low amount wares to be carried, ignoring their efficiency and fill up the cargo with other wares as usual. I think the station mule has a settings like this "Allow Food and Meds" and "Allow Energy Cells". Might be worth a look at the implementation.

I would understand if you don't want to divert too much from your original idea. These are just my 2 cents. And I know that sometimes a dev might need to choose to not listen to every request to keep the overall quality high enough.. And more options means more user problems maybe. But I think in this case, I am on the side of less hardcoding xD

But anyway: After the raw material changes your mod works very well so far. It's just more QoL :D It's actually amazing now, all my supply hubs are getting resources so I dont have to appoint miners for every station in every production sector and instead can use the surplus!

So thanks for your time and openness to ideas so far!