[Script] Scrap Ship at HQ v2.02 ** NON-BP version **

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

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

eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

[Script] Scrap Ship at HQ v2.02 ** NON-BP version **

Post by eladan » Wed, 22. Nov 06, 15:46

Scrap Ship at HQ
--------------------

NOTE: This script is part of bonus pack 3.1.06. If you have installed the version in the bonus pack, you should uninstall this version, and vice versa.

Allows the player to dismantle a ship into its component pieces - roughly the same amounts of each that would be required to build a ship of the same type (less a proportional amount due to hull damage, if any, and a small reduction for wear and tear.) Credit costs will not be retrieved - consider it depreciation! :wink:

A new command in the additional ship commands menu will generate a report to the message log detailing approx. costs for building/RE'ing a ship of that type at the HQ.

Updated 10-12-06 - minor bugfix

Version 2.02 - Download here (Hosted by Xai Corp - thanks moggy!)

Changelog:
v2.02
- Fix for command being interrupted forcing command to be rerun twice to scrap ship again
- Corrected time factor for scrapping and reporting build/RE time for Goner ships

v2.01
- Added German translation by finnTO (Thanks finnTO!)

v2.00
- Script restructure
- Ships will now take around 10% of the time to be recycled that it would take to build the ship at the HQ
- Ship name will change to reflect the progress of recycling (percentage and time left)
- Running the command a second time or issuing any command to the ship before recycling is finished will abort the process, losing any progress made.
- Fixed the wear and tear cost at 5%. There will still also be random reductions of certain resource amounts on top of that.
- Added new command in the additional ship commands which will generate a report on approximate build/RE costs at the HQ for a ship of that type. This command can be run on any ship, and does nothing but generate the report.

v1.20
- Changed code for calculating ship value for recycling (code by Jakesnake5 - thanks Jake!)
- Removed command from playership menu
- Slightly reduces amounts recycled (randomised) - some wares will lose more than others (ore/silicon)
- Added check for more khaak ships, just in case anyone gets one somehow :roll:
- Not in the readme - You will always get at least 1 unit for the primary resources - Energy Cells, Ore, Silicon, Nividium (if khaak,) Teladianium and Crystals.

v1.10
- Fixed bug for script not checking if enough storage existed before recycling
- Fixed bug for khaak ships not providing nividium from recycling
- Fixed low relval ships not supplying resources
- Added script setup check for HQ to disable command if HQ not yet built
- Added log entry giving resource amounts recovered when recycling
- General script cleanup and improvement

v1.00
- Initial release

Kudos to Dave Toome for his work on the HQ production cost calculator - I have based the formulae I am using in this script on his work. The calculator is available for download from this thread

The script uses COMMAND_TYPE_SPECIAL_56, COMMAND_TYPE_SHIP_38 and page id 8235
Last edited by eladan on Tue, 19. Jun 07, 08:29, edited 7 times in total.

Colonelnj10
Posts: 478
Joined: Mon, 6. Feb 06, 03:56
x3

Post by Colonelnj10 » Wed, 22. Nov 06, 21:55

FINALLY!

something that I can do to my capped ships collection!

User avatar
arcana75
Posts: 2165
Joined: Tue, 2. Dec 03, 09:28
x3tc

Post by arcana75 » Thu, 23. Nov 06, 03:34

Does this mean you can use capped ships to directly fuel your RE ships?

:o

eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

Post by eladan » Thu, 23. Nov 06, 03:48

That's what it means. You could supply the HQ with a steady stream of capped ships, and all you'd need to give the HQ is the credits it needs.

I wrote this with a thought for those people who aren't traders by nature...

[CMA]Radon
Posts: 63
Joined: Wed, 15. Mar 06, 22:07
x3

Post by [CMA]Radon » Thu, 23. Nov 06, 09:10

What's a trader???? :P

This is great. As per above, I have a good use for all those capped ships!!

Heh heh. I can use the resources for other factories too!!! I will await with anticipation to use it and see what sort of resource boost it will give. :twisted:

User avatar
arcana75
Posts: 2165
Joined: Tue, 2. Dec 03, 09:28
x3tc

Post by arcana75 » Thu, 23. Nov 06, 12:32

eladan, can I install this script without actually owning the PHQ? I don't have the PHQ yet.

eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

Post by eladan » Thu, 23. Nov 06, 13:07

You can install it, yes, but obviously you won't be able to use it until you have the player HQ! :D

