Skip to content

Commit

Permalink
NameGen - Spice up the station names
Browse files Browse the repository at this point in the history
* Add separate name formats for asteroids: NameGen.asteroidStarportFormats = {}
* Occasional Roman numerals to planet names
* Add new station names/functions
* Add occasional random station number
  • Loading branch information
zonkmachine authored and Webster Sheets committed Oct 5, 2024
1 parent db340e5 commit 1213d00
Showing 1 changed file with 73 additions and 10 deletions.
83 changes: 73 additions & 10 deletions data/libs/NameGen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ local Engine = require 'Engine'
local Culture = require 'culture/culture'

local r = function (t, rand) return t[rand:Integer(1,#t)] end
local romanNumerals = {"II","III","IV","V","VI","VII","VIII","IX","X","XI","XII","XIII","XIV","XV","XVI","XVII","XVIII","XIX"}

local NameGen
NameGen = {
Expand All @@ -19,6 +20,7 @@ NameGen = {

orbitalStarportFormats = {},
surfaceStarportFormats = {},
asteroidStarportFormats = {},

--
-- Function: FullName
Expand Down Expand Up @@ -120,36 +122,58 @@ NameGen = {
--
-- experimental
--

BodyName = function (body, rand)
local ascii = true -- want only ascii compatible characers in name

-- Occasional Roman numeral stuck to a planet name looks good
-- Called in the planet names with: "{name} {suffix}"
local suffix = ""
if rand:Number() < 0.4 then
local srand = 1 + math.floor((rand:Number() ^ 3) * #romanNumerals)
suffix = romanNumerals[srand]
end

if not rand then rand = Engine.rand end

-- One in three chance of a random station number. Only some formats use it.
-- Station names ending in: {number}"
local number = ""
if rand:Integer(0,2) == 0 then
number = " " .. math.min(rand:Integer(1,27), rand:Integer(1,27)) -- FIXUP: max could depend on system
end -- population or faction size.

local name = NameGen.Surname(rand, ascii)
if body.type == "STARPORT_ORBITAL" then
return string.interp(r(NameGen.orbitalStarportFormats, rand), { name = NameGen.Surname(rand, ascii) })
return string.interp(r(NameGen.orbitalStarportFormats, rand), { name = name, number = number })
end

if body.type == "STARPORT_SURFACE" then
return string.interp(r(NameGen.surfaceStarportFormats, rand), { name = NameGen.Surname(rand, ascii) })
if body.parent.type == "PLANET_ASTEROID" then
return string.interp(r(NameGen.asteroidStarportFormats, rand), { name = name, number = number })
else
return string.interp(r(NameGen.surfaceStarportFormats, rand), { name = name, number = number })
end
end

if body.superType == "ROCKY_PLANET" then

-- XXX -15-50C is "outdoor". once more planet composition
-- attributes are exposed we can do better here
if body.averageTemp >= 258 and body.averageTemp <= 323 then
return string.interp(r(NameGen.outdoorPlanetFormats, rand), { name = NameGen.Surname(rand, ascii) })
return string.interp(r(NameGen.outdoorPlanetFormats, rand), { name = name, suffix = suffix })
end

return string.interp(r(NameGen.rockPlanetFormats, rand), { name = NameGen.Surname(rand, ascii) })
return string.interp(r(NameGen.rockPlanetFormats, rand), { name = name, suffix = suffix })
end

error("No available namegen for body type '" .. body.type .. "'")
end
}

NameGen.outdoorPlanetFormats = {
"{name}",
"{name} {suffix}",
"{name} {suffix}",
"{name} {suffix}",
"{name}'s World",
"{name}world",
"{name} Colony",
Expand All @@ -159,7 +183,9 @@ NameGen.outdoorPlanetFormats = {
}

NameGen.rockPlanetFormats = {
"{name}'s Mine",
"{name} {suffix}",
"{name} {suffix}",
"{name} {suffix}",
"{name}'s Claim",
"{name}'s Folly",
"{name}'s Grave",
Expand All @@ -170,7 +196,10 @@ NameGen.rockPlanetFormats = {
}

NameGen.orbitalStarportFormats = {
"{name}",
"{name}{number}",
"{name}{number}",
"{name}{number}",
"{name}{number}",
"{name} Spaceport",
"{name} High",
"{name} Orbiter",
Expand All @@ -195,11 +224,20 @@ NameGen.orbitalStarportFormats = {
"{name} Dock",
"{name} Depot",
"{name} Anchorage",
"{name} Junction",
"{name} Connection",
"{name} Academy",
"{name} University",
"{name} Waystation",
"{name} Laboratory",
"{name} Station{number}",
"{name} Citadel",
}

NameGen.surfaceStarportFormats = {
"{name}",
"{name}",
"{name}{number}",
"{name}{number}",
"{name}{number}",
"{name} Starport",
"{name} Spaceport",
"{name} Town",
Expand All @@ -209,13 +247,38 @@ NameGen.surfaceStarportFormats = {
"Fortress {name}",
"{name} Base",
"{name} Station",
"{name} Base{number}",
"{name} Station{number}",
"{name}ton",
"{name}ville",
"Port {name}",
"{name} Port",
"{name} Pad",
"{name} Terminal",
"{name} Oasis",
"{name} Landing",
"{name} Plains",
"{name} Flats",
"{name} Fields",
"Camp {name}",
"{name} Ward{number}",
"{name} Mine",
"{name} Mine",
}

NameGen.asteroidStarportFormats = {
"{name}{number}",
"{name}{number}",
"{name}{number}",
"{name} Station",
"{name} Refinery",
"{name} Drilling Station{number}",
"{name} Depot",
"{name} Anchorage",
"Fort {name}",
"{name} Base",
"{name} Mine",
"{name} Mine",
}

return NameGen

0 comments on commit 1213d00

Please sign in to comment.