Back to Unciv

Miscellaneous JSON files

docs/Modders/Mod-file-structure/5-Miscellaneous-JSON-files.md

4.20.450.4 KB
Original Source

Miscellaneous JSON files

Difficulties.json

Link to original

This optional file defines the difficulty levels a player can choose when starting a new game.

Base ruleset Mods can omit the file or supply an empty list, even though at least one difficulty is mandatory, in which case they inherit the ones from the Vanilla ruleset.

Each difficulty level has the following structure:

AttributeTypeDefaultNotes
nameStringRequired
baseHappinessInteger0
extraHappinessPerLuxuryFloat0
researchCostModifierFloat1
unitCostModifierFloat1
unitSupplyBaseInteger5
unitSupplyPerCityInteger2
buildingCostModifierFloat1
policyCostModifierFloat1
unhappinessModifierFloat1
barbarianBonusFloat0
barbarianSpawnDelayInteger0
playerBonusStartingUnitsList of StringsemptyCan also be 'Era Starting Unit', maps to startingMilitaryUnit of the Eras file. All other units must be in Units.json. Applies only to human player civs
aiDifficultyLevelStringemptyApplies some modifiers to the AI from the chosen difficulty. Modifiers such as unhappinessModifier and aiUnhappinessModifier stack multiplicatively. If empty: defaults to "Chieftain", or the first available difficulty.
aiCityGrowthModifierFloat1
aiUnitCostModifierFloat1
aiBuildingCostModifierFloat1
aiWonderCostModifierFloat1
aiBuildingMaintenanceModifierFloat1
aiUnitMaintenanceModifierFloat1
aiUnitSupplyModifierInteger5
aiFreeTechsList of StringsemptyMust be in Techs.json
aiMajorCivBonusStartingUnitsList of StringsemptySame rules as playerBonusStartingUnits, See above. Applies only to AI major civs
aiCityStateBonusStartingUnitsList of StringsemptySame rules as playerBonusStartingUnits, See above. Applies only to city-state civs
aiUnhappinessModifierFloat1
turnBarbariansCanEnterPlayerTilesInteger0
clearBarbarianCampRewardInteger25
uniquesList of StringsemptyWill be treated as part of GlobalUniques when this difficulty is chosen

Eras.json

Link to original

This file should contain all the era's you want to use in your mod.

Each era can have the following attributes:

AttributeTypeDefaultNotes
nameStringRequired
researchAgreementCostInteger (≥0)300Cost of research agreements when the most technologically advanced civ is in this era
iconRGBList of 3× IntegerwhiteRGB color that icons for technologies of this era should have in the Tech screen
startingSettlerCountInteger (≥0)1Amount of settler units that should be spawned when starting a game in this era (setting this to zero is discouraged 1)
startingSettlerUnitString"Settler"Name of the unit that should be used for the previous field. Must be in Units.json, or a unit with the "Founds a new city" unique must exist
startingWorkerCountInteger (≥0)0Amount of worker units that should be spawned when starting a game in this era
startingWorkerUnitString"Worker"Name of the unit that should be used for the previous field. If startingWorkerCount>0, then it must exist in Units.json, or a unit with the "Can build [filter] improvements on tiles" unique must exist
startingMilitaryUnitCountInteger (≥0)1Amount of military units that should be spawned when starting a game in this era
startingMilitaryUnitString"Warrior"Name of the unit that should be used for the previous field. Must be in Units.json
startingGoldInteger (≥0)0Amount of gold each civ should receive when starting a game in this era
startingCultureInteger (≥0)0Amount of culture each civ should receive when starting a game in this era
settlerPopulationInteger (>0)1Amount of population each city should have when settled when starting a game in this era
settlerBuildingsList of StringsemptyBuildings that should automatically be built whenever a city is settled when starting a game in this era
startingObsoleteWondersList of StringsemptyWonders (and technically buildings) that should be impossible to built when starting a game in this era. Used in the base game to remove all wonders older than 2 era's
baseUnitBuyCostInteger200Default value used for the unique Can be purchased with [stat] [cityFilter]
embarkDefenseInteger3Default defense for embarked unit in this era
startPercentInteger0When starting, percentage ([0]%-[100]%) of turns skipped in total turns specified in Speed.json
citySoundString"cityClassical"Sound used when city is founded in this era
uniquesList of StringsemptyWill be treated as part of GlobalUniques when starting in this era

Speeds.json

Link to original

This optional file should contain all the speeds you want to use in your mod.

Base ruleset Mods can omit the file or supply an empty list, even though at least one game speed is mandatory, in which case they inherit the ones from the Vanilla ruleset.

