Help requested

Gulo

Chieftain
Joined
May 13, 2012
Messages
4
Hi, I'm fairly new to modding and hoped someone could help with an issue I have.
Basicly, I want to create new resources, like the gold resource works. I know how to add a strategic / luxury resources. What I specificly want is a resource that stockpiles. E.g. a resource like wood or stone that adds up when working a tile so that can buy say a building from them (just like you can buy units / buildings with gold). I've tried adding YIELD_STONE like in the CIV5Yields folder, but that doesn't seem to work. Can anyone help me out / link a tutorial on this?
Thanks in advance, Gulo
 
Short answer - resources are kinda hard-coded and not fully moddable. Some have succeeded, but others have given up in tears.

I do know that in the table there is a field (don't have it in-front of me) that indicates if it is strategic (stockpile), luxury etc. An integer defines each type and you just have to use the same integer for another resource. Thus sheep can be made strategic by changing the above mentioned integer to the same ones used by oil etc.

Graphics are a completely different bag of pain and don't remove any existing strategic resource or else all hell breaks loose!
 
Changing a bonus resource into a strategic resource isn't really that much of a problem. Both work very simular. Just changing _bonus into _rush would do. Changing the resource so it stacks is a different story though. I've tried adding my extra resource to YieldIconManager.lua, but nothing happened :sad:. Ah well, trial and error...
 
So you mean adding new yields... I think it should be possible, but you'll need to create a way to use them, modify the interface in various places to show them, and also make the AI use them properly. None of these things in easy to do.
 
Well, if there's a way to be able to stack strategic resources each turn, that would do. And I don't care about the AI using them, it's not relevant for me.
But I'd figured it wouldn't be easy. I could only find one post on this issue, and they didn't succeed.
 
So you mean adding new yields... I think it should be possible

Unfortunately, it's not. You can add a new entry in the <Yields> table, but the Lua uses the entirely separate YieldTypes data structure, which is NOT altered by any XML additions. All of the Lua functions that return yield values will give nulls when you try to access the amounts for your new yield type. I had to go through all of this with the Favor resource in my Mythology mod.
The same goes for the ResourceTypes, TerrainTypes, ImprovementTypes, etc. tables; ones you add simply won't be appended. You can try manually doing this yourself outside of the XML, but I wouldn't be surprised if that were very unstable.

As to the original question, there are a few things to note when adding a new resource:

1> If you intend a new resource to be placed on the map, you'll need to modify AssignStartingPlots.lua. I wouldn't wish that on my worst enemy, by the way; I spent far too much time figuring out exactly what each bit did for my own mods, because it's not very well laid out.
Besides just being very difficult and time-consuming, this will make your mod conflict with any other mod editing that file, so it's best used for something like a scenario and not a general-use mod.

2> RESOURCECLASS_BONUS, _RUSH, etc. are NOT used for many aspects of the UI. For instance, if you add Happiness to a strategic resource, it will now be classified as a Luxury, regardless of what resource class you select for it. Likewise, the separation between strategics and bonus resources basically comes down to how many units a hex provides (1 vs >1). A few very simple modifications to things like TopPanel.lua will fix most of this, though.

3> Forget about custom graphics for it. You CAN do new icons, and the small icons along the top panel are drawn from the texticons list (which has a lot of extras), but the basic graphics are limited to the existing resources. And remember that strategic resources require two separate art definitions, one for "small" deposits and one for "large" ones, so just changing the resource class will cause issues.
You CAN do some interesting things with this; when I wanted a new crystalline resource that only spawns in water, I simply used the Uranium graphic; as the game treats water as having a slightly lower elevation (so that boats can be partially submerged), you'll only see the tops of the green bits of metal. Likewise, an organic resource that can spawn on water or land used the Spices graphic, resulting in a seaweed sort of look.
The downside of this is that you'll be limited to whatever improvement graphic is normal for that resource. So in the case of my water-based resource using the Uranium graphic, only the Mine improvement graphic can be used with it (even though an entirely new Improvement type uses that graphic). Any "invalid" combination of resource and improvement graphic will result in a blank hex.
 
Top Bottom