2012-07-03 09:41:09 -06:00
|
|
|
# fix doors that are frozen in 'open' state
|
|
|
|
|
2013-04-21 03:27:35 -06:00
|
|
|
# this may happen after people mess with the game by (incorrectly) teleporting units or items
|
|
|
|
# a door may stick open if the map occupancy flags are wrong
|
2012-07-03 09:41:09 -06:00
|
|
|
|
|
|
|
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)
|
2013-04-21 03:27:35 -06:00
|
|
|
if (occ.unit or occ.unit_grounded) and not
|
|
|
|
# check if an unit is present
|
|
|
|
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 = occ.unit_grounded = false
|
|
|
|
end
|
|
|
|
if occ.item and not df.world.items.all.find { |i| i.pos.x == bld.x1 and i.pos.y == bld.y1 and u.pos.z == bld.z }
|
|
|
|
count += 1
|
|
|
|
occ.item = false
|
|
|
|
end
|
2012-07-03 09:41:09 -06:00
|
|
|
}
|
|
|
|
puts "unstuck #{count} doors"
|