Each speed can have the following attributes:

AttributeTypeDefaultNotes
nameStringRequiredName of the speed
modifierFloat (≥0)1.0Overall game speed modifier
productionCostModifierFloat (≥0)modifier valueScales production cost of units and buildings
goldCostModifierFloat (≥0)modifier valueScales gold costs
scienceCostModifierFloat (≥0)modifier valueScales science costs
cultureCostModifierFloat (≥0)modifier valueScales culture costs
faithCostModifierFloat (≥0)modifier valueScales faith costs
improvementBuildLengthModifierFloat (≥0)modifier valueScales the time it takes for a worker to build tile improvements
barbarianModifierFloat (≥0)modifier valueScales the time between barbarian spawns
goldGiftModifierFloat (≥0)modifier valueScales the influence gained from gifting gold to city-states
cityStateTributeScalingIntervalFloat (≥0)6.5The number of turns it takes for the amount of gold a player demands from city-states to increase by 5 gold
goldenAgeLengthModifierFloat (≥0)modifier valueScales the length of golden ages
religiousPressureAdjacentCityInteger (≥0)6Defines how much religious pressure a city exerts on nearby cities
peaceDealDurationInteger (≥0)10The number of turns a peace deal lasts
dealDurationInteger (≥0)30The number of turns a non-peace deal (research agreement, open borders, etc.) lasts
startYearFloat-4000The start year of the game (negative is BC/BCE)
turnsListRequiredList of time interval per turn, see below
uniquesList of StringsemptyWill be treated as part of GlobalUniques when this speed is chosen

Time interval per turn

The "turns" attribute defines the number of years passing between turns. The attribute consists of a list of objects, each having 2 required attributes: "yearsPerTurn" (Float) and "untilTurn" (Integer)

AttributeTypeDefaultNotes
yearsPerTurnIntegerRequiredNumber of years passing between turns
untilTurnIntegerRequiredEnd of this interval (if it is the last object, see below)

For each row, "yearsPerTurn" is applied up to the "untilTurn"-1 to "untilTurn" step. The last "untilTurn" in the list is ignored for year calculation, that is, if a game passes that turn number, years continue to increment by the "yearsPerTurn" of the last entry. However, this is used when starting a game in a later Era: Era.startPercent is relative to the last "untilTurn".

The code below is an example of a valid "turns" definition and it specifies that the first 50 turns of a game last for 60 years each, then the next 30 turns (and any played after the 80th) last for 40 years each.

json
"turns": [
    {"yearsPerTurn": 60, "untilTurn":  50},
    {"yearsPerTurn": 40, "untilTurn":  80}
]

Events.json

Events allow users to choose between options of triggers to activate.

AttributeTypeDefaultNotes
nameStringRequiredUsed for triggering via "Triggers a [event] event" unique
textStringNoneFlavor text displayed to user
presentationOne of: "None", "Alert", "Floating"Alert"Alert" indicates a regular popup, "None" means the choice is made randomly, "Floating" is for tutorial-style indicators
civilopediaTextListOptionalSee civilopediaText chapter
choicesList of EventChoicesUser can choose to trigger one of the viable choices

You can use text and/or civilopediaText, if both are present both are shown (but why would you?)

Event choices are comprised of:

AttributeTypeDefaultNotes
textStringRequiredDisplayed to user as button. Should be an action name - "Do X"
uniquesList of uniques to trigger or limit conditionsRequiredThe triggers that this choice activates upon being chosen, and "Unavailable" / "Only available" uniques
keyShortcutkey to select (name)noneKey names see Gdx.Input.Keys
civilopediaTextListOptionalSee civilopediaText chapter

Here, civilopediaText is shown outside the active Button, before the triggeredUniques.

ModOptions.json

