From be2d7d203d40703fc0b1b601a52abce3ff29e8f9 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sat, 11 Sep 2010 18:48:08 -0700 Subject: [PATCH] frost module: during winter, some oceans freeze over --- res/e3a/ships.xml | 16 ++++++++++++++++ scripts/e3a/frost.lua | 36 ++++++++++++++++++++++++++++++++++++ scripts/eressea/main.lua | 2 ++ 3 files changed, 54 insertions(+) create mode 100644 scripts/e3a/frost.lua diff --git a/res/e3a/ships.xml b/res/e3a/ships.xml index 0c8c184e0..393479234 100644 --- a/res/e3a/ships.xml +++ b/res/e3a/ships.xml @@ -22,6 +22,8 @@ + + @@ -83,6 +85,8 @@ + + @@ -93,6 +97,8 @@ + + @@ -101,6 +107,8 @@ + + @@ -111,6 +119,8 @@ + + @@ -121,6 +131,8 @@ + + @@ -133,6 +145,8 @@ + + @@ -144,6 +158,8 @@ + + diff --git a/scripts/e3a/frost.lua b/scripts/e3a/frost.lua new file mode 100644 index 000000000..7cd788de9 --- /dev/null +++ b/scripts/e3a/frost.lua @@ -0,0 +1,36 @@ +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 + rn.terrain = "iceberg_sleep" + 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 + else if is_winter(turn-1) then + for r in regions() do + if r.terrain=="iceberg_sleep" then + thaw(r) + end + end + end +end \ No newline at end of file diff --git a/scripts/eressea/main.lua b/scripts/eressea/main.lua index 060fdbf8c..4eed4d057 100644 --- a/scripts/eressea/main.lua +++ b/scripts/eressea/main.lua @@ -1,4 +1,5 @@ require "multis" +require "e3a.frost" function apply_fixes() local turn = get_turn() @@ -48,6 +49,7 @@ function process(orders) update_embassies() update_guards() update_scores() + frost.update() local localechange = { de = { "ii" } } change_locales(localechange)