Don't you test your scripts on a map? It seems fine at first glance, but you never know...
Yes. In combination with min, it works correctly. If an enemy town is closer, it returns its name; if it's your own town, it returns nil. It also returns nil if the hero is in a town, is dead, or is on a level where there are no towns. However, for the latter, you need to add
if not targetTown then
return nil;
end;after defining targetTown.
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4