Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [DFHack]Populate.rb - Modify world and site animal populations after worldgen  (Read 5657 times)

rndmvar

  • Escaped Lunatic
    • View Profile

Download on DFFD

Tested versions of Dwarf Fortress:
0.43.03 32bit with DFHack (Masterwork 1.23) (Ruby version 1.8.7)
0.43.05 64bit with DFHack (Masterwork 1.24a - unofficial ) (Ruby version 2.0.0)

Populate.rb features:
Add/Modify world region and world location animal populations
Add/Modify/Delete site animal populations and the animal's trade goods

Warnings:
Before modifying any populations, make a backup of your save by running "quicksave" in the DFHack console, and copying the most recently modified region# folder in "Dwarf Fortress\data\save".  All changes to populations, and trade goods are final.

Setup:
To use hack/scripts/populate.rb extract it into Dwarf Fortress/hack/scripts, and hack/ruby/optparse.rb into Dwarf Fortress/hack/ruby.

Examples:
  Add Kea birds to 3 regions and 10 locations:
    populate -s BIRD_KEA -r 3 -l 10
  Now only add to 10 locations in up to 3 regions where Keas already live:
    populate -s BIRD_KEA -r 3 -l 10 -e
  Or drop some wild populations on the Elves by requiring sites with ForestRetreat:
    populate -s BIRD_KEA -r 3 -l 10 -n ForestRetreat
  Or maybe just increase already existing populations:
    populate -s BIRD_KEA -b 1000 -i 100
  Or maybe you want (tame) ones in Elven trade caravans:
    populate -s BIRD_KEA -o ELF -a
  Or maybe you don't want (tame) ones in Elven trade caravans:
    populate -s BIRD_KEA -o ELF -z
  And you don't want (tame) vermin either:
    populate -s BIRD_KEA -o ELF -z -k
  Or you think the Elves need MORE (TAME) KEAS:
    populate -s BIRD_KEA -o ELF -p 1000
  Maybe you just want to see what a command WILL do:
    populate -s BIRD_KEA -o ELF -p 1000 -d
  You really want lots of text printed to your screen:
    populate -s BIRD_KEA -o ELF -p 1000 -d -v
  You want Humans to have Keas, and to set all import agreements on Keas, and Kea products to maximum priority
    populate -s BIRD_KEA -o HUMAN -a -y 4

All command arguments:
Code: [Select]
Mandatory arguments:
    -s, --species CREATURE           Raw creature name to [re]populate.
Population Filters:
    -r, --regions #                  Maximum number of regions to limit creature to.
                                      - Regions are collections of orthogonally connected locations (x,y coordinates)
                                        on the world map that share their major Biome type.
    -l, --locations #                Maximum number of locations to limit creature to.
                                      - Locations are x,y coordinates on the world map.
    -e, --existing                   Add populations only to regions where a regional population already exists.
    -n, --need-site [TYPE]           Restrict habitable locations to those with sites.
                                     Valid TYPEs: PlayerFortress, DarkFortress, Cave, MountainHalls,
                                       ForestRetreat, Town, ImportantLocation, LairShrine, Fortress, Camp, Monument
Population Modifiers:
    -b, --boost #                    Increment region populations by the specified amount.
    -i, --increment #                Increment local populations by the specified amount.
Site Filters:
    -t, --site-id #                  The ID of the site in memory.
    -c, --civilization-id #          The ID of the target civilization in memory.
    -o, --civilization-race CREATURE The raw creature name of the founder of the civilization.
Site Modifiers:
    -a, --add-creature               The creature [-s] will be added to the filtered site(s) that do not already have any.
    -m, --set-amount #               The creature [-s] will have their population(s) at the filtered site(s) set to # amount.
    -p, --add-amount #               The creature [-s] will have their population(s) at the filtered site(s) increased by # amount.
    -k, --all-vermin                 All vermin creatures will be matched on operations for the target civilization's pet list/trading goods and site populations.
    -z, --remove-animal              The creature [-s] will be removed from the target civilization's pet list/trading goods and site populations.
    -y, --trade-priority #           The creature [-s] that was added [-a] will have all of their trade goods set to this priority.
