Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 161 162 [163] 164 165 ... 242

Author Topic: DFHack 50.11-r6  (Read 795616 times)

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2430 on: June 12, 2020, 02:21:06 pm »

At least temperature takes effect, but for this you can simply disable weather in init.

xzaxza

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2431 on: June 13, 2020, 03:17:38 pm »

Does anyone know where and how economical linking is stored? Or is it stored even? I tried looking around in df.global.world.entities with gui/gm-editor, but the only entity_link I found was to the parent civilization. And site_links doesn't seem to be that either, there's just a site that has the residence flag. Also, looks like the parent civ has an entity_link to each child, and a site_link to each child with the land_for_holding tag. Maybe that's enough, in combination with the later site having no baron and having a founding event, or something?

Although, there seems to be a site id, so there is data for the sites themselves, containing this data? I haven't found those, at least yet.
Logged
Known issues
You may get a dwarf that likes bugged stockpiles.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2432 on: June 14, 2020, 03:17:08 am »

It's in your site's entity_links. There's a link to the government of the site (i.e. the entity, not the site), and flags.local_market is set. Land for holding links have to go from an entity to a site, and I believe those are between the civ and the site, not the site government and a site (with a possible exception for necro towers). In my case I have an economic link to a gobbo conquered (formerly human) site, but no land for holding claim on it from the (dead) civ. The civ has claims only on the (lost) capital and my fortress.
I believe it's a bug that nobility for land holding sites other than your own nevertheless demand to be given noble quarters at your site. You really should have to satisfy your own nobles only (if nobility over other sites are keen on noble treatment they should go to their sites to demand it...).
Logged

xzaxza

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2433 on: June 14, 2020, 05:54:41 am »

It's in your site's entity_links. There's a link to the government of the site (i.e. the entity, not the site), and flags.local_market is set. Land for holding links have to go from an entity to a site, and I believe those are between the civ and the site, not the site government and a site (with a possible exception for necro towers). In my case I have an economic link to a gobbo conquered (formerly human) site, but no land for holding claim on it from the (dead) civ. The civ has claims only on the (lost) capital and my fortress.
I believe it's a bug that nobility for land holding sites other than your own nevertheless demand to be given noble quarters at your site. You really should have to satisfy your own nobles only (if nobility over other sites are keen on noble treatment they should go to their sites to demand it...).
Thanks! I had trouble finding the site data apart from df.global.world.world_data.active_site[0], but df.world_site.find() helped with that. I also noticed that there's a site_link that matches my site's id in the entity of the linked economy, and removing that seems to get rid of the message on the civilizations view, but I'll also remove the entity_link from my site to be safer.

I'll also make that into a script, just need to figure out how to delete things safely.
Logged
Known issues
You may get a dwarf that likes bugged stockpiles.

xzaxza

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2434 on: June 14, 2020, 10:33:36 am »

Here's the script, in case anyone's interested. Doesn't seem to crash the game for me at least.

Code: [Select]
-- show and sever economic links, by xzaxza
local help = [====[
economiclinks
======================
Displays the economic links of a site, or optionally severs them.

Usage:
economiclinks [sever] [site_id]

Both options are optional. If absent, site_id defaults to the current site.

Examples:
Running `economiclinks` without arguments displays the economic links of the current site.
Running `economiclinks 7` displays the economic links of the site with id 7.
Running `economiclinks sever` severs the economic links of the current site.
Running `economiclinks sever 7` severs the economic links of the site with id 7.
]====]
function fullname(item) --lifted from modtools/extra-gamelog
    return dfhack.TranslateName(item.name)..' ('..dfhack.TranslateName(item.name ,true)..')'
