2121 option to attach to a map feature
2222]]
2323
24+ -- @ module = true
25+
2426local usage = [====[
2527
2628modtools/create-unit
@@ -245,26 +247,29 @@ function createFigure(trgunit,he,he_group)
245247 -- note that innate skills are automaticaly set by DF
246248 hf .info .skills = {new = true }
247249
250+ if he then
251+ he .histfig_ids :insert (' #' , hf .id )
252+ he .hist_figures :insert (' #' , hf )
253+ hf .entity_links :insert (" #" ,{new = df .histfig_entity_link_memberst ,entity_id = trgunit .civ_id ,link_strength = 100 })
254+
255+ -- add entity event
256+ local hf_event_id = df .global .hist_event_next_id
257+ df .global .hist_event_next_id = df .global .hist_event_next_id + 1
258+ df .global .world .history .events :insert (" #" ,{new = df .history_event_add_hf_entity_linkst ,year = trgunit .birth_year ,
259+ seconds = trgunit .birth_time ,id = hf_event_id ,civ = hf .civ_id ,histfig = hf .id ,link_type = 0 })
260+ end
248261
249- he .histfig_ids :insert (' #' , hf .id )
250- he .hist_figures :insert (' #' , hf )
251262 if he_group and he_group ~= he then
252263 he_group .histfig_ids :insert (' #' , hf .id )
253264 he_group .hist_figures :insert (' #' , hf )
254265 hf .entity_links :insert (" #" ,{new = df .histfig_entity_link_memberst ,entity_id = he_group .id ,link_strength = 100 })
255266 end
267+
256268 trgunit .flags1 .important_historical_figure = true
257269 trgunit .flags2 .important_historical_figure = true
258270 trgunit .hist_figure_id = hf .id
259271 trgunit .hist_figure_id2 = hf .id
260272
261- hf .entity_links :insert (" #" ,{new = df .histfig_entity_link_memberst ,entity_id = trgunit .civ_id ,link_strength = 100 })
262-
263- -- add entity event
264- local hf_event_id = df .global .hist_event_next_id
265- df .global .hist_event_next_id = df .global .hist_event_next_id + 1
266- df .global .world .history .events :insert (" #" ,{new = df .history_event_add_hf_entity_linkst ,year = trgunit .birth_year ,
267- seconds = trgunit .birth_time ,id = hf_event_id ,civ = hf .civ_id ,histfig = hf .id ,link_type = 0 })
268273 return hf
269274end
270275
@@ -297,9 +302,12 @@ function createNemesis(trgunit,civ_id,group_id)
297302
298303 nem .save_file_id =- 1
299304
300- local he = df .historical_entity .find (civ_id )
301- he .nemesis_ids :insert (" #" ,id )
302- he .nemesis :insert (" #" ,nem )
305+ if civ_id ~= - 1 then
306+ local he = df .historical_entity .find (civ_id )
307+ he .nemesis_ids :insert (" #" ,id )
308+ he .nemesis :insert (" #" ,nem )
309+ allocateIds (nem ,he )
310+ end
303311 local he_group
304312 if group_id and group_id ~= - 1 then
305313 he_group = df .historical_entity .find (group_id )
@@ -308,8 +316,8 @@ function createNemesis(trgunit,civ_id,group_id)
308316 he_group .nemesis_ids :insert (" #" ,id )
309317 he_group .nemesis :insert (" #" ,nem )
310318 end
311- allocateIds (nem ,he )
312319 nem .figure = createFigure (trgunit ,he ,he_group )
320+ return nem
313321end
314322
315323function createUnitInCiv (race_id , caste_id , civ_id , group_id , location , entityRawName )
0 commit comments