Capt. Murphy wrote:Just spotted these posts last night and had a quick look at 0.7 this morning. I think I know what is needed. Am I correct in thinking I can basically rework the the logic/code from this.specialLegalPenalty = function()
in CargoTypeExtension.js (with dryrun set to true for the permit checking calls) to create a function in Illegal Goods that will check to see if any detected contraband should be ignored (or have a reduced penalty?) as it is a specialCargo with a valid permit?
Yes, pretty much. There are some API functions you can use - but I've realised there's an edge case that you won't be able to detect with them. If you wait until 0.8 I'll add an extra function that you can use.
-
specialCargoesCarried
will say how many of which cargo IDs are currently carried: returns an array of {type,quantity} objects. (e.g. "CTE_CTS_IN7",10)
-
cargoDefinition
with the second parameter "genericType" will tell you what the base type of the cargo is (e.g. "narcotics")
- You can then call
importPermitLevel
for each type of cargo to find out if any permits apply. The number it returns should be added to the
per TC import penalty for that cargo. (e.g. -2)
There can be a slight problem sometimes, though. If the player has a permit for Insect Slaves, this will give importPermitLevel of -1. You can then add this to the penalty you would apply.
If the system has a specific ban on importing Insect Slaves, then this will give an importPermitLevel of +1. You then don't need to apply a penalty for that cargo either, because the player will have already taken a legal status hit for them.
If both apply at once, then the net importPermitLevel will be zero, but no penalty should be applied by IGT either.
I think what I'll need to do is add
importPermitDetails
which gives an array of the legal status modifiers rather than the total, for this situation. You'd then only apply IGT treatment to cargo which had a full array of zeros (and was therefore from the system's perspective identical to generic cargo).
The API is not yet entirely stable - there are some changes needed to accommodate OXP stations, though they shouldn't have much effect here - so I haven't documented it yet. As a general rule, only call functions in the "public" commented block of the cargotypeextension.js script.
Out of interest how does New Cargoes interact with things like HyperCargo and Vortex which create 'virtual' manifests.
Not sure. Very badly, I suspect - if you shove a special cargo into a virtual manifest, and don't have enough generic cargo of the right type in the new real manifest, New Cargoes will assume that the special cargo has been sold or destroyed. If you can rotate the manifests in flight then there would be even stranger effects where some of your cargo mysteriously becomes special cargo (or changes type). It'll also have odd interactions with auctions and other trade floor contracts, because player.ship.cargoSpaceAvailable is no longer reliable.
I suspect the best way to solve it is in HyperCargo/Vortex rather than New Cargoes - when those OXPs rotate the cargo bay, they need to take the New Cargoes data for the cargo with them and put it back when they rotate it back. I can add a couple of API functions to make that straightforward and talk to Thargoid about including them once they're done.