Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 329 330 [331] 332 333 ... 360

Author Topic: DFHack 0.43.03-r1  (Read 1097250 times)

PeridexisErrant

  • Bay Watcher
  • Dai stihó, Hrasht.
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4950 on: November 30, 2016, 12:12:38 am »

Okay, it sounds like we really need some automated testing.  I'm thinking that for a start, just trying to run all of the commands in a reasonably sensible context (eg correct game mode) and reporting any crashes would be great.  This will still take a fair bit of work, including maybe a script to navigate DF menus, but the payoff should be worth it.
Yeah, testing is something I've wanted to do. I looked at unit tests recently, although those wouldn't be as useful for the DF-related issues. I have a script that walks through all of the structures (well, mostly), which crashes when something is misaligned badly enough, so that might be a decent place to start. Besides that, actual tests that run in DF would have a couple things to sort out (nothing impossible, though):
- Needing to start DF (this takes time, although it might be fast on Travis)
- Needing to restart DF if a test crashes DF (but not restarting unnecessarily, to save time)
- Needing to restart DF (or abort and reload the current game?) if a test does something difficult to reverse (3dveins, exterminate, etc.). Hopefully this isn't necessary often, though.

In short, it could be slow, but it's definitely something I want to look into.

Basically there's tests that run in seconds (before every commit), in minutes (when you go get a coffee), and in hours (overnight).  Obviously the faster the better!  Your script sounds fantastic as a fast-unit-test-ish-thing, and I'd certainly see how far it can go.  Interaction with DF is certain to slow things down, but that's just a feature of integration testing... which is exactly what DFHack needs to do.

I'd probably try to build two settings - one fast check (minutes) that either passes or fails, and one longer stress-test (many minutes or hours) that just hammers at everything I can think of and reports in detail on each thing it breaks.  I'm thinking more like AFL fuzzing than unit tests, if that clarifies things.
Logged
I maintain the DF Starter Pack - over a million downloads and still counting!
 Donations here.

Immortal-D

  • Bay Watcher
  • [Not_A_Tree]
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4951 on: December 01, 2016, 08:37:58 am »

I was playing with the SpawnUnit command, and it works as expected.  However, I was wondering if anyone knows a way to spawn critters.  Or is it only possible for sentients?

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4952 on: December 01, 2016, 10:51:38 am »

Are you referring to "vermin" (like ants, small fish, etc.)? Spawnunit doesn't support those, and I'm not sure if it's possible to create them in another way.
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.

TheFlame52

  • Bay Watcher
  • Master of the randomly generated
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4953 on: December 01, 2016, 02:06:30 pm »

I think createitem can make vermin.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4954 on: December 01, 2016, 04:06:18 pm »

I'm sure I saw a command to create colony vermin (defaulting to bees). However, I thought the question was about regular animals rather than vermin or sapients?
Logged

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4955 on: December 01, 2016, 04:14:29 pm »

Well, I poked around with edb trying to follow the old methods to track down the last few linux 64 bit globals missing, had a few that looked like the right range for ui_advmode, but I had to kinda hit and miss hunt around because doing the full analysis step made edb hang and start eating Xorg's head, bleh.

It feels like it should be in the range of these but I finally just started counting through what should have been the right number of steps to find them before I noticed ui_look_list was missing too and I had been trying to work from the ui_look_sidebar or some shit, oh and first I started out trying to hunt it down in the wrong direction, I'm pretty sure it's just a bit (like 10000_16 or so) lower than the ui hex (0x1a6e540) but I wasn't paying attention to that since I was leaning in and squinting at the little numbers in the edb panes.

Code: [Select]
0x205cd40
0x2058140
0x1a81280
0x1a7e600
0x1a5e480
0x1a5b800
0x17f4020
0x17f3220
0x1484940
0x147fd40
I had thought I was closing in on it until I noticed the ui_look_list fuckup I was making, but none of those worked, just spat segfaults at me til I gave up and made a fort intending to track down the ui_look_list global before I started having fun poking at my dorfs and whatnot.
Logged

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4956 on: December 01, 2016, 10:57:49 pm »

