Peter1138/Towngrowth Challenge

From OpenTTD
Jump to: navigation, search

This is the project page for the Towngrowth Challenge, based on the [Openttd Challenge Spinoff] by Korenn. Hopefully, this project will allow the gameplay to be viable for trunk inclusion.


Towngrowth Challenge (TC) gameplay goals:

Each game started with TC has a population goal set, which can be defined at the beginning of the game and is immutable once the game has started. Once a company's claimed population reaches the population goal, that company wins the game. After the game is won, play can continue in the normal fashion but without scoring (like in regular ttd). The normal ttd game rules still count, so construction still costs money and a company losing too much money will go bankrupt.

additional rules and definitions:

  • the claimed population of a company is the sum of the population of all towns claimed by that company
  • a town is claimed by the company that delivered the highest amount of cargo units to it. The cargo that counts towards this are passengers, mail, water, food, goods and valuables

With these rules the challenge becomes to make the towns you have claimed grow. But other than in normal ttd, the towns do not grow unless their demands are met.

TC introduces 7 classifications for towns: The cargo deliveries mentioned are on a per month basis.

  • A small settlement of up to 300 inhabitants.
  • Communities demand either passengers or mail delivered to grow.
  • When a community is smaller than 150, it will grow on its own to make sure passenger transport is possible.
  • A village has 300 up to 600 inhabitants.
  • Villages require both passengers and mail delivered to grow.
  • Townships are villages on the edge of becoming a town, they have from 600 up to a 1000 inhabitants.
  • Townships require a larger amount of passengers and mail delivered, plus either a supply of water or food before they'll grow
  • Towns are small larger concentrations of people of 1000 to 3000 inhabitants.
  • Towns require even more passengers and mail, plus both food and water to grow.
  • A city can have from 3000 up to 6000 inhabitants.
  • Cities require large amounts of passengeers and mail, larger amounts of food and water, and either goods or valuables to grow.
  • A metropolis is a thriving hub of civilization with a minimum of 6000 and a maximum of 15000 inhabitants.
  • A metropolis requires all cargo: large amounts of passengers and mail, serious amounts of food and water and both goods and valuables before it will grow.
  • A capital is the largest size a town can be in TC.
  • It allows for a small amount of growth under the same requirements as a metropolis up to 15500 inhabitants, to avoid a town bouncing between metropolis and capital.
  • Once at or over 15500 inhabitants, it can no longer grow.

Towns track how many units of cargo they have received from all companies since start of game. The company with the highest amount has claim of the town and its population counts towards this company's population total. Cargo supplied to a power station belonging to a town counts as power for the town. A town with sufficient power (power demand depends on town size) grows 4 times faster than a town without power.

Cargo and industries

there are 3 types of industries in TC, internally classified as primary, secondary and tertiary industries.

  • Primary industries produce raw materials. These are the mines, plantations, etc.
  • Secondary industries process materials into cargo. Sometimes the resulting cargo requires more processing at another secondary industry. These are the factories and refineries.
  • Tertiary industries accept cargo. These industries service the towns, they are the water tower, banks, shopping mall and power station.

Only secondary industries can be funded (in fact, they will not start on their own). Tertiary industries can be funded through the town authorities, who will then decide on their own where to build that industry.

Only primary industries start as new random industries during the game.

Oilwells act like other primary industries, so they do not forcibly close down.

Overview generated by pts for OCS:

This is a graph with borders and nodes. Maybe there is an Imagemap used so the nodes may be linking to some Pages.

