Logo Platform
logo amplifiers simplified

Tutorial: How to remove district cost scaling from extractors

Reply
Copied to clipboard!
3 years ago
Nov 15, 2021, 7:32:35 PM

I've found what I believe to be the best way at present to remove district cost scaling from extractors, and I'd like to show you how. The big issue with doing this through any means is that the only relevant variable we have access to when defining district cost scaling is ExtensionDistrictsCount, with no further specificity of what kind of districts we're accessing. So, we'll have to make do with this information.



Step 1: Removing extractors from the district count


Import Settlement > ConstructibleCommonExtensionDescriptor > Tag_Extension_Urban.


Remove the one property Settlement.ExtensionDistrictsCount.Add(1).


In the ConstructibleCommonExtensionDescriptor collection, create a new Descriptor called something like Tag_Extension_CostScaling. Add the same property which we removed from Tag_Extension_Urban, Settlement.ExtensionDistrictsCount.Add(1 ).


Import these definitions from Settlement > ConstructibleCommonExtensionDefinition: Extension_Prototype_BaseEconomy, Extension_Prototype_BaseMilitary, Extension_PrototypeBaseEmblematic.


In these three definitions, add the tag we created. Go to Own Descriptor References, click the plus, and add Tag_Extension_CostScaling.


This immediately produces favorable results, however, there are still some things that need taken care of. Notably, extractors will still count for Builder Era Stars. despite the fact that they are no longer counted as districts in the settlement. You probably don't want that, so here's how to fix it.



Step 2: Adjusting Builder Stars


Import Fame > DeedsDefinition > Deed_EraStar_Builder.


Change the Evaluator type from DeedEvaluator_SImpleAccumulator to DeedEvaluator_PropertyEvaluator.


Change the Path to MajorEmpire.Settlements.


Under Property, set Entity to Settlements, set Property to ExtensionDistrictsCount, and set Evaluation Method to Accumulte.


Under Score, change Scoring Method to Set.


That will make sure that completing an extractor, or any other district you don't want to increase scaling, will not increment the Builder Era Stars district requirement. If you build and play though, there are still some problems. Notably, on founding your first city, you will notice that you already have 1 out of 6 Districts required for the first Builder star. That's because the Main Plaza inherits from Extension_Prototype_BaseEconomy, and increases our district count, and this type of Deed Evaluator simply counts the ExtensionDistrictsCount property in all of our settlements. So there are a couple things left to tweak, if you so desire.



Step 3: Preferences


It's up to you which district types besides extractors do or do not count towards district cost scaling, but here are my recommendations. We don't want Main Plazas or Administrative Centers to count as districts, as this will mess up our builder stars


To remove Main Plazas and Administrative Centers from the district count : Import Settlement > ConstructibleCommonExtensionDefinition > {Extension_Base_CityCenter, Extension_Base_AdministrativeCenter}. Change their Prototype from Extension_Prototype_BaseEconomy to Extension_Prototype_Base.


Add the tag Tag_Extension_Urban to Extension_Base_CityCenter and Extension_Base_AdministrativeCenter.


This also has the nice effect of making it so that attaching a territory does not increase your district cost, so you don't have to wait for your district to complete to attach a territory. You want to make sure to add the Tag_Extension_Urban tag or else your main districts will not work for adjacencies.



There are some districts that do not inherit from the prototypes we changed that you may want to count for district cost scaling, including Commons Quarters, Harbors, and Train Stations. Additionally, there are some districts which you may not want to count for cost scaling, such as Nature Reserves. Their respective data paths are Settlement > ConstructibleCommonExtensionDefinition > {Extension_Base_PublicOrder, Extension_Base_Harbour, Extension_Base_TrainStation, Extension_Base_NaturalReserve}.


If you want a district to count for scaling: Make sure that it uses Extension_Prototype_BaseEconomy, Extension_Prototype_BaseMilitary, or Extension_Prototype_BaseEmblematic as its Prototype, or manually add the tag Tag_Extension_CostScaling to its definition 


