[Script] Scrap Ship at HQ v2.02 ** NON-BP version **
Moderators: Moderators for English X Forum, Scripting / Modding Moderators
[Script] Scrap Ship at HQ v2.02 ** NON-BP version **
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!
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
- 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
--------------------
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!
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
- 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.
-
- Posts: 478
- Joined: Mon, 6. Feb 06, 03:56
-
- Posts: 63
- Joined: Wed, 15. Mar 06, 22:07
Useful little script!
If you wanted to improve on that you could always use:
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!
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)'
[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!
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...
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.
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.
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.al_main wrote:The same as returning 0 you mean?
Any actual advantage to using that rather than 0 out of interest?
its just clearer when using the constants, as thats what they are designed for
-
- Posts: 2880
- Joined: Fri, 17. Feb 06, 04:55
Excellent. I was going to write one for a mod I'm helping with, but this will do (modified slightly of course )
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.©
[ 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.©
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.
There is no station component to the script.
-
- Posts: 2880
- Joined: Fri, 17. Feb 06, 04:55
@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:
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: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:
Sorry to bust on you like that, eladan, but I'm a betatester, and I notice things like this.
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
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
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" />.
Sorry to bust on you like that, eladan, but I'm a betatester, and I notice things like this.
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.©
[ 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.©
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.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.
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? )
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.
Ah, my bad. Yep, that one I can fix up. I had forgotten about that.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:
Sorry to bust on you like that, eladan, but I'm a betatester, and I notice things like this.
No problem - it all helps to make a better script.