If you try to run the command without the HQ it will simply write a message to the effect of "you don't have a HQ" to your log and do nothing.

User avatar
al_main
Posts: 1379
Joined: Wed, 6. Oct 04, 10:26
x3

Post by al_main » Thu, 23. Nov 06, 13:16

Useful little script!

If you wanted to improve on that you could always use:

Code: Select all

002   set script command upgrade: command=COMMAND_SCRAP_SHIP  upgrade=[TRUE] script='(Your check script)'
to register the script and then in the check script return:
[CmdConCheck.Available] if the ship can be scrapped
or return either [CmdConCheck.Disabled] or 0 if the player does not have an HQ or if the ship is the playership.

([CmdConCheck.Disabled] greys out the command, 0 makes it completely unavailable) - perhaps not show the command at all if the player has no HQ and grey it out to make it unselectable on the playership?

That way you avoid some of the log messages sent to the player.

Amyway, just my two cents!

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Thu, 23. Nov 06, 13:43

[CmdConCheck.Infinte] will make it not show at all ;)

User avatar
al_main
Posts: 1379
Joined: Wed, 6. Oct 04, 10:26
x3

Post by al_main » Thu, 23. Nov 06, 13:53

The same as returning 0 you mean?

Any actual advantage to using that rather than 0 out of interest?

eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

Post by eladan » Thu, 23. Nov 06, 14:08

Yep, I had planned on writing a check script, but I was too tired last night when I had finished the bulk of the script to be bothered with it then... :roll:

Didn't know about the [CmdConCheck.Disabled] or [CmdConCheck.Available] conditions though! (Was just going to have the command mapping strictly dependent on whether the HQ existed or not...

Still have to look up how to do it... thanks for the suggestion.

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

Post by jlehtone » Thu, 23. Nov 06, 14:15

al_main wrote:Any actual advantage to using that rather than 0 out of interest?
Better self-documenting?

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22227
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Thu, 23. Nov 06, 15:01

al_main wrote:The same as returning 0 you mean?

Any actual advantage to using that rather than 0 out of interest?
well basically, all those constant are are defines to numbers. so putting in [CmdConCheck.Disabled] will simply be using a number, so using a number is the same.

its just clearer when using the constants, as thats what they are designed for

eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

Post by eladan » Thu, 23. Nov 06, 15:51

New version 1.10 - see first post.

Jakesnake5
Posts: 2880
Joined: Fri, 17. Feb 06, 04:55
x4

Post by Jakesnake5 » Fri, 24. Nov 06, 05:00

Excellent. I was going to write one for a mod I'm helping with, but this will do (modified slightly of course :D)
Perfection is in the hands of God, we bags of dirt can only do the best we can©
[ external image ]
Modders are a source of ideas to help the Game Makers improve what they have made. Cherrish them, for they are the fruit of thy labors.©

eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

Post by eladan » Fri, 24. Nov 06, 05:40

Cheers Jake. Which mod, out of interest?

User avatar
arcana75
Posts: 2165
Joined: Tue, 2. Dec 03, 09:28
x3tc

Post by arcana75 » Fri, 24. Nov 06, 06:42

Sorry again eladan... isn't this a station command script? I haven't installed it yet but it sounds like you activate the script from the to-be-scrapped-ship.

eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

Post by eladan » Fri, 24. Nov 06, 06:53

That's right - from the special command menu on the ship you want scrapped. It will then fly itself to your player HQ and after 60 seconds will dismantle itself. (The delay is in case you run the command on a ship already at the PHQ, so you have a chance to get out of the ship menu before the ship disappears!)

There is no station component to the script.

Jakesnake5
Posts: 2880
Joined: Fri, 17. Feb 06, 04:55
x4

Post by Jakesnake5 » Fri, 24. Nov 06, 08:19

@arcana75
This is how it needs to be done, as there is no way to create a menu of ships docked at the station you wish to use the command on. This way, your SURE which ship you want to scrap. :)

@eladan
Exodus mod

BUT, your math is seriously messed up. You need to correct lines 78 and 80 (or just 78, see below). Remember, SE does not do floating point, and it doesn't carry FP numbers between operations:

Code: Select all

