1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Tutorial: How to add a new Resource

Discussion in 'Civ5 - Modding Tutorials & Reference' started by Kyoss, Oct 8, 2010.

  1. blazekid87

    blazekid87 Warlord

    Joined:
    Oct 5, 2010
    Messages:
    179
    Location:
    NYC
    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.
     
  2. Tarkeel

    Tarkeel Imperial

    Joined:
    Jun 27, 2003
    Messages:
    756
    Location:
    Norway
    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.
     
  3. Kyoss

    Kyoss Chieftain

    Joined:
    Jun 21, 2008
    Messages:
    50
    Location:
    Germany
    Thats done here. There's a modified AssignStartingPlots.lua in the .zip
     
  4. Quethas

    Quethas Chieftain

    Joined:
    Sep 30, 2010
    Messages:
    8
    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!
     
  5. ssaga

    ssaga Chieftain

    Joined:
    Nov 18, 2008
    Messages:
    7
    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.
     
  6. Deep_Blue

    Deep_Blue Knight

    Joined:
    Aug 2, 2005
    Messages:
    750
    Do you know how to add a luxury? it seems this tutorial cant be used to add luxury, I tried many times through lua / xml but no success.
     
  7. Deep_Blue

    Deep_Blue Knight

    Joined:
    Aug 2, 2005
    Messages:
    750
    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?
     
  8. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    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.
     
  9. Deep_Blue

    Deep_Blue Knight

    Joined:
    Aug 2, 2005
    Messages:
    750
    I tired that and it fails, I get runtime error every time although I did copy the code from old luxury.
     
  10. Deep_Blue

    Deep_Blue Knight

    Joined:
    Aug 2, 2005
    Messages:
    750
    Please edit: you have to select DXT3 when saving the file, if you select DTX1 Alpha mask will be lost.
     
  11. Slowpoke

    Slowpoke The Mad Modder

    Joined:
    Sep 30, 2010
    Messages:
    1,321
    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"?
     
  12. Kyoss

    Kyoss Chieftain

    Joined:
    Jun 21, 2008
    Messages:
    50
    Location:
    Germany
    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.
     
  13. Slowpoke

    Slowpoke The Mad Modder

    Joined:
    Sep 30, 2010
    Messages:
    1,321
    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.
     
  14. alpaca

    alpaca King of Ungulates

    Joined:
    Aug 3, 2006
    Messages:
    2,322
    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.
     
  15. Slowpoke

    Slowpoke The Mad Modder

    Joined:
    Sep 30, 2010
    Messages:
    1,321
    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.
     
  16. Deep_Blue

    Deep_Blue Knight

    Joined:
    Aug 2, 2005
    Messages:
    750
  17. Slowpoke

    Slowpoke The Mad Modder

    Joined:
    Sep 30, 2010
    Messages:
    1,321
    Edit: nevermind
     
  18. liaa

    liaa Chieftain

    Joined:
    Jan 11, 2011
    Messages:
    42
    Thanks for a guide, good work!

    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".
     
  19. civcivv

    civcivv Warlord

    Joined:
    Dec 1, 2009
    Messages:
    126
    Location:
    London
    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?
     
  20. Riker13

    Riker13 King

    Joined:
    Nov 9, 2001
    Messages:
    802
    Location:
    UK
    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.
     

Share This Page