Map Database Modding

CREATE TABLE MapGate (\_id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, quadrant1\_id INTEGER, quadrant2\_id INTEGER, length INTEGER, danger INTEGER, active INTEGER, quadrant1\_dir INTEGER, quadrant2\_dir INTEGER);

```

### MapQuadrant

```
CREATE TABLE MapQuadrant (\_id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, regionId INTEGER, active INTEGER, factionId INTEGER);

```

* \_id : id of the quadrant
* name : the name of the quadrant
* regionId : this value is referenced in the Region table(column \_id) that links every quadrant with its tmx file ( Tiled quadrant layout)
* active: only 2 values should be used active =1 and inactive=-1
* factionId: numerical value of owner of the quadrant. Normally the owner of the quadrant is the faction that has the most planets in that quadrant.

For more info check out Modding\_Enums#Factions in the STF wiki.

### MapPlanet

```
CREATE TABLE MapPlanet (\_id INTEGER PRIMARY KEY AUTOINCREMENT, regionId INTEGER, worldId INTEGER, name TEXT, type INTEGER, size INTEGER, atmosphere INTEGER, danger INTEGER, factionId INTEGER, planetStoryId INTEGER);

```

* \_id : id of the planet
* regionId : this value is referenced in the Region table that links every quadrant with its tmx file ( Tiled quadrant layout)
* worldId: starts at 1 and is incremented by 1 for each planet of a quadrant/regionId. switching to a new quadrant restarts the counting at 1.
* name: name of the Planet/System
* type: the type of planet.For more info check out Modding\_Enums#Planet\_Types in the STF wiki.
* size: the size of the planets. For more info check out Modding\_Enums#Planet\_Sizes in the STF wiki.
* atmosphere: atmosphere of the planet.For more info check out Zones#Planet\_Atmospheres in the STF wiki.Possible values below:
	+ 1:Hard Vacuum
	+ 2:Vacuum
	+ 3:Thin
	+ 4:Very Thin
	+ 5:Standard
	+ 6:Standard
	+ 7:Dense
	+ 8:Very Dense
	+ 9:Ultra Dense
	+ 10:Extreme
* danger: defines how dangerous is the planet for its inhabitants(also how tough they are). Possible values below:
	+ 0:Very Safe
	+ 1:Safe
	+ 2:Harmless
	+ 3:Benign
	+ 4:Normal
	+ 5:Tainted
	+ 6:Hazardous
	+ 7:Toxic
	+ 8:Corrosive
	+ 9:Deadly
	+ 10:Insidious
* factionId: numerical value of owner of the planet.For more info check out Modding\_Enums#Factions in the STF wiki.
* planet story: seems to be always NULL and not used

### MapZone

```
CREATE TABLE MapZone (\_id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, planetId INTEGER, zoneType INTEGER, econRating INTEGER, starportRating INTEGER, militaryRating INTEGER, govRating INTEGER, spiceRating INTEGER, lawType INTEGER, techType INTEGER, populationRating INTEGER, explorerRating INTEGER, gatherRating INTEGER, cacheRating INTEGER, richnessRating INTEGER, dangerRating INTEGER, factionId INTEGER, zoneStoryId INTEGER);

