
Originally Posted by
Ciaran
Instead of opening a new threat, I might just as well post my question here, since it goes into much a similar vein.
Is it possible to use multiple building requirements for units in M2TW, like in MTW 1, or can any unit have only one certain building as a building requirement? And how about other buildings, can one building or building upgrade be dependant on the presence of another building (for example, the highest stable level requires the presence of at least a blacksmith)?
I wonder because, in short, I think acessing the high-quality troops, like Knights, is way too easy. Heck, even spear militia require a seperate building, but you get the best Knights by simply upgrading your castle. Now, when I think what I have to do in order to get even Feudal Knights in MTW 1, that feels like a real achievement, and it is also worth the time and money.
Okay, Q&A Time. I'll post code and discuss.
Is it possible to use multiple building requirements for units in M2TW, like in MTW 1, or can any unit have only one certain building as a building requirement?
A: I think it is possible. Look at the following code that defines the wooden wall building for a city.
Code:
wooden_wall city requires factions { northern_european, mesoamerican, middle_eastern, eastern_european, greek, southern_european, }
{
convert_to 2
capability
{
recruit_pool "Conquistadores" 1 0.4 3 0 requires factions { spain, portugal, } and hidden_resource america
recruit_pool "Dismounted Conquistadores" 1 0.4 3 0 requires factions { spain, portugal, } and hidden_resource america
recruit_pool "Town Militia" 1 0.2 2 0 requires factions { england, scotland, france, hre, denmark, spain, portugal, Normans, }
recruit_pool "Italian Militia" 1 0.2 2 0 requires factions { milan, venice, papal_states, sicily, }
recruit_pool "EE Town Militia" 1 0.2 2 0 requires factions { poland, hungary, }
recruit_pool "EE Archer Militia" 1 0.2 2 0 requires factions { russia, }
recruit_pool "SE Town Militia" 1 0.2 2 0 requires factions { byzantium, }
recruit_pool "ME Town Militia" 1 0.2 2 0 requires factions { moors, turks, mongols, timurids, }
recruit_pool "ME Archer Militia" 1 0.2 2 0 requires factions { egypt, }
recruit_pool "Peasant Spearmen" 1 0.2 2 0 requires factions { Saxons, }
wall_level 1
gate_strength 1
tower_level 1
free_upkeep bonus 3
happiness_bonus bonus 1
recruitment_slots 2
}
material wooden
construction 2
cost 1200
settlement_min town
upgrades
{
stone_wall
}
}
Note that I've highlighted a line, because it does something interesting: it sets up a unit to be available for recruitment, but only to be available if the settlement is in America (it refers to a resource "america" but IIRC it's used to label all cities of the americas as american for game purposes). You should be able to do something very similar to this to impose building requirements on unit availability. More on that once I cover the particular mechanic.
And how about other buildings, can one building or building upgrade be dependant on the presence of another building (for example, the highest stable level requires the presence of at least a blacksmith)?
Most certainly this can be (and is already) done. View the code below.
Code:
merchants_wharf city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } and building_present_min_level port port
{
capability
{
trade_fleet 1
trade_base_income_bonus bonus 2
}
material wooden
construction 3
cost 1600
settlement_min city
upgrades
{
warehouse
}
}
After the line sets up the factions allowed to build the building, it goes on to specify that a port type building must exist (the first word port) of at least the level port (the second use of port). If you made this for instance instead read as follows...
Code:
merchants_wharf city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } and building_present_min_level smith armourer
...then you would have to have an armourer (smith tells the game which set of buildings armourer is part of) built in this city before you could build a merchant's wharf. I could be wrong, but I am guessing that building_present_min_level can be used in a similar way to how "hidden_resource america" was used in the first example, in order to impose a building presence requirement on a recruitable unit. So if you wanted to require at least a "knight's stables" in order to allow the conquistadores to be recruited by the walls (instead of forcing it to be in america), I think the code should be:
Code:
recruit_pool "Conquistadores" 1 0.4 3 0 requires factions { spain, portugal, } and building_present_min_level equestrian knights_stables
Important notes:
1. Make sure you check where any building you set as a requirement can be built. Often they are city- or castle-specific. In the case of the armourer I showed above, that Merchants Wharf could only be built in a city then, because the smith line of buildings requires a city to be built. The building also requires it can only be built in a city, by "merchants_wharf city requires." There is a nearly identical castle_smith line of buildings, but the game considers them entirely different things. So if I did this:
Code:
merchants_wharf city requires factions { northern_european, middle_eastern, eastern_european, greek, southern_european, } and building_present_min_level castle_smith c_armourer
..Then all the code looks fine, and seems to make sense, except that a city as required by merchants_wharf can in fact never build a c_armourer building (restricted to castles) and therefore the wharf would be unavailable anywhere. Similar things could happen with units, if you impose for instance a smith (city only) requirement on a unit that is only recruited in castle wall buildings. This is very important, and you'll drive yourself nuts if you don't make certain what you're doing as you're doing it.
2. Test each idea at least once before starting to change everything. I haven't tried ANY of these things myself, but I'm quite good at picking this sort of thing up just from reading files. That being the case, though, it's still possible I misinterpreted something, or that something you want to do just isn't supported by the game, and I'd hate for a custom EDB file to get into a state where you can't figure out all of your changes to undo them and get the game running. This also gives you a better idea of what you've botched if the game decides not to load at any point as there's less changes to consider as possible sources of trouble.
3. I intentionally avoided handing you the code for exactly what you want to do. You wouldn't learn anything that way, and if I'm going to take this much time explaining something, I at least want the satisfaction of knowing you took that information and successfully applied it your problem... plus it puts you in a far better position should you decide to mod the file beyond the few things you outlined. I realize it may be a little less convenient, but I also hope it will end up being far more helpful to you and perhaps the community at large.
That said... best of luck. Keep me posted with any questions you have, and of course results!
Bookmarks