Jump to content

City Building Mod (A23 & A24)

Recommended Posts

Hi all,

I'm working on a City Building mod. This mod is trying to incorporate elements of city building games like Caesar or SimCity to 0 A.D. The end goal here is to have a RTS/city building hybrid mod using 0 A.D engine. The balance between the two genres that I'm trying to achieve here is to ensure that the city building part should be fun enough without getting too complicated. 

The plan I've made consists of several phases, each with different features to implement. But currently I'm focusing on two mechanics:

I. Building placement 

  • In city building games, building placement is important. Especially housing zone. People will only live in your city if their needs are met. Job, food, desirable location. Otherwise they will leave.
  • Resource and storage building placement is also important, finding sweet spots to shorten the route without disturbing existing residences.
  • Since this is still a RTS game, effects need to be tweaked in such a way that normal player can play the game without crippling penalty, but player who takes time to plan the city can optimize it to gain edge.


  • Every building has aura that indicates their desirability, which will increase or decrease population count of nearby houses, e.g. civic building increasing nearby house population, military building decreasing it.
  • Since resource management is already complicated in 0AD, alternative implementation is using building aura to increase performance of related nearby building, e.g mining dropsite increase nearby blacksmith research speed, blacksmith increase nearby barrack training speed, etc.
  • This will cause crowds of buildings in desirable area, so to justify it every building is implied to have been constructed along with its nearby infrastructure, increasing nearby unit speed. 

Status & TODO:

Released, but with general rule. These are the desired changes and their detailed implementations.

  • Desirability: Every buildings will have different auras that affect nearby housing. (DONE)
    • Desirable
      • Wonder: +3 population cap within 80 m
      • Civic & Special (temple, library, theatron, etc): +2 population cap within 60 m
      • Other House: +1 population cap within 20 m
    • Undesirable
      • Military (barrack, dock, blacksmith etc): -2 population cap within 30 m
      • Defense (wall, tower): -1 population cap within 30 m
      • Economy & Resources (farms, mines, dropsites): -1 population cap within 30 m
    • Mixed 
      • Market: -1 population cap within 20 m,  +2 population cap within 60 m
  • Production chain: Building that functionally depends on another building will receive performance bonus (DONE)
    • Manpower: House > workers & building that consume population
      • +10% build & gather to nearby workers (female & citizen soldiers) within 20 m
      • -10% batch training time for military buildings, temple, market, and civil center within 20 m
    • Weapon: Storehouse > Blacksmith > Military 
      • Storehouse: -10% research time for blacksmith within 20 m
      • Blacksmith: -10% batch training time for military buildings
    • Resource trade: Raw resources > Market
      • Dropsites (farmstead, corral, storehouse): +10% international bonus on market within 20 m
      • Blacksmith: 10% research time for market within 20 m
  • Infrastructure: Implying that constructing building also includes paved roads and other conveniences in its vicinity (DONE)
    • Civil center +10% unit movement speed within 60 m

A complete explanation of Phase I and download link is posted here.

II. Economy

In city building games, money is usually the only resource the player needs to build the city. It can be gathered from each citizen, or received by importing resources to other cities.


New resource available to simulate productions.

  • Money: House and Economic buildings trickle money periodically. The amount of taxes will be influenced with the same rule as Phase I. The trickle should be low enough that player should spend responsibly, but should also be high enough so that it's not the first resource to run out before other resources. Money should be requirement of every building and unit creation, as it is analogous to builder/soldier salary.
  • Weapon: Blacksmith will be available to construct in town phase and trickles weapon over time. This will be used to train soldiers. It would consume wood and metal, so wood and metal resource for unit training can be removed and replaced with only food, money, and weapon. Training time should also be made faster.
  • Working animal: Horses/Elephant is trickled resources as well. Useful to train cavalry.


In progress. Money has been proven to be workable, but still tweaking 0AD GUI to support more than 4 resources. Weapon and Working animal is still being researched.


Test other impacts of new resources, finding out other uses of money, learning about Summary screen (after battle) GUI as it is bugged out on Resource Tab.