```
In STF each planet can have 1 or 2 Zones each with different stats. In case a planet has 2 zones , each Zone can either be populated by factions or waiting to be explored by ST Captains as a wilderness zone.

* \_id : id of the zone
* name: zone name
* planetId: references the planet in the table MapPlanet(column \_id)
* zoneType:For more info check out Modding\_Enums#Zone\_Types.
* all the ratings are explained in the Zones#Urban\_Zones part of the STF wiki (all populated zones have their stats rating :econ->population and all wilderness zones have their own :explorer->richness Zones#Wilderness\_Zones).All these ratings (except econ=[1,28] ) should be in an interval [1,10] for populated zones and [1,10] for wilderness zones (@Cory for cacheRating I don't have any info on that field).

Higher ratings means: better recruits , more production of goods , capability to absorb more goods for population zones.

Higher ratings means: better cards while exploring and higher number of hands(5 cards each hand) during Exploration minigame for wilderness zones.

* danger: see planet danger for values
* factionId: numerical value of owner of the planet.For more info check out Modding\_Enums#Factions in the STF wiki. **Important note:** this value should be the same as **planet owner if it's a populated zone**!(or 0 for wilderness)
* zoneStoryId: Normally this is set to 0. If this zone is involved in a story mission this number should be non zero. (@Cory to give more details)
	+ interesting fact: Prime planets(ex:Alta Mesa Prime =8, Steel Song Prima=6) have their zoneStoryId =factionId

### Example query Get atlas from a map db in ST:F

```
select
mq.name QuadName, --Sector/Quad name,
mf.factionName PrimaryFaction, -- quad Primary Faction,
mp.name PlanetName, --System/Planet name,
mz.name ZoneName,
CASE
WHEN mz.factionId =0 THEN 'Independents'
WHEN mz.factionId =1 THEN 'De Valtos Syndicate'
WHEN mz.factionId =2 THEN 'Cadar Syndicate'
WHEN mz.factionId =3 THEN 'Syndicate Rychart'
WHEN mz.factionId =4 THEN 'House Thulun'
WHEN mz.factionId =5 THEN 'Clan Javat'
WHEN mz.factionId =6 THEN 'Steel Song Clan'
WHEN mz.factionId =7 THEN 'Moklumnue Clan'
WHEN mz.factionId =8 THEN 'Clan Alta Mesa'
WHEN mz.factionId =9 THEN 'Clan Zenrin'
WHEN mz.factionId =10 THEN 'Templar Order'
ELSE 'UNDEFINED'
END as Owner, --zone faction
mz.zoneType ZoneNType, -- zone type number
CASE
WHEN mz.zoneType =1 THEN 'Population'
WHEN mz.zoneType =2 THEN 'Farming'
WHEN mz.zoneType =3 THEN 'Mining'
WHEN mz.zoneType =4 THEN 'Refinery'
WHEN mz.zoneType =5 THEN 'Industrial'
WHEN mz.zoneType =6 THEN 'High Tech Industrial'
WHEN mz.zoneType =7 THEN 'Luxury Population'
WHEN mz.zoneType =8 THEN 'Tradeway'
WHEN mz.zoneType =9 THEN 'Wilderness'
WHEN mz.zoneType =10 THEN 'Orbital'
ELSE 'UNDEFINED'
END as ZoneType, --zone type name
mz.econRating Econ,
mz.populationRating Pop,
mz.starportRating Port,
mz.militaryRating Mil,
mz.govRating Govt,
mz.spiceRating Spice,
mz.lawType TradeLaw,
mz.richnessRating Rich, -- explorer richness
mz.explorerRating Exp, --Explorer rating
mz.dangerRating ExpDanger, --Exploration danger
mp.size PlanetNSize,--PlanetN size
CASE
WHEN mp.size=1 THEN 'Tiny'
WHEN mp.size=2 THEN 'Small'
WHEN mp.size=3 THEN 'Standard'
WHEN mp.size=4 THEN 'Large'
WHEN mp.size=5 THEN 'Huge'
ELSE 'UNDEFINED'
END as PlanetSize, --Planet size,
mp.type PlanetNType,--Planet type,
CASE
WHEN mp.type =1 THEN 'Ice'
WHEN mp.type =2 THEN 'Desert'
WHEN mp.type =3 THEN 'Desert'
WHEN mp.type =4 THEN 'Garden'
WHEN mp.type =5 THEN 'Garden'
WHEN mp.type =6 THEN 'Oceanic'
WHEN mp.type =7 THEN 'Oceanic'
WHEN mp.type =8 THEN 'Jungle'
WHEN mp.type =9 THEN 'Jungle'
WHEN mp.type =10 THEN 'Radiation'
WHEN mp.type =11 THEN 'Radiation'
WHEN mp.type =12 THEN 'Molten'
ELSE 'UNDEFINED'
END as PlanetTypeName, --Planet type Name,
mp.atmosphere AtmoN,--Planet Atmo Number,
CASE
WHEN mp.atmosphere =1 THEN 'Hard Vacuum'
WHEN mp.atmosphere =2 THEN 'Vacuum'
WHEN mp.atmosphere =3 THEN 'Thin'
WHEN mp.atmosphere =4 THEN 'Very Thin'
WHEN mp.atmosphere =5 THEN 'Standard'
WHEN mp.atmosphere =6 THEN 'Standard'
WHEN mp.atmosphere =7 THEN 'Dense'
WHEN mp.atmosphere =8 THEN 'Very Dense'
WHEN mp.atmosphere =9 THEN 'Ultra Dense'
WHEN mp.atmosphere =10 THEN 'Extreme'
ELSE 'UNDEFINED'
END as Atmo, --Atmo name
mp.danger PlanetNDanger, --Planet Danger Number
CASE
WHEN mp.danger =0 THEN 'Very safe'
WHEN mp.danger =1 THEN 'Safe'
WHEN mp.danger =2 THEN 'Harmless'
WHEN mp.danger =3 THEN 'Benign'
WHEN mp.danger =4 THEN 'Normal'
WHEN mp.danger =5 THEN 'Tainted'
WHEN mp.danger =6 THEN 'Hazardous'
WHEN mp.danger =7 THEN 'Toxic'
WHEN mp.danger =8 THEN 'Corrosive'
WHEN mp.danger =9 THEN 'Deadly'
WHEN mp.danger =10 THEN 'Insidious'
ELSE 'UNDEFINED'
END as PlanetDanger --Planet Danger Name
from MapZone mz, MapPlanet mp, MapFaction mf , MapQuadrant mq
where mz.planetId=mp.\_id
and mf.\_id=mq.factionId
and mq.regionId=mp.regionId;

```

### Query: Activate inactive gates in old default map map\_2.db

```
select
mg.\_id,
mg.quadrant1\_id,
mq.name,
mg.quadrant2\_id,
mq2.name ,
mg.active
from mapgate mg, mapquadrant mq , ( select \_id, name from mapquadrant ) as mq2
where mg.active=-1
and mg.quadrant1\_id=mq.\_id
and mg.quadrant2\_id=mq2.\_id
and mg.\_id in (6,7,20,80,85); -- ids of gates that we want to activate

-- activate the gates selected in the previous select statement
update mapgate
set active =1
where \_id in (6,7,20,80,85);

Result should be:

6 4 Les Ecumes Pass 9 Cirm Sector 1
7 9 Cirm Sector 8 Sween Belt 1
20 8 Sween Belt 15 Rhein-Ruhr Run 1
80 60 Nadello Run 61 Catherine's Pass 1
85 61 Catherine's Pass 25 Orion Expanse 1

```

### Query: Modify stats of a planet&zone in old default map map\_2.db

```
select
\*
from mapplanet mp , mapzone mz
where mz.planetId=mp.\_id
and mz.planetId=194; -- planet=Mantleforge in Quad Orion Expanse

update mapplanet
set size=5 -- 5=huge
where \_id=194; -- planet=Mantleforge in Quad Orion Expanse

update mapzone
set econRating=28,
populationRating=10
where \_id=269; -- zone=Mantleforge in Quad Orion Expanse

```