I am working on some scripts and have a couple questions;

1. Is there a script that removes a tree (and all connecting branches and such) from a map? As in, I target a location or a tree id (I don't know, do tree's have individual ids?) and it will be erased?
2. Similarly, a script that does the same for bushes/shrubs/any growths?
3. Is milo christiansen's script still the best way to get a tile's material using lua?
4. Back to trees, is there a way to see how old a tree is and to get more information about it?
5. Do the current scripts for resurrecting corpses handle body parts? That is to say, if I target a corpse whose hand was chopped off and then rez it, will the hand corpse item be removed or will it stay in game?
6. Along the same lines, if a unit is resurrected will the other members of your fort still want to bury them?

I will have more questions later, but that's enough for now.
Logged

PeridexisErrant

  • Bay Watcher
  • Dai stihó, Hrasht.
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4957 on: December 02, 2016, 02:23:36 am »

I'm sure I saw a command to create colony vermin (defaulting to bees). However, I thought the question was about regular animals rather than vermin or sapients?

FWIW, that command is colonies
Logged
I maintain the DF Starter Pack - over a million downloads and still counting!
 Donations here.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4958 on: December 02, 2016, 04:19:42 am »

I am working on some scripts and have a couple questions;

Collection of vague guesses and pointers:

1. Is there a script that removes a tree (and all connecting branches and such) from a map? As in, I target a location or a tree id (I don't know, do tree's have individual ids?) and it will be erased?
2. Similarly, a script that does the same for bushes/shrubs/any growths?
3. Is milo christiansen's script still the best way to get a tile's material using lua?
4. Back to trees, is there a way to see how old a tree is and to get more information about it?
5. Do the current scripts for resurrecting corpses handle body parts? That is to say, if I target a corpse whose hand was chopped off and then rez it, will the hand corpse item be removed or will it stay in game?
6. Along the same lines, if a unit is resurrected will the other members of your fort still want to bury them?

I will have more questions later, but that's enough for now.
1. I don't know. Each tree/shrub on the map has it's individual entity in the df.global.world.plants.all list ("path" might not be completely correct as it's from memory). In addition to that, there's also info on the tile itself that there's a trunk/sapling. Highwood can cover several tiles. Branches are likewise "present" on their tiles. I haven't tried to remove any though, and I don't know if there are additional references (trees designated for cutting end up in the jobs list, but the tree being gone just results in an extra cutting job doing nothing, which happens when getplants is run several times with unpauses in between to designate the same trees). The Plants command creates plants, and you sort of want to do the reverse.
2. -
3. Probe does it interactively. I haven't looked at the script. I can use Probe's logic to get at the data using lua, though.
4. The plant info contains at least one timer, so you should be able to get the info there.
5. I don't really know, but other discussions indicate the corpse and body parts are generated upon death as separate items, so resurrecting a creature ought to give it a new body.
6. Speculating, I would expect the burial situation would correspond to the normal case of a lost body part without dying, in which case the body parts ought to be "stored" in the corpse stockpile until the final death. Would both/all bodies be buried? You try it out and tell us!
Logged

Rumrusher

  • Bay Watcher
  • current project : searching...
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4959 on: December 02, 2016, 07:38:35 am »

well most of the rez scripts are bringing back the unit from death and usually leaves a body behind.
them dying again doesn't produce another corpse and they blink out of living realm.
rez interaction checks for a dead unit with matching historical figures to the corpse and Rez them with proper wounds or makes a new unit with the correct historical figures to the dead unit if the interaction couldn't find the dead unit in the list of all or active units.
if there a weird case of multiple rez attempts it will reanimate the other corpse parts and usually makes a new unit that just shares traits descriptions of the original.
leading to the clone zombie army dfhack trick where you resurrect the zombie you made with the script then reanimate them in game then get the fresh zombie killed so you can resurrect their soul.


hmm in other dfhack ideas I wonder if it's possible to remove the site restrictions on building in adventure mode in towns and have it not make a new camp on top of the site either.
Logged
I thought I would I had never hear my daughter's escapades from some boy...
DAMN YOU RUMRUSHER!!!!!!!!
"body swapping and YOU!"
Adventure in baby making!Adv Homes

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4960 on: December 02, 2016, 12:51:36 pm »

1. Is there a script that removes a tree (and all connecting branches and such) from a map? As in, I target a location or a tree id (I don't know, do tree's have individual ids?) and it will be erased?
2. Similarly, a script that does the same for bushes/shrubs/any growths?
3. Is milo christiansen's script still the best way to get a tile's material using lua?

1) Not that I know of, but it wouldn't be hard to write one...
2) I have a script that forcibly removes surface saplings. Actually if you look back a few pages in this thread I posted an early version of my sapling elimination code.

