From 1213d00b816ee8e293b696b7b7a43c0e776a6370 Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Thu, 22 Aug 2024 01:09:40 +0200 Subject: [PATCH] NameGen - Spice up the station names * Add separate name formats for asteroids: NameGen.asteroidStarportFormats = {} * Occasional Roman numerals to planet names * Add new station names/functions * Add occasional random station number --- data/libs/NameGen.lua | 83 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 73 insertions(+), 10 deletions(-) diff --git a/data/libs/NameGen.lua b/data/libs/NameGen.lua index 42cf9b006d2..5139d479d8e 100644 --- a/data/libs/NameGen.lua +++ b/data/libs/NameGen.lua @@ -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 = { @@ -19,6 +20,7 @@ NameGen = { orbitalStarportFormats = {}, surfaceStarportFormats = {}, + asteroidStarportFormats = {}, -- -- Function: FullName @@ -120,28 +122,48 @@ 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 .. "'") @@ -149,7 +171,9 @@ NameGen = { } NameGen.outdoorPlanetFormats = { - "{name}", + "{name} {suffix}", + "{name} {suffix}", + "{name} {suffix}", "{name}'s World", "{name}world", "{name} Colony", @@ -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", @@ -170,7 +196,10 @@ NameGen.rockPlanetFormats = { } NameGen.orbitalStarportFormats = { - "{name}", + "{name}{number}", + "{name}{number}", + "{name}{number}", + "{name}{number}", "{name} Spaceport", "{name} High", "{name} Orbiter", @@ -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", @@ -209,6 +247,8 @@ NameGen.surfaceStarportFormats = { "Fortress {name}", "{name} Base", "{name} Station", + "{name} Base{number}", + "{name} Station{number}", "{name}ton", "{name}ville", "Port {name}", @@ -216,6 +256,29 @@ NameGen.surfaceStarportFormats = { "{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