If you do not want a district to count for scaling: Set its Prototype to Extension_Prototype_Base, and make sure to add Tag_Extension_Urban if you want it to benefit from generic district adjacency bonuses.


Lastly, if you run the game, you will see that on every district which does count for district scaling, the game has added the tooltip effect "+1 District". If you'd like to keep this effect to be explicit about exactly which districts do and do not increase scaling, then go ahead. If you'd like to remove this and make the district tooltips display as normal, do the following:


To remove "+1 District" on tooltips: Create a new collection of type EffectMapper > DescriptorMapperCollection named DescriptorMapperExtensionCollection, if you do not have it already. In this collection, add a new DescriptorMapper called Tag_Extension_CostScaling. Select it and check the "Hide Descriptor" box.



IMPORTANT NOTES


UNLESS ALTERED, THIS WILL MESS UP YOUR DISTRICT COST SCALING. The default district production cost formulas in Settlement > RpnIndustryDefinition > ProductionCost_Extension_Base_X, where X is Medium, High, Emblematic_EraN, etc. expect that the Main Plaza counts as a district, and so include the term (Target.ExtensionDistrictsCount - 1) where checking for how many districts are in your city. 


Change all instances of the term (Target.ExtensionDistrictsCount - 1) in all of the ProductionCost_Extension_Base_definitions to just Target.ExtensionDistrictsCount, or districts will be much cheaper than normal. Which is probably a good thing, but since you all probably changed the district cost scaling formula for your mods anyways, make sure you adjust your terms accordingly or you will encounter unexpected behavior, including 0 or negative district  production costs in some cases.


THIS WILL AFFECT THE BEHAVIOR OF SOME BONUSES.  Some Districts/Constructibles/Wonders/Legacy Traits/etc. have an effect that scales with the number of districts - the only ones I can think of right now are the Ming Grand Teahouse, the Mausoleum at Halicarnassus, and Saint Basil's Cathedral, all of which give an effect of "+X per District". These have a Path to Settlement and simply read the ExtensionDistrictsCount property, which, if you're following along no longer counts Extractors, City Centers, or Administrative Centers.


You may choose to keep this behavior and increase the effects of these bonuses to reward investment into scaling districts, or you may want to change their effects entirely. Or, if you want to keep the effects and include Extractors or any other districts which you removed from scaling costs, do the following:


To count non-cost scaling districts as districts for bonuses: Import any descriptors you want to change that give "+X per District". Change the Path from ... > Settlement to ... > Settlement > Districts. Change the Property from N * ExtensionDistrictsCount to N.


This will iterate through al Districts in the Settlement and add N resources each time, preserving the effect. And, handily enough, the tooltip works too! I don't know all the effects in the game that work like this, and I can't account for whatever you've changed in your own mod, so make sure you review your assets carefully.



Conclusion:


So that's the best way I've found to control which districts count for scaling until Amplitude expands the modding tools and exposes more possibilities. It's a bit of a hack, but it works perfectly. The only side effect is that your cities will only display how many districts they have that account for scaling, so they will appear to have fewer districts than they actually have. But other than that, I haven't found any bugs or issues with this implementation.


Please use this as you see fit in your mods; no credit needed unless you're feeling especially generous. I would put this feature in a mod myself, but I'm busy making a much more encompassing mod which uses it, so be my guest if you want to do that.


I think I covered all the steps here, but if anything is unaccounted for, or If you do find any bugs inherent to this implementation, please comment below.



Thanks for reading, and have fun!

Updated 3 years ago.
0Send private message
3 years ago
Nov 15, 2021, 9:25:25 PM

Heads up: it turns out I missed something, which is that districts that increase cost scaling display with the tooltip effect "+1 District". I added a section to Step 3 that tells you how to remove it.

0Send private message
3 years ago
Nov 16, 2021, 3:47:47 AM

