Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: DFHack and river tiles  (Read 1399 times)

Jazz Cat

  • Bay Watcher
  • Adept stringed instrumentalist
    • View Profile
DFHack and river tiles
« on: June 12, 2022, 12:27:42 pm »

Is there a script/plugin that allows you to mark a tile as part of a river? I'm not talking about sources or gui/liquids—those let you create a river source, but what I'm looking for is some way to mark a tile as part of the embark's river feature in a such a way that river fish-vermin will spawn in it for my fisherdwarves.

Thanks!
Logged
Give your dwarves a pet
My holiday mod (only offensive to elves)
The check-laundry script

Quote
Just give the Crossbow weapon the [AMMO:CROSSBOW] tag in the raws. You can make a crossbow that shoots crossbows.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack and river tiles
« Reply #1 on: June 12, 2022, 03:39:15 pm »

I haven't checked whether vermin fish spawn, but the Region Manipulator (http://www.bay12forums.com/smf/index.php?topic=164136.msg7454345#msg7454345) allows you to create/modify rivers at the Mid Level Tile level, although the DF logic logic for bends is decidedly weird (different depending on orientation and with implicitly defined tiles based on adjacent tiles).
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack and river tiles
« Reply #2 on: June 12, 2022, 06:12:00 pm »

From what I recall, in order to get vermin spawning (and allow fish to be caught), you need to set the proper "map feature" flags in the relevant tiles. I'm not sure about the exact details, but if you look at existing river tiles you should be able to figure it out fairly easily.

If you're extending the river into a map_block where it previously did not exist, then you'll also need to set the correct feature ID in the new block itself (and hope that it doesn't already reference a different map feature).
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.

Jazz Cat

  • Bay Watcher
  • Adept stringed instrumentalist
    • View Profile
Re: DFHack and river tiles
« Reply #3 on: June 19, 2022, 04:06:30 pm »

From what I recall, in order to get vermin spawning (and allow fish to be caught), you need to set the proper "map feature" flags in the relevant tiles. I'm not sure about the exact details, but if you look at existing river tiles you should be able to figure it out fairly easily.


That's what I'm looking for, yeah! I just don't know how to change tile flags with DFHack. Is there something akin to gm-editor for tiles that I could be using?
Logged
Give your dwarves a pet
My holiday mod (only offensive to elves)
The check-laundry script

Quote
Just give the Crossbow weapon the [AMMO:CROSSBOW] tag in the raws. You can make a crossbow that shoots crossbows.

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack and river tiles
« Reply #4 on: June 19, 2022, 07:11:17 pm »

You'll probably need to do it "the hard way", which is by writing a Lua script or running commands directly at the console interactively.

From what I can see, you first want to use the k cursor over an existing River tile and then run the "probe" command - the output should contain "feature_local = Y" and the "local feature idx" should be something other than "-1".
Once you've gotten that information, the following commands should do what you want, assuming you've got the map cursor hovering over the tile into which you want your river to extend:
Code: [Select]
-- grab a pointer to the map "chunk" beneath the cursor
blk = dfhack.maps.ensureTileBlock(df.global.cursor.x, df.global.cursor.y, df.global.cursor.z)

-- check if it's already assigned to a local feature
print(blk.local_feature)
-- if you see a number other than "-1" or the feature index you got above, then you can't extend the river into this tile

-- if it was "-1", then change it to the feature index from above (replace "N")
blk.local_feature = N

-- mark the tile as being part of the local feature
blk.designation[df.global.cursor.x % 16][df.global.cursor.y % 16].feature_local = true

You should only need to perform these actions on the actual tiles filled with water - the air blocks above should be left alone. If you're placing actual Brook tiles (which include a special floor tile above them), then you'll want to flag those as well.
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.

Jazz Cat

  • Bay Watcher
  • Adept stringed instrumentalist
    • View Profile
Re: DFHack and river tiles
« Reply #5 on: June 19, 2022, 11:07:36 pm »

Hmmm. I wonder if I could designate a chunk of solid ground as a fishing zone this way...

Thank you for the code snippet, by the way! That's immensely helpful.
Logged
Give your dwarves a pet
My holiday mod (only offensive to elves)
The check-laundry script

Quote
Just give the Crossbow weapon the [AMMO:CROSSBOW] tag in the raws. You can make a crossbow that shoots crossbows.

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack and river tiles
« Reply #6 on: June 20, 2022, 09:10:17 am »

Hmmm. I wonder if I could designate a chunk of solid ground as a fishing zone this way...
I'm pretty sure that won't work, because the fishing code will check to make sure that there's actually water in the target tiles - otherwise, you'd be able to dam a river and still fish from 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.