Modding Ships

For details on the tables related to ships, see Data Database Modding and the ShipType, ShipComponent, ShipAiTypeRoller, ShipDataCompartment tables

## Starting Ships

Be careful to set a startShipCost that fits within the tiers of the new game templates.

If you want to create a starting ship that is not availale in the starport, set its startShipCost, set its startingShip field to 1 and set its faction to 50. This will prevent it from appearing in the starport but allow new captains to pick it.

## Example of Adding a New Ship

* Step 0. Define what you want to make
	+ We will create a variant of the Longbolt called the Corvette with a component change.
* Step 1. Create a new entry in ShipType
	+ Find the Longbolt
		- ```
		SELECT \* FROM shipType WHERE shipType.shipTypeName= 'Longbolt'

		```
		- The Longbolt is shipType.\_id = 44
	+ Find the highest \_id so we do not overwrite an existing ship
		- ```
		SELECT MAX(\_id) FROM shipType

		```
	+ The highest \_id is 82. Ours will be 83
	+ Copy the Longbolt entry into our new ship #83
		- ```
		CREATE TEMPORARY TABLE newShip AS SELECT \* FROM shipType WHERE shipType.shipTypeName= 'Longbolt'
		UPDATE newShip set \_id = 83, shipTypeName = 'Corvette', unlockId = 0
		INSERT INTO ShipType SELECT \* FROM newShip

		```
* Step 2. Create the new entries in ShipDataCompartments
	+ Find the highest \_id so we do not overwrite existing components
		- ```
		SELECT MAX(\_id) FROM ShipDataCompartments

		```
		- The highest is 1774.
			* ShipDataCompartments will autoincrement the \_id field if you do not provide one. We'll take advantage of this later to avoid having to calculate new \_ids.
		- Replace the Dual-Arc Signal Array with a Sig Dampener (ids can be found in ShipComponents)
		- ```
		SELECT \* FROM ShipDataCompartments WHERE shipId = 44

		```
	+ Copy the Longbolt compartments (shipId = 44) into our new ship (Shipid = #83).
		- ```
		CREATE TEMPORARY TABLE newShipDataCompartment AS SELECT \* FROM shipDataCompartment WHERE shipDataCompartment.shipId= 44
		UPDATE newShipDataCompartment set shipId = 83
		UPDATE newShipDataCompartment set defaultComponent=32 where \_id = 1303
		INSERT INTO ShipDataCompartment (shipId, tmxId, size, componentType, defaultComponent, typeLocked) SELECT shipId, tmxId, size, componentType, defaultComponent, typeLocked FROM newShipDataCompartment

		```
	+ Step 3. Add to your SQL file and update your database
		- Annotate your SQL with the reasoning and effect
		- ```
		-- Add a new starting ship based upon the Longbolt
		-- Create a temporary table to store the data before inserting in the database
		CREATE TEMPORARY TABLE newShip AS SELECT \* FROM shipType WHERE shipType.shipTypeName= 'Longbolt'
		-- make the changes to the Longbolt Shiptype
		UPDATE newShip set \_id = 83, shipTypeName = 'Corvette', unlockId = 0
		-- Insert back into the ShipType table
		INSERT INTO ShipType SELECT \* FROM newShip
		-- Modify the default ship compartments
		-- create a temporary table to store the data before inserting into the database
		CREATE TEMPORARY TABLE newShipDataCompartment AS SELECT \* FROM shipDataCompartment WHERE shipDataCompartment.shipId= 44
		-- change the shipId to our new shipId
		UPDATE newShipDataCompartment set shipId = 83
		-- Replace the Dual-Arc Signal Array with a Signal Dampener
		UPDATE newShipDataCompartment set defaultComponent=32 where \_id = 1303
		-- Insert back into the ShipDataCompartment
		INSERT INTO ShipDataCompartment (shipId, tmxId, size, componentType, defaultComponent, typeLocked) SELECT shipId, tmxId, size, componentType, defaultComponent, typeLocked FROM newShipDataCompartment

		```

## Example of Modding an Existing Weapon Component

Here is an example of how to modify a ship component. In this case, the weapon the Dual-Linked Autocannon.

* Step 0. Define what you want to change
	+ We will change the Dual-Linked Autocannon in 3 ways
		- Add Pilot dice
			* Add Pilot dice equal to its ShipOps dice value minus 1
		- Change its Base To Hit Craft accuracy
			* From 65 to 80
		- Increase its Craft Defense Value
			* From 2 to 12
* Step 1. Find the relevant database entries.
	+ The Dual Linked Autocannon is a Ship Component located in the shipComponent Table.
	+ Its data can be seen with:
		- ```
		SELECT \* FROM shipComponent WHERE shipComponent.componentName = 'Dual-Linked Autocannon'

		```
	+ Find any other table entries that also effect the component.
		- It is a weapon, so it has a shipWeaponId (5)
			* ```
			SELECT \* FROM shipWeapon WHERE \_id = 5

			```
		- It has an effect, so it has a shipEffectId (192)
			* ```
			SELECT \* FROM shipEffect WHERE \_id =192

			```
		- It is not an engine, so it does not have a relevant engineId (0)
		- It is not faction specific, so it does not have a relevant factionId (0).
* Step 2. Update the relevant database entries
	+ To change the Pilot dice
		- ```
		UPDATE shipcomponent set skPilot = skShipOps - 1 where \_id = 109

		```
	+ To change the Base to Hit Craft Accuracy
		- ```
		UPDATE shipWeapon set baseToHitCraft = 80 WHERE \_id = 5

		```
		- ```
		UPDATE shipeffect set craftdefensebonus = 12 WHERE \_id = 192 -- Dual-Linked Autocannon

		```
* Step 3. Add to your SQL file and update your database
	+ Annotate your SQL with the reasoning and effect

```
-- Dual-Linked Autocannon improvements
-- Add Pilot Dice to increase defense
update shipcomponent set skPilot = skShipOps - 1 where \_id = 109 -- Dual-Linked Autocannon Component
-- Increase base to hit craft
update shipWeapon set baseToHitCraft = 80 where \_id = 5 -- Dual-Linked Autocannon Weapon
--increase craft defense bonus
update shipeffect set craftdefensebonus = 12 where \_id = 192 -- Dual-Linked Autocannon Effect

```