Special options:
    -x, --extinct #                  Remove the extinct flag from populations of this species,
                                      and set the population amount to the specified number.
    -f, --fortress                   Force adding a population to the current fortress location.
                                      - Will show a warning if the surroundings/biome don't match the creature's raws.
    -d, --display                    Display only.  Do not do any additions.
    -v, --verbose                    Print extra information to the console.
Logged

rndmvar

  • Escaped Lunatic
    • View Profile

Some screenshot examples:
Before:
Spoiler (click to show/hide)
After:
Spoiler (click to show/hide)

Commands used to add:
Code: [Select]
populate -o DWARF -c 967 -s LION_ADAMANT_MTH -a -p 30 -y 4
populate -o DWARF -c 967 -s DRAGON_WEATHER -a -p 30 -y 3
populate -o DWARF -c 967 -s DRAGON_BLUE -a -p 30 -y 3
populate -o DWARF -c 967 -s DRAGON_CHROMATIC -a -p 30 -y 3
populate -o DWARF -c 967 -s DRAGON_GREEN -a -p 30 -y 3
populate -o DWARF -c 967 -s DRAGON_SKY -a -p 30 -y 3
populate -o DWARF -c 967 -s LOONG_MTH -a -p 30 -y 3
populate -o DWARF -c 967 -s NYMPH_MTH -a -y 4
populate -o DWARF -c 967 -s MASTODON -a -p 30 -y 3
populate -o DWARF -c 967 -s SPIDER_BLADE_GIANT_QUEEN -a -p 30 -y 4

Commands used to remove:
Code: [Select]
populate -o DWARF -c 967 -s LION_ADAMANT_MTH -z
populate -o DWARF -c 967 -s DRAGON_WEATHER -z
populate -o DWARF -c 967 -s DRAGON_BLUE -z
populate -o DWARF -c 967 -s DRAGON_CHROMATIC -z
populate -o DWARF -c 967 -s DRAGON_GREEN -z
populate -o DWARF -c 967 -s DRAGON_SKY -z
populate -o DWARF -c 967 -s LOONG_MTH -z
populate -o DWARF -c 967 -s NYMPH_MTH -z
populate -o DWARF -c 967 -s MASTODON -z
populate -o DWARF -c 967 -s SPIDER_BLADE_GIANT_QUEEN -z
Logged

ImACatNamedGloves

  • Bay Watcher
    • View Profile

Holy shit, are you god? This is exactly what I need! I'm going to try it, thanks!
Logged

feelotraveller

  • Bay Watcher
  • (y-sqrt{|x|})^2+x^2=1
    • View Profile

I haven't used this, and may never, but I highly commend your efforts!  8)
Logged

Altaree

  • Bay Watcher
    • View Profile

Looks extremely useful for getting more sieges when the attacking population has been exhausted.
Logged
Dan Pearson:
This is a game which calculates the volume of blood in every creature it generates so it knows how much alcohol it would have to consume to get drunk, an update which, remarkably, ended up covering people's fortresses in cat vomit.

PatrikLundell

  • Bay Watcher
    • View Profile

I'm not sure you can add enemies with it, as those are not animals. Similarly, mounts may also be treated differently, so I'm not sure about beak dogs and ogres (not as mounts, of course, but as cannon fodder "soldiers") either since those go into separate lists.

I haven't looked at the script, just based the comment above on the tool description.

I don't know if increasing the generic population of a site increases the pool from which soldiers (and visitors to other sites) are drawn, and they become hist figs when embarking on their journeys, or whether you have to add them as hist figs from the start. My own test didn't show any results, but was too brief for results to be expected (trying to generate animal people visitors, but only played for 1½ month, and Legends Mode didn't show any animal people visitors to any other civs within that time).
Logged