III. Citizens

City building has NPCs that simulates production chain and distribution. To enhance the experience several new citizen types can be created that work like modified Trader but between resource dropsite and market/house/blacksmith. This is still in research phase.

Feel free to criticize or ask if any of these doesn't make sense/needs work/impossible to implement in 0 A.D. I still have a lot to learn in modding 0 A.D, any feedback is welcome. I will keep updating this post if there's a new idea to share.


Thank you.



Edited by azayrahmad
added link to finished phase and link to detailed explanation
  • Like 9
  • Thanks 2
Link to post
Share on other sites
19 hours ago, Lopess said:
Great initiative, I'm sure to play, had a very interesting project of economic mod in the forum, maybe it's interesting for you.

Wow that's a loong read but worth it, @Lopess. @Monder87 is insanely talented, making the mod with such depth I can only hope. It has different purpose compared to my mod though. His mod aims to realistically simulate economy, while my economy phase was initiated merely to support my building placement mod. I think it's best that I focus on enhancing my building placement phase, perhaps later I could integrate his mod into mine to make some kind of ultimate city building simulation game. I still can't run the mod though, too many error messages. Perhaps it was made with nightly base?

18 hours ago, asterix said:

Thanks for the suggestion, @asterix. I envision the money to be tradeable and barterable just like any other resources though, so no further modification needed for now. It's amazing how the AI catches up with added resource, they quickly buy food with coins when they are about to train masses of soldiers.

  • Like 1
Link to post
Share on other sites

A little update about the mod behavior.

Here is the typical AI city layout with the mod. No change has been made to the AI.



Since the AI apparently used to play AoE2 often, it's a tradition to build farms adjacent to Civil Center, even though this is not historically accurate at all. Houses clustered together, which is good, but they build them next to mines, which is bad. 17 houses got them 138 total population.

This is me, trying to optimize population cap.



I tried plotting a realistic city. Civil Center surrounded by houses, with public places such as temple and market nearby. Farms and storehouses were built on hillside, barracks and blacksmith on the forefront. With only 14 houses in,  I've already got 143 population cap, which is 5 population (=1 house) more than a city with bad design.

So in conclusion, the mod seems to work as intended. Although now that I think about it, without mod 17 houses combined with initial population would only get you 105 population, so even without understanding city planning the AI still able to get 33 pop bonus, which is about 7 houses. I probably should tweak the effects more to not drastically changes the existing economy.

  • Like 2
Link to post
Share on other sites

City Building Mod: Building Aura

This is Phase I of my city building mod that focuses on improving building auras to simulate city-building. Download the latest version here on GitHub.



Base-building is one of the main parts of RTS games, including 0AD. However because of 0AD focus on combat, base building mostly revolves around build order, with building placement is usually optimized for resource gathering and defenses. The resulting city layout becomes strategic but unrealistic. Civic center surrounded by farms, houses built in countryside as walls; these are strategically viable but not realistic nor historically accurate. This mod attempts to bring realism of city planning to 0AD, to encourage careful building placement.



Fluctuative Population

With this mod, population cap is no longer based only on how much house you built, but also where you place it. Every single building in 0 A.D. has been revamped with new aura effects that influence desirability of its nearby area, simulated by house population. This means that a house built next to a civil center supports more population than a house in country side. Building a military base beside it will reduce the population even more. This will encourage you to find a good place to construct houses, just like a city planner would. Every building costs population to run, and default house population has been reduced by half to keep it spicy.


Production Chain

Imagine how a soldier got his weapon. Wood and metal are collected in the storehouse, then they will be brought to blacksmith to be forged, then they will be received by the soldier at the end of his training. If all of those building are very close together, the soldier doesn’t have to wait too long to receive his weapon. This mod emulates such situation by giving effects if the buildings are nearby. Storehouse fastens nearby blacksmith’s research, and blacksmith fastens nearby barrack’s training. By arranging the buildings in specific way you can optimize your barrack to pump armies as fast as possible.



