Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP lore/worldbuilding/station lobby #5283

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions data/lang/lore/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"" : {
"description" : "",
"message" : ""
},
"SOL_EARTH_LONDON" : {
"description" : "",
"message" : "Traditional center of civilization. Has recovered quite well after last centurys flooding disasters, although many of the cultural landmarks will never be restored to their former glory."
},
"SOL_EARTH_MOSCOW" : {
"description" : "",
"message" : "Moscow Spaceflight museum is a must see! See how it all started, including an actual moon lander recovered from the moon! Beware of hawkers selling moon rocks for souvenirs, often buying a ticket to the moon is cheaper."
},
"SOL_EARTH_SHANGHAI" : {
"description" : "",
"message" : "Industrial powerhouse of Earth. Dont forget your hazmat suit if you want to venture outside."
},
"SOL_MARS_CYDONIA" : {
"description" : "",
"message" : "Home of the core systems champion gravball team, the Little Green Men."
},
"SOL_MARS_OLYMPUS" : {
"description" : "",
"message" : "Dont forget to enjoy the longest ski slope within a hundred lightyears!"
},
"SOL_MERCURY_CALORIS" : {
"description" : "",
"message" : "Located in Caloris Planitia, one of the largest impact craters in the system. Mercury being so close to the sun has lead to most things around here being named accordingly, 'Calor' even means 'heat' in latin and here there is a surplus of it. The almost unlimited solar power has been put to good use in the recycling business."
}
}
4 changes: 2 additions & 2 deletions data/lang/ui-core/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@
},
"STATION_DOCKS": {
"description": "Information shown in the station lobby, for total number of docking pads",
"message": "Our total capacity is {total_docking_pads} docking pads."
"message": "Your ship is docked on pad {shipbay} out of {bays} docking pads."
Copy link
Contributor

@bszlrd bszlrd Sep 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea! Is the "out of bays" part necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont know but see the diff, how many bays there are in the station was all there was before, I only added the shipbay

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, then I realized that you replace the line, not adding another about the pads. Sorry

},
"STATION_LOCAL_GRAVITY": {
"description": "",
Expand Down Expand Up @@ -1925,7 +1925,7 @@
},
"TECH_CERTIFIED_MILITARY": {
"description": "Lobby screen shows the tech level of the station",
"message": "This installation holds a military technology clearance."
"message": "This installation holds a military technology certificate."
},
"TEXTURE_COMPRESSION": {
"description": "",
Expand Down
48 changes: 35 additions & 13 deletions data/libs/SpaceStation.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,28 @@ local l = Lang.GetResource("ui-core")

function SpaceStation:Constructor()
-- Use a variation of the space station seed itself to ensure consistency
local rand = Rand.New(self.seed .. '-techLevel')
local rand = Rand.New(self.seed .. 'techLevel')
local techLevel = rand:Integer(1, 6) + rand:Integer(0,6)
if Game.system.faction ~= nil and Game.system.faction.hasHomeworld and Game.system.faction.homeworld == self.path:GetSystemBody().parent.path then
local isHomeworld = 0
if Game.system.faction ~= nil and Game.system.faction.hasHomeworld and self.path:IsSameSystem(Game.system.faction.homeworld) then
techLevel = math.max(techLevel, 6) -- bump it upto at least 6 if it's a homeworld like Earth
isHomeworld = 1
end
-- cap the techlevel lower end based on the planets population
techLevel = math.max(techLevel, math.min(math.floor(self.path:GetSystemBody().parent.population * 0.5), 11))
self:setprop("techLevel", techLevel)
self:setprop("isHomeworld", isHomeworld)
local props = self:GetPropertyDefaults()
if props == nil then return end
for k,v in pairs(props) do
if k and v then
self:setprop(k, v)
end
end
if self.techModifier then
local tmp = self.techLevel + self.techModifier
self:setprop("techLevel", (tmp <= 10) and tmp or 10) -- maximum adjusted level: 10
end
end

local equipmentStock = {}
Expand All @@ -49,18 +63,22 @@ local function updateEquipmentStock (station)
if e == hydrogen then
equipmentStock[station][e] = math.floor(rn/2 + Engine.rand:Integer(0,rn)) --always stock hydrogen
else
local pricemod = Game.system:GetCommodityBasePriceAlterations(key)
local stock = (Engine.rand:Integer(0,rn) + Engine.rand:Integer(0,rn)) / 2 -- normal 0-100% stock
if pricemod > 10 then --major import, low stock
stock = stock - (rn*0.10) -- shifting .10 = 2% chance of 0 stock
elseif pricemod > 4 then --minor import
stock = stock - (rn*0.07) -- shifting .07 = 1% chance of 0 stock
elseif pricemod < -10 then --major export
stock = stock + (rn*0.8)
elseif pricemod < -4 then --minor export
stock = stock + (rn*0.3)
if station.noCargoForSale then
equipmentStock[station][e] = 0
else
local pricemod = Game.system:GetCommodityBasePriceAlterations(key)
local stock = (Engine.rand:Integer(0,rn) + Engine.rand:Integer(0,rn)) / 2 -- normal 0-100% stock
if pricemod > 10 then --major import, low stock
stock = stock - (rn*0.10) -- shifting .10 = 2% chance of 0 stock
elseif pricemod > 4 then --minor import
stock = stock - (rn*0.07) -- shifting .07 = 1% chance of 0 stock
elseif pricemod < -10 then --major export
stock = stock + (rn*0.8)
elseif pricemod < -4 then --minor export
stock = stock + (rn*0.3)
end
equipmentStock[station][e] = math.floor(stock >=0 and stock or 0)
end
equipmentStock[station][e] = math.floor(stock >=0 and stock or 0)
end
else
equipmentStock[station][e] = 0 -- commodity that cant be bought
Expand Down Expand Up @@ -141,6 +159,10 @@ end
--
function SpaceStation:GetEquipmentStock (e)
assert(self:exists())
if not equipmentStock or not equipmentStock[self] or not equipmentStock[self][e] then
print("equipmentStock is incomplete/missing")
return 0
end
return equipmentStock[self][e] or 0
end

Expand Down
66 changes: 42 additions & 24 deletions data/pigui/modules/station-view/01-lobby.lua
Original file line number Diff line number Diff line change
Expand Up @@ -228,28 +228,24 @@ end

local function drawPlayerInfo()
local station = Game.player:GetDockedWith()
if not station or not shipDef then return end

if(not (station and shipDef)) then return end

local tech_certified

if station.techLevel == 11 then
tech_certified = l.TECH_CERTIFIED_MILITARY
else
tech_certified = string.interp(l.TECH_CERTIFIED, { tech_level = station.techLevel})
end

local station_docks = string.interp(l.STATION_DOCKS, { total_docking_pads = string.format("%d", station.numDocks),})
local substrings = { shipbay = station:GetAssignedBayNumber(Game.player) + 1,
bays = string.format("%d", station.numDocks),
tech_level = station.techLevel }

local tech_certified = (station.techLevel >= 11) and l.TECH_CERTIFIED_MILITARY or string.interp(l.TECH_CERTIFIED, substrings)
local station_docks = string.interp(l.STATION_DOCKS, substrings)
local orbit_period = station.path:GetSystemBody().orbitPeriod

local station_frameBody = Space.GetBody(station.path:GetSystemBody().parent.index)
local local_gravity_pressure = ""
if station.type == "STARPORT_SURFACE" then
if station.path:GetSystemBody().parent.hasAtmosphere then
local_gravity_pressure = string.format(l.STATION_LOCAL_GRAVITY_PRESSURE, (station.path:GetSystemBody().parent.gravity/9.8), station_frameBody:GetAtmosphericState(station))
local local_conditions = ""
if station.isGroundStation then
local myBody = station.path:GetSystemBody()
if myBody.parent.hasAtmosphere then
local parentBody = Space.GetBody(myBody.parent.index)
local_conditions = string.format(l.STATION_LOCAL_GRAVITY_PRESSURE, (myBody.parent.gravity/9.8), parentBody:GetAtmosphericState(station))
else
local_gravity_pressure = string.format(l.STATION_LOCAL_GRAVITY, (station.path:GetSystemBody().parent.gravity/9.8))
local_conditions = string.format(l.STATION_LOCAL_GRAVITY, (myBody.parent.gravity/9.8))
end
end

Expand All @@ -266,16 +262,38 @@ local function drawPlayerInfo()
local infoColumnWidth = conReg.x - widgetSizes.faceSize.x - widgetSizes.windowPadding.x*3
local lobbyMenuHeight = widgetSizes.buttonSizeBase.y*3 + widgetSizes.itemSpacing.y*3 + widgetSizes.windowPadding.y*2
local lobbyMenuAtBottom = (conReg.y - widgetSizes.faceSize.y > lobbyMenuHeight + widgetSizes.windowPadding.x*2)

local tabLines = { { tech_certified, "" }, { station_docks, "" } }
if station_orbit_info ~= "" then
table.insert(tabLines, { station_orbit_info, "" })
end
if local_conditions ~= "" then
table.insert(tabLines, { local_conditions, "" })
end
ui.child("Wrapper", Vector2(0, lobbyMenuAtBottom and -lobbyMenuHeight or 0), {}, function()
ui.child("PlayerShipFuel", Vector2(infoColumnWidth, 0), {"AlwaysUseWindowPadding"}, function()
local curPos = ui.getCursorPos()
textTable.withHeading(station.label, orbiteer.xlarge, {
{ tech_certified, "" },
{ station_docks, "" },
{ station_orbit_info, "" },
{ local_gravity_pressure, ""},
})
--tabLines contain basic station information
textTable.withHeading(station.label, orbiteer.xlarge, tabLines )

-- lore text for this station, if any
local loretext = station.nolanglore or nil
if loretext == nil and station.lore ~= nil then
local lorelang = Lang.GetResource("lore")
loretext = lorelang[station.lore]
end
if loretext ~= nil then
ui.separator()
ui.pushTextWrapPos(infoColumnWidth)
ui.textWrapped(loretext)
ui.popTextWrapPos()
end

if station.visualID ~= nil then
local licensetext = "Station License: "..station.visualID
local lXY = ui.calcTextSize(licensetext)
ui.setCursorPos(Vector2(infoColumnWidth - lXY.x - 6, curPos.y))
ui.text(licensetext)
end

if not lobbyMenuAtBottom then
lobbyMenu(Vector2(curPos.x, conReg.y - lobbyMenuHeight))
Expand Down
2 changes: 1 addition & 1 deletion data/pigui/views/mainmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ local max_flavours = 22
local startLocations = {
{['name']=lui.START_AT_MARS,
['desc']=lui.START_AT_MARS_DESC,
['location']=SystemPath.New(0,0,0,0,18),
['location']=SystemPath.New(0,0,0,0,22),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an instance of '0,0,0,0,18' in /src/main.cpp also. For starting from the command line.

['logmsg']=lui.START_LOG_ENTRY_1,
['shipType']='sinonatrix',['money']=100,['hyperdrive']=true,
['equipment']={
Expand Down
50 changes: 50 additions & 0 deletions data/world/WORLD.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
world/factions/<##_name>.lua

Contains properties of factions

## determines order of precedence when loading
Name filename only. faction name is determined by contents of the file

world/systems/<##_Name>.lua

Contains manually created layouts of star systems

## determines order of precedence when loading
Name filename only. faction name is determined by contents of the file

world/stations/<faction>.json
world/stations/<system>.json
world/stations/<system+station>.json
world/stations/<system>/<station>.json

Contains patch properties for individual stations.
Faction is the first to be loaded, then system, then both (or either) system+station files.
Any attribute in earlier files that reoccur in later loaded files will be overridden by the
last loaded. For example, faction values can be overridden by specific station files.

Stations Json format:
{
"<PropertyName>" : {
"value" : "<content>"
},
...
}

Properties are passed to station:setprop(<PropertyName>, <content>) for all properties
in SpaceStation:Constructor() (libs/SpaceStation.lua).
If PropertyName contains other keys than "value", those are ignored.
Safe to use "comment" for example.

Recognized PropertyName's:

techLevel Override stations randomly generated techLevel

techModifier Alter the randomly generated techLevel by this number, up to a max of 10 or a minimum of 1

lore Use this key, translated from lang/lore/*.json, as station lore text

nolanglore Use this text as-is, as station lore text
overrides lore

noCargoForSale (true/false) if present and not false, sets all cargo stocks except hydrogen
to zero. cargo can still be sold.
File renamed without changes.
8 changes: 8 additions & 0 deletions data/world/stations/00000000-Sol/Caloris.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"techLevel" : {
"value" : "10"
},
"lore" : {
"value" : "SOL_MERCURY_CYDONIA"
}
}
8 changes: 8 additions & 0 deletions data/world/stations/00000000-Sol/Cydonia.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"techLevel" : {
"value" : "10"
},
"lore" : {
"value" : "SOL_MARS_CYDONIA"
}
}
5 changes: 5 additions & 0 deletions data/world/stations/00000000-Sol/London.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lore" : {
"value" : "SOL_EARTH_LONDON"
}
}
5 changes: 5 additions & 0 deletions data/world/stations/00000000-Sol/Moscow.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lore" : {
"value" : "SOL_EARTH_MOSCOW"
}
}
5 changes: 5 additions & 0 deletions data/world/stations/00000000-Sol/OlympusMons.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lore" : {
"value" : "SOL_MARS_OLYMPUS"
}
}
5 changes: 5 additions & 0 deletions data/world/stations/00000000-Sol/Shanghai.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"lore" : {
"value" : "SOL_EARTH_SHANGHAI"
}
}
6 changes: 6 additions & 0 deletions data/world/stations/SolarFederation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"techModifier" : {
"comment" : "added to the techLevel of all Solar Federation stations, up to 10 max",
"value" : "1"
}
}
Loading