Add one more bad thought from siren for civilians.

Originally a Tax Collector thought, but the message sounds appropriate.
develop
Alexander Gavrilov 2012-09-24 20:01:53 +04:00
parent 627f036830
commit 821271383e
1 changed files with 14 additions and 1 deletions

@ -19,6 +19,8 @@ for _,v in ipairs(args) do
table.insert(burrows, b) table.insert(burrows, b)
end end
local in_siege = false
function is_in_burrows(pos) function is_in_burrows(pos)
if #burrows == 0 then if #burrows == 0 then
return true return true
@ -75,10 +77,21 @@ function stop_break(unit)
end end
end end
-- Check siege for thought purpose
for _,v in ipairs(df.global.ui.invasions.list) do
if v.flags.siege and v.flags.active then
in_siege = true
break
end
end
-- Stop rest -- Stop rest
for _,v in ipairs(df.global.world.units.active) do for _,v in ipairs(df.global.world.units.active) do
local x,y,z = dfhack.units.getPosition(v) local x,y,z = dfhack.units.getPosition(v)
if x and not dfhack.units.isDead(v) and is_in_burrows(xyz2pos(x,y,z)) then if x and dfhack.units.isCitizen(v) and is_in_burrows(xyz2pos(x,y,z)) then
if not in_siege and v.military.squad_index < 0 then
add_thought(v, df.unit_thought_type.LackProtection)
end
wake_unit(v) wake_unit(v)
stop_break(v) stop_break(v)
end end