function start_dwellings()
local t, n = {}, 0
for i, dwelling in GetObjectNamesByType('PEASANT_HUT') do
n = n + 1
t[n] = dwelling
end
for i, dwelling in GetObjectNamesByType('ARCHERS_HOUSE') do
n = n + 1
t[n] = dwelling
end
for i, dwelling in GetObjectNamesByType('BARRACKS') do
n = n + 1
t[n] = dwelling
end
for i, dwelling in GetObjectNamesByType('HEAVEN_MILITARY_POST') do
n = n + 1
t[n] = dwelling
end
for i, dwelling in t do
if GetObjectOwner(dwelling) == 1 then
ReplaceDwelling(dwelling, 4)
else
SetObjectEnabled(dwelling, nil)
Trigger(4, dwelling, 'replace_dwelling')
end
end
end
function replace_dwelling(hero, dwelling)
if hero == 'Berein' then
ReplaceDwelling(dwelling, 4)
SetObjectEnabled(dwelling, 1)
Trigger(4, dwelling, nil)
sleep()
MakeHeroInteractWithObject(hero, dwelling)
end
end
Вместо dwell = 1 вызываем функцию start_dwellings.