@@ -49,13 +49,13 @@ function desert(u,method,civ)
4949 local civ_ent = df .historical_entity .find (hf .civ_id )
5050 local newent_id = - 1
5151 local newsite_id = - 1
52-
52+
5353 -- free owned rooms
5454 for i = # u .owned_buildings - 1 , 0 , - 1 do
5555 local temp_bld = df .building .find (u .owned_buildings [i ].id )
5656 dfhack .buildings .setOwner (temp_bld , nil )
5757 end
58-
58+
5959 -- erase the unit from the fortress entity
6060 for k ,v in ipairs (fort_ent .histfig_ids ) do
6161 if v == hf_id then
@@ -76,7 +76,7 @@ function desert(u,method,civ)
7676 break
7777 end
7878 end
79-
79+
8080 -- remove the old entity link and create new one to indicate former membership
8181 hf .entity_links :insert (" #" , {new = df .histfig_entity_link_former_memberst , entity_id = fort_ent .id , link_strength = 100 })
8282 for k ,v in ipairs (hf .entity_links ) do
@@ -85,15 +85,15 @@ function desert(u,method,civ)
8585 break
8686 end
8787 end
88-
88+
8989 -- try to find a new entity for the unit to join
9090 for k ,v in ipairs (civ_ent .entity_links ) do
9191 if v .type == df .entity_entity_link_type .CHILD and v .target ~= fort_ent .id then
9292 newent_id = v .target
9393 break
9494 end
9595 end
96-
96+
9797 if newent_id > - 1 then
9898 hf .entity_links :insert (" #" , {new = df .histfig_entity_link_memberst , entity_id = newent_id , link_strength = 100 })
9999
0 commit comments