server/scripts/e3a/frost.lua

37 lines
834 B
Lua
Raw Normal View History

module('frost', package.seeall)
local function is_winter(turn)
local season = get_season(turn)
return season == "calendar::winter"
end
local function freeze(r)
for i, rn in ipairs(r.adj) do
-- each region has a chance to freeze
if rn.terrain=="ocean" and math.mod(rng_int(), 100)<20 then
2010-09-12 04:30:19 +02:00
rn.terrain = "packice"
end
end
end
local function thaw(r)
r.terrain = "ocean"
end
function update()
local turn = get_turn()
if is_winter(turn) then
for r in regions() do
if r.terrain=="glacier" then
freeze(r)
end
end
2010-09-12 04:12:04 +02:00
elseif is_winter(turn-1) then
for r in regions() do
2010-09-12 04:30:19 +02:00
if r.terrain=="packice" then
thaw(r)
end
end
end
2010-09-12 04:12:04 +02:00
end