[Script] Cargo Delivery Service V1.04 07/01/06 (July 1)

The place to discuss scripting and game modifications for X³: Reunion.

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

What do you think?

Excellent
90
71%
Good
24
19%
OK
5
4%
Poor
2
2%
Terrible
0
No votes
Not really my thing
5
4%
 
Total votes: 126

User avatar
klaatu
Posts: 304
Joined: Fri, 21. Nov 03, 18:23
x3tc

[Script] Cargo Delivery Service V1.04 07/01/06 (July 1)

Post by klaatu » Tue, 31. Jan 06, 18:18

Note: Originally written by Jimmy Jazz (Jimmy.Jazz@Schattenseite.de) and called Freight Logistics Software, he has graciously allowed me to continue development, as he did not have the time for further updates. This plugin is an attempt to continue that initial work, as well as to teach myself X3 scripting (this is my first foray into scripting in X3).
--------------------------------------------------------------------------

Cargo Delivery Service

Trade Software for the Industrial Mogul

Download V1.04 from here

Access through the ship's Trade menu, Trade Software Mark II required.

Description:
Adds two new commands to the ship's Trade Menu:

* One Way Delivery: Delivers a ware from one of your stations to another and returns empty. This it will do forever and ever and ever….

* Two Way Delivery: Delivers a ware from one of your stations to another and returns with a second ware. This it will do forever and ever and ever….

Why do I need this?
Imagine you have an industrial complex that needs silicon and a silicon mine that needs energy. With CDS you can assign a freighter to deliver energy from your complex to the mine and return with the silicon. No money is involved. This way you can give the mine zero credits and it will work nevertheless. Industrial complexes can now become truly self sufficient even without being connected to a mine.
The software does not discriminate between products and resources. This means you can load energy cells from a complex although it uses it as a resource.

When does it stop working?:
If the hull of your ship drops below 80% or if one of the stations is destroyed it will fly to the nearest shipyard and send you a message.

Installation:
You need the XScript Installer by Cycrow from here to install this plugin. Use Cycrow's installer to place the files from the .spk into your game. The next time you start the game, you should see the commands in the trade menu.

Uninstallation:
Stop all freighters currently using either command. Use Cyrow's installer to remove the files placed into the \scripts and \t folders.

--------------------------------------------------------------------------

Features:
  • Freighter transports a) one ware from one player-owned station to another [1Way] or b) one ware from one station to another and a second ware from that station back to the first [2Way], until told otherwise.
  • Report the status of the ship as it goes about its work.
  • Indicates the ship's current destination.
  • Restarts itself in the event of a new version, so no need to reissue orders to already assigned freighters.
  • The last 10% of a station's stock is off limits to the CDS freighters.
  • Freighters wait until they can haul at least 25% of their capacity before venturing forth.
  • Built-in intelligence avoids a deadlock in case a 2-Way freighter can't load that 25%.
  • Jumpdrives are used if present. The necessary energy is taken from the departing station automatically.
  • Cargo is transferred among the stations without any credit changing hands. The only expense is the fuel for the jumpdrive (if present).
Last edited by klaatu on Sun, 2. Jul 06, 01:40, edited 4 times in total.

User avatar
klaatu
Posts: 304
Joined: Fri, 21. Nov 03, 18:23
x3tc

Post by klaatu » Tue, 31. Jan 06, 18:18

Version History:
1.04-
  • Freighter now waits for 25% (was 10%) of its cargo bay to be full before heading out.
1.03-
  • Added: 10% of a station's stock of any ware is off-limits to the CDS freighter.
  • Change: [1Way] Freighter waits for 10% of its cargo bay to be full before heading to the other station
  • Change: [2Way] Freighter waits for the same 10% to be in stock, *unless* the other station has (10% of its max stock + 10% of the freighter's max stock) of the other ware (and the current station can take the 10% of the freighter's max stock), in which case the freighter simply loads what's available (if any) and heads for the other station.
  • Added: Freighters use jumpdrives if present. They will take the needed Energy Cells from the station they are departing from. They do not jump within a single sector.
1.02-
Initial release

--------------------------------------------------------------------------

Next Steps / Currently Working On:
Seems feature complete to me. Any ideas for improvement? Bug reports?

--------------------------------------------------------------------------

Conflict section:
This script uses the following command slots:
<t id="458">COMMAND_CARGO_DELIVERY_ONE</t>
<t id="459">COMMAND_CARGO_DELIVERY_TWO</t>
Text files used:
8316

--------------------------------------------------------------------------

Previous versions:
Download: V1.03 from here, and V1.02 from here

Zip version:
You can download a zip version of V1.04 from here.
Last edited by klaatu on Sun, 2. Jul 06, 01:36, edited 5 times in total.

djssuk
Posts: 183
Joined: Thu, 11. Dec 03, 22:43
x3tc

Post by djssuk » Tue, 31. Jan 06, 18:42

I have used this a lot for transporting ore and silicon and energy and I am delighted you have made the changes and look forward to the jumping option... hope it is soon :P

User avatar
Khaakbuster
Posts: 377
Joined: Sun, 8. Jan 06, 19:43
x3tc