Bank (#12)

  • Don't build it close to Bank.
  • Build it into towns only.
  • It accepts valuables (from Bank or Jewellery) and paper (from Paper mill).
  • It produces valuables (for Bank and Shopping mall) at rate 6.
  • Uses the temperate bank graphics

Coal mine (#0)

  • Don't build it close to Power station.
  • It produces coal (for Metal foundry and Power station) at rate 15.
  • Uses the temperate coal mine graphics

Copper ore mine (#10)

  • Don't build it close to Metal Foundry.
  • It produces copper ore (for Metal foundry) at rate 10.
  • Uses the tropical copper ore mine graphics

Diamond mine (#17)

  • Don't build it close to Jewellery.
  • It produces diamonds (for Jewellery) at rate 7.
  • Uses the tropical diamond mine graphics

Factory (#6)

  • Don't build it close to Oil refinery, Metal foundry or Paper mill.
  • It accepts metal (from Metal foundry), chemicals (from Oil refinery) and paper (from Paper mill).
  • It produces goods (for Shopping mall and Town) at rate 0.
  • Uses the temperate factory graphics

Farm (#9)

  • Don't build it close to Food processing plant.
  • It produces grain (for Food processing plant) at rate 10 and livestock (for Food processing plant) at rate 10.
  • Uses the temperate farm graphics

Food processing plant (#13)

  • Don't build it close to Farm or Fruit plantation.
  • It accepts livestock (from Farm), grain (from Farm) and fruit (from Fruit plantation).
  • It produces food (for Shopping mall and Town) at rate 0.
  • Uses the tropical food processing plant graphics

Forest (#3)

  • Don't build it close to Paper mill.
  • It produces wood (for Paper mill) at rate 13.
  • Uses the temperate forest graphics

Fruit plantation (#19)

  • Don't build it close to Food processing plant.
  • It produces fruit (for Food processing plant) at rate 10.
  • Uses the tropical fruit plantation graphics

Gold mine (#15)

  • Don't build it close to Jewellery.
  • It produces gold (for Jewellery) at rate 7.
  • Uses the sub-arctic gold mine graphics

Iron ore mine (#18)

  • Don't build it close to Metal foundry.
  • It produces iron ore (for Factory2 and Metal foundry) at rate 10.
  • Uses the temperate iron ore mine graphics

Jewellery (#7)

  • Don't build it close to Gold mine or Diamond mine.
  • It accepts gold (from Gold mine) and diamonds (from Diamond mine).
  • It produces valuables (for Bank and Shopping mall) at rate 0.
  • Uses the sub-arctic printing works graphics

Metal foundry (#8)

  • Don't build it close to Iron ore mine, Coal mine or Copper ore mine.
  • It accepts iron ore (from Iron ore mine), copper ore (from Copper ore mine) and coal (from Coal mine).
  • It produces metal (for Factory) at rate 0.
  • Uses the temperate steel mill graphics

Oil refinery (#4)

  • Don't build it close to Oil rig.
  • It accepts oil (from Oil wells).
  • It produces chemicals (for Factory) at rate 0.
  • Uses the temperate oil refinery graphics

Oil wells (#11)

  • Don't build it close to Oil refinery.
  • It produces oil (for Oil refinery and Power station) at rate 12.
  • Uses the temperate oil wells graphics

Paper mill (#14)

  • Don't build it close to Forest or Factory.
  • It accepts wood (from Forest) and water (from Water supply).
  • It produces paper (for Bank and Factory) at rate 0.
  • Uses the sub-arctic paper mill graphics

Power station (#1)

  • Don't build it close to Coal mine, Oil wells or Water supply.
  • It accepts coal (from Coal mine), oil (from Oil wells) and water (from Water supply).
  • Uses the temperate power station graphics

Shopping mall (#30)

  • Build it into towns only.
  • It accepts food (from Food processing plant), goods (from Factory) and valuables (from Bank or Jewellery).
  • uses the temperate shopping mall graphics (a house)

Town (#37)

  • It accepts passengers (from Town), mail (from Town), food (from Food processing plant), goods (from Factory or Factory2) and power (via power station nearby).
  • It produces passengers (for Town) at rate 0 and mail (for Town) at rate 0.

Water supply (#21)

  • Don't build it close to Water tower or Power station.
  • It produces water (for Power station and Water tower) at rate 12.
  • Uses the tropical water supply graphics

Water tower (#22)

  • Build it into towns only.
  • It accepts water (from Water supply).
  • Uses the tropical water tower graphics

There are 19 types of cargo:

Name Bit Number Cargo Label
Passengers 00 PASS
Coal 01 COAL
Mail 02 MAIL
Oil 03 OIL_
Livestock 04 LVST
Goods 05 GOOD
Grain 06 GRAI
Wood 07 WOOD
Iron Ore 08 IORE
Metals** 09 STEL*
Valuables 0A VALU
Paper 0B PAPR
Food 0C FOOD
Fruit 0D FRUT
Copper Ore 0E CORE
Water 0F WATR
Chemicals*** 10 RFPR
Diamonds 11 DIAM
Gold 12 GOLD

* For compatibility this is in Steel's cargo slot. ** Metals use the steel cargo graphics. *** Chemicals use the oil cargo graphics.

Toys do not provide any function other than to create an easy type of cargo to earn some money with by transporting it from a factory to a shopping mall, which can be invaluable while setting up a large distribution network. To lessen code impact, Toys and Rubber were scrapped.

Sample of Town Growth Challenge Cargo GRF working with Pikkabird's UKRS

Playable implementation of cargo and industries:

Required Programming Changes

The goal with these changes is to do them in modules, and try and make them as minimally invasive as possible. Module definitions so far:

  • Town classification
  • Town growth
  • Town claiming
  • Scoring
  • Finish industries

Town classification

Display a classification for the town, depending on its size Could be done even for normal games?

  • add strings for classifications
a) "Community of {TOWN}"
b) "Village of {TOWN}"
c) "Township of {TOWN}"
d) "Town of {TOWN}"
e) "City of {TOWN}"
f) "Metropolis of {TOWN}"
g) "Capitol of {TOWN}"
  • update town gui title bar
if size < 300 display (a)
if size >= 300 && size < 600 display (b)
if size >= 600 && size < 1000 display (c)
if size >= 1000 && size < 3000 display (d)
if size >= 3000 && size < 6000 display (e)
if size >= 6000 && size < 15000 display (f)
if size >= 15000 display (g)

Town growth

Make growth of towns depend on the cargo delivered as described above.
Should this be made generic? allowing all cargos to potentially influence town growth, and setting demands through a newgrf interface? It would require some sort of newtown construction, with appropriate properties and callbacks.

Note: This module will bump the savegame version for TC, due to storing of delivered cargo last month and this month for each town.

  • store town cargo delivered
cargo delivered is added to its slot in Town
at end of month, this data is saved in the corresponding cargo_last_month slots
  • town growth depending on cargo delivered
compare cargo_last_month with demands defined by current town class. if sufficient -> town grows
when allowed, towns grow significantly faster than in vanilla ottd

  • water provided to a water tower counts as water supplied to the town normal TTD behaviour
  • food provided to a shopping mall counts as food supplied to the town (in addition to buildings) normal TTD behaviour
  • goods provided to a shopping mall counts as goods supplied to the town
  • valuables provided to a shopping mall or bank counts as valuables supplied to the town
  • do not accept passengers or mail originating from the same town

Town gui

below normal cargo supply text, show amount of cargo delivered to this town last month. Highlight in red any amount that is insufficient for town growth. Highlight in yellow any amount that is sufficient for growth.
If made generic, entries should be automatically generated depending on the cargos that influence town growth

Town claiming

Changes to allow a company to claim a town.

Note: This module will bump the savegame version for TC, due to storing of cargo delivery and claimant ID for each town

Town logic

Add a claimant variable; current town claimant
Add an integer entry for each possible company: holds received amount of cargo
When a company exceeds the current claimants amount of received cargo, they become the new claimant

World gui

  • print town names in company color of claiming company. non-claimed towns in gray
Create a translation table from company color to string color
print town name with string "{COLOR}{TOWN}", with parameter color: ColorTranslation(GetCompanyColor(Town->claimant))

Or add a company colour marker? What about a company-colored flag before town name?

draw company icon before town string

Advantage of this approach: works together with other town-string changing patches. Disadvantage: more code changes required.

Town gui

show company logo and name of claiming company

Town directory gui

show town names in claimed colors (and gray for unclaimed)

News ticker gui

add town claiming messages (with own category)

Add a category for Town claiming messages
Add string: "{TOWN} was claimed by {COMPANY}"
When town claimant changes, generate new message

Add claimed town status messages (same category as above) may need 2 categories: own town and opponent town
The message will only be displayed on growth, to reduce amount of bouncing messages, but can be shown multiple times, to void having to store message status.

Add string: "{TOWN} has grown to the status of Village!"  could introduce new variable {TOWNCLASS}
Add string: "{TOWN} has grown to the status of Township!"
Add string: "{TOWN} has grown to the status of Town!"
Add string: "{TOWN} has grown to the status of City!"
Add string: "{TOWN} has grown to the status of Metropolis!"
Add string: "{TOWN} has grown to the status of Capital!"
When town grows to new status, generate relevant message

Map gui

color claimed towns in company color in town view


This module takes the changes from the previous modules and gives feedback to the players. Graphs for population, information about the goal, a screen to display when someone has won the challenge.

Note: This module will bump the savegame version for TC, due to storing of graph data.

World Logic

  • check for winning conditions and if they are met do game won stuff (in the montly loop)

Player company gui

  • add line displaying total claimed population
  • add line displaying total number of claimed towns

(new) goal gui

  • short explanation of goal
  • show population goal for game win
  • show current claimed population
  • show 'top X' list, that shows each company with their claimed population, sorted to claimed population

(new) population graph

  • identical layout to standard company value graph
  • first option in the list is World Population (black?) Could be done for normal games as well?
  • on the y axis, instead of company value, show claimed population Why not both? - this is an additional graph, not a replacement
  • data points have to be stored for companies and world population

(new) game win gui

  • show player company name, player name and portrait of winner
  • show amount of days played since game start
  • show amount of cargo transported
  • store game over state, so that this window does not pop up again

Finish industries

In this final module, the last grf changes should be made for houses, and optionally the power station could be introduced (power station will bump savegame version, because amount of power needs to be stored for last month and this month).

  • disallow building of statues and fountains in towns, those drop population newhouses
  • disallow building of shopping mall, it is now an industry newhouses
  • add food acceptance to buildings (in addition to other acceptance) newhouses
  • Optionally: cargo supplied to a power station supplies power to the town, instead of cargo. a town supplied with power grows four times faster than one that is not.

Town authority gui

  • add 3 options: Fund water tower (cheap), Fund shopping mall (moderately expensive), Fund power station (expensive)
  • funding those buildings is not possible if that building already exists for this town

Korenn 09:58, 27 June 2009 (UTC)

Personal tools