077   if $relval < 100000
078    $value = $relval / 100 * 216413 / 10000 * $hullpc
079   else
080    $value = $relval / 10000 * 216413 / 100 * $hullpc
081   end
If we take a Xenon N, it has a RelVal of 444. Line 78 would apply to this ship. If we follow the math:
444 / 100 = 4 (remember, SE does NOT do floating point)
4 * 216413 = 865652
865652 / 10000 = 86
86 * 100 = 8600 (hullpc will be a whole number percentage)

Now, if, as you claim, your script does a 1-1 recycling (we'll use E-cells as this is the largest amount of ware used and what all other ware returns are based on):

8600 / 295 = 29

It takes 32 Ecell to BUILD a N. What this means is, your losing wares, badly for the small ships.

It also means there is no Teladianium or Ore for that ship.

Now, if your line 78 code read:

Code: Select all

078    $value = $relval * 216413 * $hullpc / 1000000
you'd get (with a 100% hull N):

444 * 216413 = 96087372 * 100 (%) = 9608737200 / 1000000 = 9608

This then equals:

9608 / 295 = ~32.56xxxxx (rounded to 32 as an integer).

My above code entry could remove the 'if', 'else' and 'end' statments, and line 80 altogether.

I did a Buster as well, the number of Ecells needed are 368, but scraping only provided 366. while this isn't so bad, it's still obvious.

Another detail. Microchips are not any longer $comp4, they should be $comp5 (value was adjusted in 2.0.02 to require less). This excerpt from the HQ.xml shows this:
  • <!-- Money -->
    <factor value="3" primary="1"/>
    <!-- Energy Cells -->
    <factor value="885" primary="1" />
    <!-- Ore -->
    <factor value="21250" primary="1" />
    <!-- Silicon -->
    <factor value="28333" primary="1" />
    <!-- Nividium -->
    <factor racemask="khaak" value="170000" primary="1" />
    <!-- Cloth Rimes -->
    <factor value="85000" />
    <!-- Rastar Oil -->
    <factor value="42500" />
    <!-- Teladianium -->
    <factor value="28333" primary="1" />
    <!-- Crystals -->
    <factor value="85000" primary="1" />
    <!-- Quantum Tubes -->
    <factor value="85000" />
    <!-- Microchips -->
    <factor value="85000" />

    <!-- Computer Components -->
    <factor value="85000" />.
One last detail. All ships below RelVal of 1308 use 1 Crystal. This needs to be checked when adding the wares.

Sorry to bust on you like that, eladan, but I'm a betatester, and I notice things like this. :D
Perfection is in the hands of God, we bags of dirt can only do the best we can©
[ external image ]
Modders are a source of ideas to help the Game Makers improve what they have made. Cherrish them, for they are the fruit of thy labors.©

eladan
Posts: 7168
Joined: Sat, 7. Jan 06, 16:01
x4

Post by eladan » Fri, 24. Nov 06, 08:53

Jakesnake5 wrote:BUT, your math is seriously messed up. You need to correct lines 78 and 80 (or just 78, see below). Remember, SE does not do floating point, and it doesn't carry FP numbers between operations:

If we take a Xenon N, it has a RelVal of 444. Line 78 would apply to this ship. If we follow the math:
444 / 100 = 4 (remember, SE does NOT do floating point)
4 * 216413 = 865652
865652 / 10000 = 86
86 * 100 = 8600 (hullpc will be a whole number percentage)

Now, if, as you claim, your script does a 1-1 recycling (we'll use E-cells as this is the largest amount of ware used and what all other ware returns are based on):

8600 / 295 = 29

It takes 32 Ecell to BUILD a N. What this means is, your losing wares, badly for the small ships.
Yep - well aware of that. This was just the best approximation I could come up with for what I had to work with. If I did as you suggested, I get overflow problems for the bigger relval ships. There may be a better way to do it, but I was going to get rounding errors whatever I did.

I never claimed it was 1-1, and I don't see it as a burning need to be exact. IMHO, it is close enough to be good enough. (You ever get screws left over when taking apart and putting things back together again? :D )
The figures should be ballpark for all ships (has been for me.)

I may fix it to use euclid's floating point lib - which I would hope would give more exact figures.
Another detail. Microchips are not any longer $comp4, they should be $comp5 (value was adjusted in 2.0.02 to require less). This excerpt from the HQ.xml shows this:
Ah, my bad. Yep, that one I can fix up. I had forgotten about that.
Sorry to bust on you like that, eladan, but I'm a betatester, and I notice things like this. :D


No problem - it all helps to make a better script.

Post Reply

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