[SCRIPT] Complex production cost V3.0 (3-12-06)

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

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

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 10695
Joined: Sun, 15. Feb 04, 21:12

[SCRIPT] Complex production cost V3.0 (3-12-06)

Post by euclid » Wed, 18. Oct 06, 02:26

Version 3 (3-12-06)

# 1 Computations now done with floating point numbers to reduce truncating/rounding errors. Necessary utility files from the floating point math lib are included in the zip, so no need for any extra download.

# 2 Improved filter to extract fabs belonging to the selected complex. This is now done via a subscript.

# 3 Extended ware2relval list to include Jakesnake5's Yaki script (you can now have typhoon and/or disrupter missile fabs in your complex). Also nividium, spaceflies, and Kha'ak and Terran missiles and weapons included.



Installation

Extract the 447004.xml into the /t folder of your X3 folder and all other files into the /scripts folder.



How it works

You will find a new trade command in your ship's trader command menue. Click that, select one of your complexes and then check your log. For each ware the complex is producing you will find an entry with the production cost based on the price settings of the resources of the complex.



Download Link

Thanks to Jakesnake5 for hosting :thumb_up:


===========original post========================

As we all know the current production cost (value in square brackets below the product selling price) are always [0] for a complex (not for a station/fab).

{ Note that with 2.0.02 there is no [0] shown anymore. E. }

Although that may be true for a well-planned and self-sufficient complex it is certainly not true in general. Just connect any two stations of the same type, for example two cattle ranches. The prduction cost show [0] irrespectively of the ecell buying price.

My idea is to write a script available as a special command of the player's ship. As input select one of you complexes and the actual production cost is then calculated and written to the player's log.

Would such a script be interesting?

Edit: updated and ready for download - see 6 posts down.E.

{ Download link moved up. E. }

Cheers Euclid
Last edited by euclid on Sun, 3. Dec 06, 16:01, edited 6 times in total.

jlehtone
Posts: 17111
Joined: Sat, 23. Apr 05, 21:42

Post by jlehtone » Wed, 18. Oct 06, 08:28

That would be nice when there is only one product, like in dual Ranch.

But multiple products imply different cycle times, and that gets "complex", doesn't it? :wink:

And what about Wheat L + Whisky M? The intermediates do not match 1:1 there. Would you take that into consideration, and how?

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 10695
Joined: Sun, 15. Feb 04, 21:12

Post by euclid » Wed, 18. Oct 06, 16:38

I was thinking simple here. Different cycle times and sufficient resource production would be too complicated, indeed. For that purpose Merroc's excel sheet is the better choice.

I'd just take the products, check what and how many resources are needed to produce one unit and then use the resource price setting of the complex to compute the costs.

This is complicated enough if you bare in mind that the resources may be intermediate products and hence may also need resources for production.

For two fabs of the same type this would be easy and is straightforward to calculate with pen and paper.

Cheers Euclid

jlehtone
Posts: 17111
Joined: Sat, 23. Apr 05, 21:42

Post by jlehtone » Wed, 18. Oct 06, 20:40

euclid wrote:This is complicated enough if you bare in mind that the resources may be intermediate products and hence may also need resources for production.
One could recursively track all true resources via the intermediates, but if the complex contain is partially selfsufficient, then there is a loop and that scheme breaks.

And the integer math. The cycle time and number of products are computed from the ratios of all resources and product. Each must be an integer. (This is before the M, L, XL scale multiplication.) So if you compute for one unit of product, you will end up with floating point values. Was that "good" in a script?

Milo Rambaldi
Posts: 3206
Joined: Mon, 2. Aug 04, 22:27

Post by Milo Rambaldi » Wed, 18. Oct 06, 21:00

jlehtone wrote:
euclid wrote:This is complicated enough if you bare in mind that the resources may be intermediate products and hence may also need resources for production.
One could recursively track all true resources via the intermediates, but if the complex contain is partially selfsufficient, then there is a loop and that scheme breaks.

And the integer math. The cycle time and number of products are computed from the ratios of all resources and product. Each must be an integer. (This is before the M, L, XL scale multiplication.) So if you compute for one unit of product, you will end up with floating point values. Was that "good" in a script?
*Glases over* :o

I'm just interested in such a script if it became available :D

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 10695
Joined: Sun, 15. Feb 04, 21:12

Post by euclid » Thu, 19. Oct 06, 04:45

Almost done. Main problem is that there is no SE command to get the array of all stations of one complex. So I need to get the amount of resources per cycle from somewhere else.

Using Merroc's excel to create a DB in the script is a pain and the NPC stations have different resources. But there is a (dirty) way of doing it. :grin:

Cheers Euclid

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 10695
Joined: Sun, 15. Feb 04, 21:12

Post by euclid » Thu, 19. Oct 06, 16:53

Download link moved up to first post. E.


Motivation:

Currently the production costs, shown in square brackets below the selling price, is always [0] in a complex ( this is not shown anymore in 2.0.02). Although that may be true for self-sufficient complexes it is certainly not true in general.



What is does:

This script adds an additional trade command to the player's ship. If executed the player is asked to select a sector and within that sector a complex. The costs of each product of that complex are written to the player's log.

The computation of the costs is based exclusively on the resource price settings of the complex and on the number of the resources per cycle. So you will get nonzero costs if you run the command on a self-sufficient complex.



How to install:

Copy the 447004.xml file into the t folder and the complexProductCost.xml as well as the setup.ComplexProductCost.xml { and all other files } into your script folder.



Acknowledgement:

Thanks goes to Merroc, Moggy2, Jakesnake5 and X-Freak Cartman for some useful hints and info.



Enjoy !


