What are OppidumGarrisonBefore and OppidumGarrisonAfter supposed to do? Because now they don't do anything, probably just generating errors (nil arguments in 2nd one).
OppidumAddsHP. The loop in lines 14-35 - what is it supposed to do? Same about 37-62. Are you looking for the closest city? If so, just use Map.PlotDistance(iX1, iY1, iX2, iY2). Pseudo-code.
impX,impY = improvement coords
iMin = 999999 closestCity = nil
for city in player-cities do
dist = Map.PlotDistance(impX, impY, cityX, cityY)
if dist < iMin then iMin = dist, closestCity = city end
end
After that you can also add some checking if it is 2 or 3 tiles away, etc.
After that you can also add some checking if it is 2 or 3 tiles away, etc.