Units are also affected by this mod. In real life, in the area where a city center stands, roads and other convenience are made to anticipate crowd of people running around. This mod simulates this by giving units speed boost while walking around the city center. Putting your storehouse right next to a mine also gives gatherers one extra resource to bring back.


Mix and Match

Since every building influences another, there are bound to be some compromises. Barrack will reduce nearby house population, but house will fasten barrack’s training, so if you need soldiers fast then you can build them next to each other at the cost of one population. There are so many possibilities. Experiment and discover your ultimate city that serves your strategy to conquer the world.


Improved AI

Now AI has been taught basic lessons on city planning. Beware that the nature of this mod allows AI to optimize this and might get surplus population early if you're not careful. The city pictured above is not my creation, it's purely built by AI with tremendous efficiency. New update also reduced default house population to nerf the AI because it was just that good.


Mod is available for download on mod.io (waiting for moderator's approval). It is available both for Alpha 23 and Alpha 24. Simply download the one compatible with your installed 0 A.D. version. Extract the entire content into My Games\0ad\mods\public folder and enjoy. Alternatively it is available for download at GitHub. Choose the branch according to your installed version and download. 

As I am not well versed in modding nor I am in history, please let me know if you think the modding could be improved or if it can be made more historically accurate. Enjoy!

Edited by azayrahmad
added updated info on A24 release
  • Like 2
  • Thanks 3
Link to post
Share on other sites
  • azayrahmad changed the title to [WIP] [Phase I Released] City Building Mod
3 minutes ago, Alexandermb said:

@azayrahmad i love all you said in the last post but im a singleplayer guy so... Does IA work in this mod?

I'm sorry, what do you mean by IA?

In general, this mod is basically replaces all structure templates, so if you install it with other mods that also change structures/buildings it will not work correctly.

Link to post
Share on other sites
2 minutes ago, azayrahmad said:

I'm sorry, what do you mean by IA?

In general, this mod is basically replaces all structure templates, so if you install it with other mods that also change structures/buildings it will not work correctly.

IA/AI Petra bot/PC computer will know how to use this mod or is just based on multiplayer?

Link to post
Share on other sites
53 minutes ago, Alexandermb said:

IA/AI Petra bot/PC computer will know how to use this mod or is just based on multiplayer?

I honestly didn't make any change to AI. But this mod is designed to be discoverable on gameplay, so it's not too punishing for player who doesn't know the rules but gives advantages to those who know. 

Actually Petra bot is already pretty smart, as discovered in previous post. It build houses clustered together, which invokes Neighborhood aura that boosts population. And they put military buildings far away from residence zone. It still doesn't give any regard to dropsites though, building storehouses close to houses, which I assume simply because starting resources near Civic Center. Also remember every second you use to plan the city is used by AI to build up army, so if you're not careful you can still get rushed when deciding where to build your next house (as I have too many times).

Please let me know if you have played the game and feel the AI needs improvement.

  • Like 1
Link to post
Share on other sites
12 minutes ago, Trinketos said:

How you change the building placement of the buildings?
I mean, how did you do make the ai build houses near the civic center?
i like to do somenting similar whit the fields(building outsize of the town)

I'm still learning about this, @Trinketos. I suspect queueplanBuilding.js is responsible for building coordinates, but I'm still trying to understand the code. Let me know if you find anything ;)

Link to post
Share on other sites
On 8/8/2019 at 9:29 AM, Trinketos said:

How you change the building placement of the buildings?
I mean, how did you do make the ai build houses near the civic center?
i like to do somenting similar whit the fields(building outsize of the town)

Hi @Trinketos! After studying the code and consulted with @Freagarach on this thread I finally found out the reason why field is always built near the civic center and not houses. It's indeed in queueplanBuilding.js, specifically lines 220-227. To ensure AI do not clear area near Civ Center and plot Field change line 221 to 

if (struct.resourceDropsiteTypes() && struct.resourceDropsiteTypes().indexOf("food") != -1 && !ent.hasClass("Civic"))

It will clear plot surrounding Farmstead but not Civ Center.