Speaking of my sapling deletion script I need to get that tested... The script is supposed to be an answer to "the jungle problem" (trees growing super thick on every map regardless of biome). Basically if surface trees go over a set limit it deletes all surface saplings until trees go under the limit again :)
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

Roses

  • Bay Watcher
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4961 on: December 02, 2016, 05:09:51 pm »

1. Is there a script that removes a tree (and all connecting branches and such) from a map? As in, I target a location or a tree id (I don't know, do tree's have individual ids?) and it will be erased?
2. Similarly, a script that does the same for bushes/shrubs/any growths?
3. Is milo christiansen's script still the best way to get a tile's material using lua?

1) Not that I know of, but it wouldn't be hard to write one...
2) I have a script that forcibly removes surface saplings. Actually if you look back a few pages in this thread I posted an early version of my sapling elimination code.

Speaking of my sapling deletion script I need to get that tested... The script is supposed to be an answer to "the jungle problem" (trees growing super thick on every map regardless of biome). Basically if surface trees go over a set limit it deletes all surface saplings until trees go under the limit again :)

Well when I look at the information for a given tree I find
Code: [Select]
[lua]# ~df.plant.find(2114)
<plant: 0x18452340>
flags                    = <plant_flags: 0x18452340>
material                 = 153
pos                      = <coord: 0x18452344>
grow_counter             = 19982037
damage_flags             = <plant.T_damage_flags: 0x18452350>
hitpoints                = 400000
update_order             = 9
site_id                  = -1
srb_id                   = -1
contaminants             = <vector<spatter_common*>: 0x18452364>
tree_info                = <plant_tree_info: 0x185d0a30>
Note that this is the same as just going ~df.global.world.plants.all[2114], the 2114 was just picked at random and then I went to look at that spot on the map. What is growing here is a large three story tree. My efforts to remove it were as follows;

1. Set hitpoints to 0 and then to -1. I was really hoping this would just take care of the tree, but nothing seemed to happen.
2. Set grow counter to 0 and then to -1. Again, no visible effect.
3. Set all damage_flags to true. No change.
4. Change material just to make sure you can actually have an affect. Material of tree did change.
5. Remove the entry for the tree from the plant list. No change.
6. Change the tiletype to that of the adjacent grass square. Tile changed to grass, but rest of tree (the above trunks and branches and twigs) still remain.

