Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: How to instantaneously move building from one tile to other  (Read 586 times)

bloop_bleep

  • Bay Watcher
    • View Profile
How to instantaneously move building from one tile to other
« on: January 28, 2017, 07:53:53 pm »

Ok, so I'm new to the DFHack library and memory hacking in general, but I have extensive Python and C++ experience. I'm looking for a way to instantaneously move a building from one tile to an adjacent one. According to the comments in the DFHack code (library/include/modules/Building.h), I can't simply destroy the building with constructWithItems and recreate it somewhere else with destroyBuilding, because that would require dwarf labor, but I want to do it immediately.

Is it just as simple as modifying the x, y coordinates in the building struct? I doubt it.

Any help?
« Last Edit: January 28, 2017, 08:01:51 pm by bloop_bleep »
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: How to instantaneously move building from one tile to other
« Reply #1 on: January 28, 2017, 08:39:27 pm »

Edit the pos, items too, oh, keep the shape!

x1/y1, xcenter, x2
ycenter
y2

I spread a wagon across an embark and it's psychadelic.
« Last Edit: January 28, 2017, 08:55:36 pm by Max™ »
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: How to instantaneously move building from one tile to other
« Reply #2 on: January 28, 2017, 08:54:26 pm »

What do you mean by "items"?
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: How to instantaneously move building from one tile to other
« Reply #3 on: January 28, 2017, 08:58:06 pm »

The logs/boulders/etc have a pos, move them the same amount as you move the building, so if the workshop is:

x1 70, xcenter 71, x2 72
y1 43, ycenter 44, y2 45
z 50

If there is an anvil in it, the pos will probably be x 71, y 44, z 50 if it's in the middle, and so forth. Wagons have a ton of items on them and if you just move the logs from the building and the building itself the items stay where they were.


Oh, also check world_data.sites[yoursite id].realization.buildings for the houses and keeps and wall type buildings.

The latter is how I did this to a keep:
« Last Edit: January 28, 2017, 08:59:58 pm by Max™ »
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: How to instantaneously move building from one tile to other
« Reply #4 on: January 29, 2017, 02:55:59 am »

How do you find which items are in a building? And then, how do you move them?
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: How to instantaneously move building from one tile to other
« Reply #5 on: January 29, 2017, 05:50:54 am »

They should be listed in the building definition under contained_items, and just editing their position should work.
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: How to instantaneously move building from one tile to other
« Reply #6 on: January 29, 2017, 07:57:04 pm »

The only data members of t_building I see are x1; x2; y1; y2; z; material; type; a union of df::civzone_t, df::furnace_t, etc.; custom_type; and origin. I'm obviously missing something here. I realize I didn't mention I'm writing a DFHack plugin in C++, not a script in Lua, so I want to make sure we're on the same page there. If you were talking about the C++ library, you're probably looking at a different part of it, so can you tell me the location of this in the Github source?
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: How to instantaneously move building from one tile to other
« Reply #7 on: January 29, 2017, 09:18:13 pm »

Ahhh, no, I was talking about the lua stuff, we need to light the Quietust or Lethosor signal or something for that.
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: How to instantaneously move building from one tile to other
« Reply #8 on: January 29, 2017, 10:35:09 pm »

You know what, I'll try just modifying the x, y coords, then come back with the results.
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: How to instantaneously move building from one tile to other
« Reply #9 on: January 29, 2017, 10:51:12 pm »

Yeah, it's possible that the C++ structure handles it differently.
Logged

bloop_bleep

  • Bay Watcher
    • View Profile
Re: How to instantaneously move building from one tile to other
« Reply #10 on: February 01, 2017, 04:39:55 pm »

Oh, hah! Silly me, I was looking in the wrong place. In dfhack/library/include/df/building.h, there is actually a full-fledged building class with, among other things, a moveBuilding function.
Logged
Quote from: KittyTac
The closest thing Bay12 has to a flamewar is an argument over philosophy that slowly transitioned to an argument about quantum mechanics.
Quote from: thefriendlyhacker
The trick is to only make predictions semi-seriously.  That way, I don't have a 98% failure rate. I have a 98% sarcasm rate.

Max™

  • Bay Watcher
  • [CULL:SQUARE]
    • View Profile
Re: How to instantaneously move building from one tile to other
« Reply #11 on: February 02, 2017, 06:42:00 am »

Nng, booga booga, me lua caveman not like you include function, nng, me angry, me set locals and then do if or else!
Logged