function replacecreature ()
while (1) do
sleep(2);
local herocr = GetHeroCreatures( "Sarge", CREATURE_ARCHER );
if herocr >= 1 and
GetTownBuildingLevel("cheast_town", TOWN_BUILDING_DWELLING_2 ) == 2 then
RemoveHeroCreatures( "Sarge", CREATURE_ARCHER, herocr );
AddHeroCreatures( "Sarge", CREATURE_LONGBOWMAN, herocr );
sleep(1);
break
end;
end;
end;
startThread(replacecreature);
Я бы так написал. Разве что если нужно, чтобы лучников становилось 1 шт, тогда herocr в строчке AddHeroCreatures заменить на 1