I am working on large map and ran into an issue. I want to have it set up so town centers add to the build cap of limited structures (and maybe certain units) but the issue is that there doesn’t seem to be any way to really accomplish this.
I was initially going to setup a trigger to increase the caps per town centers constructed but there doesn’t seem to be a direct way of doing that or replicating the way dryads work.
Granted know how to just outright disable/increase build limits outright I just want to do this in a creative way.
Altering the Delta to a kbUnitTypeCount, instead of a number, gets the desired behavior. Make sure Relativity is Assign, not Absolute.
Editing to add: You can’t type directly into the field, so you’ll have to copy-paste what you want in there. If you want some base number outside of the number of TCs, adding a number to the end works.
An example of hoplites matching TC count, with a base count of 5:
kbUnitTypeCount(“TownCenter”, 1, cUnitStateAlive) + 5
With that example, if you had 4 TCs, you would be able to build 9 hoplites. If you then lose 2 TCs, it will go down to 7 hoplites.
Also, the 1 refers to which player it’s pulling the count from.
For example:
kbUnitTypeCount(“TownCenter”, 8, cUnitStateAlive) would count how many TCs player 8 has.
Finally, the trigger should also be set to loop, else it will only run once.
1 Like
Ah was going to give thanks but for some reason I am getting an error instead.
(this map is blank execpt for 12 setttlments, a P2 Town center, and 9 plenty vaults for testing) also had a construction speed boosted on a seprate trigger but I unfortunately I can confirm what you want me to input seems to be causing the error
Edit: also will note there is a slight issue with this method, I was going to ask though if it was possible to add a larger number than one per town center but then I encountered the glitch
The expression returns a number so you can apply math to it like any other.
kbUnitTypeCount(“TownCenter”, 1, cUnitStateAlive) * 5 for example would give you 5 per TC.
As for the error, looks like a formatting error. If you upload a screenshot I can help you out.
I directly input it it in delta the exact same way as your example so a screenshot isn’t going to tell you much unless your imputing it in an unorthodox way.
Ah, I managed to replicate your issue. When I copy-pasted it from this forum, it popped up that error. When I instead copy-paste it from Notepad, it works just fine. I honestly don’t know why that happens. Best guess is to try copy-pasting it from a different source until you find one that works.
1 Like
figured it out for some reason the " surrounding TownCenter is being handled as erroneous characters acording to the temp file used to store to store the info.
Edit: So yeah something is corrupting the character
Glad you got it figured out, but that made me think to check the files to see what the difference was codewise.

Top is copied from the forum, bottom is Notepad. Literally just different types of quotation marks.
Edit: I’d try putting quote marks back in, it needs those to perform properly.
1 Like
hmmm I think I will do a test then
kbUnitTypeCount("TownCenter", 1, cUnitStateAlive) * 10
kbUnitTypeCount(“TownCenter”, 1, cUnitStateAlive) * 10
bingo can confirm the issue myself here.
edit I think the real issue is the forum is converting double ’ into " to be more correct
1 Like
I guess this is exactly why they have that feature for code. I should try to remember to use that in the future, to make it more easily copy-pasted.
1 Like
well with that issue sorted I wanted to give proper thanks as when imputed properly it solves my original issue.