Oh, no, it's not. That's the historical figure id of whoever you told it to marry. That's specific to each world and whoever it is for. In this case, that just means that one of the two you were trying to marry had a historical figure id of 6965, but the number of historical figures currently in DF's memory is less than 6965. That could be either because DF doesn't load them all in adventure mode, or because they lose the 1-to-1 relationship of index associated to historical figure id I was relying on. That worked in my world, but worlds that have actually had gameplay happen in them may invalidate that.
Edit: Here's the updated script. It has a lot more error checking, does a proper look up for the historical figures, and uses the core suspension call to reduce the risk of the game crashing. Still seems to work fine in my world, testing in others would be great though.
-- Marries two specified creatures
local args = {...}
function marry (unit_id1, unit_id2)
local victim1, historic_victim1
local victim2, historic_victim2
for key, value in pairs(df.global.world.units.all) do
-- The arguments are strings, but the structs contain numbers
if value.id == unit_id1 then
victim1 = value
end
if value.id == unit_id2 then
victim2 = value
end
end
if df.isnull(victim1) then
print('The first unit was not found.')
return
end
if df.isnull(victim2) then
print('The second unit was not found.')
return
end
print("Marrying " .. victim1.name.nickname .. " and " .. victim2.name.nickname)
for key, value in pairs(df.global.world.history.figures) do
if value.id == victim1.hist_figure_id then
historic_victim1 = value
end
if value.id == victim2.hist_figure_id then
historic_victim2 = value
end
end
if df.isnull(historic_victim1) then
print('The historical figure for the first unit was not found.')
return
end
if df.isnull(historic_victim2) then
print('The historical figure for the second unit was not found.')
return
end
local new_link1 = df.histfig_hf_link_spousest:new()
local new_link2 = df.histfig_hf_link_spousest:new()
-- Not documented, but this is the historical figure id
new_link1.anon_1 = victim2.hist_figure_id
new_link1.link_strength = 100
new_link2.anon_1 = victim1.hist_figure_id
new_link2.link_strength = 100
local link_count1 = #historic_victim1.histfig_links
local link_count2 = #historic_victim2.histfig_links
historic_victim1.histfig_links:resize(link_count1 + 1)
historic_victim1.histfig_links[link_count1] = new_link1
historic_victim2.histfig_links:resize(link_count2 + 1)
historic_victim2.histfig_links[link_count2] = new_link2
victim1.relations.spouse_id = victim2.id
victim2.relations.spouse_id = victim1.id
end
if df.isnull(args[1]) or df.isnull(args[2]) then
print('You must pass in two unit ids.')
return
end
dfhack.with_suspend(marry, tonumber(args[1]), tonumber(args[2]))
Edit2: Here's a script for divorcing units:
-- Divorces a creature from its spouse and / or lover. Run this per creature in a relationship.
local args = {...}
function divorce (unit_id)
local victim, historic_victim
for key, value in pairs(df.global.world.units.all) do
-- The arguments are strings, but the structs contain numbers
if value.id == unit_id then
victim = value
end
end
if df.isnull(victim) then
print('The unit was not found.')
return
end
if victim.relations.spouse_id == -1 and victim.relations.lover_id == -1 then
print('Warning: the unit has no lover or spouse, nothing to do.')
return
end
print("Divorcing " .. victim.name.nickname)
for key, value in pairs(df.global.world.history.figures) do
if value.id == victim.hist_figure_id then
historic_victim = value
end
end
if df.isnull(historic_victim) then
print('The historical figure for the unit was not found.')
return
end
local link_count = #historic_victim.histfig_links
-- Remove the spouse hf link, if it exists
for key, value in pairs(historic_victim.histfig_links) do
if df.histfig_hf_link_spousest:is_instance(value) then
if key ~= link_count -1 then
-- Moves the spouse entry to the end of the list, then resizes the list to size - 1, erasing it
historic_victim.histfig_links[key] = historic_victim.histfig_links[link_count - 1]
end
historic_victim.histfig_links:resize(link_count - 1)
link_count = link_count - 1
value:delete()
break
end
end
-- Remove the lover hf link, if it exists
for key, value in pairs(historic_victim.histfig_links) do
if df.histfig_hf_link_loverst:is_instance(value) then
if key ~= link_count -1 then
-- Moves the lover entry to the end of the list, then resizes the list to size - 1, erasing it
historic_victim.histfig_links[key] = historic_victim.histfig_links[link_count - 1]
end
historic_victim.histfig_links:resize(link_count - 1)
link_count = link_count - 1
value:delete()
break
end
end
victim.relations.spouse_id = -1
victim.relations.lover_id = -1
end
if df.isnull(args[1]) then
print('You must pass in a unit id.')
return
end
dfhack.with_suspend(divorce, tonumber(args[1]))
The format is similar, except you run:
divorce unit_id
It just takes one unit id at a time. Yes, you can have one directional relationships this way. It also removes lover links, so you can remove these from dwarves who have a lover die, and they should be able to pick up another later. Or, if their spouse dies they can pick up another.
Tested and working on my world, but again, testing in others would be nice.