Skip to content

Instantly share code, notes, and snippets.

@warmist
Last active August 29, 2015 14:05
Show Gist options
  • Select an option

  • Save warmist/0b62f8168778f7153e72 to your computer and use it in GitHub Desktop.

Select an option

Save warmist/0b62f8168778f7153e72 to your computer and use it in GitHub Desktop.
local utils=require 'utils'
function add_to_group(entity,nemesis)
local hfig=nemesis.figure
hfig.entity_links:insert("#",{new=df.histfig_entity_link_memberst,entity_id=entity.id,link_strength=100})
entity.nemesis:insert("#",nemesis)
utils.insert_sorted(entity.histfig_ids,hfig.id)
utils.insert_sorted(entity.nemesis_ids,nemesis.id)
entity.hist_figures:insert("#",hfig)
end
function addToEntity(entity,unit,addtoLead,group_id)
local nem=dfhack.units.getNemesis(unit)
local hfig=nem.figure
add_to_group(entity,nem)
if group_id~=-1 then
group_id=df.global.ui.group_id
end
local he_group=df.historical_entity.find(group_id)
if he_group then
add_to_group(he_group,nem)
end
if addtoLead then
local lead_id
for k,v in pairs(entity.positions.own) do
if v.flags.IS_LEADER==true then
lead_id=v.id
break
end
end
if lead_id~=nil then
for k,v in pairs(entity.positions.assignments) do
if v.position_id==lead_id then
v.histfig=hfig.id
break
end
end
end
end
end
function unit_fixups( unit )
unit.flags2.resident=false
unit.flags1.merchant=false
unit.civ_id=df.global.ui.civ_id
end
addToEntity(df.global.ui.main.fortress_entity,dfhack.gui.getSelectedUnit(),false)
unit_fixups(dfhack.gui.getSelectedUnit())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment