Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 194 195 [196] 197 198 ... 243

Author Topic: DFHack 50.13-r2  (Read 820215 times)

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.47.05-r1
« Reply #2925 on: May 14, 2021, 10:57:20 am »

1. Built DFHack, RelWithDebInfo, on a fresh install of "df_47_05_win".
For what it's worth, you can just clone the "df-structures" respository and run codegen.pl directly - there's no need to build all of DFHack too.
In fact, it's probably better to clone df-structures directly, since that way you can be sure you're looking at the absolute latest definitions.

5. File -> Load File -> Parse C header file..., select codegen.h.
7. File -> Script command..., paste in MakeName statements. Confirm _pause_state exists in Names window.
Apparently, you need to do these in the opposite order - first run the MakeName statements, then import codegen.h.
Fortunately, you don't need to start over if you've gotten this far already - just import codegen.h again and it'll fix it.
You can also edit the structure XML files, rerun codegen.pl and codegen-c-hdr.pl, and reimport codegen.h in order to update the structure definitions in IDA.

I can add the structure map_block_column to the Structures window. Right-clicking the value gives an option for [r8+map_block_column.plants.ptr]. (The 't' option doesn't appear in this menu, but the shortcut works while the offset's selected. UX annoyance.) Right-clicking on the next one gives the option [r8+map_block_column.plants.endptr], so IDA seems to be pretty smart about that.
When you right-click, do you see any key name in the right column of the "Structure offset" menu item (or in any of the other menu items, for that matter)? It's possible that's something I manually configured in my own installation, since I believe it was a default setting in IDA 5.0.

9. Filter for sub_140CF0F90 in the function menu and double-click it. No named addresses present.
Unless this is another one of my custom settings, you should be able to press "g" to open a "Jump to address" prompt, then you can type in either an address (such as 0x140CF0F90) or a symbol name (sub_140CF0F90).

There are zero results for "getPlantAtCoords" on the internet (including your post and mine,) so that's kind of puzzling. (Tried Google, DuckDuckGo, and GitHub. At least Bay12Forums can find my post.)
That's because I made up that name myself, based on its apparent function. After all, we already do the exact same thing with the names of fields in df-structures.
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.

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2926 on: May 14, 2021, 09:44:35 pm »

Apparently, you need to do these in the opposite order - first run the MakeName statements, then import codegen.h.

Looks like that fixed it! Thanks!

When you right-click, do you see any key name in the right column of the "Structure offset" menu item (or in any of the other menu items, for that matter)? It's possible that's something I manually configured in my own installation, since I believe it was a default setting in IDA 5.0.



It actually appears on some of the others, like "[rax+rcx*8]" just above.

Unless this is another one of my custom settings, you should be able to press "g" to open a "Jump to address" prompt, then you can type in either an address (such as 0x140CF0F90) or a symbol name (sub_140CF0F90).

That works. It shows up when right-clicking on the ".text:" area. Didn't know it worked with symbols.

That's because I made up that name myself, based on its apparent function. After all, we already do the exact same thing with the names of fields in df-structures.

Figured as much. Should I rename the function "getPlantAtCoords_140CF0F90" for easier identification? Is there some kind of best practices standard?
« Last Edit: May 14, 2021, 09:46:54 pm by Bumber »
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)?

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2927 on: May 24, 2021, 06:55:21 pm »

