diff --git a/docs/export-map.rst b/docs/export-map.rst index 449187dff..11d1b87fb 100644 --- a/docs/export-map.rst +++ b/docs/export-map.rst @@ -87,7 +87,12 @@ Options TOPAZOLITE/BLACK_OPAL/etc.) (will return nil if the tile is empty) ``-u``, ``--underworld`` - Whether the underworld z-levels will be included [boolean] + Whether the underworld z-levels will be included + +``-e``, ``--evilness`` + Whether the evilness value will be included in MAP_SIZE table. This only + checks the value of the center map tile at ground level and will ignore + biomes at the edges of the map. JSON DATA --------- diff --git a/export-map.lua b/export-map.lua index f0706542e..4eff32cbf 100644 --- a/export-map.lua +++ b/export-map.lua @@ -10,6 +10,7 @@ local argparse = require('argparse') local include_underworld_z = false local underworld_z +local evilness -- the layer of the underworld for _, feature in ipairs(df.global.world.features.map_features) do @@ -18,6 +19,21 @@ for _, feature in ipairs(df.global.world.features.map_features) do end end +-- copied from agitation-rebalance.lua +-- check only one tile at the center of the map at ground lvl +-- (this ignore different biomes on the edges of the map) +local function get_evilness() + -- check around ground level + local lvls_above_ground = world.worldgen.worldgen_parms.levels_above_ground + local ground_z = (world.map.z_count - 2) - lvls_above_ground + local xmax, ymax = dfhack.maps.getTileSize() + local center_x, center_y = math.floor(xmax/2), math.floor(ymax/2) + local rgnX, rgnY = dfhack.maps.getTileBiomeRgn(center_x, center_y, ground_z) + local biome = dfhack.maps.getRegionBiome(rgnX, rgnY) + + return biome and biome.evilness or 0 +end + local function classify_tile(options, x, y, z) -- The last z-levels of hell shrink their x/y size unexpectedly! (ಠ_ಠ) -- if your map is 190x190, the last hell z-levels are gonna be like 90x90 @@ -155,6 +171,7 @@ local function export_all_z_levels(fortress_name, folder, options) -- subtract underworld levels if excluded from options z = include_underworld_z and zmax or (zmax - underworld_z), underworld_z_level = include_underworld_z and underworld_z or nil, + evilness = evilness or nil, } data.KEYS = setup_keys(options) @@ -230,7 +247,8 @@ local positionals = argparse.processArgsGetopt(args, { {'a', 'aquifer', handler=function() options.aquifer = true end}, {'m', 'material', handler=function() options.material = true end}, -- local var since underworld not in ordered option - {'u', 'underworld', handler= function() include_underworld_z = true end}, + {'u', 'underworld', handler=function() include_underworld_z = true end}, + {'e', 'evilness', handler=function() evilness = get_evilness() end}, }) if positionals[1] == "help" or options.help then