Bay 12 Games Forum

Please login or register.

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

Author Topic: A (kludgey) workaround for the disappearing caravan bug  (Read 35194 times)

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #15 on: July 12, 2016, 11:25:52 pm »

Maybe it's possible to write a script that determines if a unit is outside the map, then move them onto it. Not sure if they'd show up as being at a certain coordinate (outside bounds,) or whether it uses a special flag to determine they're not placed yet.
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)?

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #16 on: July 13, 2016, 02:18:11 am »

I don't see why not, though writing one is currently beyond my abilities. I remember werebeasts used to wait on arrival, though, so might want to run it just every autumn, winter, spring and summer and check for just merchants/liasons/dwarves of your civ.

Hetairos

  • Bay Watcher
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #17 on: July 15, 2016, 01:30:17 pm »

I'd try this if there were a functioning teleport script for DFHack 0.34.11-r5.

A_S00

  • Bay Watcher
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #18 on: July 18, 2016, 01:03:36 pm »

This bug existed in 0.34.x?  I thought it was new in DF2014.
Logged

Hetairos

  • Bay Watcher
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #19 on: July 21, 2016, 06:41:57 pm »

I'm not 100% sure, but it nearly perfectly fits what happened in my fort. Should I upload a save?

A_S00

  • Bay Watcher
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #20 on: July 21, 2016, 07:06:48 pm »

I'm not 100% sure, but it nearly perfectly fits what happened in my fort. Should I upload a save?
Might be worth mentioning it on the bug tracker; all the reports of it there are 0.42.x or later.
Logged

Hetairos

  • Bay Watcher
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #21 on: July 28, 2016, 03:24:21 pm »

Made an account and posted a note with a save.

I don't suppose you know how to adapt the teleport script to my version, do you? Is that even possible?

A_S00

  • Bay Watcher
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #22 on: July 28, 2016, 05:06:14 pm »

No idea, I'm afraid; I'm no expert in dfhack's internal workings.  You could try asking in the dfhack thread.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #23 on: July 29, 2016, 09:40:46 am »