I am reading with Unity open to look at the files at the same time.


Step 1.

Tag_Extension_Urban: I knew there was a place somewhere that says you add a counter to the district count. But I was sure it was not accessible in the mod tool for the moment.

Great job! It's a feat to have found this. I had searched a bit but gave up quickly.

Prototype: I look at the other Extensions, and they use prototypes. And that's where the Urban tag is shown for some. Others, like Military use the Prototype_Base which in turn uses the Urban tag. The extractors use the Base_Extractor which also uses the Urban tag.

Ok, I see how the object model links all this.


Step 2.

Ok, maybe the extractors can be left and counted to build star, too bad. But it's amazing that you were able to come up with this. Especially by changing the values here. Nothing obvious. I would have gone crazy testing this. 


Step3.

Ok, linking to the modified Urban Tag (which doesn't count districts), this avoids putting this in the era star build.

Tweak mapper: My brain has already exploded!! ahah.


All this need to make a test mod, many interactions.


Notes.

It's honest that the additional effects don't interact with the "fake districts". Especially keeping those districts counted for builder stars.


I saw a post from a developer on this forum. Apparently they are going to change the cost of districts soon in a patch. I think they will do something similar to this. Mmmh, I'll test if I have time (and it's going to take a while!), otherwise I'll wait for the update and look at what their new code looks like.


Congrats and thanks for this post. It is huge!


0Send private message
3 years ago
Nov 16, 2021, 3:54:22 PM

Yeah I saw that they were adjusting district costs shortly after posting. Better late than never I guess! I'll still leave this post here as I think it's instructional in other regards.


I'm looking forward to what other changes they have in mind for the upcoming patch. Amplitude always surprises me with the creativity of their balancing.

0Send private message
3 years ago
Nov 19, 2021, 6:27:09 AM

I got this idea:

Keep the code as it is but just add a Tag like Tag_DistrictCountAnnulation.

Then add this tag where it need to. It just do a "districtCount -1".

So, for some districts, the game add +1 then remove -1. It look silly, but as I don't know the impacts of removing the original tag, and as it is maybe used somewhere in the game code in a hidden way, it's more safe.

Then look if there is a way to use a Tag as inverted filter for the Builder Star. Then it's possible to say in a more direct way to not count a district. 

0Send private message
3 years ago
Nov 19, 2021, 3:33:42 PM
Enchanteur wrote:

I got this idea:

Keep the code as it is but just add a Tag like Tag_DistrictCountAnnulation.

Then add this tag where it need to. It just do a "districtCount -1".

So, for some districts, the game add +1 then remove -1. It look silly, but as I don't know the impacts of removing the original tag, and as it is maybe used somewhere in the game code in a hidden way, it's more safe.

Then look if there is a way to use a Tag as inverted filter for the Builder Star. Then it's possible to say in a more direct way to not count a district. 

I actually tried this during the development of this method. Now I could be wrong here, as I changed many things over the course of figuring this out, and there's a chance that some other confounding factors may be at play, but I believe this will not work. I ran into an issue where I was getting builder stars after building extractors because the game was counting that I had "added" one district before it was being removed. However, if you're inclined, I am very interested to hear if this does work. It would be a slightly more efficient and transparent way of doing things if so.

0Send private message
3 years ago
Nov 19, 2021, 4:54:10 PM
shasho wrote:

I actually tried this during the development of this method. Now I could be wrong here, as I changed many things over the course of figuring this out, and there's a chance that some other confounding factors may be at play, but I believe this will not work. I ran into an issue where I was getting builder stars after building extractors because the game was counting that I had "added" one district before it was being removed. However, if you're inclined, I am very interested to hear if this does work. It would be a slightly more efficient and transparent way of doing things if so.

I'm ready to work on this now. I made a big worksheet with costs calculation and a classification of all districts.

As it's maybe tricky, for now I won't touch Era Stars.

In the best case : If a district don't add districtCount and trigger the Star, it's ok.

