X: Rebirth
0 of 0

File information

Last updated

Original upload

Created by

jth

Uploaded by

jth1

Virus scan

Safe to use

Tags for this mod

Documentation

Readme

View as plain text

Author: jth
X Rebirth version: 4.00
StationRecycle v0.07 apr 6 2017
================================
Adds the ability to recycle or destroy ships at Player Shipyards or NPC Shipyards

Please be aware that this is a beta release and that you should back up your save games before using it. Save games zip up very efficiently to about 7% of the original size.

Installation and Compatibility with other mods
==============================================
To install it extract and copy the "shiprecycle" folder to the "Steam\steamapps\common\X Rebirth\extensions" folder (create the extensions folder if you don't have it already) or subscribe to it from Steam and restart the game.

This mod interacts with the player via the ShipTrader menu and replaces The "Sell a ship" option with "Sell or Reycle a ship".

This mod patches Egosoft's ShipTrader.xml file and adds customised versions of menu_property.lua and menu_buildcost.lua

X Rebirth will save some of the variables and the state of the Ship Recycle cues as part of a normal save game. Do not remove this mod part way through recycling a ship. If you decide not to use this mod any more just remove the "ShipRecycle" folder or unsubscribe it from Steam and restart the game.

=== How to Use ===
Fly to the zone that contains the shipyard that you want to use to recycle your ship
Open communications with the right Ship Trader for the size of vessel that you are recycling
Pick the "Sell or Recycle a ship" menu option
Select the ship and then click on either the Recycle or Sell button.
The Sell button sells the ship in the normal way using standard Egosoft code at the standard price
The Recycle button opens up the Recycle Cost menu for the selected ship where you can see the recycling information
Then pick "Yes, recycle this ship"
Sit back and watch the ship move into the docking cradle and then observe the hull, weapons, drones, ammunition, cargo and crew getting recycled

=== Upgrading from version 1 ===
After a clean start of X Rebirth with version 2 or later of this script the next ship that is recycled with a specific ship trader will convert all the NPC's that were created with version 1 by that shiptrader from player owned to hireable and pay the player for them.

The old player owned NPC's will be destroyed. The re-created NPC's will have the same name, type, race, macro and skill levels.

The conversion will skip any NPC's created by version 1 of this script that are not on the Shipyard and put an entry in the logbook for each skipped NPC so that you can identify them. There is a potential issue where these version 1 NPC may disappear over time leaving your ship without certain crew.

You need to recycle a ship at all the shiptraders that you used for recycling in version 1 to get all NPC's converted to hireable NPC's.

Some of the NPC's (the first Defense Officer and the first Engineer) that were recycled with version 1 were probably assigned to the shipyard if you did not already have a Defense Officer and Engineer. The upgrade will remove them from their posts and re-create them as hireable again.

The Recycle Ship mod :-
-----------------------------------
Allows recycling of L and XL ships in Player Shipyards and NPC Shipyards
Uses a customised version of Egosoft's PropertyMenu and BuildCostMenu GUI menus to select the ship to be recycled and show you what wares will be recovered
Checks a number of pre-requisites to make sure that recycling can proceed and notifies player if there are any problems before allowing the player to continue.
PropertyMenu checks that the recycling ship will fit into the individual ShipTrader's ship cradle.
BuildCostMenu checks that the shipyard has enough food, energy and construction drones present and shows you what will be recycled.

Recycles hull wares taking into account the state of the hull at the time
Recycles operational Weapons and Shields plus installed drones, ammunition and cargo
When recycling cargo it pays the full price for any wares that will fit in station storage and 50% if they do not fit or are not standard wares for a shipyard
If the Shipyard is NPC owned then the player is paid for the ship in the same way as the current Sell a ship
Consumes energy and food rations to carry out recycling
Moves ship into appropriate ship cradle and chops the hull up piece by piece
Pays player for crew (captain, defense officer, engineer and architect) and recreates NPC's with same skills as ship crew on shipyard where they can be hired by player. This means that if you spend time training crew then their replacement will also have the benefit of the training.
Will try to put recreated crew in the bar if it can find space there otherwise picks any personnel docking bay that has space.
Maintains individual ShipTrader locking so that an individual ship trader can only do one thing at a time
Aborts recycle if ship is destroyed before it gets into dock.
Logs ship recycling in player log book and to debug.log so that the recycling process can be checked and diagnosed
Checks selling price of NPC's and if greater than max allowed then compensates by dividing by 100

=== Known issues ===
If there is no space on the shipyard for recreating the crew then they will not be recreated but you will still be paid for the old crew.
The amount that is paid for a crew contract is calculated by calling the Egosoft FeeCalculation cue from NPC_Staff without applying any recycling factors as its going to be pretty random anyway. To quote from the code . It will almost definitely be different to what you paid for that crew member in the first place.
If you leave recycled crew on the shipyard for too long then they will eventually get cleaned up by the Egosoft station crew script and replaced by someone else with different skills.
Using multiple ShipTraders from the same shipyard at the same time may have unfortunate consequences, do not attempt to recycle two ships at the same time.
When recycling there is no check that recycled wares can fit in station storage for anything except ship cargo. There were no checks at all before v0.04

=== Recommendations for using the mod ===
Although the restriction on the recycled ship having to be in the same zone as the player is gone I would strongly recommend that you get the recycled ship into the same zone as the shipyard before starting to recycle it as a lot can happen in the time that the recycled ship flies to the shipyard

=== ToDo ===
Small ShipTraders if suitable case made by players and enough demand, ware amounts are rather small for m ships.
Fly some construction drones around during chop up phase
The two customised versions of menu_property.lua and menu_buildcost.lua are based on the ones from 3.6x so don't have the extra bells and whistles from 4.x might be worth porting the changes to the 4.x versions at some time if there is enough demand

=== Diagnosing issues ===

These instructions are for Windows 7 64 bit, please adjust for other versions

Start X Rebirth in debug logging mode by adding "-debug all -logfile debug.log" to the end of the command line

In my case this would look like

"C:\Program Files (x86)\Steam\steamapps\common\X Rebirth\XRebirth.exe" -debug all -logfile debug.log

That will create a debug.log file at the same level as your save game folder

Recycle a ship, then get a command prompt in the same folder as debug.log by shift right clicking and selecting "open command window here"

Then search for all NPC_Shiptrader lines with

find "NPC_Shiptrader" debug.log > results.txt

Open results.txt

This is a successful recycle of a Rahanas

[Scripts] *** Context:md.NPC_Shiptrader.DefaultComm: Architect conversation started: default, actor=0x5930c, Kareen Claassen
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: section: 'cArch_sellship'
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: section: 'cArch_recycleship'
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: Missile Warelist entries 0 []
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: Ammoplan is []
[=ERROR=] shiprecycle_menu_cost Recycling - Rahanas QTubes
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: section: 'cArch_recycleshipselected'
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: section: 'cArch_recycleshipconfirmed'
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: Rahanas QTubes selected for Recycling
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: Rahanas QTubes is of size dock_l
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: Kareen Claassen has an LV Shipyard
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: LV Shipyard is capable of docking [tag.dock_l] ships
[Scripts] *** Context:md.NPC_Shiptrader.LogWriter: Initial Station Cargo, foodrations 7926, scanningarray 117, reinforcedmetalplating 129, plasmaflowregulator 42, microchips 231, holtzmanfieldgenerator 58, fusionreactor 48, bioopticwiring 264, machinegunturret 16, shieldgenerator 6, energycells 14878,
[Scripts] *** Context:md.NPC_Shiptrader.LogWriter: Build wares for Rahanas QTubes - 9 Wares, units_size_l_kit_container_02_macro, bioopticwiring - 98, microchips - 86, reinforcedmetalplating - 48, scanningarray - 44, holtzmanfieldgenerator - 22, fusionreactor - 18, plasmaflowregulator - 16, machinegunturret - 8, shieldgenerator - 3,
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: Shiptrader_docking
[Scripts] *** Context:md.NPC_Shiptrader.SectionHandler: Rahanas QTubes 0x59025 told to move into dock

[Scripts] *** Context:md.NPC_Shiptrader.UpgradesFinished: Rahanas QTubes now being recycled
[Scripts] *** Context:md.NPC_Shiptrader.RecycleCrew: 1/2 commander Kaylen Cheram 0x5902a now being recycled
[Scripts] *** Context:md.NPC_Shiptrader.RecycleCrew: Received 67 730 Credits from Capital Ship Dealer Kareen Claassen for Captain Kaylen Cheram's contract
[Scripts] *** Context:md.NPC_Shiptrader.RecycleCrew: Assigned commander Kaylen Cheram 0x72713 to Station Administration
[Scripts] *** Context:md.NPC_Shiptrader.RecycleCrew: 2/2 engineer Cerise Gisler 0x59029 now being recycled
[Scripts] *** Context:md.NPC_Shiptrader.RecycleCrew: Received 36 101 Credits from Capital Ship Dealer Kareen Claassen for Engineer Cerise Gisler's contract
[Scripts] *** Context:md.NPC_Shiptrader.RecycleCrew: Assigned engineer Cerise Gisler 0x72722 to Station Administration
[Scripts] *** Context:md.NPC_Shiptrader.LogWriter: Hull Wares added to Capital Shipyard I, bioopticwiring - 98, microchips - 86, reinforcedmetalplating - 48, scanningarray - 44, holtzmanfieldgenerator - 22, fusionreactor - 18, plasmaflowregulator - 16, machinegunturret - 8, shieldgenerator - 3,
[Scripts] *** Context:md.NPC_Shiptrader.LogWriter: Extra Wares added to Capital Shipyard I, drp_cargolifter - 10, microchips - 5000,
[Scripts] *** Context:md.NPC_Shiptrader.RecycleFinished: Recycling of Rahanas QTubes in zone Gushing Spring - done
[Scripts] *** Context:md.NPC_Shiptrader.LogWriter: Final Station Cargo, drp_cargolifter 10, foodrations 7686, scanningarray 161, reinforcedmetalplating 177, plasmaflowregulator 58, microchips 5317, holtzmanfieldgenerator 80, fusionreactor 66, bioopticwiring 362, machinegunturret 24, shieldgenerator 9, energycells 14438,
[Scripts] *** Context:md.NPC_Shiptrader.DelayedDestroyShip: Rahanas QTubes destroyed
[Scripts] *** Context:md.NPC_Engineer.NPC_Destroyed: NPC_Destroyed
[Scripts] *** Context:md.NPC_Staff.NPC_Destroyed: NPC_Destroyed


=== Release history ===

- [6.4.2017 - V0.07 Public Beta]
shiprecycle_menu_cost gui - Compensate for format of version string changing in 4.10 RC3 and add extra paranoia when checking version to prevent crashing the GUI

- [24.2.2016 - V0.06 Public Beta]
shiprecycle_menu_cost gui - Add remote logging via md script to remove false positive Error messages, caused by DebugError logging commands, in debug.log that were actually informational
shiprecycle_menu_cost gui - Compensate for parameter changes to Encyclopaedia API in 4.00 RC2 to prevent Encyclopaedia buttons crashing the GUI
shiprecycle_menu_cost gui - Apply a 90% recycling factor to ship hull wares
shiprecycle_menu_cost gui - Rebalance prices to track what shipbuilders pay to buy back ships (80%), drones (85%) and ammunition (90%)
shiprecycle_menu_cost gui - Add an extra 10% handling charge to wares that could be sold to the station by the player before the ship is recycled. As the Teladi say "time is money".
shiprecycle_menu_cost gui - Changed API call used for calculating free space to take into account the available space for the ware instead of total available space
shiprecycle_menu_cost gui - Fix issue with calculating refund when recycling where there is no storage space for a specific ware. Now correctly refunds 50%
shiprecycle_menu_cost gui - Adjusted on screen messages a litle for when ware doesn't all fit into shipyard storage
shiprecycle_menu_cost gui - Suppress Drone section when there are no drones

- [11.1.2016 - V0.05 Public Beta]
shiprecycle_menu_cost gui - Fixed failure to recycle any ships when there was zero energycells or foodrations on the shipyard which will happen with a brand new player shipyard
- [10.12.2015 - V0.04 Public Beta]
Completely rewrote the ship selection user interface using customised versions of menu_property.lua and menu_buildcost.lua
Moved ship selection logic out of md script and into the GUI
This means that you cannot select a ship for recycling that does not fit in the ShipTraders cradle unlike previous versions where this was allowed initially but detected later and the process aborted
RecycleCostMenu checks the shipyard prerequisites before allowing you to OK which again avoids a later abort for lack of ShipTrader resources
The GUI API calls can get the shields and turrets from a ship that is Out Of Zone (OOZ) so the restriction on the recycled ship being in the same zone as the player has gone
No longer shares the sellship confirm menu so it makes one less change to ShipTrader.xml
Now recycles installed drones, ammunition and cargo
When recycling cargo it pays the full price for any wares that will fit in station storage and 50% if they do not fit or are not standard wares for a shipyard
When cloning the crew to the shipyard bar it now keeps their original names
Now multi lingualwhich means that a lot of the messages will have changed subtly to fit existing translated words
Now makes a single fund transfer for all crew contracts to cut down on event monitor messages
Now uses the FormatThousands library to format the money amounts with a separator between thousands
Removed ship selection logic and its event monitor messages from md script
Removed ship building ware estimate code from md script as this is now done in the RecycleCostMenu lua script which means that it no longer builds a dummy ship to find the necessary wares
Removed ship turret and shields finding code from md script as this is now done in the RecycleCostMenu lua script
Modified the station stocking code to use the less complicated array that RecycleCostMenu creates
Replaced the turret and shields stocking code with a simple loop that adds the drones, ammunition and cargo to the station from another array that RecycleCostMenu creates
- [27.3.2015 - V0.03 Public Beta]
Interoperability - added support for Combined Docks example code by UniTrader even though its not on Steam or Nexus
- [13.3.2015 - V0.02 Public Beta]
Major change - Removed use of boarding pods to transport crew onto shipyard, crew contracts now sold to the shipdealer and they stay on board ship
Pays player for crew and recreates NPC's with same skills as ship crew on shipyard where they can be hired by player.
Tries to put recreated crew in the bar if there is room otherwise picks any docking bay that has space.
Converts the player owned NPC's that were transported to the shipyard via boarding pod while running version 1 of this script into hireable NPC's and pays player for them
Fixes an issue where recycling was refused due to insufficient shipyard resources caused the commander of the ship that was being recycled to get a blackboard entry of $shiptrader_docking added which prevented that ship from ever being recycled or sold.
- [14.12.2014 - V0.01 Public Beta]
Initial Release