basic shipbroker info

Freeform discussion about anything related to modding Transcendence.
Post Reply
relanat
Militia Captain
Militia Captain
Posts: 941
Joined: Tue Nov 05, 2013 9:56 am

The Ship Broker added to the game in version 1.8b1 is a great feature.

Here's some info on why ships appear at some stations and not others and why they appear at all and others don't. Hopefully this info will help anyone who wants to add mod playerships to the game. I'm assuming a basic level of modding knowledge. Knowing how to decompile Transcendence.tdb and edit the resulting .xml files in an editing program will let you get the most from this topic. As will knowing how to use the debug screen.

The ship broker feature is controlled by the code in ShipBroker.xml. But that all happens automatically so fortunately (actually very fortunately because there is some complex code in there!) we don't need to look at it.

Instead we look at the playership code and the station code of stations that offer the ship broker feature.

There are 14 new playerships which have been added to the game in Version 1.8b1. Their code is in StdPlayerShips.xml. We'll use the first one as an example. It's a Centurion, &scCenturionBlock2PlayerL6;. Here's the first bit of its code.

Code: Select all

<ShipClass UNID="&scCenturionBlock2PlayerL6;"
		manufacturer=		"Pacific Defense Corporation"
		class=				"Centurion"
		type=				"heavy gunship"

		attributes=			"commonwealth, military, pacificDefense, shipBroker"
		inherit=			"&scCenturionBlock2;"
		>
One of the relevant bits of code is the attributes. One of them is "shipBroker".
To get a ship to appear for sale at a Ship Broker, that ship must have this attribute. If it doesn't, the code in ShipBroker.xml will ignore it. George tells us this in the API 40 Ministry topic and also some other info we need to know which is mentioned later.
Note that this ship also has the attributes "commonwealth" and military". These will be needed later.

The other relevant piece of information we need for this ship is its level. George has conveniently let us know what this is in the UNID name, scCenturionBlock2PlayerL6 (thank you). The "L6" that has been added at the end tells us it is a level 6 ship.
This can also be found by using (typGetProperty &scCenturionBlock2PlayerL6; 'level) or, if you are in this Centurion, (objGetProperty gPlayership 'level).

So we have a level 6 Centurion playership with the attributes "shipBroker", "commonwealth" and "military".

Other playerships have different attributes and levels. The EI200 playership, &EI200PlayerL4;, is a level 4 ship with the "commonwealth" and "shipBroker" attributes , but not "military".

Now we move to the station code.
Every station that has a Ship Broker has information in its code in <SellShip> and <BuyShip> blocks.

Here's that code from the Commonwealth Dry Docks (&stCommonwealthDryDock in Commonwealth.xml):

Code: Select all

<SellShip	criteria="s +commonwealth; +systemLevel:0-2; -military; -notStandard; -notForSale;" priceAdj="100"/>
<BuyShip	criteria="s L:1-7; -notForSale;" priceAdj="80"/>
It's always inside the <Trade> block of code.

This code determines which ships the station will sell and buy.
The <SellShip> element can be translated as:
The station will sell ships (the 's' at the beginning of the criteria) that have the attribute "commonwealth" but not if they have any of the attributes "military", "notStandard" or "notForSale".
There is also the criteria of "+systemLevel:0-2;" in there. This is new to Version 1.8b1 and I'll quote George to explain it. This is from the API 40 Ministry topic.
The +systemLevel:nn special attribute allows searching for types relative to the current system level. For example, +systemLevel:0 selects only types that are equal to the system level. +systemLevel:0-2 selects types that are between the system level and 2 levels above the system level (inclusive).
Star systems also have levels. Eridani is a level 1 system, Rigel is level 3 and Pt Juno is level 8. This can be determined using the 'sysGetLevel' function.
So if the dry dock is in a level 3 system (and there are two in Rigel) it will sell level 3 ships and also ships up to level 5 (two levels higher). Level 2 ships won't appear for sale and neither will level 6 ships.
Because Eridani is a level 1 system, the Starton Dry Dock in Eridani will only sell ships of level 1 to 3. The added playerships, however, are all level 4 or above so this explains why there aren't any ships for sale in Eridani.
Note that the "ShipBroker" attribute isn't mentioned here. This is because the code in ShipBroker.xml automatically ignores any ship without this attribute.

So how does this relate to the example playerships. Neither of them will appear for sale in the Eridani dry dock because they are both above level 3.
The Rigel dry docks will sell ships from level 3 to 5 so the EI200 can be sold there because it is level 4. And it has the attribute "commonwealth" but not "military", "notStandard" or "notForSale".So it matches.
The Centurion will never be offered for sale at a dry dock because it has the attribute "military". Even if the dry dock is in a level 4 system, so will sell ships from level 4 to 6, the level 6 Centurion wont appear because it has the "military" attribute.

Now lets look at the Commonwealth Fortresses which also have a Ship Broker.
The station code is:

Code: Select all

<SellShip	criteria="s +commonwealth; +military; +systemLevel:0-2; -notStandard; -notForSale;" priceAdj="100"/>
<BuyShip	criteria="s L:1-7; -notForSale;" priceAdj="80"/>
Very similar to the dry dock code but here instead of being excluded for having the "military" attribute, ships must have that attribute to be offered for sale.
Also note that Commonwealth Fortresses are limited to level 4 to level 7 systems (this is defined in the station code).
So you would never be able to buy a level 3 ship at a Comm Fortress because they don't occur in level 3 systems. Similarly you can only buy level 9 ships at a Comm Fortress if it is in a level 7 system.
Checking back with our example ships, you will never see an EI200 for sale in a Comm Fortress. Even if the Fortress is in a level 4 system, so will buy level 4 ships, the EI200 doesn't have both the "commonwealth" and "military" attributes, only "commonwealth" so is excluded from the list.
The level 6 Centurion, however, can be sold as it has both the right level and both necessary attributes. The only exception is if the Fortress is in a level 7 system. Then the Centurion's level isn't high enough so it won't appear.


A quick look at Point Juno.
Station code is:

Code: Select all

<SellShip	criteria="s L:7-9; +commonwealth; +military; -notStandard; -notForSale;" priceAdj="100"/>
<BuyShip	criteria="s L:1-9; -notForSale;" priceAdj="80"/>
Very similar to the Fortresses except for the system level criteria. Here it is in the format "L:7-9;" This is a fixed form of level criteria. The ships offered for sale can only be level 7 to 9. I assume this is because Point Juno station is unique and always in the level 8 point Juno system so a varying system level criteria isn't needed.

That'll do for now. I still need to work out how swapping ships affects things. Until then I hope this helped.
As always please post any additional information or let me know if anything is incorrect.
Stupid code. Do what I want, not what I typed in!
Post Reply