From 2ad6aa593a246004068a791d9522a18e72e27055 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Tue, 19 Jun 2018 11:23:46 -0300 Subject: Simplify weather code, to make easier to read/edit --- npc/functions/weather.txt | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/npc/functions/weather.txt b/npc/functions/weather.txt index cb426516d..631934bad 100644 --- a/npc/functions/weather.txt +++ b/npc/functions/weather.txt @@ -50,13 +50,13 @@ OnInit: // Icelands htput(.wcore, "001-7", "iceland"); + debugmes "[Weather.sys] Total Maps = " + htsize(.wcore); // No "end" here, so server starts with weather OnMinute00: OnMinute15: OnMinute30: OnMinute45: - debugmes "[Weather.sys] Total Maps = " + htsize(.wcore); .@hti = htiterator(.wcore); for(.@key$ = htinextkey(.@hti); hticheck(.@hti); .@key$ = htinextkey(.@hti)) { @@ -68,33 +68,28 @@ OnMinute45: // Local variables: .@key$ .@type .@r .@type$=htget(.wcore, .@key$); .@r=rand(0,10000); + .@mk=MASK_NONE; // Remove all current masks, and add rain/snow/sand if (.@type$ == "desert") { if (.@r < 10) - setmapmask .@key$, MASK_RAIN; + .@mk=MASK_RAIN; else if (.@r < 100) - setmapmask .@key$, MASK_SANDSTORM; - else - setmapmask .@key$, MASK_NONE; + .@mk=MASK_SANDSTORM; } else if (.@type$ == "woodland") { if (.@r < 100) - setmapmask .@key$, MASK_RAIN; + .@mk=MASK_RAIN; else if (.@r < 120) - setmapmask .@key$, MASK_SANDSTORM; + .@mk=MASK_SANDSTORM; else if (.@r < 140) - setmapmask .@key$, MASK_SNOW; - else - setmapmask .@key$, MASK_NONE; + .@mk=MASK_SNOW; } else if (.@type$ == "iceland") { if (.@r < 10) - setmapmask .@key$, MASK_RAIN; + .@mk=MASK_RAIN; else if (.@r < 100) - setmapmask .@key$, MASK_SNOW; - else - setmapmask .@key$, MASK_NONE; + .@mk=MASK_SNOW; } else { debugmes "Warning warning, blame Saulc! Weather system error on map "+.@key$; @@ -102,6 +97,8 @@ OnMinute45: atcommand "@mapexit"; } + setmapmask .@key$, .@mk; + // Is it night time? // For convenience, night time is from 00:15 to 00:45, every hour. // 2 = GETTIME_MINUTE -- cgit v1.2.3-60-g2f50