I updated the first post of this thread with some new chat options. We have a Discord server and an IRC channel on Libera now. (I'm avoiding linking them here in case any links become stale, so check out the first post for links.)
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.

vettlingr

  • Bay Watcher
  • Þjóðalfur
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2928 on: June 03, 2021, 10:37:09 am »

I have a request:
 Make a "tweak nestbox-color" for hives. to show material hive is made out of

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.47.05-r1
« Reply #2929 on: June 03, 2021, 04:45:44 pm »

I have a request:
 Make a "tweak nestbox-color" for hives. to show material hive is made out of

Should it also affect the color that shows up when you <q>uery the building? If so, it could be done by overriding building_hivest::getNameColor() with something like this:
Code: [Select]
MaterialInfo mat(mat_type, mat_index);
gps.screenf = mat.material.basic_color[0];
gps.screenbright = mat.material.basic_color[1];
(with some extra error checks to make sure the material is actually valid - if not, it should fall back to 6:1).

The same change could also be made to the nestbox-color tweak, if that behavior is desired.

If not, it could be done the same as the existing nestbox-color tweak.
« Last Edit: June 03, 2021, 05:17:21 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.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.47.05-r1
« Reply #2930 on: June 08, 2021, 04:35:08 pm »

I couldn't find any in the dfhack documentation, so I'll just ask: Is there a script floating around that could give me the temperature of a tile?
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 :::

myk

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2931 on: June 08, 2021, 05:03:51 pm »

The probe plugin can do this.  Docs here: https://docs.dfhack.org/en/latest/docs/Plugins.html#probe
Logged

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2932 on: June 09, 2021, 03:20:41 am »

Could "unk_v40_1" on projectiles be related to abilities/powers? It's set to 4885 for magma crab globs, 7035 for intelligent undead icicles, and -1 for bolts fired from a crossbow. Falling objects seem to have it set to really high garbage values. Could be the "parabolic" or "unk9" flag that has the game ignore that.

Update on this: Looks like it's the target unit's id. Magma crab was aiming at one of my undead, my undead were all aiming at the magma crab, and the bolt was aimed at an archery target.
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)?

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.47.05-r1
« Reply #2933 on: June 09, 2021, 09:13:53 am »

Could "unk_v40_1" on projectiles be related to abilities/powers? It's set to 4885 for magma crab globs, 7035 for intelligent undead icicles, and -1 for bolts fired from a crossbow. Falling objects seem to have it set to really high garbage values. Could be the "parabolic" or "unk9" flag that has the game ignore that.

Update on this: Looks like it's the target unit's id. Magma crab was aiming at one of my undead, my undead were all aiming at the magma crab, and the bolt was aimed at an archery target.
Are the other nearby fields still correct? It's possible the structure might be misaligned and you might actually be looking at the "unk_unit_id" field immediately above 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.

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: DFHack 0.47.05-r1
« Reply #2934 on: June 09, 2021, 12:40:55 pm »

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 :::

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2935 on: June 09, 2021, 08:48:15 pm »

Are the other nearby fields still correct? It's possible the structure might be misaligned and you might actually be looking at the "unk_unit_id" field immediately above it.

As near as I can tell. For a bolt fired at a porcupine:
Code: [Select]
...
hit_rating 251
unk_21 0
unk_22 40
bow_id 176393
unk_item_id -1
unk_unit_id -1
unk_v40_1 7040
pos_x 0
pos_y 0
pos_z 0
speed_x 0
speed_y 0
speed_z 0
accel_x 0
accel_y 0
accel_z 0
item <item_ammost: 000000C5CCF690E0>
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)?

wooks

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2936 on: June 13, 2021, 10:20:43 pm »

I'm getting that old bug (in DF) where conscious dwarfs refuse to go get diagnosed in the hospital even though they have serious problems like the inability to stand. Is there a way for me to force him to go to the hospital without outright healing him? My first thought is to just make him unconscious, is there an easy way to do that with DFhack?

Figured it out: gui/gm-unit is your friend future search bar warrior.
However, being unconscious alone was not a solution, as the dwarf in question had only lost the inability to stand, despite having no nerve damage, and thus did 'not require a crutch'. I just fixed his wounds till he walked again because wtf is that.
« Last Edit: June 14, 2021, 12:43:33 am by wooks »
Logged
In a game like Dwarf Fortress, going to the wiki being cheating is like saying bringing a parachute is cheating for skydiving.
"Has it been 4 days? Better check if my penis is still there again."

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2937 on: June 14, 2021, 03:24:53 pm »

