User:Fleeting Frames/assigndeathdate

From Dwarf Fortress Wiki
Jump to navigation Jump to search

Takes up to three numbers: unitid, deathyear and deathtick. If they're not given, uses currently selected unit, current year and current tick.

DF will fail to save and crash instead after running this script.

--assigns death date to an unit (cause: slaughter)
--cannot save after using
local args = {...}
local unitid = tonumber(args[1]) or dfhack.gui.getSelectedUnit().id
local unit = df.unit.find(unitid)
if unit.counters.death_id>-1 then 
	qerror("This unit's death has already been recorded")
local deathyear = tonumber(args[2]) or
local deathtick = tonumber(args[3]) or

local myincident = df.incident:new()

for i,v in pairs(myincident) do
	if(i~="witnesses" and i~="flags") then
		myincident[i] = -1
end =
myincident.unk_4 = 0--owo what's this? Probably the reason game can't save after using this script
myincident.event_year = deathyear
myincident.death_cause = 49
myincident.flags.announced_missing = true
myincident.flags.discovered = true
myincident.flags.unk2 = true
myincident.unk_v40_3a=20 --what does this do? Linked to group? Who knows. Maybe instead this is the reason?
local playerfort = df.world_site.find(
myincident.world_x= 48*(playerfort.global_min_x)+unit.pos.x--dwarfmode tile scale
myincident.world_y= 48*(playerfort.global_min_y)+unit.pos.y
myincident.world_z= --lowest map z-level."#",myincident) = +1