How To Have More Than 64 “Hard Coded” Hidden Resources
Many good mods push the Medieval II Total War engine to the limit. One of those limits is the amount of hidden resources available. There are several methods of extending the number of hidden resources, but I will show the method that I use and am comfortable with. MTW II has a limit of 64 hidden resources that can be used.
What is a hidden resource and where are they located?
Hidden resources are located in the data folder of the mod you are working on, specifically the export_descr_buildings file and the descr_regions file located in the data\world\maps\base folder. There can be up to 199 regions in a MTW II mod. To help make each region unique hidden resources are added to each region. The effect of these hidden resources is found in the export_descr_buildings file where hidden resources are used to determine whether or not a particular building can be constructed or a particular unit can be recruited. In combination with culture and faction and settlement size and type, as well as using event counters, hidden resources allow the modder the ability to make his world as detailed and unique as possible.
Here is an example of the descr_regions file, the hidden resources are listed in red:
Here are a few lines to show how hidden resources are used in the export_descr_buildings (edb) file (HRs in red):
Spoiler Alert, click show to read:
Code:
The first example is for a unit:
recruit_pool "gondor light swordsmen" 1 0.2 3 0 requires factions { sicily, } and region_religion islam 25 and hidden_resource grasland and not hidden_resource amroth and not hidden_resource hr_5 and not hidden_resource hr_Q and not event_counter is_the_ai 1 and hidden_resource gondor and not event_counter gondor_units 1
The second example is a hidden resource to determine whether or not a building can be constructed:
building forest_camps
{
levels hunting_camp lumber_camp
{
hunting_camp requires factions { turks, scotland, } and hidden_resource forest or hidden_resource grasland
{
capability
{
A few note when working with the edb, when adding new HRs, the complete word "hidden_resource" must be used prior to the actual resource used. The connecting words, "and", "and not", "or" must also be used when working with hidden resources in the edb.
Next is the export_descr_buildings hidden resources section at the top of the file. The first example shown shows the hidden resources in the standard method showing all 64 HRs used:
Here is the same mod with the edb showing the new method of HRs:
Spoiler Alert, click show to read:
Code:
;------------------------------------------------------------------------
;
; TO SEE THE BREAK DOWN OF ASSIGNED HIDDEN RESOURCES, SEE THE EXCEL FILE "HIDDEN RESOURCES."
In the above example only 54 hidden resources are used. In using 20 letters and 10 numbers, a modder now has used 30 hidden resources to create as many as 90 hidden resources. Even more letters can be used if needed. I would recommend omitting the letters I and O to avoid confusion with the numbers 1 and 0. In fact even more can be achieved using the numbers 11, 12 etc. I also prefix the letters with "hr_" also to avoid confusion and possible crashes.
In order to be as safe and detailed as possible, I would highly recommend using MS Excel to set up a matrix to hopefully avoid as much confusion and having to correct errors. Here is the matrix I set up for adding ne hidden resources for the Reunited Kingdom submod for MOS:
As you can see above I use a two letter, one number hidden resource combination. When adding or converting over your hidden resources thought must be given so that you do not have overlapping HR conflicts, especially when using the negative HR "and not hidden_resource hr_X". To avoid conflicts the modder must have a fairly good grasp of where all the hidden resources are located. In cases where a hidden resource is used a lot and throughout the map, than using the standard HR naming procedure should be used.
Once you have assigned the old HRs to the new three digit HR system the next step is actually applying them to both the export_regions file and the export_descr_buildings files. First, if you are not using notepad++ you are wrong. Using the standard notepad will lead you to much heartache and grief and will probably lead you to scrapping your project (any modding project where editing text files) before it is implemented. Secondly, before starting this, I would make a backup copy of your export_descr_buildings and the descr_regions files.
The first file I start on is the export_regions file. I start from the top of the new HR matrix, in this case the old HR is "tharbad" and the new replacement HR is hr_A, hr_M, hr_0. I then open up the descr_regions file and open a blank file so they are side by side. The reason I do this is to minimize errors and focus on replacing one HR at a time. This is what it will look like:
Code:
tharbad
hr_A, hr_M, hr_0
The reason for setting it up like this HR is that it makes using the replacement function of notepad++ so much easier. To use the notepad++ replacement function open the "search" tab and scroll down to where it says "replace". In the "find what :" section, copy the old HR to be replaced. In the "replace with :" section copy hr_A, hr_M, hr_0.
Spoiler Alert, click show to read:
When I can I will post a screenshot
Make sure you start at the very top working your way down, I do not use the replace all function because there are cases where tharbad may be listed as something other than a hidden resource such as being a province name for example. So use the 'find next' function followed by the "replace" function. This is a time consuming process, but accuracy is everything, you don't want replace the wrong hidden resource which may at best cause unwanted recruiting or buildings to appear in a region and at worse it may cause an immediate crash to desktop.
After all the new replacement HRs have been added to the export_buildings file it is time to move onto the the export_descr_buildings file. It is slightly more complicated. One saying that was pounded into me is this: "slow is smooth, and smooth is fast," and it applies to this process. Take your time! It is better to do it correctly the first time around then to go back and correct mistakes repeatedly. Open the edb up with notepad++, open a blank file next to it. the HRs will look like this;
Code:
and hidden_resource tharbad
and hidden_resource hr_A and hidden_resource hr_M and hidden_resource hr_0
Once again copy the top line into the replacement function of notepad++ followed by the bottom line. Then starting at the top of the edb, slowly work your way down one instance of tharbad at a time, ensuring that you are ONLY replacing the "tharbad" hidden resource and nothing else. Repeat this procedure all HRs to be replaced.
We are not yet done however, now must replace the negative HRs (this is why we leave the "and" in "and hidden_resource tharbad." If there are units or buildings that cannot be recruited or built if a region has the hidden resource tharbad it will look like this: "and not hidden_resource tharbad." When replacing the negative HRs it will look like this:
Code:
and not hidden_resource tharbad
and not hidden_resource hr_A and not hidden_resource hr_M and not hidden_resource hr_0
It is also possible to just use a number to use for the negative HR especially since you may have other HRs used with the same letters here is an example:
Code:
and not hidden_resource tharbad
and not hidden_resource hr_0
As you can see this is a fairly easy system to set up, this is not the only method of expanding the number of hidden resources but it is the one I use and it is effective and is in use and works. Some thought MUST be given to the process of assigning HRs and you may have to go back and adjust some as the case may be as I have had to do. Having patient playtesters is a HUGE plus when taking something like this on. So that units that don't appear that should or all units appear when they should not can be identified and de-bugged as soon as possible.
August 07, 2014, 11:46 AM
MIKE GOLF
3 Attachment(s)
Re: HOW TO HAVE MORE THAN 64 “HARD CODED” HIDDEN RESOURCES
I do not think this post will be needed. A moderator can delete this post if he/she is able to.
August 09, 2014, 09:40 AM
Gigantus
Re: How To Have More Than 64 “Hard Coded” Hidden Resources
I could have sworn to have seen a similar article somewhere that explain how to use multiple hidden resource to create exponential combinations.
Good to have it anyhow - nice article. :thumbsup2
August 09, 2014, 09:56 AM
irishron
Re: How To Have More Than 64 “Hard Coded” Hidden Resources
I thought Mak did one.
August 09, 2014, 11:00 AM
makanyane
Re: How To Have More Than 64 “Hard Coded” Hidden Resources
no - only this
we all thought there was a full version around somewhere but couldn't find it... so this is definitely useful
it is the or conditions that can pose a problem though - if you had something that needed tharabad or mirkwood or moria... then the conversion gets you an 'and / or' string that probably won't work, my brain's not up to figuring that out at the moment though
August 09, 2014, 02:52 PM
Aikanár
Re: How To Have More Than 64 “Hard Coded” Hidden Resources
Quote:
Originally Posted by Gigantus
I could have sworn to have seen a similar article somewhere that explain how to use multiple hidden resource to create exponential combinations.
Re: How To Have More Than 64 “Hard Coded” Hidden Resources
You could also use a single letter with a number as well. I'm not sure why I used two letters, I had a reason for that at the time but now I can't remember..... :mallet:.
The biggest thing when setting this up is avoiding confusion. In the RK mod I am helping with I have had to go back make several corrections now. Two errors were typos (staying up till 4am doing this doesn't help). Three were from overlapping hidden resources, where there were to negative hidden resources and one was for a unique building which (hypothetical) (hr_A and hr_G and hr 3), in another region I had the hidden resources (hr_A and hr_G and hr_7) plus another hidden resource (hr_D and hr_K and hr_3). So in the region where I did not want the building I had hrs A,G and 3 for two other HR groups. After looking at the excel spreadsheet I reassigned the hrs for the unique building.
Having good play testers helping out is a must when using this method to help catch some of the errors that, even with the best planning can mistakes can slip by. Even so I still have room for another 25 or 30 hidden resources to use, not that TATW MOS or its submods will ever need that many.
August 09, 2014, 08:28 PM
Tellos Athenaios
Re: How To Have More Than 64 “Hard Coded” Hidden Resources
This is more or less what was done for EB (RTW mod). Since we have only 199 regions to play with that means you can do with just 8 hidden resources to give each region a unique fingerprint (since 2^7 = 128 and 2^8 = 256) for simple AOR purposes.
January 27, 2022, 09:27 AM
Express777
Re: How To Have More Than 64 “Hard Coded” Hidden Resources
Important note
if added new hidden resource in descr_regions you must delete file map.rwm in data\world\maps\base. It will be
regenerated after launch.
Or you wil not see resource on the map