end
function CountLinks(site_id)
    if df.world_site.find(site_id) == nil then
        print "Error: site not found."
        return nil
    end
    local site = df.world_site.find(site_id)
    local local_markets = {}

    for k,v in pairs(site.entity_links) do
        if v.flags.local_market then
            local_markets[#local_markets+1] = v.entity_id
        end
    end
    return #local_markets
end
function ShowLinks(site_id)
    if df.world_site.find(site_id) == nil then
        print "Error: site not found."
        return
    end
    local site = df.world_site.find(site_id)
    local local_markets = {}
    print(dfhack.df2console('Site '..site_id..': '..fullname(site)..' at coordinates ('..site.pos.x..','..site.pos.y..')'))

    for k,v in pairs(site.entity_links) do
        if v.flags.local_market then
            local_markets[#local_markets+1] = v.entity_id
        end
    end
    if #local_markets > 0 then
        print(dfhack.df2console('The site has the following economic links:'))
        for k,v in pairs(local_markets) do
            tmp_ent = df.historical_entity.find(v)
            if tmp_ent ~= nil then
                print(dfhack.df2console('  Entity '..v..', '..fullname(tmp_ent)))
            else
                print('  Entity '..v..', <unknown entity>')
            end
        end
    else
        print(dfhack.df2console('The site has no economic links.'))
    end
end
function SeverLinks(site_id)
    if df.world_site.find(site_id) == nil then
        print "Error: site not found."
        return
    end

    local site = df.world_site.find(site_id)
    local tmp_ent
    local tmp_ent_id

    for k,v in pairs(site.entity_links) do
        tmp_size1 = #site.entity_links
        if v.flags.local_market then
            tmp_ent_id = v.entity_id
            tmp_ent = df.historical_entity.find(tmp_ent_id)

            for k2,v2 in pairs(tmp_ent.site_links) do
                if v2.target == site_id and v2.flags.local_market then
                    tmp_ent.site_links:erase(k2)
                    break
                end
            end
            site.entity_links:erase(k)
            return
        end
    end
end
-- main script
local opt = ...
local args = {...}
local site_id = df.global.ui.site_id
local link_count

if opt and opt ~= "" then
    if opt=="sever" then
        if tonumber(args[2]) then
            site_id = math.floor(tonumber(args[2]))
        end
        link_count = CountLinks(site_id)
        for i = 1,link_count,1 do
            SeverLinks(site_id)
        end
        return
    elseif tonumber(opt) then
        site_id = math.floor(tonumber(opt))
        ShowLinks(site_id)
        return
    else
        print(help)
    end
else
    ShowLinks(site_id)
end
Logged
Known issues
You may get a dwarf that likes bugged stockpiles.

Tokeli

  • Bay Watcher
  • Oh wow, mew
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2435 on: June 22, 2020, 03:41:21 pm »

I've been poking around trying to learn DFHack for some tile-designation manipulation, and since there's no documentation on the why-

Is there documentation of, or does anyone know the purpose of the crazy coordinate system used for map tiles? At first I figured "block.map_pos" was the proper coordinates but they increment oddly instead of reflecting the real coords.

Digging through other scripts reveals a crazy 2D array in some of the fields such "block.designation", which I can't figure out the purpose or function of. I've managed to get something working by copying what other people have done, but I'd sure love to know what this structure's for.


Logged

ragundo

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2436 on: June 22, 2020, 05:15:38 pm »

I've been poking around trying to learn DFHack for some tile-designation manipulation, and since there's no documentation on the why-

Is there documentation of, or does anyone know the purpose of the crazy coordinate system used for map tiles? At first I figured "block.map_pos" was the proper coordinates but they increment oddly instead of reflecting the real coords.

Digging through other scripts reveals a crazy 2D array in some of the fields such "block.designation", which I can't figure out the purpose or function of. I've managed to get something working by copying what other people have done, but I'd sure love to know what this structure's for.




The tiles are stored in the df.global.world.map structure.
Inside this structure the datais stored in different ways. There's a 3 dimmensional array (x)(y)(z) of map_blocks called block_index and, also, a vector of pointers to map_blocks called map_blocks.

You can access a map_block of coordinates (x)(y)(z) directly using block_index or iterate over the map_blocks_vector to reach the desired coordinate, or better, use DFHack.

Each map_block stores a 16x16 array of tyletypes, that is the data you are looking for.

It's better to explain it with a image

« Last Edit: June 22, 2020, 05:17:58 pm by ragundo »
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2437 on: June 22, 2020, 06:24:44 pm »


Map blocks are 16x16x1 tiles. Looks to me like getTileBlock returns the block that a tile is in, and the map_pos field is the coordinates of one corner of that block. Some attributes are stored in 16x16 arrays in each block and some are stored at the block level. It is a little complicated.

As for your question about designations, they're mostly stored in the "designation" field of each block, which is a 16x16 array of tile_designation, each of which have a "dig" field of type tile_dig_designation. I can try to track down an example if that would help - I suspect the "dig" plugin works with these, but I'm not sure about Lua scripts.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2438 on: June 22, 2020, 07:06:42 pm »

map_pos field is the coordinates of one corner of that block.

This is handy info for something I'm currenty working on. I was using an ugly "math.modf(cursor_x/16)*16" instead.
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

Archereon

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2439 on: June 23, 2020, 06:58:25 pm »

Hey, I was screwing around, and it seems like the "names" script, which lets you use the native interface to rename units, is broken unless I'm using it wrong, it seems to be throwing an error.




https://imgur.com/Im6t0M9
Logged
I want to tell you they were bad men, cephalo.  I want to tell you that with a better overseer the Fortress never would've gotten so bad someone would get offed in a pointless fisticuffs.
But the sad truth charlie?
It was inevitable.

Tokeli

  • Bay Watcher
  • Oh wow, mew
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2440 on: June 23, 2020, 07:06:23 pm »

Heck, thank you both lethosor and ragundo. Knowing it's a 16x16 chunk format more or less ala Minecraft has it make a helluva lot more sense now. The way it's all organized made it confusing. And having the chunks be named "blocks".
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.47.04-r1
« Reply #2441 on: June 24, 2020, 08:40:33 am »

The way it's all organized made it confusing. And having the chunks be named "blocks".
We don't know what they're actually called, because the actual structure name isn't exposed anywhere within the executable - we know the names of all of the C++ classes that have virtual methods (e.g. "building_civzonest", "feature_init_deep_special_tubest", "world_construction_wallst") thanks to RTTI, but for everything else we have to guess what it's called based on how it's used.

In the case of map_block, it might actually be called something like "block_squarest" (based on the various "block_square_eventst" subclasses used to keep track of stuff like minerals, spatters, grass, and designation priorities), but unless Toady outright tells us the class's name (or adds a virtual method to it), we'll never know.

But given that Dwarf Fortress predates Minecraft by over 3 years (and has used the "map_block" structure at least since late 2006), you probably shouldn't expect them to be called "chunks".
« Last Edit: June 24, 2020, 08:42:34 am 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.

Atomic Chicken

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2442 on: June 24, 2020, 03:30:43 pm »

Here’s an overview of the way the DF map is organised, as copied from my notes. Note that these names aren't official and others might refer to them differently, but I believe I had based them on various references in the structures at the time. ("region tile" might be particularly confusing as it isn't directly related to actual regions).

At the lowest level we have local tiles; 1 local tile is the space the cursor takes up during regular fortress/adventure mode play. Coordinates of units, items, projectiles, etc are written in the local tile scale, where (x = 0, y = 0, z = 0) is the tile at the upper left corner of the lowest z-level on the currently loaded map.

Local tiles on each z-level are grouped into blocks, where
1 block = 16*16*1 local tiles
Blocks are visible during zoomed-in fast travel in adventure mode. Army coordinates use this scale.

Columns of blocks are grouped into region tiles as such:
1 region tile
  = 3*3 block columns
  = 48*48 local tile columns
Region tiles are visible when resizing your fort before embarking, or during zoomed-out fast travel in adventure mode.

Finally comes the world tile:
1 world tile
  = 16*16 region tiles
  = 48*48 block columns
  = 768*768 local tile columns
These are the largest map tiles, visible on the world map before embarking, when checking the dwarf mode civilization screen map and when checking the adventure mode quest log.
« Last Edit: June 24, 2020, 03:38:54 pm by Atomic Chicken »
Logged
As mentioned in the previous turn, the most exciting field of battle this year will be in the Arstotzkan capitol, with plenty of close-quarter fighting and siege warfare.  Arstotzka, accordingly, spent their design phase developing a high-altitude tactical bomber. 

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2443 on: June 24, 2020, 05:08:56 pm »

I believe Toady referred to "region tiles" as "Mid Level Tiles" (MLT) when asked about scales used at some point (also note that the "Region Map" displayed pre embark is the middle one, not the left one, to add to the confusion).

There's also one level above world tiles, namely the "feature shell", which consists of 16 * 16 world tiles. These are strange creatures that take quite some time to load/generate, and after that they're still only populated as needed for some info (and trying to read a feature shell other than the current one typically results in an access violation crash). The main known data in feature shells are "features", i.e. things like volcanoes, magma pipes, candy spires, as well as caverns and the other underground levels, but only on a fairly high level.

There's also a 2 * 2 MLT scale used for candy spire locations.

Edit: Something completely different:
I've run into the problem of trying to compare a Z coordinate in the local (embark) coordinate system with an elevation Z coordinate that's used in a different structure (plant vs picked plant growths, for those curious). However, I don't know of any straight forward way to translate between the coordinate systems. Could someone provide me with the missing relation?

Edit 2: In case someone else looks for the answer to the question in Edit: df.global.world.map.map_block_column [<appropriate 16 * 16 block>].z_base contains the value to be removed from the elevation value to get the local z coordinate).
« Last Edit: July 03, 2020, 10:50:51 am by PatrikLundell »
Logged

Iä! RIAKTOR!

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.04-r1
« Reply #2444 on: June 26, 2020, 11:39:38 pm »

How extract raws of generated noble position from saved world?
Logged
Pages: 1 ... 161 162 [163] 164 165 ... 242