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

Using Modifiers - Chapter 1: Creating and attaching modifiers 2016-11-22

Learn how to implement modifiers into the game.

  1. NycholusV

    NycholusV Chieftain

    Joined:
    Jun 25, 2016
    Messages:
    85
    Gender:
    Male
    Location:
    Sydney, Australia
    This is the first chapter of a guide that I will be working on to explain Civ 6's new system of modifiers. The file attached is the example mod created in this first chapter, and the guide itself is on my website:

    https://nycholusv.com/civilization-6-modding/guides/using-modifiers/chapter-1/

    I've been working very hard to get this out ASAP to help people who are trying to mod and get their head around modifiers. Hopefully there aren't any mistakes or errors in the guide or the example mod, but if there are, please alert me.

    * * *​

    Civilization 6 introduces a new system of game mechanics known as ‘modifiers’. Modifiers allow dynamic changes to entities in the game, allowing a far greater degree of flexibility to modders. They are already used ubiquitously throughout the game; bonuses from civics, technologies, buildings, religion, policies etc. are all modifiers. They also exist in the form of unit promotions, diplomatic boosts and penalties, and elsewhere. Modifiers are perhaps the most crucial component of the game that modders must be able to use effectively to create custom content.

    This guide assumes that:
    • You are familiar at least at a very basic level with SQL.
    • You understand the file structure and implementation of XML/SQL based mods.
    • You can create a modinfo file for very basic mods. (There will be no discussion of this in the guide’s examples.)

    * * *​

    In this chapter, you will learn how to implement modifiers into the game. We will be creating a very basic ‘balance patch’, that will make a few changes to the game:
    1. The Stave Church (Norwegian unique building) grants a free missionary when built.
    2. Pax Britannica (Victoria’s leader bonus) grants +10% Production in cities settled on foreign continents.
    3. Increases the rate of border expansion universally by 50%.
    By the end of this chapter, you should be able to:
    • Attach modifiers to entities using the entity-modifier tables.
    • Understand what is meant by attaching a modifier as opposed to applying a modifier.
    • Create your own modifiers using modifier types and requirement sets included in the base game.
    • Understand the difference between modifiers and dynamic modifiers.
    • Understand the purpose and usage of the modifier arguments table.
    • Debug modifiers using log files and the tuner.
     
  2. gelodgreat

    gelodgreat Chieftain

    Joined:
    Oct 23, 2015
    Messages:
    441
    Gender:
    Male
    Location:
    Manila, Philippines
    Thanks really helpful :)
     
  3. cromcrom

    cromcrom Cernu

    Joined:
    Nov 11, 2005
    Messages:
    268
    Gender:
    Male
    Location:
    Chateauroux
    Yes, thanks a lot for taking the time for this. Cheers.
     
  4. Lord Yanaek

    Lord Yanaek Chieftain

    Joined:
    Aug 15, 2003
    Messages:
    1,465
    +1 for thanks and very useful

    Probably you already have this, but just in case i was looking at the DynamicModifiers table after learning of it's existence and i've extracted all the collections, effects and effects/collection in Libre Office spreadsheets if you want those.

    I guess effects and collections are hard-coded and DynamicModifiers is as far as we can go without dll modification aren't they?
     
  5. NycholusV

    NycholusV Chieftain

    Joined:
    Jun 25, 2016
    Messages:
    85
    Gender:
    Male
    Location:
    Sydney, Australia
    Effects and Collections are listed in GameEffects.xml, but cross-referencing is required to find out what they do, what their arguments are, and whether one should use some of the quirkier columns (like RunOnce and Permanent).

    Yes, effects and collections are hard-coded. The red boxes in the diagram at the top of the page represent hard-coded components. Still, there's so much you can do with just defining DynamicModifiers.
     
  6. Eltoshan

    Eltoshan Chieftain

    Joined:
    Jul 21, 2012
    Messages:
    14
    My God. I cannot begin to express how helpful this is. Thank you so much. I only wish I had this two days ago when I spent the entire day frustrated and trying to assess why my mod wouldn't work (I'm self-taught with this stuff), until I eventually noticed the "Modifiers.xml" file and started analyzing it. A few hours later, I literally smacked myself on the forehead. I've still got some issues getting certain aspects of my mod(s) to work, but at the very least they now load every time.

    (btw if anyone successfully added their own unique improvement to a mod and wouldn't mind giving me some help, I would appreciate it. I scoured the files for hours yesterday and it seems like currently it isn't possible solely by using .xml files)
     
    NycholusV likes this.
  7. NycholusV

    NycholusV Chieftain

    Joined:
    Jun 25, 2016
    Messages:
    85
    Gender:
    Male
    Location:
    Sydney, Australia
    Makes me really glad that this has helped this much. :)

    I have almost finished working on a custom civ with a unique improvement, and it's working fine. What in particular isn't working for you?
     
  8. gelodgreat

    gelodgreat Chieftain

    Joined:
    Oct 23, 2015
    Messages:
    441
    Gender:
    Male
    Location:
    Manila, Philippines
    i made a unique trait. you can see my code in GDG OP Civ mod. maybe it can help you
     
  9. gelodgreat

    gelodgreat Chieftain

    Joined:
    Oct 23, 2015
    Messages:
    441
    Gender:
    Male
    Location:
    Manila, Philippines
    @NycholusV can you help me making china to allow faster builds on every wonder? i cant seem to find the era modifier that needs to be altered
     
  10. Hajee

    Hajee Chieftain

    Joined:
    Nov 4, 2014
    Messages:
    332
    to any Mod can this thread be sticky?

    this thread should stay relevant for the life of the game
     
  11. Eltoshan

    Eltoshan Chieftain

    Joined:
    Jul 21, 2012
    Messages:
    14
    Basically my builders have no option for building the improvement. It never even shows that the builders WOULD be able to build it but can't due to "incorrect terrain/feature". That would at least narrow down my problem a bit. Maybe it specifically needs to be a leader trait and I'm using it as a civilization trait? I don't know the rules/etiquette on posting any actual code, but I know I have tried to copy the code from the main game files verbatim and couldn't get it to show up.
    I must have missed that one, I will take a look right now. Thanks.
     
    Last edited: Nov 22, 2016
  12. Lord Yanaek

    Lord Yanaek Chieftain

    Joined:
    Aug 15, 2003
    Messages:
    1,465
    Yep, but nothing i found to create a yield/population modifier for instance.
     
  13. thecrazyscot

    thecrazyscot Spiffy

    Joined:
    Dec 27, 2012
    Messages:
    1,735
    Great work. Any chance you'll be doing a deep dive into dynamic modifiers? Specifically collections? I'm not entirely sure what the differences are between them and when one is more appropriate than another.
     
  14. NycholusV

    NycholusV Chieftain

    Joined:
    Jun 25, 2016
    Messages:
    85
    Gender:
    Male
    Location:
    Sydney, Australia
    Took me some time to find it too. One would expect this would simply be a modifier argument, but it turns out it isn't. Line 44 in UnitCommands.xml is what is restricting this; the last field is 'MaxEra', which has been set to '2'. Seems a bit silly the way this is coded, but there's probably a good reason for it.

    Unique components must have their own trait. The trait can be the civ's or the leader's, but the important thing is that it is a trait exclusively for the unique component, it seems that otherwise it doesn't work. Units, improvements, etc. have a field called 'TraitType', which is where you associate the trait to the component.

    What specifically do you mean by a "yield/population modifier"? That sounds like something that is possible, if you would care to elaborate.

    Absolutely. That'll be the next part. Have you read the entire first chapter? I try to explain their difference. Also refer to the diagram at the top of the page, which shows the relationships between different tables.
     
  15. gelodgreat

    gelodgreat Chieftain

    Joined:
    Oct 23, 2015
    Messages:
    441
    Gender:
    Male
    Location:
    Manila, Philippines
    So you can only just alter it and not recreate it?
     
  16. NycholusV

    NycholusV Chieftain

    Joined:
    Jun 25, 2016
    Messages:
    85
    Gender:
    Male
    Location:
    Sydney, Australia
    Yeah, it seems so. I do wonder if there's a way to combine it with a Requirement. Though the developers would probably have done that if it were the case.
     
  17. Lord Yanaek

    Lord Yanaek Chieftain

    Joined:
    Aug 15, 2003
    Messages:
    1,465
    As a simple example, something that would add gold/population to every city after Currency to represent taxes, like 0.3 gold/population.
    I guess it's possible to create +1 gold/city and add a condition to check city is size 3, then another +1 if city is size 6 and so on to get roughly the same effect, but i haven't found an effect that directly adds a yield that grows with the size of the city. They are either fixed or % modifiers.
     
  18. cromcrom

    cromcrom Cernu

    Joined:
    Nov 11, 2005
    Messages:
    268
    Gender:
    Male
    Location:
    Chateauroux
    wouldn't lua quite simply allow this kind of effect ?
     
  19. Lord Yanaek

    Lord Yanaek Chieftain

    Joined:
    Aug 15, 2003
    Messages:
    1,465
    When/if we can finally load gameplay scripts into saved games probably.
    However, since we now have a very flexible modifiers system, it would be nice to be able to create such a modifier without scripts.
     
  20. NycholusV

    NycholusV Chieftain

    Joined:
    Jun 25, 2016
    Messages:
    85
    Gender:
    Male
    Location:
    Sydney, Australia
    Can't Lua scripts be used at this point?
     

Share This Page