Tutorial: How to add a new Resource

If you want to ADD a resource requirement use a code like:
Spoiler :

<Unit_ResourceQuantityRequirements>
<Row>
<UnitType>UNIT_MUSKETMAN</UnitType>
<ResourceType>RESOURCE_GUNPOWDER</ResourceType>​
</Row>​
<Unit_ResourceQuantityRequirements>


To CHANGE the current requirement:

Spoiler :

<Unit_ResourceQuantityRequirements>
<Update>
<Where UnitType="UNIT_CANNON" Where ResourceType="RESOURCE_IRON" />
<Set ResourceType="RESOURCE_GUNPOWDER" />​
</Update>​


The difference is the first code adds onto the existing prequisites while leaving the original. And the second code overwrites the original one with the one you want. Hope this helps.

And I believe AIStopTrading is simply the Era in which you want the AI to no longer need this resource and stop trading it.
 
The problem with adding a resource as requirement is that there is currently no dynamic way for it to be added to maps; you will have to alter the LUA that does resourceplacement.
 
Based on your comments on the need for graphics for new resources I started messing around with the textures for resources. I've got my replacement textures into the game, now I just need to make a mod that adds it as a new resource rather than replacing the graphics for an existing resource. I started with the silver texture and just modified it to a random color, to be sure the texture changes were working. I ended up with a green and grey resource, which actually looks like a passable attempt at copper ore.

Copper Image

Admittedly, this was probably the easy part, but my hope is to start giving you modders with the grand schemes the art you need to incorporate new resources into your mods. Like I said before, changing the texture for the silver ore was pretty easy, and once I get the whole process done from old resource to resource mod down I'll put together a tutorial.

This is a post I made on the official civ 5 forums about, oddly enough, making a copper resource mod. I've run into a lot of the same issues you have, and figured out a lot of the same things, though you have certainly gotten into the nitty gritty of mod-making to a greater extent than I have. However, the picture I made above is my reskinned silver resource made to look something like copper ore.

I was actually just having a conversation with Lemmy101 via PM about my issues getting the art defines into the mod rather than just rewriting the silver resource to look like copper. Unfortunately he says that the capability to add new art defines, and therefore resources with new art, has not been enabled yet. Hopefully with a little bit of pressure on the dev team our dream of a copper resource in game will soon be possible! (and when it is if you want to use this dds for the reskin for your mod you're more than welcome to, just PM me. I know it isn't perfect, I actually did it mostly by accident, but it would be a decent graphic placeholder for a more in depth redesign of the resource)

Quethas

P.S. And thanks for the in depth review of how to make this mod, it will be very helpful in my future attempts to make new resources!
 
Just a quick question. What does the Resource_FeatureTerrainBooleans tag work in modding? I can see some resources use both Resource_TerrainBooleans and Resource_FeatureTerrainBooleans but most of the data are the same, which makes me feel quite confused.
 
I discovered the problem with adding a new luxury, the problem is in attribute <ResourceUsage> which is defined in Civ5Resources.xml. From reading some lua files I found that ResourceUsage=0 for strategic resources and ResourceUsage=2 for luxuries.

The default value for ResourceUsage is 0 so if you didnt define it in the xml the resource will be considered a strategic resource even if you set ResourceClassType="RESOURCECLASS_LUXURY".

Now if you change this value to 2 in the xml for your new luxury resource the game will crash, that is because luxuries are hardcoded and not modular, for some reason they limited the number of allowed luxuries in the game I discovered this when I checked AssignStartingPlots.lua in this file you can see that luxuries have fixed size table and if you add a new luxury a runtime error will occur. I tried to modify the code myself but the file is very large and the code for luxuries is scattered along it, the code it self is messy inflexible and was not written with moddability in mid.

If anyone knows how to work around this please tell me?
 
I think adding luxuries would require significant changes to AssignStartingPlots but it should be possible. Your best bet is to take an existing luxury and copy it wherever it occurs.
 
I think adding luxuries would require significant changes to AssignStartingPlots but it should be possible. Your best bet is to take an existing luxury and copy it wherever it occurs.

I tired that and it fails, I get runtime error every time although I did copy the code from old luxury.
 
I looked at the assignstartingplots.lua and that's a lot of stuff to add, but some of it seems to be optional. What's the minimum work that needs to be done to get it to be available for use in "Place strategic resources"?
 
I'd say better safe than sorry and clone all of my changes. I still have to fiddle around with the values to get an even placement of all resources.
Currently Copper gets placed a LOT less than iron. Sad.

@Deep_Blue: Thanks for the feedback. Will update the first post with your suggestions.

I have to admit i haven't looked into this for a while. Other projects came up and i was kind of disappointed with the way firaxis implemented the so-called modding.
 
Ah okay. Well the problem is I want to add a flatland only strategic resource, so I'm guessing cloning it won't work.

Edit: Meh, just added it to hills too. Also, THANKS! This tutorial was very helpful.
 
To be honest, AssignStartingPlots in my opinion deserves to be ripped out and re-done completely. It's a massive, messy, multi-layered beast that doesn't even produce any significantly more interesting distributions than a completely random placement in my gameplay experience.
 
For most resources yeah, but for the landscape/lux resources it's worthwhile. But yeah, even a simple scan through all tiles giving a weighted chance for the strategy resources would be infintely easier on anyone wanting to add something.
 
Edit: nevermind
 
Thanks for a guide, good work!

This is a post I made on the official civ 5 forums about, oddly enough, making a copper resource mod. I've run into a lot of the same issues you have, and figured out a lot of the same things, though you have certainly gotten into the nitty gritty of mod-making to a greater extent than I have. However, the picture I made above is my reskinned silver resource made to look something like copper ore.

Quethas, how you reskining a silver? I create a cooper as in this giude and try to reskining as in this guide. Then i place it on a map in worldbuilder, but i run a game, i can't see it.



I check "reload landmark system".
 
How does ConstAppearance and RandApp1 and RandApp2 work in Civ5?

Are the RandApp entries used at all anymore? How exactly does each change of 1 affect ConstAppearance?
 
Is it me or does it seem that adding new items like this is a lot more difficult. :confused:

I remember adding a new resource in Civ 3 to be a lot easier.
 
Back
Top Bottom