Post by Khaakbuster » Tue, 31. Jan 06, 21:13

Thanx for picking up the work of Jimmy. I really need this script for my self supplying complexes. It would be great if you could add a function soon, where the freighter would be forced to leave some of the resources in the factorys to prevent them from bleeding out.

My freighters always pick up all the energy cells from my complexes and deliver them to the mines and leave nothing for the complexes to work with. :(

User avatar
klaatu
Posts: 304
Joined: Fri, 21. Nov 03, 18:23
x3tc

Post by klaatu » Tue, 31. Jan 06, 21:47

Khaakbuster wrote:It would be great if you could add a function soon, where the freighter would be forced to leave some of the resources in the factorys to prevent them from bleeding out.
Yes, I think that'll be the next thing I work on. Sounds easier to do than adding jump capability anyway. :)

Would you agree that leaving 10% of the station/complex's stock of whatever off limits to the CDS freighters would be a good starting point? This would be true of any station it's working with, so even a mine would have 10% of its stock (minimum) on hand at all times.

Should frieghters wait for a certain percentage of their cargo holds to become filled before heading out? This is easier done on a one-way delivery than a two-way, as the freighter may be waiting at one end for a supply from that station, but the station on the other end is either in need of what the freighter would bring or is full of what it will pick up. This deadlock wouldn't be true of a one-way delivery. As it's coded now on the one-way the freighter will not head out until it has at least something to transport, even if it's only one unit. The two-way heads out regardless of if it was able to pick up any cargo or not, since the station may be in need of what's being transported from the other end.
"It's so simple. No, wait--it's needlessly complex!"
- Homer Simpson
You need this!: Cargo Delivery Service

Fachtna
Posts: 717
Joined: Tue, 3. Feb 04, 00:25
x3

Post by Fachtna » Tue, 31. Jan 06, 23:04

10% would be fine

if anyone can do a similiar script, whereby a station trader would sell excess stock to the npc's, that would be good too.

the two would go hand-in-hand. one sorts your factories, one sorts your profits :)

Naffarin
Posts: 465
Joined: Sat, 3. Dec 05, 10:49
x3

Post by Naffarin » Tue, 31. Jan 06, 23:19

@Fachtna: Take a look here Station Manager by Burianek & AalaarDB

User avatar
Khaakbuster
Posts: 377
Joined: Sun, 8. Jan 06, 19:43
x3tc

Post by Khaakbuster » Tue, 31. Jan 06, 23:38

I think that 10% is a good value. I checked my biggest complex and it has a capacity for 225k energy cells and about 15k to 25k units of other small goods. So the 10% would be just 22k cells and about 2k units of the goods which is a comfortable rest.


I would recommend a solution where the frighter would wait for a certain amount of goods before heading out.


Another question really troubles me. If the destination is already full of the supplies which we want to bring there, lets say we want to bring silizium from the mine to a SPP, will the freighter take a full hold of silizium, dock at the SPP and be unable to take energy cells back to the mine because its hold is still blocked?
For such a situation the check for a certain amount of goods to transport would be good, because the freighter would have to wait for enough cells to be put into its hold while unloading silizium at the same time.
Do you understand what I mean? It's probably a little complicated to program.

I guess a more simple solution to this problem might be, that when loading the supplies you check that you only load so much supplies that they fit into the hold of the target station.

User avatar
klaatu
Posts: 304
Joined: Fri, 21. Nov 03, 18:23
x3tc

Post by klaatu » Wed, 1. Feb 06, 00:02

Yes, currently the freighter only carries as much as the receiving station can hold. The situation you postulate would occur if, for instance, the CDS freighter checks the receiving station and determines that a full load can be taken, so it loads up and heads out. Meanwhile, something else fills up the receiving station with the ware the CDS freighter is bringing, so it can't unload. This would be a bad thing, leading to the end of life as we know it. :)

(2Way) If the receiving station is already totally full before the CDS freighter heads out, it will transport nothing since it assumes the factory it's leaving from will need the other ware it will be picking up at that other station. Placing a check for a minimum to transport could hold up the exchange of one ware at the expense of the other.

In the one-way situation the above hold up would not occur since there is only one ware being transported and placing a minimum of, say, 10% of the freighter's cargo bay could be beneficial. With the current version there is a minimum of 1 unit. Changing it to a certain percent of freighter's cargo bay would be trivial.
"It's so simple. No, wait--it's needlessly complex!"
- Homer Simpson
You need this!: Cargo Delivery Service

User avatar
Khaakbuster
Posts: 377
Joined: Sun, 8. Jan 06, 19:43
x3tc

Post by Khaakbuster » Wed, 1. Feb 06, 01:18

I'm glad to hear that your script already checks for enough free space at the destination. I haven't had a problem with this so far, but one of my mines is producing silizium like crazy and I was afraid of a deadlock to come. :o


Changing the minimum amount to transport from 1 unit to 10% would be very nice.


In the end it's your decisions to make, I can just tell you my wishes. :)

