I was able to use teleport.lua as long as I filled out both unitID and position. If I omitted one, I got errors. Here's a screenshot.
Tiny Pic because my internet is shit right now.
It looks to me like you didn't have your cursor set somewhere. You can try putting a printall(pos) right before teleport(unit,pos). I'm guessing you will get nil or something like that.
Does anyone have experience with adding wounds to units with DFHack? Every time I try to add a wound using gm-editor or just the command line it reverts back after a few ticks.
It might just heal... Wounds are complicated to say the least.
Let's see... I had a script that adds a wound... A heart ripping out script. here
The wound just removes the heart and adds a HUGE amount of bleed per tick (without the bleeding ripping out a heart does nothing... dwarves can be heartless strangely). So more complicated stuff like damaging tissues and breaking bones or even figureing out how much bleeding to add for heart removal (also it would be fun to add a hole through to the heart ) is left as an exercise to the reader
Hmm, I may be able to use that to achieve what I am thinking, but I will have to investigate wounds a bit more in arena first I think. Get a good bench mark for numbers and such.
So I have spent quite a bit of time looking through wounds, from what I can tell there are three main components. The first is adding the actual wound to the unit. Namely;
[lua]# ~unit.body.wounds[0]
<unit_wound: 0x1606de90>
id = 1
parts = <vector<unit_wound.T_parts*>: 0x1606de94>
age = 343
attacker_unit_id = 3
attacker_hist_figure_id = -1
flags = <unit_wound.T_flags: 0x1606deb0>
syndrome_id = -1
pain = 0
nausea = 0
dizziness = 0
paralysis = 0
numbness = 0
fever = 0
curse = nil
Then you have to add the parts that the wound affects. Each wound can have more than one body part affected, although it usually appears to be the same body part with different layers.
[lua]# ~unit.body.wounds[0].parts[0]
<unit_wound.T_parts: 0x13da0dc0>
global_layer_idx = 64
body_part_id = 15
layer_idx = 0
contact_area = 24
surface_perc = 100
strain = 49900
effect_perc1 = <vector<int16_t>: 0x13da0dd4>
effect_perc2 = <vector<int16_t>: 0x13da0de4>
effect_type = <vector<wound_effect_type>: 0x13da0df4>
edged_curve_perc = 29
flags1 = <wound_damage_flags1: 0x13da0e08>
flags2 = <wound_damage_flags2: 0x13da0e0c>
bleeding = 0
pain = 5
nausea = 0
dizziness = 0
paralysis = 0
numbness = 0
swelling = 0
impaired = 0
cur_penetration_perc = 99
max_penetration_perc = 100
jammed_layer_idx = -1
unk_v406_1 = 0
Lastly, the corresponding body part AND layer must have the correct values and flags set.
[lua]# ~unit.body.components
<body_component_info: 0x15ff4c98>
body_part_status = <vector<body_part_status>: 0x15ff4c98>
numbered_masks = <vector<uint32_t>: 0x15ff4ca8>
nonsolid_remaining = <vector<uint32_t>: 0x15ff4cb8>
layer_status = <vector<body_layer_status>: 0x15ff4cc8>
layer_wound_area = <vector<uint32_t>: 0x15ff4cd8>
layer_cut_fraction = <vector<uint32_t>: 0x15ff4ce8>
layer_dent_fraction = <vector<uint32_t>: 0x15ff4cf8>
layer_effect_fraction = <vector<uint32_t>: 0x15ff4d08>
With all three of these things I have managed to add persistent wounds (although in about 10% of my trials the damage was undone and the wound removed, but that may have been because the wound healed, or there is another check somewhere that I am unaware of for certain wounds).
So it seems adding wounds to units is at least possible, now the issue is getting correct values for everything. I could definitely use some help in that department. What would be awesome is if anytime you are playing and one of your units gets a cool wound you could post all the values. Or if you have a fort that has lived through a bunch of different sieges and monster attacks I can go through the units (both alive and dead) and get a set of wounds, ranging from stubbed toes to torn in half. My hope is to build a, sort of, wound database, that I can use in modding and scripts to simulate an adventuring system inside of fortress mode.