Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Is there a utility for extracting generated creatures out of savefiles?  (Read 2623 times)

Orbotosh

  • Bay Watcher
    • View Profile

As far as I understand, extracting randomly generated creatures is just a matter of directly copying their creature files, removing the weird symbols and then fixing up the formatting a little. Is there already something to do this?
Logged
It's a buyers market. The author writes what sells, catering to the lowly demands of uneducated masses. In this case, apparently, charioteers.
Can we get migrant sponge cooks, a squid for bookkeeper, a starfish peasants, squirrel mechanics, vermin invaders, and cook roast crab meats? 

Frango Nicolbidok

  • Bay Watcher
  • Legendary Peasant
    • View Profile

I'm not aware if there is one, but I would very much so appreciate the existence of one. My only desire to remove their trap_avoid tags.
Logged
However, now I wanted some more challenge and embarked to evil biome.
"Terrifying screams come from above!"

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions

I have a Perl script which can extract all generated raws from a savegame, available here. Also have a PHP version here, in case you happen to have that installed.

[edit] Updated it to properly recognize worlds generated in version 0.42.06.
« Last Edit: March 02, 2016, 09:33:06 pm by Quietust »
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile

Hmm... A utility to pack and unpack generated raws (and/or apply changes in place) may be an interesting addition to Rubble.

I'll see what I can do.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions

I'm pretty sure there's another tool like that on DFFD somewhere, but my most recent search attempt failed to locate it.
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

Vattic

  • Bay Watcher
  • bibo ergo sum
    • View Profile

I'm pretty sure there's another tool like that on DFFD somewhere, but my most recent search attempt failed to locate it.
It's been inactive for years, but possibly ziplin's World Tinker?
Logged
6 out of 7 dwarves aren't Happy.
How To Generate Small Islands

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile

I played around with the idea some, but ultimately decided that I do not want anything more to maintain. The problems is that I don't want to have to mess with keeping a tool up to date. Making it in the first place would be trivial, but updating all the time would be a pain. Rubble is work enough right now.
Logged
Rubble 8 - The most powerful modding suite in existence!
After all, coke is for furnaces, not for snorting.
You're not true dwarven royalty unless you own the complete 'Signature Collection' baby-bone bedroom set from NOKEAS

TheFlame52

  • Bay Watcher
  • Certified geezer & only man to win 0.40.24
    • View Profile

I have a Perl script which can extract all generated raws from a savegame, available here. Also have a PHP version here, in case you happen to have that installed.

[edit] Updated it to properly recognize worlds generated in version 0.42.06.
How do I use these? Either one?

klassekatze

  • Bay Watcher
    • View Profile

https://gist.github.com/Putnam3145/d46ffdedb4d335b2ab5a

I don't know if it works out of the box, but if it doesn't I've been using this mutilated version:

Code: [Select]
local creatures = assert(io.open(dfhack.getDFPath()..'/generated_creatures.txt', 'w'))

local items = assert(io.open(dfhack.getDFPath()..'/generated_items.txt', 'w'))

local materials = assert(io.open(dfhack.getDFPath()..'/generated_materials.txt', 'w'))

local entities = assert(io.open(dfhack.getDFPath()..'/generated_entities.txt', 'w'))
   
local interactions = assert(io.open(dfhack.getDFPath()..'/generated_interactions.txt', 'w'))

local languages = assert(io.open(dfhack.getDFPath()..'/generated_languages.txt', 'w'))

if creatures then
    for k,v in ipairs(df.global.world.raws.creatures.all) do
        if v.flags.GENERATED then
            creatures:write('[CREATURE:'..v.creature_id..']\n')
            for kk,vv in ipairs(v.raws) do
                creatures:write('    '..vv.value..'\n')
            end
        end
    end
    creatures:close()
end

if items then
    for k,v in ipairs(df.global.world.raws.itemdefs.all) do
        if v.base_flags[0] then --base_flags[0] is GENERATED, but apparently not actually in structures yet
            items:write('[ITEM_SOMETHING:'..v.id..']\n') --the way this loop is precludes actually including proper item whosit.
            for kk,vv in ipairs(v.raw_strings) do
                items:write('    '..vv.value..'\n')
            end
        end
    end
    items:close()
end

if materials then
    for k,v in ipairs(df.global.world.raws.inorganics) do
        if v.flags.GENERATED then
            materials:write('[INORGANIC:'..v.id..']\n')
            for kk,vv in ipairs(v.str) do
                materials:write('    '..vv.value..'\n')
            end
        end
    end
    materials:close()
end

