local args = {...}
function animaldiversity (yesmegas)
local profile =
{BIOME_MOUNTAIN = 0,
BIOME_GLACIER = 0,
BIOME_TUNDRA = 0,
BIOME_SWAMP_TEMPERATE_SALTWATER = 0,
BIOME_SWAMP_TEMPERATE_FRESHWATER = 0,
BIOME_MARSH_TEMPERATE_FRESHWATER = 0,
BIOME_MARSH_TEMPERATE_SALTWATER = 0,
BIOME_SWAMP_TROPICAL_FRESHWATER = 0,
BIOME_SWAMP_TROPICAL_SALTWATER = 0,
BIOME_SWAMP_MANGROVE = 0,
BIOME_MARSH_TROPICAL_FRESHWATER = 0,
BIOME_MARSH_TROPICAL_SALTWATER = 0,
BIOME_FOREST_TAIGA = 0,
BIOME_FOREST_TEMPERATE_CONIFER = 0,
BIOME_FOREST_TEMPERATE_BROADLEAF = 0,
BIOME_FOREST_TROPICAL_CONIFER = 0,
BIOME_FOREST_TROPICAL_DRY_BROADLEAF = 0,
BIOME_FOREST_TROPICAL_MOIST_BROADLEAF = 0,
BIOME_GRASSLAND_TEMPERATE = 0,
BIOME_SAVANNA_TEMPERATE = 0,
BIOME_SHRUBLAND_TEMPERATE = 0,
BIOME_GRASSLAND_TROPICAL = 0,
BIOME_SAVANNA_TROPICAL = 0,
BIOME_SHRUBLAND_TROPICAL = 0,
BIOME_DESERT_BADLAND = 0,
BIOME_DESERT_ROCK = 0,
BIOME_DESERT_SAND = 0,
BIOME_OCEAN_TROPICAL = 0,
BIOME_OCEAN_TEMPERATE = 0,
BIOME_OCEAN_ARCTIC = 0,
--BIOME_SUBTERRANEAN_WATER = 0,
--BIOME_SUBTERRANEAN_CHASM = 0,
--BIOME_SUBTERRANEAN_LAVA = 0,
GOOD = false,
EVIL = false,
SAVAGE = false}
local map_height = df.global.world.world_data.world_height
local pole = df.global.world.world_data.flip_latitude
--============================================================
function addone(p,k)
p[k]=p[k]+1
end
--============================================================
function check_tropicality_no_poles_world (temperature)
local is_possible_tropical_area_by_latitude = false
local is_tropical_area_by_latitude = false
-- No poles => Temperature determines tropicality
--
if temperature >= 75 then
is_possible_tropical_area_by_latitude = true
end
is_tropical_area_by_latitude = temperature >= 85
return is_possible_tropical_area_by_latitude, is_tropical_area_by_latitude
end
--============================================================
function check_tropicality_north_pole_only_world (pos_y,
map_height)
local v6
local is_possible_tropical_area_by_latitude = false
local is_tropical_area_by_latitude = false
if map_height == 17 then
v6 = pos_y * 16
elseif map_height == 33 then
v6 = pos_y * 8
elseif map_height == 65 then
v6 = pos_y * 4
elseif map_height == 129 then
v6 = pos_y * 2
else
v6 = pos_y
end
is_possible_tropical_area_by_latitude = v6 > 170
is_tropical_area_by_latitude = v6 >= 200
return is_possible_tropical_area_by_latitude, is_tropical_area_by_latitude
end
--============================================================
function check_tropicality_south_pole_only_world (pos_y,
map_height)
local v6 = map_height - pos_y - 1
local is_possible_tropical_area_by_latitude = false
local is_tropical_area_by_latitude = false
if map_height == 17 then
v6 = v6 * 16
elseif map_height == 33 then
v6 = v6 * 8
elseif map_height == 65 then
v6 = v6 * 4
elseif map_height == 129 then
v6 = v6 * 2
else
v6 = v6
end
is_possible_tropical_area_by_latitude = v6 > 170
is_tropical_area_by_latitude = v6 >= 200
return is_possible_tropical_area_by_latitude, is_tropical_area_by_latitude
end
--============================================================
function check_tropicality_both_poles_world (pos_y,
map_height)
local v6
local is_possible_tropical_area_by_latitude = false
local is_tropical_area_by_latitude = false
if pos_y < math.floor (map_height / 2) then
v6 = 2 * pos_y
else
v6 = map_height + 2 * (math.floor (map_height / 2) - pos_y) - 1
if v6 < 0 then
v6 = 0
end
if v6 >= map_height then
v6 = map_height - 1
end
end
if map_height == 17 then
v6 = v6 * 16
elseif map_height == 33 then
v6 = v6 * 8
elseif map_height == 65 then
v6 = v6 * 4
elseif map_height == 129 then
v6 = v6 * 2
else
v6 = v6
end
is_possible_tropical_area_by_latitude = v6 > 170
is_tropical_area_by_latitude = v6 >= 200
return is_possible_tropical_area_by_latitude, is_tropical_area_by_latitude
end
--============================================================
function check_tropicality (pos_y,
map_height,
temperature,
pole)
if pole == -1 then -- No poles
return check_tropicality_no_poles_world (temperature)
elseif pole == 0 then -- North pole
return check_tropicality_north_pole_only_world (pos_y,
map_height)
elseif pole == 1 then -- South pole
return check_tropicality_south_pole_only_world (pos_y,
map_height)
elseif pole == 2 then -- Both poles
return check_tropicality_both_poles_world (pos_y,
map_height)
else
return false, false
end
end
--============================================================
function get_parameter_percentage (flip_latitude,
pos_y,
rainfall,
map_height)
local result
local ypos = pos_y
if flip_latitude == -1 then -- No poles
return 100
elseif flip_latitude == 1 then -- South pole
ypos = map_height - ypos - 1
elseif flip_latitude == 2 then -- North and South pole
if ypos < math.floor (map_height / 2) then
ypos = ypos * 2
else
ypos = map_height + 2 * (math.floor (map_height / 2) - ypos) - 1
if ypos < 0 then
ypos = 0
end
if ypos >= map_height then
ypos = map_height - 1
end
end
end
local latitude
if map_height == 17 then
latitude = 16 * ypos
elseif map_height == 33 then
latitude = 8 * ypos
elseif map_height == 65 then
latitude = 4 * ypos
elseif map_height == 129 then
latitude = 2 * ypos
else
latitude = ypos
end
if latitude > 220 then
return 100
elseif latitude > 190 and
latitude < 201 then
return 0
elseif latitude >= 201 then
result = rainfall + 16 * (latitude - 207)
else
result = 16 * (184 - latitude) - rainfall
end
if result < 0 then
return 0
elseif result > 100 then
return 100
else
return result
end
end
--============================================================
function get_region_parameter (pos_y,
rainfall,
map_height)
local result = 100
if map_height > 65 then -- Medium & Large worlds
return get_parameter_percentage (pole,
pos_y,
rainfall,
map_height)
end
return result
end
--============================================================
function get_ocean_biome (is_tropical_area_by_latitude,
temperature)
if is_tropical_area_by_latitude then
return df.biome_type.OCEAN_TROPICAL
elseif temperature <= -5 then
return df.biome_type.OCEAN_ARCTIC
else
return df.biome_type.OCEAN_TEMPERATE
end
end
--============================================================
function get_desert_biome (drainage)
if drainage < 33 then
return df.biome_type.DESERT_SAND
elseif drainage < 66 then
return df.biome_type.DESERT_ROCK
else
return df.biome_type.DESERT_BADLAND
end
end
--============================================================
function get_biome_grassland (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
rainfall,
pos_y,
map_height)
if (is_possible_tropical_area_by_latitude and
get_region_parameter(pos_y, rainfall, map_height) < 66) or
is_tropical_area_by_latitude then
return df.biome_type.GRASSLAND_TROPICAL
else
return df.biome_type.GRASSLAND_TEMPERATE
end
end
--============================================================
function get_biome_savanna (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
rainfall,
pos_y,
map_height)
if is_tropical_area_by_latitude or
(is_possible_tropical_area_by_latitude and
get_region_parameter (pos_y, rainfall, map_height) <= 6) then
return df.biome_type.SAVANNA_TROPICAL
else
return df.biome_type.SAVANNA_TEMPERATE
end
end
--============================================================
function get_biome_desert_or_grassland_or_savanna (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
vegetation,
drainage,
rainfall,
pos_y,
map_height)
if vegetation < 10 then
return get_desert_biome (drainage)
elseif vegetation < 20 then
return get_biome_grassland (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
rainfall,
pos_y,
map_height)
else
return get_biome_savanna (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
rainfall,
pos_y,
map_height)
end
end
--============================================================
function get_biome_shrubland (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
rainfall,
pos_y,
map_height)
if is_tropical_area_by_latitude or
(is_possible_tropical_area_by_latitude and
get_region_parameter (pos_y, rainfall, map_height) < 66) then
return df.biome_type.SHRUBLAND_TROPICAL
else
return df.biome_type.SHRUBLAND_TEMPERATE
end
end
--============================================================
function get_biome_marsh (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
salinity,
rainfall,
pos_y,
map_height)
if salinity < 66 then
if is_tropical_area_by_latitude or
(is_possible_tropical_area_by_latitude and
get_region_parameter (pos_y, rainfall, map_height) < 66) then
return df.biome_type.MARSH_TROPICAL_FRESHWATER
else
return df.biome_type.MARSH_TEMPERATE_FRESHWATER
end
else
if is_tropical_area_by_latitude or
(is_possible_tropical_area_by_latitude and
get_region_parameter (pos_y, rainfall, map_height) < 66) then
return df.biome_type.MARSH_TROPICAL_SALTWATER
else
return df.biome_type.MARSH_TEMPERATE_SALTWATER
end
end
end
--============================================================
function get_biome_shrubland_or_marsh (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
drainage,
salinity,
rainfall,
pos_y,
map_height)
if drainage < 33 then
return get_biome_marsh (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
salinity,
rainfall,
pos_y,
map_height)
else
return get_biome_shrubland (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
rainfall,
pos_y,
map_height)
end
end
--============================================================
function get_biome_forest (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
rainfall,
temperature,
pos_y,
map_height)
local parameter = get_region_parameter (pos_y, rainfall, map_height)
if is_possible_tropical_area_by_latitude then
if (parameter < 66 or
is_tropical_area_by_latitude) and
rainfall < 75 then
return df.biome_type.FOREST_TROPICAL_CONIFER
elseif parameter < 66 then
return df.biome_type.FOREST_TROPICAL_DRY_BROADLEAF
elseif is_tropical_area_by_latitude then
return df.biome_type.FOREST_TROPICAL_MOIST_BROADLEAF
elseif rainfall < 75 or
temperature < 65 then
if temperature < 10 then
return df.biome_type.FOREST_TAIGA
else
return df.biome_type.FOREST_TEMPERATE_CONIFER
end
else
return df.biome_type.FOREST_TEMPERATE_BROADLEAF
end
else
if rainfall < 75 or
temperature < 65 then
if temperature < 10 then
return df.biome_type.FOREST_TAIGA
else
return df.biome_type.FOREST_TEMPERATE_CONIFER
end
else
return df.biome_type.FOREST_TEMPERATE_BROADLEAF
end
end
end
--============================================================
function get_biome_swamp (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
salinity,
drainage,
rainfall,
pos_y,
map_height)
local parameter = get_region_parameter (pos_y, rainfall, map_height)
if is_possible_tropical_area_by_latitude then
if salinity < 66 then
if parameter < 66 or
is_tropical_area_by_latitude then
return df.biome_type.SWAMP_TROPICAL_FRESHWATER
else
return df.biome_type.SWAMP_TEMPERATE_FRESHWATER
end
elseif parameter < 66 or
is_tropical_area_by_latitude then
if drainage < 10 then
return df.biome_type.SWAMP_MANGROVE
else
return df.biome_type.SWAMP_TROPICAL_SALTWATER
end
else
return df.biome_type.SWAMP_TEMPERATE_SALTWATER
end
else
if salinity < 66 then
return df.biome_type.SWAMP_TEMPERATE_FRESHWATER
else
return df.biome_type.SWAMP_TEMPERATE_SALTWATER
end
end
end
--============================================================
function get_biome_type (biome_pos_y,
map_height,
temperature,
elevation,
drainage,
rainfall,
salinity,
vegetation,
pole,
is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude)
if elevation >= 300 then -- Adjusted to world gen elevations
return df.biome_type.MOUNTAIN
elseif elevation < 100 then
return get_ocean_biome (is_tropical_area_by_latitude,
temperature)
elseif temperature <= -5 then
if drainage < 75 then
return df.biome_type.TUNDRA
else
return df.biome_type.GLACIER
end
elseif vegetation < 33 then
return get_biome_desert_or_grassland_or_savanna (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
vegetation,
drainage,
rainfall,
biome_pos_y,
map_height)
elseif vegetation < 66 then
return get_biome_shrubland_or_marsh (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
drainage,
salinity,
rainfall,
biome_pos_y,
map_height)
elseif drainage < 33 then
return get_biome_swamp (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
salinity,
drainage,
rainfall,
biome_pos_y,
map_height)
else
return get_biome_forest (is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude,
rainfall,
temperature,
biome_pos_y,
map_height)
end
end
--============================================================
for i, region in ipairs (df.global.world.world_data.regions) do
profile.BIOME_MOUNTAIN = 0
profile.BIOME_GLACIER = 0
profile.BIOME_TUNDRA = 0
profile.BIOME_SWAMP_TEMPERATE_SALTWATER = 0
profile.BIOME_SWAMP_TEMPERATE_FRESHWATER = 0
profile.BIOME_MARSH_TEMPERATE_FRESHWATER = 0
profile.BIOME_MARSH_TEMPERATE_SALTWATER = 0
profile.BIOME_SWAMP_TROPICAL_FRESHWATER = 0
profile.BIOME_SWAMP_TROPICAL_SALTWATER = 0
profile.BIOME_SWAMP_MANGROVE = 0
profile.BIOME_MARSH_TROPICAL_FRESHWATER = 0
profile.BIOME_MARSH_TROPICAL_SALTWATER = 0
profile.BIOME_FOREST_TAIGA = 0
profile.BIOME_FOREST_TEMPERATE_CONIFER = 0
profile.BIOME_FOREST_TEMPERATE_BROADLEAF = 0
profile.BIOME_FOREST_TROPICAL_CONIFER = 0
profile.BIOME_FOREST_TROPICAL_DRY_BROADLEAF = 0
profile.BIOME_FOREST_TROPICAL_MOIST_BROADLEAF = 0
profile.BIOME_GRASSLAND_TEMPERATE = 0
profile.BIOME_SAVANNA_TEMPERATE = 0
profile.BIOME_SHRUBLAND_TEMPERATE = 0
profile.BIOME_GRASSLAND_TROPICAL = 0
profile.BIOME_SAVANNA_TROPICAL = 0
profile.BIOME_SHRUBLAND_TROPICAL = 0
profile.BIOME_DESERT_BADLAND = 0
profile.BIOME_DESERT_ROCK = 0
profile.BIOME_DESERT_SAND = 0
profile.BIOME_OCEAN_TROPICAL = 0
profile.BIOME_OCEAN_TEMPERATE = 0
profile.BIOME_OCEAN_ARCTIC = 0
--profile.BIOME_SUBTERRANEAN_WATER = 0
--profile.BIOME_SUBTERRANEAN_CHASM = 0
--profile.BIOME_SUBTERRANEAN_LAVA = 0
profile.GOOD = false
profile.EVIL = false
profile.SAVAGE = false
for k, y in ipairs (region.region_coords.y) do
local biome = df.global.world.world_data.region_map [region.region_coords.x [k]]:_displace(y)
local is_possible_tropical_area_by_latitude, is_tropical_area_by_latitude =
check_tropicality (y,
map_height,
biome.temperature,
pole)
local biome_type = get_biome_type
(y,
map_height,
biome.temperature,
biome.elevation,
biome.drainage,
biome.rainfall,
biome.salinity,
biome.rainfall, -- biome_data.vegetation, -- Should be vegetation, but doesn't seem to be set before finalization.
pole,
is_possible_tropical_area_by_latitude,
is_tropical_area_by_latitude)
if biome.evilness < 33 then
profile.GOOD = true
elseif biome.evilness >= 66 then
profile.EVIL = true
end
if biome.savagery >= 66 then
profile.SAVAGE = true
end
if biome_type == df.biome_type.MOUNTAIN then
addone(profile, "BIOME_MOUNTAIN")
elseif biome_type == df.biome_type.GLACIER then
addone(profile, "BIOME_GLACIER")
elseif biome_type == df.biome_type.TUNDRA then
addone(profile, "BIOME_TUNDRA")
elseif biome_type == df.biome_type.SWAMP_TEMPERATE_FRESHWATER then
addone(profile, "BIOME_SWAMP_TEMPERATE_FRESHWATER")
elseif biome_type == df.biome_type.SWAMP_TEMPERATE_SALTWATER then
addone(profile, "BIOME_SWAMP_TEMPERATE_SALTWATER")
elseif biome_type == df.biome_type.MARSH_TEMPERATE_FRESHWATER then
addone(profile, "BIOME_MARSH_TEMPERATE_FRESHWATER")
elseif biome_type == df.biome_type.MARSH_TEMPERATE_SALTWATER then
addone(profile, "BIOME_MARSH_TEMPERATE_SALTWATER")
elseif biome_type == df.biome_type.SWAMP_TROPICAL_FRESHWATER then
addone(profile, "BIOME_SWAMP_TROPICAL_FRESHWATER")
elseif biome_type == df.biome_type.SWAMP_TROPICAL_SALTWATER then
addone(profile, "BIOME_SWAMP_TROPICAL_SALTWATER")
elseif biome_type == df.biome_type.SWAMP_MANGROVE then
addone(profile, "BIOME_SWAMP_MANGROVE")
elseif biome_type == df.biome_type.MARSH_TROPICAL_FRESHWATER then
addone(profile, "BIOME_MARSH_TROPICAL_FRESHWATER")
elseif biome_type == df.biome_type.MARSH_TROPICAL_SALTWATER then
addone(profile, "BIOME_MARSH_TROPICAL_SALTWATER")
elseif biome_type == df.biome_type.FOREST_TAIGA then
addone(profile, "BIOME_FOREST_TAIGA")
elseif biome_type == df.biome_type.FOREST_TEMPERATE_CONIFER then
addone(profile, "BIOME_FOREST_TEMPERATE_CONIFER")
elseif biome_type == df.biome_type.FOREST_TEMPERATE_BROADLEAF then
addone(profile, "BIOME_FOREST_TEMPERATE_BROADLEAF")
elseif biome_type == df.biome_type.FOREST_TROPICAL_CONIFER then
addone(profile, "BIOME_FOREST_TROPICAL_CONIFER")
elseif biome_type == df.biome_type.FOREST_TROPICAL_DRY_BROADLEAF then
addone(profile, "BIOME_FOREST_TROPICAL_DRY_BROADLEAF")
elseif biome_type == df.biome_type.FOREST_TROPICAL_MOIST_BROADLEAF then
addone(profile, "BIOME_FOREST_TROPICAL_MOIST_BROADLEAF")
elseif biome_type == df.biome_type.GRASSLAND_TEMPERATE then
addone(profile, "BIOME_GRASSLAND_TEMPERATE")
elseif biome_type == df.biome_type.SAVANNA_TEMPERATE then
addone(profile, "BIOME_SAVANNA_TEMPERATE")
elseif biome_type == df.biome_type.SHRUBLAND_TEMPERATE then
addone(profile, "BIOME_SHRUBLAND_TEMPERATE")
elseif biome_type == df.biome_type.GRASSLAND_TROPICAL then
addone(profile, "BIOME_GRASSLAND_TROPICAL")
elseif biome_type == df.biome_type.SAVANNA_TROPICAL then
addone(profile, "BIOME_SAVANNA_TROPICAL")
elseif biome_type == df.biome_type.SHRUBLAND_TROPICAL then
addone(profile, "BIOME_SHRUBLAND_TROPICAL")
elseif biome_type == df.biome_type.DESERT_BADLAND then
addone(profile, "BIOME_DESERT_BADLAND")
elseif biome_type == df.biome_type.DESERT_ROCK then
addone(profile, "BIOME_DESERT_ROCK")
elseif biome_type == df.biome_type.DESERT_SAND then
addone(profile, "BIOME_DESERT_SAND")
elseif biome_type == df.biome_type.OCEAN_TROPICAL then
addone(profile, "BIOME_OCEAN_TROPICAL")
elseif biome_type == df.biome_type.OCEAN_TEMPERATE then
addone(profile, "BIOME_OCEAN_TEMPERATE")
elseif biome_type == df.biome_type.OCEAN_ARCTIC then
addone(profile, "BIOME_OCEAN_ARCTIC")
elseif biome_type == df.biome_type.POOL_TEMPERATE_FRESHWATER then -- Never generated
elseif biome_type == df.biome_type.POOL_TEMPERATE_BRACKISHWATER then -- Never generated
elseif biome_type == df.biome_type.POOL_TEMPERATE_SALTWATER then -- Never generated
elseif biome_type == df.biome_type.POOL_TROPICAL_FRESHWATER then -- Never generated
elseif biome_type == df.biome_type.POOL_TROPICAL_BRACKISHWATER then -- Never generated
elseif biome_type == df.biome_type.POOL_TROPICAL_SALTWATER then -- Never generated
elseif biome_type == df.biome_type.LAKE_TEMPERATE_FRESHWATER then -- Never generated
elseif biome_type == df.biome_type.LAKE_TEMPERATE_BRACKISHWATER then -- Never generated
elseif biome_type == df.biome_type.LAKE_TEMPERATE_SALTWATER then -- Never generated
elseif biome_type == df.biome_type.LAKE_TROPICAL_FRESHWATER then -- Never generated
elseif biome_type == df.biome_type.LAKE_TROPICAL_BRACKISHWATER then -- Never generated
elseif biome_type == df.biome_type.LAKE_TROPICAL_SALTWATER then -- Never generated
elseif biome_type == df.biome_type.RIVER_TEMPERATE_FRESHWATER then -- Never generated
elseif biome_type == df.biome_type.RIVER_TEMPERATE_BRACKISHWATER then -- Never generated
elseif biome_type == df.biome_type.RIVER_TEMPERATE_SALTWATER then -- Never generated
elseif biome_type == df.biome_type.RIVER_TROPICAL_FRESHWATER then -- Never generated
elseif biome_type == df.biome_type.RIVER_TROPICAL_BRACKISHWATER then -- Never generated
elseif biome_type == df.biome_type.RIVER_TROPICAL_SALTWATER then -- Never generated
elseif biome_type == df.biome_type.SUBTERRANEAN_WATER then -- Never generated
elseif biome_type == df.biome_type.SUBTERRANEAN_CHASM then -- Never generated
elseif biome_type == df.biome_type.SUBTERRANEAN_LAVA then -- Never generated
end
end
for k, creature in ipairs (df.global.world.raws.creatures.all) do
local found = false
local matching
for l, v in ipairs (region.population) do
if (v.type == df.world_population_type.Animal) and
v.race == k then
found = true
break
end
end
if not found then
if (creature.flags.GOOD and not profile.GOOD) or
(creature.flags.EVIL and not profile.EVIL) or
( (creature.flags.CASTE_MEGABEAST or creature.flags.CASTE_SEMIMEGABEAST or creature.flags.GENERATED) and not (yesmegas == "megas")) or
(creature.flags.SAVAGE and not profile.SAVAGE) then
matching = false
elseif (creature.flags.BIOME_MOUNTAIN and profile.BIOME_MOUNTAIN > 0) or
(creature.flags.BIOME_GLACIER and profile.BIOME_GLACIER > 0) or
(creature.flags.BIOME_TUNDRA and profile.BIOME_TUNDRA > 0) or
(creature.flags.BIOME_SWAMP_TEMPERATE_FRESHWATER and profile.BIOME_SWAMP_TEMPERATE_FRESHWATER > 0) or
(creature.flags.BIOME_SWAMP_TEMPERATE_SALTWATER and profile.BIOME_SWAMP_TEMPERATE_SALTWATER > 0) or
(creature.flags.BIOME_MARSH_TEMPERATE_FRESHWATER and profile.BIOME_MARSH_TEMPERATE_FRESHWATER > 0) or
(creature.flags.BIOME_MARSH_TEMPERATE_SALTWATER and profile.BIOME_MARSH_TEMPERATE_SALTWATER > 0) or
(creature.flags.BIOME_SWAMP_TROPICAL_FRESHWATER and profile.BIOME_SWAMP_TROPICAL_FRESHWATER > 0) or
(creature.flags.BIOME_SWAMP_TROPICAL_SALTWATER and profile.BIOME_SWAMP_TROPICAL_SALTWATER > 0) or
(creature.flags.BIOME_SWAMP_MANGROVE and profile.BIOME_SWAMP_MANGROVE > 0) or
(creature.flags.BIOME_MARSH_TROPICAL_FRESHWATER and profile.BIOME_MARSH_TROPICAL_FRESHWATER > 0) or
(creature.flags.BIOME_MARSH_TROPICAL_SALTWATER and profile.BIOME_MARSH_TROPICAL_SALTWATER > 0) or
(creature.flags.BIOME_FOREST_TAIGA and profile.BIOME_FOREST_TAIGA > 0) or
(creature.flags.BIOME_FOREST_TEMPERATE_CONIFER and profile.BIOME_FOREST_TEMPERATE_CONIFER > 0) or
(creature.flags.BIOME_FOREST_TEMPERATE_BROADLEAF and profile.BIOME_FOREST_TEMPERATE_BROADLEAF > 0) or
(creature.flags.BIOME_FOREST_TROPICAL_CONIFER and profile.BIOME_FOREST_TROPICAL_CONIFER > 0) or
(creature.flags.BIOME_FOREST_TROPICAL_DRY_BROADLEAF and profile.BIOME_FOREST_TROPICAL_DRY_BROADLEAF > 0) or
(creature.flags.BIOME_FOREST_TROPICAL_MOIST_BROADLEAF and profile.BIOME_FOREST_TROPICAL_MOIST_BROADLEAF > 0) or
(creature.flags.BIOME_GRASSLAND_TEMPERATE and profile.BIOME_GRASSLAND_TEMPERATE > 0) or
(creature.flags.BIOME_SAVANNA_TEMPERATE and profile.BIOME_SAVANNA_TEMPERATE > 0) or
(creature.flags.BIOME_SHRUBLAND_TEMPERATE and profile.BIOME_SHRUBLAND_TEMPERATE > 0) or
(creature.flags.BIOME_GRASSLAND_TROPICAL and profile.BIOME_GRASSLAND_TROPICAL > 0) or
(creature.flags.BIOME_SAVANNA_TROPICAL and profile.BIOME_SAVANNA_TROPICAL > 0) or
(creature.flags.BIOME_SHRUBLAND_TROPICAL and profile.BIOME_SHRUBLAND_TROPICAL > 0) or
(creature.flags.BIOME_DESERT_BADLAND and profile.BIOME_DESERT_BADLAND > 0) or
(creature.flags.BIOME_DESERT_ROCK and profile.BIOME_DESERT_ROCK > 0) or
(creature.flags.BIOME_DESERT_SAND and profile.BIOME_DESERT_SAND > 0) or
(creature.flags.BIOME_OCEAN_TROPICAL and profile.BIOME_OCEAN_TROPICAL > 0) or
(creature.flags.BIOME_OCEAN_TEMPERATE and profile.BIOME_OCEAN_TEMPERATE > 0) or
(creature.flags.BIOME_OCEAN_ARCTIC and profile.BIOME_OCEAN_ARCTIC > 0) then
matching = true
end
if matching then
local new_creature = df.world_population:new()
local creature_biome_counts = 0
for t, q in pairs(profile) do
if not (type(q) == "boolean") then
if creature.flags[t] then
creature_biome_counts = creature_biome_counts + q
end
end
end
new_creature.race = k
new_creature.type = df.world_population_type.Animal
local typestring = "Animal"
local count = creature_biome_counts * (7+math.random(9))
if false and (creature.flags.VERMIN_GROUNDER or creature.flags.VERMIN_SOIL or creature.flags.any_vermin) then
new_creature.type = df.world_population_type.Vermin
typestring = "Vermin"
end
if creature.flags.UBIQUITOUS then
new_creature.type = df.world_population_type.VerminInnumerable
typestring = "VerminInnumerable"
count = 100001
else
new_creature.count_min = count
new_creature.count_max = count
end
if false and creature.flags.VERMIN_SOIL_COLONY then
new_creature.type = df.world_population_type.ColonyInsect
typestring = "ColonyInsect"
end
dfhack.println ("Adding " .. tostring(count) .. " " .. tostring(creature.name[0]) .. "s to region " .. tostring (i) .. " as " .. typestring)
region.population:insert ("#", new_creature)
end
end
end
end
end
animaldiversity (args[1])
Use during worldgen or before embark with no arguments to populate all missing creatures from their matching biomes in reasonable numbers, or animaldiversity megas if you want to populate (semi-)megabeasts into fitting biomes as well (can lead to losing surface no-wall fortress before hitting 20 pop).
If you don't want to add vermins, just remove "false and" on lines 853 and 868.
Based on PatrikLundell's plant diversity which eventually was wrapped, amongst many other things, into his regionmanipulator.lua, iirc.
PS: Note that Fluffy Wramblers both lack PET tag and are good-aligned, so you won't be able to embark with them anyway. Though given their 2k body size (the size of adolescent cat), they might give some butchering returns I imagine.