From 1d6160de02c72513ab5e1b89152daae976744545 Mon Sep 17 00:00:00 2001 From: jj Date: Tue, 3 Jul 2012 17:41:09 +0200 Subject: [PATCH] added fixstuckdoors.rb script --- scripts/fixstuckdoors.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 scripts/fixstuckdoors.rb diff --git a/scripts/fixstuckdoors.rb b/scripts/fixstuckdoors.rb new file mode 100644 index 000000000..619ceeeb6 --- /dev/null +++ b/scripts/fixstuckdoors.rb @@ -0,0 +1,20 @@ +# fix doors that are frozen in 'open' state + +# door is stuck in open state if the map occupancy flag incorrectly indicates +# that an unit is present (and creatures will prone to pass through) + +count = 0 +df.world.buildings.all.each { |bld| + # for all doors + next if bld._rtti_classname != :building_doorst + # check if it is open + next if bld.close_timer == 0 + # check if occupancy is set + occ = df.map_occupancy_at(bld.x1, bld.y1, bld.z) + next if not occ.unit + # check if an unit is present + next if df.world.units.active.find { |u| u.pos.x == bld.x1 and u.pos.y == bld.y1 and u.pos.z == bld.z } + count += 1 + occ.unit = false +} +puts "unstuck #{count} doors"