But if it's the other way, it will be a problem.

So maybe what you say now could help. If adding then removing still trigger the star, it's better for now.

I know it's maybe not fair to count easy to build district for stars, but in another way:

- everyone can build it, so it's fair for all players. the number of room is limited (number of ressources and so on).

- it can push the player to use a strategy about building. Example: it need 4 more building to get the star, but it have to be done quickly, then build easy building. If the player was smart, they keep some easy to build districts in the pocket for this kind of urgent situation.

- my main mod have already a setting for changing difficulty to get the stars.


THere is another difficulty: I would like to not touch the differents districts definition. Because other modders often need to touch that.

So, if I find a way to touch only districts other don't touch, it's better. Aka : the basic ones.

I maybe will have to change the classification of districts I made before.

When modding amplitude games, often, you don't do what you wan't, but what you can.




Guidline:


Ranking of districts for the mod.


Districts with scalable cost, and increasing the cost of other districts:

Farmers, Makers, Market, Research. 


Districts with flat or low scalable cost, and increasing the cost of other districts:

Emblematic district. 


Districts with flat or low scalable costs, and not increasing the cost of other districts:

Nature Reserve, Resource extractors.


Districts with scalable cost, and not increasing the cost of other districts:

Garrison, Aerodrome, Train station, Airport, Missile Silo. Harbor, Hamlet. Commons Quarter. 


For simplicity of implementation, this classification also corresponds to the importance of costs, for which the game already has a file by level of importance.

Low cost: for districts with low scalability, and not increasing the cost of other districts.

Medium and high cost: for districts with scalability, and not increasing the cost of other districts.

Special Cost, 4 Basic Districts: for districts with scalability, and increasing the cost of other districts, with the special formula for each.

Special Cost, 6 Eras of Emblematic Districts: Each era cost can be defined.

Special Cost, Commons Quarter: this district is currently too expensive for what it produces.

Flat cost: all resource extractors. Differents costs each Era and type (luxury/strategic).

Updated 3 years ago.
0Send private message
3 years ago
Nov 19, 2021, 5:24:49 PM

First try : I will create a new prototype. Like "Basic". I duplicate BaseEconomy. 

Then I will link basic quarters to this instead of BaseEconomy.

After that, I could tweak BaseEconomy and try to remove the districtCount from that.

Or keep the UrbanTag, and add a tag "remove 1 to district count".

Here, I don't need to touch any specific DistrictDefinition, other than the 4 basic ones.


EDIT: Yaaaaaaaaaaahhhhhhh!!!!

It work!!!

If you add +1 districtCount, then remove it, it just add +1 for the EraStar.

The stars trigger always "on build".

When I check if the Artisan District (of which I remove -1 to the count) make another district more expensive : No!


Now, it's just perfect. I can't believe it. Just 30 minutes of work and this engine is Ok.

All the guidlines can be meet and it don't touch most of DistrictsDefinition.

I need to write the formulas, and create some missing one.

I'll do this in my existing mod OnlyProdDistrictScale. It don't have success, but this mod was supposed to do that, so I won't create a new one.

I wan't to try it in a isolated component before to integrate that in BuyThis.


EDIT again: no, it work, but I forgot to param something. ARgh. It's not the end.

I forgot to remove -1 on extractor. But when I build it, my basic district cost don't change.

As if the game was hard coded to not take that ?!!


EDIT aaaagain: I'm so stupid!!! I'm doing that on this mod, which take only PopulationLimit about districts, so it already don't count the extractor.

I have first to use the cost with DistrictCount.

Updated 3 years ago.
0Send private message
3 years ago
Nov 19, 2021, 6:47:38 PM

So... It don't work as I try to do that :

Duplicate BaseEconomy. Duplicate Base.

In Base, I put the tag Substractor -1 district count : all districts should be affected.

I rely the 4 basic districts to the copy of BaseEconomy. This copy is linked to the copy of Base (without any substractor).