if entities then
    entities:write('THIS FILE IS INCOMPLETE! Only some of the more interesting stuff is included since the entity raws do not have an exact listing of their raw file in their data structures.\n\n')
    for k,v in ipairs(df.global.world.raws.entities) do
        if true then
            entities:write('[ENTITY:'..v.code..']\n')
            --Fun fact: entities do not have a raw listing like other raw objects.
            for kk,vv in pairs(v.creatures) do
                entities:write('    [CREATURE:'..vv.value..']\n')
            end
            ---if v.translation:len()>0 then
            --    entities:write('    [TRANSLATION:'..v.translation..']\n')
            --end
            --entities:write('    [ADVENTURE_TIER:'..v.adventure_tier..']\n')
            --entities:write('    [FRIENDLY_COLOR:'..v.friendly_color[0]..':'..v.friendly_color[1]..':'..v.friendly_color[2]..']\n')
            --entities:write('    [DEFAULT_SITE_TYPE:'..df.site_type[v.default_site_type]..']\n')
            --for kk,vv in pairs(v.likes_site) do
            --    if vv==1 then
            --        entities:write('    [LIKES_SITE:'..kk..']\n')
            --    end
            --end
            --for kk,vv in pairs(v.tolerates_site) do
            --    if vv==1 then
            --        entities:write('    [TOLERATES_SITE:'..kk..']\n')
            --    end
           -- end
            --for kk,vv in pairs(v.equipment) do
            --    if tostring(kk):find('_str') then
           --         for kkk,vvv in pairs(vv) do --ahahaha
            --            entities:write('    ['..kk:sub(1,-5):upper()..':'..vvv.value..']\n') --not bothering with rarity cause crap's pretty arcane, moreso than this
            --        end
            --    end
            --end
            --for kk,vv in pairs(v.ethic) do
            --    entities:write('    [ETHIC:'..kk..':'..df.ethic_response[vv]..']\n')
            --end
            --for kk,vv in pairs(v.values) do
           --     entities:write('    [VALUE:'..kk..':'..vv..']\n')
           -- end
            --entities:write('    [HFID:'..v.source_hfid..']\n')
            for kk,vv in pairs(v.flags) do
                if vv then
                    entities:write('    ['..kk..']\n')
                end
            end
        end
    end
    entities:close()
end

if interactions then
    for k,v in ipairs(df.global.world.raws.interactions) do
        if v.flags[0] then --flags[0] is GENERATED
            interactions:write('[INTERACTION:'..v.name..']\n')
            for kk,vv in ipairs(v.str) do
                interactions:write('    '..vv.value..'\n')
            end
        end
    end
    interactions:close()
end

--if languages then
--    for k,v in ipairs(df.global.world.raws.language.translations) do
--        if v.flags%2==1 then --translation.flags isn't a bitfield yet, so I gotta use some binary snazz to get to where I want
--            languages:write('[TRANSLATION:'..v.name..']\n')
 --           for kk,vv in ipairs(v.str) do
 --               languages:write('    '..vv.value..'\n')
 --           end
 --       end
 --   end
--    languages:close()
--end
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions

I have a Perl script which can extract all generated raws from a savegame, available here. Also have a PHP version here, in case you happen to have that installed.

[edit] Updated it to properly recognize worlds generated in version 0.42.06.
How do I use these? Either one?
Run the script inside the relevant region folder with no parameters, or run it from anywhere and specify the path to the region folder. All of the raws will be extracted into the current directory, one object per file.

Needless to say, you will need Perl (or PHP) installed in order to run the script.
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

TheFlame52

  • Bay Watcher
  • Certified geezer & only man to win 0.40.24
    • View Profile
Re: Is there a utility for extracting generated creatures out of savefiles?
« Reply #10 on: April 24, 2016, 05:13:04 pm »

I did that and it didn't work, but I also learned how to look at raws using DFhack's gui/gm-editor, so my problems are solved.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Is there a utility for extracting generated creatures out of savefiles?
« Reply #11 on: April 29, 2016, 05:51:03 pm »

I'm pretty sure there's another tool like that on DFFD somewhere, but my most recent search attempt failed to locate it.
It's been inactive for years, but possibly ziplin's World Tinker?
That one still works btw.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

TheFlame52

  • Bay Watcher
  • Certified geezer & only man to win 0.40.24
    • View Profile
Re: Is there a utility for extracting generated creatures out of savefiles?
« Reply #12 on: April 29, 2016, 06:50:30 pm »

Really? That's great! I still have the program from when I used it way back in 0.34!

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist

Mh... sorry, I seems I have been wrong. I used it on Masterwork a couple of times when it was already outdated and it still worked, but I tried today with the newest df version and it throws errors.

I'll try some of Quietust options next

Edit: His Perl script worked. :)
« Last Edit: May 02, 2016, 04:24:27 am by Meph »
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist

Done, everything uploaded for you here: http://www.bay12forums.com/smf/index.php?topic=157900.0

Hope it helps. :)
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::