<!-- [Link to original](https://github.com/yairm210/Unciv/tree/master/android/assets/jsons/Civ%20V%20-%20Gods%20&%20Kings/ModOptions.json) -->

This file is a little different:

  • Does not exist in Vanilla ruleset
  • Is entirely optional but will be created after downloading a mod

Note that this file controls declarative mod compatibility (Work in progress) - e.g. there's uniques to say your Mod should only or never be used as 'Permanent audiovisual mod'. Incompatibility filtering works so far between extension and base mods, but feel free to document known extension-to-extension incompatibilities using the same Unique now. Stay tuned!

The file can have the following attributes, not including the values Unciv sets automatically:

AttributeTypedefaultNotes
isBaseRulesetBooleanfalseReplaces vanilla ruleset if true
uniquesListemptyMod-wide specials, see here
techsToRemoveListemptyList of Technologies or technologyFilter to remove (isBaseRuleset=false only)
buildingsToRemoveListemptyList of Buildings or Wonders or buildingFilter to remove (isBaseRuleset=false only)
unitsToRemoveListemptyList of Units or unitFilter to remove (isBaseRuleset=false only)
nationsToRemoveListemptyList of Nations or nationFilter to remove (isBaseRuleset=false only)
policyBranchesToRemoveListemptyList of Policy Branches to remove (isBaseRuleset=false only)
policiesToRemoveListemptyList of Policies to remove (isBaseRuleset=false only)
beliefsToRemoveListemptyList of Beliefs to remove (isBaseRuleset=false only)
religionsToRemoveListemptyList of Religions to remove (isBaseRuleset=false only)
constantsObjectemptySee ModConstants
tilesetStringemptyOnly applicable for base rulesets
unitsetStringemptyOnly applicable for base rulesets

The values normally set automatically from github metadata are:

AttributeTypeNotes
modUrlStringThe github page the mod was downloaded from, or empty if a freely hosted zip was used
defaultBranchStringmasterThe repo's default branch
authorStringRepo owner
lastUpdatedStringISO date
modSizeInteger0Size in kB
topicsListemptyA list of "unciv-mod-*" github topics

To clarify: When your Mod is distributed via github, including these in the Mod repo has no effect. However, when a Mod is distributed without a github repository, these values can and should be set by the author in the distributed ModOptions.json.

ModConstants

Stored in ModOptions.constants, this is a collection of constants used internally in Unciv. This is the only structure that is merged field by field from mods, not overwritten, so you can change XP from Barbarians in one mod and city distance in another. In case of conflicts, there is no guarantee which mod wins, only that default values are ignored.

AttributeTypeDefaultNotes
maxXPfromBarbariansInt302
cityStrengthBaseFloat8.03
cityStrengthPerPopFloat0.43
cityStrengthFromTechsMultiplierFloat5.53
cityStrengthFromTechsExponentFloat2.83
cityStrengthFromTechsFullMultiplierFloat1.03
cityStrengthFromGarrisonFloat0.23
baseCityBombardRangeInt24
cityWorkRangeInt35
cityExpandRangeInt56
cityAirUnitCapacityInt67
unitSupplyPerPopulationFloat0.58
minimalCityDistanceInt39
minimalCityDistanceOnDifferentContinentsInt29
unitUpgradeCostObjectSee below10
naturalWonderCountMultiplierFloat0.12411
naturalWonderCountAddedConstantFloat0.111
ancientRuinCountMultiplierFloat0.0212
spawnIceBelowTemperatureFloat-0.813
maxLakeSizeInt1014
riverCountMultiplierFloat0.0115
minRiverLengthInt515
maxRiverLengthInt66615
religionLimitBaseInt116
religionLimitMultiplierFloat0.516
pantheonBaseInt1017
pantheonGrowthInt517
workboatAutomationSearchMaxTilesInt2018
maxSpyRankInt319
spyRankSkillPercentBonusFloat3020
minimumWarDurationInt1021
baseTurnsUntilRevoltInt422
cityStateElectionTurnsInt1523
maxImprovementTechErasForwardIntNone4
goldGiftMultiplierFloat15
goldGiftTradeMultiplierFloat0.86
goldGiftDegradationMultiplierFloat1.0[^V]

Legend:

UnitUpgradeCost

These values are not merged individually, only the entire sub-structure is.

AttributeTypeNotes
baseFloat10
perProductionFloat2
eraMultiplierFloat0
exponentFloat1
roundToInt5

The formula for the gold cost of a unit upgrade is (rounded down to a multiple of roundTo): ( max((base + perProduction * (new_unit_cost - old_unit_cost)), 0) * (1 + eraNumber * eraMultiplier) * civModifier ) ^ exponent With civModifier being the multiplicative aggregate of "[relativeAmount]% Gold cost of upgrading" uniques that apply.

GlobalUniques.json

link to original

GlobalUniques defines uniques that apply globally. e.g. Vanilla rulesets define the effects of Unhappiness here.

Base ruleset Mods can omit the file, in which case they inherit the ones from the Vanilla ruleset. Alternatively, they can supply a file with an empty object ({}), meaning that no global Uniques exist for that Mod.

It has the following structure:

AttributeTypeDefaultNotes
nameString"GlobalUniques"The name field is not used, but still must be set (the Ruleset validator might display it).
uniquesList of StringsemptyList of unique abilities that apply globally
unitUniquesList of StringsemptyList of unique abilities that applies to each unit

When extension rulesets define GlobalUniques, all uniques are merged. At the moment there is no way to change/remove uniques set by a base mod.

Tutorials.json

link to original

Note a Base Ruleset mod can define a "welcome page" here by adding a "Tutorial" with a name equal to the name of the mod! As an exception to the general rule, this file in a Base Ruleset mod will not replace the default, but add to it like extension mods do. Also, place it under <mod>/jsons/ normally even if the original is found one level above the vanilla jsons.

Each tutorial has the following structure:

AttributeTypeDefaultNotes
nameStringRequiredEntry name
categoryStringOptionalThe category where this tutorial will be displayed. "Tutorials" is the default.
civilopediaTextListOptionalSee civilopediaText chapter
stepsList of StringsOptionalPlain text

If an entry contains both steps and civilopediaText attributes, the civilopediaText is shown first. Tutorials shown as Popup can show an show an external image (not part of the texture atlases) if there is an image unter ExtraImages (directly under assets or the Mod folder) having the same name. This is searched for, meaning the mod defining the Tutorial is irrelevant, mods can override builtin ExtraImages, and case sensitivity depends on the OS.

VictoryTypes.json

link to original

These files contain which victories this mod provides, and what milestones must be reached for someone to win a victory. Most of the file contains of strings that are shown to the user in the victory screen, with the rest being the requirements for winning.

Base ruleset Mods can omit the file or supply an empty list, even though at least one victory type is mandatory, in which case they inherit the ones from the Vanilla ruleset.

Each victory have the following structure:

AttributeTypeDefaultNotes
nameStringRequiredName of the victory
victoryScreenHeaderStringnoneShown in the footer of the victory in the our status in the victory screen
victoryStringStringnoneShown in the footer of the victory screen when you won the game with this victory
defeatStringStringnoneShown in the footer of the victory screen when someone else won the game with this victory
hiddenInVictoryScreenBooleanfalseWhether progress of this victory is hidden in the victory screen
requiredSpaceshipPartsList of StringsemptyWhat spaceship parts must be added to the capital for the corresponding milestone
MilestonesList of StringsRequiredList of milestones that must be accomplished to win, see below
civilopediaTextListOptionalSee civilopediaText chapter

Milestones

Currently the following milestones are supported:

MilestoneRequirement
Build [building]Build the building [building] in any city
Anyone should build [building]Anyone must build the building [building] for all players to have this milestone
Add all [comment] in capitalAdd all units in the requiredSpaceshipParts field of this victory to the capital
Destroy all playersYou must be the only major civilization with any cities left
Capture all capitalsCapture all the original capitals of major civilizations in the game
Complete [amount] Policy branchesFully complete at least [amount] policy branches
Win diplomatic voteAt any point in the game win a diplomatic vote (UN). You may lose afterwards and still retain this milestone
Become the world religionHave your religion be the majority religion in a majority of cities of all major civs
Have highest score after max turnsBasically time victory. Enables the 'max turn' slider and calculates score when that amount is reached
Have more [countable] than each player's [countable]Have your given countable be more than every other Civilization's countable to achieve this victory. This is useful to simulate a victory similar to the Cultural Victory in Brave New World.

Civilopedia text

Any 'thing' defined in json and listed in the Civilopedia can supply extra text, specifically for the Civilopedia. This can be used to explain special considerations better when the automatically generated display is insufficient, or for 'flavour', background stories and the like. Such text can be formatted and linked to other Civilopedia entries, within limits.

An example of the format is:

json
"civilopediaText": [
    { "text": "Ancient ruins provide a one-time random bonus when explored" },
    { "separator": true },
    {
        "text": "This line is red and links to the Scout including icons",
        "link": "Unit/Scout",
        "color": "red"
    },
    {
        "text": "A big fat header sporting a golden star",
        "header": 1,
        "starred": true,
        "color": "#ffeb7f"
    },
],

List of attributes - note not all combinations are valid:

AttributeTypeDescription
textStringText to display
linkStringCreate link and icon, format: Category/Name or external link ('http://','https://','mailto:')
iconStringShow icon without linking, format: Category/Name
extraImageStringDisplay an Image instead of text. Can be a path found in a texture atlas or or the name of a png or jpg in the ExtraImages folder
imageSizeFloatSize in world units of the [extraImage], the smaller coordinate is calculated preserving aspect ratio. available width
headerIntegerHeader level. 1 means double text size and decreases from there
sizeIntegerText size, is 18. Use size or header but not both
indentIntegerIndent level. 0 means text will follow icons, 1 aligns to the right of all icons, each further step is 30 units
paddingFloatVertical padding between rows, 5 units
colorStringSets text color, accepts names or 6/3-digit web colors (e.g. #FFA040)
separatorBooleanRenders a separator line instead of text. Can be combined only with color and size (line width, default 2)
starredBooleanDecorates text with a star icon - if set, it receives the color instead of the text
centeredBooleanCenters the line (and turns off automatic wrap). For an extraImage, turns on crop-to-content to equalize transparent borders
iconCrossedBooleanPaint a red X over the icon or link image

The lines from json will 'surround' the automatically generated lines such that the latter are inserted just above the first json line carrying a link, if any. If no json lines have links, they will be inserted between the automatic title and the automatic info. This method may, however, change in the future.

Note: text now also supports inline color markup. Insert «color» to start coloring text, «» to stop. color can be a name or 6/8-digit hex notation like #ffa040 (different from the color attribute notation only by not allowing 3-digit codes, but allowing the alpha channel). Effectively, the «» markers are replaced with [] after translation and then passed to gdx markup language.

Note: Using an ExtraImages folder in a mod was not working until version 4.11.5

RGB colors list

Certain objects can be specified to have its own unique color. The colors are defined by a list of 3× Integer in this order: red, green, blue. The range of color is from [0, 0, 0] (black) to [255, 255, 255] (white).

Note: The default of some objects are gdx color classes. The values of the constants are as follows:

namevalue
gold[225, 215, 0]
white[255, 255, 255]
black[0, 0, 0]

Footnotes

  1. Successfully setting startingSettlerCount to zero in a mod (idea: conquer or die) is not easy. Some player-controlled settings require at least one Settler, through any source (see difficulties for other possible settler sources), or you won't be able to start a game: Once City Challenge requires one for all players, and allowing any city-states requires one for those. Would also affect defeat rules.

  2. Max amount of experience that can be gained from combat with barbarians

  3. Formula for city Strength: Strength = baseStrength + strengthPerPop + strengthFromTiles + ((%techs * multiplier) ^ exponent) * fullMultiplier + (garrisonBonus * garrisonUnitStrength * garrisonUnitHealth/100) + defensiveBuildingStrength where %techs is the percentage of techs in the tech tree that are complete If no techs exist in this ruleset, %techs = 0.5 (=50%) 2 3 4 5 6

  4. The distance that cities can attack 2

  5. The tiles in distance that population in cities can work on. Note: Higher values may lead to performace issues and may cause bugs. cityWorkRange may be greater than cityExpandRange. 2

  6. The distance that cities can expand their borders to. Note: Higher values may lead to performace issues and may cause bugs. 2

  7. Number of air units that can be stationed in a city, not including carried/transported air units.

  8. Formula for Unit Supply: Supply = unitSupplyBase (difficulties.json) unitSupplyPerCity * amountOfCities + (difficulties.json) unitSupplyPerPopulation * amountOfPopulationInAllCities unitSupplyBase and unitSupplyPerCity can be found in difficulties.json unitSupplyBase, unitSupplyPerCity and unitSupplyPerPopulation can also be increased through uniques

  9. The minimal distance that must be between any two cities, not counting the tiles cities are on The number is the amount of tiles between two cities, not counting the tiles the cities are on. e.g. "C__C", where "C" is a tile with a city and "_" is a tile without a city, has a distance of 2. First constant is for cities on the same landmass, the second is for cities on different continents. 2

  10. A UnitUpgradeCost sub-structure.

  11. NaturalWonderGenerator uses these to determine the number of Natural Wonders to spawn for a given map size. The number scales linearly with map radius: #wonders = radius * naturalWonderCountMultiplier + naturalWonderCountAddedConstant. The defaults effectively mean Tiny - 1, Small - 2, Medium - 3, Large - 4, Huge - 5, Custom radius >=109 - all G&K wonders. 2

  12. MapGenerator.spreadAncientRuins: number of ruins = suitable tile count * this

  13. MapGenerator.spawnIce: spawn Ice where T < this, with T calculated from temperatureExtremeness, latitude and perlin noise.

  14. MapGenerator.spawnLakesAndCoasts: Water bodies up to this tile count become Lakes

  15. RiverGenerator: river frequency and length bounds 2 3

  16. Maximum foundable Religions = religionLimitBase + floor(MajorCivCount * religionLimitMultiplier) 2

  17. Cost of pantheon = pantheonBase + CivsWithReligion * pantheonGrowth 2

  18. When the AI decides whether to build a work boat, how many tiles to search from the city center for an improvable tile

  19. The maximum rank any spy can reach

  20. How much skill bonus each rank gives

  21. The number of turns a civ has to wait before negotiating for peace

  22. The number of turns before a revolt is spawned

  23. The number of turns between city-state elections