Cheers Euclid
Last edited by euclid on Sun, 3. Dec 06, 16:06, edited 2 times in total.

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 10695
Joined: Sun, 15. Feb 04, 21:12

Post by euclid » Fri, 20. Oct 06, 18:25

Bug fixed - version 1 see link above.

Feedback welcome :grin:

Cheers Euclid

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 10695
Joined: Sun, 15. Feb 04, 21:12

Post by euclid » Sun, 22. Oct 06, 20:04

New version 2.0 uploaded (thank Merroc :thumb_up: )


Version 2 - Update:

Version 1 was based on the script command 'get number of resources per cycle for ware' but unfortunately this command is broken, i.e. it does NOT return the correct amounts for some resources.
This 'bug' seems to exists for some time and, although the Devs know about it, it's not likely to be fixed soon.

As a workaround version 2 now computes the number of resources directly from the player RelVal of a ware. If you want to know more use 'relval' in the extra search. Since relvals are NOT accessible via an SE command I had to import them manually. The script 'ware2relval' delivers the relval for a given ware.

Note for modders/scripters: Currently only wares which can be produced and/or are needed as a resource in a vanilla X3 game are listed in 'wares2relval'. If your mod introduces fabs with other
products or resources then please append these wares and their player relvals in ware2relval.xml.


Cheers Euclid

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 10695
Joined: Sun, 15. Feb 04, 21:12

Post by euclid » Tue, 24. Oct 06, 12:45

Just for clarification (thanks to Cycrow for pointing that out):

The SE command

Code: Select all

<retvar> = get relvalue <var/ware>
does returns the NPC RelVal and not the Player RelVal and hence I could not use it in my script.

Cheers Euclid

jlehtone
Posts: 17111
Joined: Sat, 23. Apr 05, 21:42

Post by jlehtone » Tue, 24. Oct 06, 13:26

It would work for wares (energy/bio/food/minerals) that are consumed as primary resource by some factory, because for those the RetVal's are (AFAIK) identical.

Naturally, there is no garantee for them to be identical (in modded game). It is simpler to have one complete table.
Goner Pancake Protector X
Insanity included at no extra charge.
There is no Box. I am the sand.

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 10695
Joined: Sun, 15. Feb 04, 21:12

Post by euclid » Thu, 26. Oct 06, 13:28

Yes, quite right, jlehtone. In detail (ware,player relval, NPC relval):

Code: Select all

Energy Cells,4,4
Delexian Wheat,6,6
Agnu beef,20,20
Plankton,4,4
BoGas,72,72
Scruffin Fruits,4,4
Chelts Meat,20,20
Soja Beans,5,5
Maja Snails,30,30
Sunrise Flowers,4,4
Teladianium,30,30
Swamp Plant,30,30
Cloth Rimes,24,24
Meatsteak Cahoonas,6,6
Stott Spices,6,6
BoFu,24,24
Massom powder,3,3
Rastar Oil,40,40
Majaglit,3,3
Soja Husk,30,30
Nostrop Oil,6,6
Ore,24,24
Silicon Wafers,96,96
Crystals,60,60
Computer Components,48,48
Wasp Missile,48,48
Strange that wasps have the same relval for player and NPC. Anyway, as you said it may change in a mod so a list is better.

Cheers Euclid

jlehtone
Posts: 17111
Joined: Sat, 23. Apr 05, 21:42

Post by jlehtone » Thu, 26. Oct 06, 13:42

euclid wrote:

Code: Select all

Computer Components,48,48
Wasp Missile,48,48
Strange that wasps have the same relval for player and NPC. Anyway, as you said it may change in a mod so a list is better.
Well, it would be better, if the value could be read by internal function, because now anyone modding the RelVal's should mod the table in your script as well. Innocent user downloading both your script (for vanilla version) and some RelVal-mod cannot be expected to realize the dependecy.

And Computer Components are not primary to anyone either. Weren't some wares faster/cheaper to produce in player fab? Guns are certainly slower.

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 10695
Joined: Sun, 15. Feb 04, 21:12

Post by euclid » Sun, 5. Nov 06, 21:06

jlehtone wrote: .....Well, it would be better, if the value could be read by internal function, because now anyone modding the RelVal's should mod the table in your script as well. Innocent user downloading both your script (for vanilla version) and some RelVal-mod cannot be expected to realize the dependecy.
I utterly agree here. The current SE command

Code: Select all

<RetVar> = get relvalue of <Var/Ware>
reads offset 8 of the TWare files and this is the NPC relval. It shouldn't be too difficult to to modify the command, for example

Code: Select all

<RetVar> = get relvalue of <Var/Ware> NPC = <Var/Number>
so that for NPC = [FALSE] the offset 12 is read - the Player's relval.
.......Weren't some wares faster/cheaper to produce in player fab? Guns are certainly slower.
Yes, some wares are produced faster in player-owned fabs, some are not. I think the purpose of different relvals is to have an additional economy control. The current settings may not be optimum, if there is such a thing anyway :wink:

Cheers Euclid

User avatar
euclid
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 10695
Joined: Sun, 15. Feb 04, 21:12

Post by euclid » Sun, 3. Dec 06, 16:18

New version available (see first post).

Now the command will work even if you have several complexes or stations in the same sector (thank to X-Freak Cartman for the how-to hint).

Increased accuracy of the result due to floating point number computations.

Extended ware2relval list. Complexes now may also produce all missiles (including Yaki, Kha'ak and Terran). Also Nividium, spaceflies and all Kha'ak and Terran weapons are included.

However, the production costs are still based on the resource price settings only.


Any feedback is welcome.


Cheers Euclid

Post Reply

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