This should be much more efficient and avoid line length limits:
Code: [Select]
:lua for _, unit in pairs(df.global.world.units.active) do dfhack.run_script('teleport','-unit',unit.id) end
(Don't forget the colon at the beginning of the line!)

Edit: Oh, and this will avoid the issues with bad unit IDs. I'm sure there's a way to distinguish merchants and only teleport them, but I won't be able to check on that for a while. Others in the DFHack thread may be able to help.

Anyway, multicmd is really intended to be used for keybindings and other things that don't involve running thousands of commands.

*edit:  Unfortunately for my sanity, teleport is one of the DFhack features that has been FUBAR'd for my save (40.24).  Somehow, 3 or 4 different versions of plug-ins/scripts for DFHack got jumbled together and many do not work.  Yet the game runs... fine... and if I try to open it on a fresh install with updated dfhack versions, it won't get past the load screen.  I'll keep this method in mind, however, should I ever need it in another fort.

With the fresh install, are you using a DFHack version that's actually built for 0.40.24 (i.e. 0.40.24-r5)? If that fails because of a pack or something, I guess you could try to move your "hack" folder somewhere else and replace it with one from a fresh DFHack 0.40.24-r5 download.
« Last Edit: July 29, 2016, 09:51:52 am by lethosor »
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.

A_S00

  • Bay Watcher
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #24 on: July 29, 2016, 11:58:25 am »

Hey look someone who actually knows what they're doing in dfhack is here!

I'll test your lua command when I get home and update the OP.  I could definitely tell that I was not using multicmd for its intended purpose.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #25 on: July 29, 2016, 02:15:25 pm »

This may work for teleporting just merchants in theory, but it's completely untested:
Code: [Select]
:lua for _, unit in pairs(df.global.world.units.active) do if dfhack.units.isMerchant(unit) then dfhack.run_script('teleport','-unit',unit.id) end end
This definitely won't work in DFHack versions before 0.40.24-r2, though.
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.

Daris

  • Bay Watcher
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #26 on: July 29, 2016, 07:16:42 pm »

THAT WORKED SO WELL OMG

eta: It doesn't work 100% of the time, and sometimes has to be run more than once before the wagons will spawn.  It always brings in the merchants with pack animals; the wagons can be more stubborn.
« Last Edit: July 30, 2016, 10:10:02 am by Daris »
Logged

Dunamisdeos

  • Bay Watcher
  • Duggin was the hero we needed.
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #27 on: November 05, 2016, 07:08:15 pm »

I can't get this to work :(

I've got the multicmd all set up with teleport -unit 1; teleport -unit 2; teleport -unit 3; etc etc up to 10000. It returns errors and does not teleport anything.

Am I setting it up wrongly?
Logged
FACT I: Post note art is best art.
FACT II: Dunamisdeos is a forum-certified wordsmith.
FACT III: "All life begins with Post-it notes and ends with Post-it notes. This is the truth! This is my belief!...At least for now."
FACT IV: SPEECHO THE TRUSTWORM IS YOUR FRIEND or BEHOLD: THE FRUIT ENGINE 3.0

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #28 on: November 05, 2016, 07:09:41 pm »

Did you try lethosor's lua script?

PatrikLundell

  • Bay Watcher
    • View Profile
Re: A (kludgey) workaround for the disappearing caravan bug
« Reply #29 on: November 06, 2016, 07:15:57 am »

I hacked together a script that tries to select only merchants and seems to use the same basic logic as lethosor does (which I didn't see until posting). Since I don't know how to call other scripts I brute forced it by including the teleport script into it...

It's been marginally tested on a normal caravan, where it only teleported the units that had entered the map, but if the stuck units in the bug sort of have entered it ought to work.
The differences from lethosor's logic is that it's a script, so it might be more convenient to call than copy/pasting a command, and I've also added an additional check to exclude dead units (trying to avoid homicidal players' previous exploits from being teleported around: not tested, as I'm not intentionally killing merchants).

Anyway, always make a backup before trying.

Code: [Select]
-- Teleports merchants to the selected position. Incorporates the teleport script.
--[====[

teleportmerchants
=================

teleport
========
-- teleports a unit to a location
-- author Putnam
-- edited by expwnent
]====]

function teleport(unit,pos)
 local unitoccupancy = dfhack.maps.getTileBlock(unit.pos).occupancy[unit.pos.x%16][unit.pos.y%16]
 local newoccupancy = dfhack.maps.getTileBlock(pos).occupancy[pos.x%16][pos.y%16]
 if newoccupancy.unit then
  unit.flags1.on_ground=true
 end
 unit.pos.x = pos.x
 unit.pos.y = pos.y
 unit.pos.z = pos.z
 if not unit.flags1.on_ground then unitoccupancy.unit = false else unitoccupancy.unit_grounded = false end
end

utils = require('utils')

validArgs = validArgs or utils.invert({
 'unit',
 'x',
 'y',
 'z',
 'showunitid',
 'showpos'
})

if moduleMode then
 return
end

--local args = utils.processArgs({...}, validArgs)

--if args.showunitid or args.showpos then
-- if args.showunitid then
--  print(dfhack.gui.getSelectedUnit(true).id)
-- else
--  printall(df.global.cursor)
-- end
--else
-- local unit = args.unit and df.unit.find(args.unit) or dfhack.gui.getSelectedUnit(true)
-- local pos = not(not args.x or not args.y or not args.z) and {x=args.x,y=args.y,z=args.z} or {x=df.global.cursor.x,y=df.global.cursor.y,z=df.global.cursor.z}
-- if not unit then qerror('A unit needs to be selected or specified. Use teleport -showunitid to get a unit\'s ID.') end
-- if not pos.x or pos.x==-30000 then qerror('A position needs to be highlighted or specified. Use teleport -showpos to get a position\'s exact xyz values.') end
-- teleport(unit,pos)
--end

function teleportmerchants ()
  local pos
  if not df.global.cursor.x or df.global.cursor.x == -30000 then
    qerror("A position needs to be highlighted")
  else
    pos = {x=df.global.cursor.x,y=df.global.cursor.y,z=df.global.cursor.z}
  end
 
  for i = 0, #df.global.world.units.active - 1 do
    if df.global.world.units.active [i].flags1.merchant and
   not df.global.world.units.active [i].flags1.dead then
  dfhack.println ("Teleporting unit: " .. tostring (df.global.world.units.active [i].id) .. " index: " .. tostring (i))
      teleport (df.unit.find (df.global.world.units.active [i].id), pos)
end
  end
end

teleportmerchants ()

Edit: By the way, my unit id:s for the merchants were over 30000, so a low range brute force approach can easily miss the merchants.
« Last Edit: November 06, 2016, 07:18:26 am by PatrikLundell »
Logged
Pages: 1 [2] 3 4 ... 6