Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: A suggestion for a DFHack script...  (Read 4550 times)

Frango Nicolbidok

  • Bay Watcher
  • Legendary Peasant
    • View Profile
A suggestion for a DFHack script...
« on: March 12, 2014, 06:14:23 pm »

I have not yet learned to code in lua (and I would like to if I didn't have work and college), but...

I think it would be cool to have a trappable script for dfhack. Its purpose would be so, in DF, you could put your "Looking" cursor (k --> hover over non-trappable creature) and type "trappable here" in the console. Then, your creature (which is most likely a
Spoiler (click to show/hide)
or kobold if its not already trappable) will be able to walk over a trap and be affected by it (weapon traps, stone-fall traps, and cage traps).

I know forgotten beasts/demons/etc. are hard coded, but I imagine it would be possible to change or disable that ability for an individual/already spawned creature.
Logged
However, now I wanted some more challenge and embarked to evil biome.
"Terrifying screams come from above!"

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: A suggestion for a DFHack script...
« Reply #1 on: March 12, 2014, 06:34:46 pm »

For a single creature, this would be impossible, as TRAPAVOID is only checked at the caste level - if you wanted to be able to trap a single kobold, you would have to (temporarily) turn off TRAPAVOID for all kobolds (and then turn it back on once your single kobold is trapped). Alternatively, you could simply mark the creature as being "webbed" (to make it trigger traps anyways), but you'd have to do it while it's standing on top of the trap in question.

Also, putting "clown" inside a spoiler tag is completely stupid and pointless - if you're going to put it in a spoiler tag, call it a "demon" (aside from the fact that people in the Modding forum generally already know all about that, so it's not as important to spoiler it).

Also also, DFHack-specific stuff belongs in the "Utilities and 3rd Party Applications" subforum.
« Last Edit: March 12, 2014, 06:39:40 pm by Quietust »
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.

Frango Nicolbidok

  • Bay Watcher
  • Legendary Peasant
    • View Profile
Re: A suggestion for a DFHack script...
« Reply #2 on: March 12, 2014, 06:45:08 pm »

For a single creature, this would be impossible, as TRAPAVOID is only checked at the caste level - if you wanted to be able to trap a single kobold, you would have to (temporarily) turn off TRAPAVOID for all kobolds (and then turn it back on once your single kobold is trapped). Alternatively, you could simply mark the creature as being "webbed" (to make it trigger traps anyways), but you'd have to do it while it's standing on top of the trap in question.

Makes sense. That sounds easier in terms of programming.
Logged
However, now I wanted some more challenge and embarked to evil biome.
"Terrifying screams come from above!"

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: A suggestion for a DFHack script...
« Reply #3 on: March 12, 2014, 09:48:27 pm »

After thinking about it a bit more, something like this might be possible by hooking into the building_trapst::updateAction() vmethod (or whatever Toady calls it) and inserting some logic to incapacitate (set webbed/unconscious/etc.) any "marked" creatures standing on the trap if it's properly loaded (which might be tricky for ranged weapons) and not jammed. However, this would have to be done as a plugin, as I'm pretty sure Lua scripts can't interpose vmethods.
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.

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: A suggestion for a DFHack script...
« Reply #4 on: March 13, 2014, 01:45:04 pm »

I'm pretty sure Lua scripts can't interpose vmethods.

You'd be right, though there are some interpose-based events exposed to it.

Roses

  • Bay Watcher
    • View Profile
Re: A suggestion for a DFHack script...
« Reply #5 on: March 14, 2014, 01:06:59 am »

After thinking about it a bit more, something like this might be possible by hooking into the building_trapst::updateAction() vmethod (or whatever Toady calls it) and inserting some logic to incapacitate (set webbed/unconscious/etc.) any "marked" creatures standing on the trap if it's properly loaded (which might be tricky for ranged weapons) and not jammed. However, this would have to be done as a plugin, as I'm pretty sure Lua scripts can't interpose vmethods.

That would be kind of interesting actually. You could make different levels of trap avoidance that way.
Logged