Not sure if anyone's posted this before, but if you want a safe way to kill something, use this:
unit=dfhack.gui.getSelectedUnit()
unit.body.blood_count=0
Obviously this only works on creatures that need blood to survive. For undead, I think that removing the tags that keep them alive despite the shape their body is in might work, especially if followed by the above command. Sort of an undeath-to-death spell I guess.
For mineral and other unusual material creatures, will need to do more !!SCIENCE!!.
So, for someone who has absolutely no idea on how to use that little snippet, what do I do?
Copy the two lines of script.
Open your text editor of choice.
Paste the text and save as drainblood.lua or whatever name you want, and put it in the scripts folder of your DFhack directory.
In dwarf mode, you only need to highlight the unit with v. In adventure mode, you'll need to use l to look at the unit and then select that unit from the a/b/c/d/e list so you're viewing the creature's status screen.
In the DFhack console, make sure you're in the root menu and not in liquids, dfusion or lua mode. Type drainblood or whatever name you used for the script.
Nothing will seem to have happened, but the creature will be a corpse as soon as time advances.
Be aware that if you fail to properly select the unit and somehow unit=your adventurer or one of your dwarves from a previous script, this will apply to you or the dwarf instead.