Also a couple of lines below that you'll want to ensure Farmstead can be built on territory border, because currently AI prevents this. Remove line 249-258. I applied these changes to my mod and now farms are always built by AI in countryside.

  • Thanks 1
Link to post
Share on other sites
On 8/8/2019 at 7:28 AM, Alexandermb said:

IA/AI Petra bot/PC computer will know how to use this mod or is just based on multiplayer?

Hi @Alexandermb! I 've just updated the mod to have AI know how to use this mod along with several other updates. Download it here at GitHub. Let me know whether the AI match is challenging enough.

Thank you.

  • Like 3
  • Thanks 1
Link to post
Share on other sites

A little update about Phase II

As I have finished patching the Phase I for both Alpha 23 and Alpha 24 (available on Mod.io) it's time for me to continue to Phase II: Economy. In this phase I attempt to make extensive change to the way economy is handled in 0 A.D. to make it more resemble city builder games, namely Impression city builders like Caesar, Pharaoh, and Zeus, and also taking some inspiration from castle builder games like Stronghold. I'm still in the research part of the process, and really overwhelmed by the code, as I'm not too familiar with Javascript. So any programmer who wishes to help is very much appreciated. 

So here's a list of things I want to accomplish in this mod, and the status of their progression:

Money resource: A new resource that cannot be gathered, but instead trickled. House and Markets will trickle money over time, which can be used to train units and construct buildings. There are many mod projects that are already implemented this modification, some of my favorites are 0abc and also Delenda Est, so I plan to add some of my own twist to it. Trickle rate is based on location desirability of each house, with ruleset already established in Phase I to make city planning has a more tangible reward.

Status: Largely finished, still tweaking the trickle rate. Also have to merge with Phase I completely before adding other changes. Adding features from other mods like tax adjustment etc (if permitted).

Secondary Resources: New secondary resources that can be produced using primary resources. Like Weapon made from wood and metal, Horses from food, etc. In city building games they usually have different building for making different weapon and there will be automated NPCs bringing wood to the fletcher and another to bring the finished bows to armory. The way to do it is probably by trickling Weapon periodically while also negative trickle on wood and metal. And also having citizens tasked to 'gather' weapon from blacksmith and drop it at barracks.

Status: Not sure if it's going to be enjoyable. Perhaps a refinement of the idea could help. I'm also not sure how to stop trickling if the primary resources goes to zero.  

Victory Condition: As with city-building tradition, several new victory conditions are planned to be added as options. Population Victory (first faction to reach 500 population), Economic Victory (reach 10000 money), etc.

Status: Still an idea, but peeking through code seems like it could be done.

Resource Cap: Just like population, I'd like to make resources have limit too. Every dropsite will increase the resource cap just like house to population. For example a Farmstead could only accept 500 food, so if it reaches 500 then all available food dropsite will stop functioning until a new one is built.

Status: Learning the code. It seems very complex as there seems to be many files that have to be changed. Hopefully I can do it. Any programmer out there that have experience in handling resource and population Javascript, I need your help.

So the most realistic part of this plan is probably the money resource and victory condition. I hope I have enough time to learn while my day job is not too hectic recently (it might change soon though).

Thanks for reading!

  • Like 8
Link to post
Share on other sites
  • 2 weeks later...

A belated update.

City Building Mod has been updated with Coin resources from Phase II. Not all of Phase II plans are completed, hopefully can be finished soon. Coin resource and how it works might sound familiar for those who played great mods like Delenda Est or especially 0abc where this mod takes a lot of inspirations from. I promised I would give it a different spin so here they are, Update 0.2.0:

  • Coin resource added. It is meant to be a measure of prosperity of your city.
  • All buildings consume Coin (negative trickle), except houses and markets/tavern. This is to simulate salary. Houses and markets generate Coin instead, to simulate taxation.
  • Houses pay different amount of taxes depending on location desirability. House beside a barrack pay less tax than house beside a wonder.
  • Units consume Food. Cavalry consume twice as much, and Elephants consume five times human food portions. Stable and kennels consume food as well
  • Building consume Wood to simulate maintenance, as wood is degradable. Bigger building consume more wood.
  • Some technologies also cost Coins where it makes sense. Phasing up always use coins.
  • Mercenaries, Champions, and Heroes cost significant amount of coins, and mercenaries also consume Coins periodically.
  • All resources can only be reduced to zero, but Coins can go negative to simulate government debts.
  • etc.