1. Leave station only if at least 10% cargo space is used for the goods.
2. Leave at least 10% of the selected source goods at the supplying station.

User avatar
Mobuj
Posts: 264
Joined: Wed, 23. Nov 05, 01:30
x3tc

Post by Mobuj » Wed, 1. Feb 06, 02:05

Hi Klatuu

This is a FAB script!

You should get it posted to the "Index of Community Scripts / Mods for X3".

Sure is gonna be a life saver. 8)
---------------------------
I am Popeye of Borg
You will be askimilated!

User avatar
Jimmy Jazz
Posts: 738
Joined: Wed, 4. Jun 03, 17:20
x3

Post by Jimmy Jazz » Wed, 1. Feb 06, 13:53

@Klaatu: Thank you for taking over the work.

I linked your thread to my original one, so that all the new user find your improved version

If you have any questions concerning the original code, just contact me. When I wrote the code I didn't get the comment function to work, but I tried to make the code self-explanatory.
Pinky : "Gee, Brain what do you want to do tonight?"
Brain : "The same thing we do every night Pinky. Try to take over the world!"

User avatar
klaatu
Posts: 304
Joined: Fri, 21. Nov 03, 18:23
x3tc

Post by klaatu » Wed, 1. Feb 06, 17:52

You're welcome Jimmy, and thanks for the original version; it was very helpful in making self-sufficient complexes when silicon or ore was not close by. The code itself was very readable; of course, I've had more than a few years practice. :)

Regarding the issue of waiting for a minimum amount to haul: Jimmy was right to be very conservative here, as a deadlock can occur fairly easily if a silicon mine has little silicon waiting for transport and also has no energy to produce more. If a CDS freighter is the only freighter maintaining the station so is expected to bring it energy on its return trip, waiting to load 10% of its cargo bay with silicon will cause it to wait forever. This situation needs to be avoided, so more is needed than just a wait for a minimum load.

Here's the way I've implemented it in the version I'm testing now:

10% of a station's stock of any ware is off-limits to the CDS freighter, so it'll never touch a station's last bit of stock. This is true for both one and two-way CDS freighters. Also true for both is that the freighter will never haul more than the other station could take (at the time of loading).

For the one-way version the freighter simply waits for 10% of its cargo bay to be full before heading to the other station. This means the station must have (10% of station's max stock + 10% of the freighter's max stock) on hand before the freighter will load.

For the two-way version the freighter waits for the same amount to be in stock, unless the other station has (10% of its max stock + 10% of the freighter's max stock) of the other ware (and the current station can take the 10% of the freighter's max stock), in which case the freighter simply loads what's available (if any) and heads for the other station.

This prevents the above deadlock from occurring since it looks at both stations to see if there's something it could be hauling, and if there is it heads there.

If, after some more testing, it appears that things are functioning as designed, I'll be releasing it. Unless someone sees a flaw in my logic or has a better idea. Speak up if so.
Last edited by klaatu on Thu, 2. Feb 06, 17:58, edited 1 time in total.

User avatar
Khaakbuster
Posts: 377
Joined: Sun, 8. Jan 06, 19:43
x3tc

Post by Khaakbuster » Wed, 1. Feb 06, 18:53

klaatu wrote: Here's the way I've implemented it in the version I'm testing now:

10% of a station's stock of any ware is off-limits to the CDS freighter, so it'll never touch a station's last bit of stock. This is true for both one and two-way CDS freighters. Also true for both is that the freighter will never haul more than the other station could take (at the time of loading).
This alone would make it worth releasing. Please hand it over. :D

klaatu wrote: For the one-way version the freighter simply waits for 10% of its cargo bay to be full before heading to the other station. This means the station must have (10% of station's max stock + 10% of the freighter's max stock) on hand before the freighter will load.
Ok, there can be no deadlock in this scenario. I'm already thinking about using two freighters with one way delivery to minimize traffic... :wink:

klaatu wrote: For the two-way version the freighter waits for the same amount to be in stock, unless the other station has (10% of its max stock + 10% of the freighter's max stock) of the other ware (and the current station can take the 10% of the freighter's max stock), in which case the freighter simply loads what's available (if any) and heads for the other station.
Interesting solution! Sounds perfect to me, although it could mean a few more runs of the freighter but better have more runs than a deadlock.

whiteraider
Posts: 499
Joined: Sun, 7. Mar 04, 01:08
x3tc

Post by whiteraider » Thu, 2. Feb 06, 11:41

Have used JimmyJazz's version and like it so I'm assuming it'll pick up from that. Going to test it later :)

One thing I've not seen anyone do is a deliver to NPC Equipment Dock, for goods that they dont sell e.g.
AIREs in Antigone Memorial, so a frieghter (M4) could wait for x items then take them to the EQ and sell, returning home empty
Bring back the TS Pirate Ship, I miss my liberated fleet runing around the universe :twisted:
Maybe a fleet of liberated Pirate Ship Super Freighters :roll:

"Priests Dukes Compliments... Here is ship!"
"Teladi now show you how to fight... Ship all yours! Dont kill Teladi!"

Post Reply

Return to “X³: Reunion - Scripts and Modding”