Skip to content

Commit

Permalink
Merge pull request #959 from myk002/myk_whereabouts
Browse files Browse the repository at this point in the history
[makeown] fix field names changed in structures update
  • Loading branch information
myk002 authored Jan 26, 2024
2 parents 5898e83 + 2c2e605 commit f606e94
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Template for new versions:
## New Features

## Fixes
- `makeown`: fix error when adopting units that need a historical figure to be created

## Misc Improvements

Expand Down
25 changes: 10 additions & 15 deletions makeown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ local function fix_clothing_ownership(unit)
unit.military.uniforms[0]:insert('#',item.id) --insert_into_vector(unit->military.uniforms[0], item->id);
fixcount = fixcount + 1 --fixcount++;
else
dfhack.printerr("makeown: could not change ownership for an item!")
dfhack.printerr("could not change ownership for an item!")
end
end
end
Expand All @@ -66,7 +66,7 @@ local function fix_clothing_ownership(unit)
-- dirty?
unit.military.uniform_drop:resize(0) --unit->military.uniform_drop.clear();
----out << "ownership for " << fixcount << " clothes fixed" << endl;
print("makeown: claimed ownership for "..tostring(fixcount).." worn items")
print("claimed ownership for "..tostring(fixcount).." worn items")
end

local function entity_link(hf, eid, do_event, add, replace_idx)
Expand Down Expand Up @@ -104,8 +104,8 @@ local function entity_link(hf, eid, do_event, add, replace_idx)
end

local function change_state(hf, site_id, pos)
hf.info.whereabouts.whereabouts_type = 1 -- state? arrived?
hf.info.whereabouts.site = site_id
hf.info.whereabouts.state = df.whereabouts_type.settler
hf.info.whereabouts.site_id = site_id
local event = df.history_event_change_hf_statest:new()
event.year = df.global.cur_year
event.seconds = df.global.cur_year_tick
Expand Down Expand Up @@ -167,13 +167,8 @@ function make_citizen(unit)
entity_link(hf, civ_id, false) -- so lets skip event here
entity_link(hf, group_id)

hf.info = df.historical_figure_info:new()
hf.info.whereabouts = df.historical_figure_info.T_whereabouts:new()
hf.info.whereabouts.region_id = -1;
hf.info.whereabouts.underground_region_id = -1;
hf.info.whereabouts.army_id = -1;
hf.info.whereabouts.unk_1 = -1;
hf.info.whereabouts.unk_2 = -1;
hf.info = {new=true}
hf.info.whereabouts = {new=true}
change_state(hf, df.global.plotinfo.site_id, region_pos)


Expand All @@ -194,7 +189,7 @@ function make_citizen(unit)
unit.flags2.important_historical_figure = true
unit.hist_figure_id = hf.id
unit.hist_figure_id2 = hf.id
print("makeown: created historical figure: "..tostring(hf.id))
print("created historical figure: "..tostring(hf.id))
else
-- only insert into civ/fort if not already there
-- Migrants change previous histfig_entity_link_memberst to histfig_entity_link_former_memberst
Expand Down Expand Up @@ -237,7 +232,7 @@ function make_citizen(unit)
fortent.histfig_ids:insert('#', hf.id)
fortent.hist_figures:insert('#', hf)
end
print("makeown: migrated historical figure")
print("migrated historical figure")
end -- hf

local nemesis = dfhack.units.getNemesis(unit)
Expand Down Expand Up @@ -265,7 +260,7 @@ function make_citizen(unit)
fortent.nemesis:insert('#', nemesis)
civent.nemesis_ids:insert('#', nemesis.id)
civent.nemesis:insert('#', nemesis)
print("makeown: created nemesis entry")
print("created nemesis entry")
else-- only insert into civ/fort if not already there
local found = false
for _,v in ipairs(civent.nemesis_ids) do
Expand All @@ -283,7 +278,7 @@ function make_citizen(unit)
fortent.nemesis_ids:insert('#', nemesis.id)
fortent.nemesis:insert('#', nemesis)
end
print("makeown: migrated nemesis entry")
print("migrated nemesis entry")
end -- nemesis

-- generate a name for the unit if it doesn't already have one
Expand Down
6 changes: 2 additions & 4 deletions modtools/create-unit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -517,10 +517,8 @@ function createFigure(unit,he_civ,he_group)

df.global.world.history.figures:insert("#", hf)

hf.info = df.historical_figure_info:new()
hf.info.whereabouts = df.historical_figure_info.T_whereabouts:new()
hf.info.whereabouts.death_condition_parameter_1 = -1
hf.info.whereabouts.death_condition_parameter_2 = -1
hf.info = {new=true}
hf.info.whereabouts = {new=true}
-- set values that seem related to state and do event
--change_state(hf, dfg.ui.site_id, region_pos)

Expand Down

0 comments on commit f606e94

Please sign in to comment.