As usual, if you're interested to try the mod it is available on Mod.io and GitHub

Challenges faced on Phase II are these:

  • Resource Cap: It's still a mystery to me. I thought I could just mimic Population Cap behaviour, but turns out it's very difficult. Not only Cost.js and Player.js has to be modified, it seems GuiInterface.js should also be changed, and I still don't understand this file.
  • Victory Condition: Still figuring out how to trigger based on amount resources collected. My dream would be an option in Game Type before battle that says "Economic Victory" and the goal is to be the first to reach 50,000 Coins.
  • Secondary resources: This should be implemented alongside resource cap. Also my concern is that this is going to make unnecessary microes. Therefore I shall postpone this until later.

I'd probably dabble around Phase III meanwhile. Phase III is overhaul for Citizens to make it more interesting. Some of the main ideas I'd like to explore in this phase is to introduce a unit called Leader. A hero type unit that will be available since the beginning, replacing current cavalry. Leader is meant to be player avatar thus bestowed with advanced capabilities and aura which could be upgraded like in RPG games. I also would like to explore the possibilities of militia as starting units, which can be promoted to regular soldiers later.

Thanks for reading!

  • Like 4
  • Thanks 1
Link to post
Share on other sites
  • azayrahmad changed the title to [Phase II Released] City Building Mod
  • 2 weeks later...
56 minutes ago, bioinfornatics said:



thanks for your mod

I tried citybuildingmod_0.2.0_a23.zip but on my gameplay I am not able to get coins. Could you check my game play ?



savegame-0006.0adsave 1.33 MB · 0 downloads

Hi @bioinfornatics, thanks for trying my mod!

It seems that you use Formation Fighting mod alongside the City Building mod. This mod overwrites many changes made in mod, therefore most building don't get territory effects or produce coins. I'd probably make a compatibility patch in the future, but meanwhile I'm afraid you cannot use both mods at once.

  • Like 1
Link to post
Share on other sites

A little mod diary.

As I've mentioned before, Phase II is kind of stuck because of my limited technical knowledge. I decided to postpone the Economy phase update until I gain sufficient coding experience and start researching and developing Phase III.

So Phase III is about Citizens. The focus here is the citizens and units in 0 A.D.. What I intend to achieve in this mod is to inject more historical details beyond military functions and visuals. These are the breakdown of the plan:

  • More fleshed out social hierarchy. I'd like to depict the social life of each civs to be as close as historical reality at the time, e.g. Greco-Roman factions didn't have women as workers, Mauryan Kshatriyas didn't do manual labor (similar to Spartiates), cavalry were a luxury reserved for nobility, prevalence of slavery, etc.. Social caste should be apparent not only in their military functions but also in their civilian functions i.e. different social caste should have different gathering and building abilities and rate. Delenda Est has attempted this 
  • More realistic units and buildings functions. Priest did not heal in 0 A.D. time period, and Temples are not hospitals (this is the age where medical science were born). Civic centers in different phase should serve different functions, and not all civilization use barracks to train soldiers, especially civs that use citizen-soldier concept (barracks are for professional soldiers and citizen-soldiers were trained military skills at home/gymnasium).
  • A simple lore for contextualization. While waiting for campaign mode, I think it's not bad if we make up a little story about why skirmish map start the way it is. It is also useful as a guide to any new modification to the game to keep them thematically connected with the base game.

So I haven't implement all of these, but I'll show the example of new Athenian design. Last week I had a low intensity period at work so I used the opportunity to do some amateur research on ancient Athenian life, but I'm still no historian so feel free to criticize my draft. Forgive me for butchering ancient Greek but hopefully my points can come across.