Now 4 and 5 together might be necessary to remove the tree (didn't try 5 without 4) but what I can't figure out is how to find all of the tiles for the tree. The plant entry only lists the base trunk, but changing the material of the base trunk changes the material of the entire tree, so they must be connected. Now I could just iterate over all of the squares next to the base of the tree and see which ones are also TREE tile types, but what if two trees are right next to eachother? How do you determine which branches belong to which tree?

Also, I can't think of a slick way to determine the id of a tree at a given location. It's possible to just brute force it and go through the position of all the plants on the df.global.world.plants.all list, but that could be several thousand even on a small map. And also you may be looking at not the main tree trunk but a different part of the tree, in which case you would need to look for the main trunk first and then look for the id.

All of these issues definitely can be dealt with brute force style. Just wondering if anyone else can think of a more elegant way to go about it.
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4962 on: December 02, 2016, 05:30:02 pm »

I haven't looked at it, but I would expect the tree_info pointer to contain the rest of the tree (including roots...).
Thus, I would expect you to have to remove the tree parts tile for tile, and figure out when to replace roots with soil and branches with air (and probably cater for trees growing through bridges as well). You also need to experiment to find out if digging through tree roots changes the tree root info or not: if it doesn't you have to figure out when you should do nothing. Also note that tree parts can be dead and burned, so the tile type can be the burned version as well as the live one (at least).

I've found tree entries in the plants list that point to neither trees nor saplings, so I suspect the tree isn't actually removed upon cutting, but I don't know. IF you need to remove it you probably have to remove int from not only the plants.all, but from the plants.tree list as well.

One experiment you may want to do is to fire a ballista arrow at a tree to disintegrate it and see how things look before and after.
Logged

milo christiansen

  • Bay Watcher
  • Something generic here
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4963 on: December 02, 2016, 06:50:13 pm »

What I would do is find tree tiles based on the tree_info field and set them to an appropriate tile type (open space mostly). Then delete the plant object from the list. Don't forget that there are actually two other lists containing trees (one for dry, one for wet), also you need to delete the tree object itself or you will leak memory.

If you want to see how to tell if a given tile is part of the tree see my material finder module.

Here is (an old version of) the code I use to delete saplings. For trees the main difference would be that you would need to change all the tiles, not just one.
Code: [Select]
-- Note that "del" is a (sorted) table of tables containing the plant index and a reference to the plant object itself
for _, plant in ipairs(del) do
local block = dfhack.maps.ensureTileBlock(plant.pos.x, plant.pos.y, plant.pos.z)
block.tiletype[plant.pos.x%16][plant.pos.y%16] = df.tiletype["SoilFloor1"]

-- The list is high indexes to low indexes, so we can just delete from the list without fear of messing up later indexes.
df.global.world.plants.all:erase(plant.i)

-- Plants do not have an ID number, so we need to compare them based on location.

for j = 0, #df.global.world.plants.tree_dry - 1, 1 do
if same_xyz(df.global.world.plants.tree_dry[j].pos, plant.ref.pos) then
df.global.world.plants.tree_dry:erase(j)
break
end
end

for j = 0, #df.global.world.plants.tree_wet - 1, 1 do
if same_xyz(df.global.world.plants.tree_wet[j].pos, plant.ref.pos) then
df.global.world.plants.tree_wet:erase(j)
break
end
end

plant.ref:delete()
end
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

mirrizin

  • Bay Watcher
    • View Profile
Re: DFHack 0.43.03-r1
« Reply #4964 on: December 02, 2016, 09:55:07 pm »

That document pretty much just covers globals. Most of the globals (except a few debug flags, I think) are already located.

To answer the original question, we need to check most tools and make sure they don't crash. It's also helpful to explore structure layouts (e.g. with gui/gm-editor) and make sure that doesn't crash either. Also, there are a couple other things to fix, like 64-bit Stonesense (which is mainly just missing allegro libraries).

Part of the delay is due to a lack of time spent testing. Out of the 247 people that have downloaded the 64-bit Windows build, I've seen exactly one report of a crash that occurs with the majority of Ruby scripts (exterminate, etc.). If only one person bothered to report an obvious crash like that, I'm not entirely confident in that build's overall stability.

Stonesense is already updated on windows, for both versions.

If nobody else can do it, I can try to update the Linux build process, but it's a last resort because I'd have to set up a dev environment first.
So...this means that Stonesense works? Do the other visualizers work as well?
Logged
Pages: 1 ... 329 330 [331] 332 333 ... 360