From my own analysis, the function you found appears to be "df::plant *getPlantAtCoords(int x, int y, int z)" - the code immediately below "loc_140CF1080" checks for an exact coordinate match (e.g. for shrubs), the code just above "loc_140CF115B" checks if it's part of a tree branch, and the code below "loc_140CF115B" checks if it's a tree root.

Okay, I think I've got a complete understanding of the function.

The assembly seems to use rdx, r8, and r9 for the coordinates. Is this just an optimization?

Or would the real thing be something like:
getPlantAtCoords(unused, unused, x, unused, y, z, &rbp_value, &x_mod_48, &y_mod_48, &rbx_value)

Can we call this function using dfhack, or do we have to write our own version?

I wrote an equivalent in Lua:
Code: [Select]
function getPlantAtCoords(x_coord, y_coord, z_coord)
if ((x_coord // 48) * 48) < 0 then
return nil
elseif ((x_coord // 48) * 48) >= df.global.world.map.x_count then
return nil
elseif ((y_coord // 48) * 48) < 0 then
return nil
elseif ((y_coord // 48) * 48) >= df.global.world.map.y_count then
return nil
elseif not df.global.world.map.column_index then
return nil
end

local mbc = df.global.world.map.column_index[x_coord//48*3][y_coord//48*3]
if not mbc then
return nil
end
for _, p in ipairs(mbc.plants) do
if p.pos.x == x_coord and p.pos.y == y_coord and p.pos.z == z_coord then
return p
else
local t = p.tree_info
if t then
local x_index = t.dim_x // 2 - p.pos.x%48 + x_coord%48
local y_index = t.dim_y // 2 - p.pos.y%48 + y_coord%48
local z_dis = z_coord - p.pos.z

if x_index >= 0 and x_index < t.dim_x and
y_index >= 0 and y_index < t.dim_y and
z_dis < t.body_height and z_dis >= -t.roots_depth then
local bits
if z_dis >= 0 then
bits = t.body[z_dis]:_displace(x_index + y_index*t.dim_x)
else
bits = t.roots[-1 - z_dis]:_displace(x_index + y_index*t.dim_x)
end
if bits[0] or bits[1] or bits[2] or bits[3] or bits[4] or bits[5] or bits[6] then
return p
end
end
end
end
end
return nil
end

Is there a way to access the tree_tile bitfield as a number in Lua so I can use bitwise logic instead?
« Last Edit: June 14, 2021, 03:48:31 pm by Bumber »
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)?

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2938 on: June 14, 2021, 04:33:29 pm »

Generally, due to optimizations (possibly including the ones you've noted), we cannot call DF functions directly from DFHack in a cross-platform way. There are some exceptions, like virtual methods, where it's easy, however. There's some precedent in existing library modules for reimplementing pieces of DF logic in DFHack (e.g. Units::getNominalSkill, Units::getVisibleName).

Apparently there are holes in our documentation about bitfields. There's a special "whole" field that provides the raw integer value of a bitfield (i.e. "bits.whole"). That said, I would prefer using symbolic names (e.g. "flags.trunk" instead of "flags[0]") except in cases where it makes a significant difference in performance.
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.05-r1
« Reply #2939 on: June 14, 2021, 05:12:33 pm »

I'll just leave a comment:
Code: [Select]
if bits.whole & 0x7F > 0 then --Any non-blocked tree_tile
It should probably be implemented in C++, really, since you get type checking (coords are int16_t?) and loop continue, which would look more like the assembly. I had to flip some of the conditions.

Edit: Actually, Lua supports GOTO, so I could really make my script look like assembly if I wanted.

Apparently there are holes in our documentation about bitfields. There's a special "whole" field that provides the raw integer value of a bitfield (i.e. "bits.whole").

Maybe it should be printed for "gui/gm-editor" and the Lua "printall". Could something be done about allowing tree_tiles to be indexed (beyond the z-level) instead of using "_displace", or is that not possible due to them not being vectors? I'll add this to the issue tracker it if it's possible.
« Last Edit: June 14, 2021, 05:35:10 pm by Bumber »
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)?
Pages: 1 ... 194 195 [196] 197 198 ... 243