A extrator is Base_Extractor, with tag urban, but also with Base. And in base there is the substractor.

But when building the Extractor it don't do +1 -1, and the districtCout increase 1 about the cost of other district using this property.

Why I do all that ? Because in Harbor, there is urbanTag and Base. I don't want to edit that file.

Now, I could try to do something else. Maybe give up about the idea of harbor don't up the scale first.


I rollback, I will use the "remove from urban tag the -1", then add it to the 4 basic districts and emblematic ones.

I erase All and import again. I was looking for something complicated when it don't need.


EDIT: now it work!

And I made a new BaseEco prototype for adding the tag +1 districtCount into it, and linked that to the 4 basic quarters.

In emblematic prototype I added the tage +1 district count..

So why before it didn't ?!

WHen the -1 +1 where in a way the calculation give what we wan't.

Is there like a priority about prototype ? Or any property of a prototype is canceled for any reason ?

Well, for now I won't look more. Now it's sure, it make exactly what I need.

I tested with Farmer quarter (take DistrictCount in the cost).

Harbor and Ressource are set to don't up the cost. And it didn't up the cost. But still count for era star. Perfect.

Another Farmer or Maker up the cost, and the farmer quarter cost more. All is ok now.

But I'm so tired now, more than 2h of laborious mind puzzle at the end of the day. I will make the other parts of the mod tomorrow.

Updated 3 years ago.
0Send private message
3 years ago
Nov 19, 2021, 9:45:05 PM

Glad to hear it's helping with your mod! Regardless of the specifics of what tags or methods you use to achieve the effect, I think it's better than the default district scaling right now.

0Send private message
3 years ago
Nov 20, 2021, 3:50:22 AM
shasho wrote:

Glad to hear it's helping with your mod! Regardless of the specifics of what tags or methods you use to achieve the effect, I think it's better than the default district scaling right now.

Hello. I also found a way to do what do the new cost, but without suffering Slots impact. I need to make new calculations so. I just got the idea during the night. So simple. 

The formula will use : 

- RealDistrictsCount, some districts don't up the scale. I still have some doubts about the list of districts increasing the scale. I don't know if I should add Commons to that.

- Build the same basic district cost more, but more balanced than vanilla, and with a method that reduce external Slots impacts a lot.


 

0Send private message
0Send private message
3 years ago
Nov 20, 2021, 11:20:23 AM
Ningauble wrote:

Awesome thread. Thanks.

This cost mod is now done!!

There was a last trap. 

City and Administrative Center also use UrbanTag.

So, if these 2 don't get the additionnal tag +1 district, it make something funny (for the city) : the first District don't trigger cost increase.

Updated 3 years ago.
0Send private message
0Send private message
3 years ago
Nov 20, 2021, 5:11:34 PM

I'll consider doing more tutorials like this on helpful tricks like this since this one seems to have been useful, or I might just explain some of them in my mod's documents whenever I get around to releasing it.

0Send private message
3 years ago
Nov 23, 2021, 1:54:14 PM

Hello here!!!

I have a bad new: NEVER SET URBAN_TAG TO ZERO!

I don't know how the game work, but it look like at some point, there is a division using this tag value.

So it should happen like that: when conquering a city, there is like a reset of the value, and the game need to get at least ONE as the total of urban_tag.

So, my method for the mod was to modify base_economy, because it's used by a lot of districts. It was a nice way to do, so it was compatible with any new content.

But obviously, it was generating the bug.

It was a bit painfull to identify the source of the problem. I first made another correction (that is don't lost). Then, I had to make a real game, time consuming, and siege and conquest a city.

So now, my mod just work with adding a tag "-1 district cost" on each of other Districts, except extractor and military ones, because they have a Prototype where I can set here.

I can't do the same with the prototype Base_Economy of course, because it's used by city_center. And I suppose if city_center get a districtCount zero during a conquest, it break.

0Send private message
?

Click here to login

Reply
Comment