Resource Manipulation

Putmalk

Deity
Joined
Sep 26, 2010
Messages
2,652
Location
New York
Hi guys.

I want to make Aluminum appear more frequently on the map.

I already experimented with making it have more terrain booleans, but do I need to also edit the map generation LUA scripts to get it to produce Aluminum more (read: is resource generation hardcoded?)?

Iron is everywhere. Every continent has multiple sources of Iron. I want Aluminum to be like Iron. This map generated only one Aluminum for the entire map. If everyone doesn't have access to Aluminum, then the game will break (they won't be able to make the units they have to make).

Thanks in advance.

Just checkin AssignStartingPlots.lua. It looks like they hardcoded this stuff. My god, what the hell were they thinking?
 
Okay, I've done some testing and Aluminum seems to be showing up nicely around the map. I'll definitely make my early game more of a challenge now.

Anyone have any tips on how to make resource generations better for gameplay?
 
Yes, it's pretty much all hard-coded inside AssignStartingPlots.lua. Basically, there are several components, all within that file:

1> There are two small subroutines that determine how many units of a resource are in a single deposit. One handles large ("major") deposits, the other handles "small" deposits. And no, I didn't screw that up; it really does use Major/Small as the nomenclature.
Note that map scripts can override these routines easily by including their own versions of these subroutines. In the core game, the Great Plains, Highlands, and Lakes scripts do this. Unfortunately, this makes those map scripts incompatible with any mods that add new resources (like mine).

2> The game then uses two large routines that call the above two. These create the large and small deposits, but the two use a completely different method. Map scripts can ALSO override these individual routines, but they're much larger and more complex than the above, so it's not nearly as easy.

Large deposits are placed on a percentile basis. That is, each Grasslands tile has a 1 in 13 chance of having a strategic resource, and if it does, it has an 85% chance of it being a Horses and a 15% chance of an Iron (just making up an example). These tables are at the very end of the file.
The thing to note with these is that it's purely random by terrain type, which means that depending on your map script, one terrain type might be extremely rare (or even nonexistent), which could really throw off the balance. (This is WHY the Great Plains, Highlands, and Lakes scripts overrode the quantities; they were trying to make up for how rare certain terrains would be.) EVERY hex is checked to see if it can have a resource, with the same probability; there's a small limit on the minimum distance between one deposit of a resource and either other resources or other deposits of this resource, but for the most part it's just a straight random check on each tile.

Small deposits work a bit differently. The game will place 23 of these, assuming standard resource quantities. (It scales this depending on your scarce/standard/abundant setting to help compensate.) It'll pick a land (NOT sea) map hex at random; if that hex has no resource, then it'll place a resource on that hex using a more rigid table (like "pick a number from 0 to 5; if it's a 0 or a 1, place an Iron, if it's a 2, place an Aluminum, etc.") Repeat until all 23 are placed.

3> Then, at the end, it'll place the water-based Oil. Take however many units of Oil were placed on land (UNITS, not deposits), divide by 4 (6 if Abundant), divide by 2, round down, and place that many 4-unit (6 on Abundant) Oil deposits in the water.

4> Finally, there's a minimum check; there will always be at least one deposit on the map for every resource. I know, one deposit isn't much, but without it the map scripts would crash.

---------------------------------------
So if you want Iron to be more abundant, you can change the quantities, probabilities, and so on in any of the above sections. It's all a bit interconnected, but generally speaking it's not too bad. The only real headache is that ASP is so huge that ModBuddy can't edit it without slowing down, so you're better off just opening it in Notepad and making your changes there, then rebuilding ModBuddy as normal.

Now, in my own Ascension mod, I had to adjust this whole thing already to add three new resources, so I also fixed a lot of the things you're talking about. You may want to take a look at my version; you can't use it directly in your own mods, since you don't have Omnicytes, Dilithium, or Neutronium in your games, but a lot of the other bits can be copied.
One of the things I did was add a better minimum logic. For Iron, after placing the large and small deposits it might add N/4 large and N/4 small deposits, where N is the number of civs; to compensate for this, I reduced the number of deposits placed through the old mechanisms. It's a bit less random this way; you're still not guaranteed to have one near your starting point, but you won't have one single civ controlling the world's entire supply.
I did this for all of the resources, in different ways; Aluminum gained N/3 small deposits but no larges, and so on. Similar logic applied to the sea-based Oil as well, with it placing two separate sizes in the water, one based on the land deposits as before, and a different set based on the number of civs. (Of course, I also made more units require Oil, so I needed the extra deposits.)
The point is, this whole AssignStartingPlots is very flexible to modify if you don't like the resource balance, but you generally have to replace the entire file, which makes your mod/map incompatible with anyone else who does the same.
 
Yeah, don't worry Ancient World is already incompatible with any other mod.

What I did was make Aluminum available on more terrains, then I went into AssignStartingPlots.lua and for those terrains in "small" I added the aluminum resource ID and adjusted the "diceroll" check so that aluminum would become more likely.

Then there were some percentages towards the end of the file. I basically lowered coal and oil to like 5 and made aluminum somewhere around 35-45. Eventually Aluminum was appearing quite nicely around the map, and in large numbers (like 8). Of course, those numbers are still subject to test but I am very pleased with the end result.

Your help is appreciated, however. It's good to have an indepth analysis on how resources work.

And screw the hardcoding! They should've made resource percentages based off of XML coding...
 
Back
Top Bottom