Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1] 2

Author Topic: Standing Siege tags, lost forgotten beasts, and missing wildlife  (Read 7330 times)

RocheLimit

  • Bay Watcher
    • View Profile

This script does the follow:

  • Recovers lost invading armies so that you can kill them and remove the [Siege] Tag
  • Recover forgotten beasts that never appear despite the announcement
  • Recover packs of wildlife that are missing from your surface/caverns
  • Recover caravans that are partially or completely missing, fixing the caravans that are constantly 'unloading'

(5-8-2017 Edit: The missing i's have been found.  It should now work as copied.  Many thanks to Lethosar)
Spoiler (click to show/hide)

It should look something like this:
(5-18-2017 Edit: Note that this code will only look at the first 6 or 7 units of the fort; I will swap it out later with one showing code that checks all the active units Updated image)
Spoiler (click to show/hide)

Backstory:
My generational fort has had a constant issue with siege tags being stuck, forgotten beasts saying they have arrived when they really did not, and years of 1 or 2 herds of wildlife despite having a surface and three caverns.  Using a recent siege whose tag still remained, a recent forgotten beast that stood me up, and PatrikLundell's mention of df.global.world.units.active, I found that not only were the 'missing' units on the active unit list, but their flags could be altered using DFHack. 
Spoiler (click to show/hide)
It turns out that the 'missing' units universally had move_state=false, dead=true, and incoming=true, invaders and forgotten beast alike.  When reversing the aforementioned three flags, and ensuring can_swap is true which *most of the other units had, I was able to manually 'spawn' the unit where it should have been and add it to the Unit List.

I then used PatrikLundell's script for Dismissmerchants (http://www.bay12forums.com/smf/index.php?topic=159297.45) as a base and adapted it to search the unit list for anything with dead=true and incoming=true, then making flag changes to those that fit the parameters. 

Results:
Spoiler (click to show/hide)
Spoiler (click to show/hide)
Spoiler (click to show/hide)
Spoiler (click to show/hide)
Spoiler (click to show/hide)

Kill the retrieved invaders and the siege tag will disappear.

I imagine that, so long as an overseer is prompt in dealing with squatters in the void, no group spawned with this will be very large.

That said, I am unsure of this script's usefulness for my own fort.  I think my computer will die if I unpause with 6000+ Other Units.

(5-18-2017 Edit: For now, it is unlikely it works in the most recent version of DF, 43.05.  I will make a current fort and see what can be done with the script, if anything.)
« Last Edit: May 22, 2017, 07:22:44 am by RocheLimit »
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #1 on: April 08, 2017, 05:14:45 am »

Interesting info.

You might try to run your modified script with a counter to e.g. release 300 critters at a time, deal with those, and then repeat until the whole lot has been dealt with.
Logged

RocheLimit

  • Bay Watcher
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #2 on: April 08, 2017, 08:04:17 am »

I hadn't thought of that.  And it works; I changed the iterative formula to only go after the last 200 active units, and pretty much just the last siege and a relative handful of wildlife appeared.

Spoiler (click to show/hide)

Spoiler (click to show/hide)

It will take a while, but I am sure I can work my way through my own fort's backlog now.  Thanks!

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #3 on: April 08, 2017, 12:44:19 pm »

You're welcome!

If your findings help the community it's a decent win in my book.
Logged

RocheLimit

  • Bay Watcher
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #4 on: April 10, 2017, 08:32:50 pm »

I just tried this script out on some stuck merchants; there were only a handful of merchants and guards at the depot and when I could eventually got a dwarf there to trade a few weeks after they arrived, they were perpetually unloading.

Ran the script for the past 100 active units or so and the rest of the merchant convoy popped out of the void and began making their way to the depot.  Once there, my dwarf was allowed to trade with them. 

So now this script can unclog sieges to allow their complete destruction and remove the siege tag, recover packs of wildlife for fun and profit, and retrieve the rest of a merchant caravan to stop them constantly 'unloading' and allow trade.

It is turning out to be quite versatile.

Spoiler (click to show/hide)

Spoiler (click to show/hide)

Spoiler (click to show/hide)

Spoiler (click to show/hide)

Spoiler (click to show/hide)

nuget102

  • Bay Watcher
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #5 on: April 11, 2017, 09:03:06 am »

Would it be possible to set this up to run automatically, like every season or year even?

This script will no doubt help countless people, and I know I'll happily use it.
Logged
The fort where filth melts your skin! (updated 4/9/15)

Curiosity killed the cat.
Satisfaction brought it back.

lethosor

  • Bay Watcher
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #6 on: May 07, 2017, 10:21:45 pm »

It looks like the occurrences of "[i]" in your first post are being interpreted as tags, so copying the script won't work as intended. I'd recommend putting it inside a [code] block too:

Code: [Select]
[i]
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.

RocheLimit

  • Bay Watcher
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #7 on: May 08, 2017, 05:22:56 am »

Wow, that was a dumb mistake on my part.  Thank you for pointing that out, Lethosor.

I have edited the code in my first post to be inside a code-tag and the rather important instances of
Code: [Select]
[i] now show.

azrael4h

  • Bay Watcher
    • View Profile
    • My Dwarf Fortress-centric You Tube videos, part of my nominally vintage gaming channel.
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #8 on: May 17, 2017, 10:06:53 pm »

It doesn't seem to work in 43.05 (64bit). DFHack doesn't display any errors like there isn't a script, or the text the script is supposed to have, and the siege tag remains active, units list only shows 10 gazelles, and nothing happens. 
Logged

TheFlame52

  • Bay Watcher
  • Master of the randomly generated
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #9 on: May 17, 2017, 10:54:07 pm »

This is awesome. I'm going to use it to fix Bastiongate.

Ryga_

  • Bay Watcher
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #10 on: May 17, 2017, 11:21:31 pm »

PTW

Thanks, been looking for something like this for a while
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #11 on: May 17, 2017, 11:24:20 pm »

It doesn't seem to work in 43.05 (64bit). DFHack doesn't display any errors like there isn't a script, or the text the script is supposed to have, and the siege tag remains active, units list only shows 10 gazelles, and nothing happens.
Is there any output from the script? Did you make sure you copied the entire text, including the last "unitretrieval()" line?
You could try PatrikLundell's script too, I suppose.
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.

azrael4h

  • Bay Watcher
    • View Profile
    • My Dwarf Fortress-centric You Tube videos, part of my nominally vintage gaming channel.
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #12 on: May 18, 2017, 12:46:37 am »

No output. I typed in unitretrieval in the console, and it just goes to another line. I just copy-pasted the text in the spoiler tag above:
Spoiler (click to show/hide)

After it didn't work, I edited it to look like the following screenshot. Same thing, no output, no error messages, nothing.

Dismissmerchants doesn't work either, though it did work on a stuck caravan when I first tested it, so that's not it. I tried fix-unit-occupancy as well. It didn't detect any occupancy issues. Last I walked a squad around the borders of the map, in an attempt to draw them from off the map edge. No one came out.

It's as if the invaders were never created at all.

It's been 8 months straight, siege continues with no end and no actual invaders.
Logged

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #13 on: May 18, 2017, 04:22:30 am »

I wouldn't exactly be surprised if the scripts we've come up with so far doesn't cover every bugged case.
If you can provide a link to the save I can take a look at it, but I wouldn't hold my hopes up too high.

The modified script version (in the screen shot) isn't good, as it will look at the first 7 units in the list (every time).
If you wanted to just unstick say 10 at a time, you should iterate over the whole range (as the original), but introduce
"local released = 0" directly after "function unitretrieval ()",
"released = released + 1" after "... hidden in ambush = false" and
"if released == 10 then break end" immediately after that (looks nicer if split over 3 lines, though).

However, if trying to process all units failed to produce anything, there is no reason to believe processing a subset would.
Logged

RocheLimit

  • Bay Watcher
    • View Profile
Re: Standing Siege tags, lost forgotten beasts, and missing wildlife
« Reply #14 on: May 18, 2017, 05:55:38 am »

The code Azrael4h pasted was from the original post without the code tag and missing the i's.  And if the code was copied exactly from the screenshot posted after that, then it would only look at the first 6 or so units of the embark.  The first will not work and the second will not look at the besieging units; both my fault, as I did not originally post with the code tag and the screenshot was for a test... I will have to go back and correct the screenshot as well.

(Edit: Well, scratch that.  I notice that the code pasted by Azrael4h was not in a code tag itself; the i's are there.  So while the 2nd code attempted would still only look at the first 6 or 7 active units, the first should have worked.  Statement above: Retracted.)

That said, Azrael4h's case makes me wonder if the script really needs to be looking at the dead tag.  Would it still work if it only looked for the incoming flag? It would make a certain amount of sense if only the incoming flag was relevant.

Spoiler (click to show/hide)

I will try it out later on my own fort, which still occasionally gets missing forgotten beasts/sieges.
« Last Edit: May 18, 2017, 06:06:03 am by RocheLimit »
Logged
Pages: [1] 2