LORE: You are a magistrate, sent by your faction leader to build an Athenian colony in a new land, and to conquer any who oppose you.


  • Civic Center: can train all Citizen units. Will be divided into three different buildings based on phase.
    • Village Center: +10 population bonus, can be used as dropsite, can be upgraded to Town Center. Use Hellenic Stoa model.
    • Town Center: +15 population bonus, can be used as dropsite, can be upgraded to City Center. Use Hellenic Royal Stoa model.
    • City Center: +20 population bonus, cannot be used as dropsite, can only have one in a game. Use Civic Center model.
  • Market: will be available in Village phase but cannot train traders until Town phase.
  • Barrack: will be renamed as Gymnasium, cannot train military unit, but all training upgrades from Blacksmith will be relocated here. Every added building increases all unit movement speed.
  • Temple: Can no longer heal or train healer. Can still research religious technologies. Every added building increases all unit attack.
  • Blacksmith: Can only research weapon & armor upgrades. Every added building increases all unit armor.
  • Gymnasium: will be renamed as Strategeion (replaces barrack), can train champion unit only (Epilektoi).


  • Academy: imported from Macedonian Library. Can train healers.
  • Embassy: Can train allied and mercenary units. Not sure about any existing building that can be used for this.
  • Fortress: Removed because it looks like medieval castle. Siege weapons will be buildable by units like in Delenda Est.
  • Stoa and Royal Stoa: Removed because used as civic center. Special units will be moved to Embassy.


  • Magistrate: Replaces starting cavalry. Your in-game avatar. Hero-like unit with building & gathering rate increasing aura. Can plot Village Center building, but cannot build by himself. Good for early scouting and rush.
  • Armored Hoplite: Replace females. Basically Elite Hoplite but trainable in Village Phase. Slow but thick armor.
  • Milita Hoplite:  Basically default hoplite, but with rank Advanced permanently.
  • Slave: Worker units trainable in market at City phase. Good at all building and gathering. Capturable.


Units and their rank will be categorized into their social class based on Solonian Constitution. This means units don't get promoted, they get assigned rank in training. 

  • Pentacosiomedimnoi: Aristocrats, founder of the city. Citizens can only build Civic and Military buildings, good at gathering food, mediocre at lumbering, bad at mining. Soldiers, move slower but stronger armor. Rank elite/champion. Units included: Armored Hoplite, Magistrate (Village), Priest (Town), Epilektoi (City).
  • Hippeis: Similar to Aristocrats, but cavalry, so cannot build, only hunt. Trainable in Town Phase. Rank Advanced. Units included: Hippeus/Cavalry swordsman.
  • Zeugitai: Commoner, middle class. Citizens can only build Economic and Defense buildings. Mediocre at gathering food and lumbering, bad at mining. As soldiers, has the same stats as vanilla Basic Hoplites. Trainable in Village Phase. Rank Advanced. Units included: Militia Hoplite (Village), Trader (Town), Healer (City).
  • Thetes: Commoner, lower class. Same citizen stat as Zeugites, but poorer so no armor. Rank Basic.Units included: Slinger (Village), Podromoi (City).

Outside of the constitution, there are other social classes:

  • Metics: Outsiders. Non Citizens soldiers. Trainable in City Phase. Units included: All mercenary and allied units
  • Slave: Workers only.
  • Mechanical and Ship: Haven't found any research on what social class handle these machines. 

Support also have expanded roles, like Trader can also be Supply Wagon that heals, Priest doesn't heal but have aura that increase attack, etc.

Let me know what you guys think!

  • Thanks 1
Link to post
Share on other sites
8 hours ago, Alexandermb said:

@azayrahmad in case you want to implement levy, theres a new animation for spear with two hands but less heavy than sarissa.

At least in ancient Athena I haven't found any source about two-handed spearman, their hoplite were always fight with spear and shield, even the peasant. It will be provided by the state if they can't afford it. This is perhaps going to be used in another civilization.

Link to post
Share on other sites
  • azayrahmad changed the title to City Building Mod (A23 & A24)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...