summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-04-14 21:34:06 -0300
committerJesusaves <cpntb1@ymail.com>2021-04-14 21:34:06 -0300
commit3f3280f8a70d9fd73e135ac224dbe5e6ee69a606 (patch)
tree2c52da57bb17e19483627dfbe8254d665b9e3c62
parent62351505ea92140bfb0cbe99a97b187749264ae3 (diff)
downloadserverdata-3f3280f8a70d9fd73e135ac224dbe5e6ee69a606.tar.gz
serverdata-3f3280f8a70d9fd73e135ac224dbe5e6ee69a606.tar.bz2
serverdata-3f3280f8a70d9fd73e135ac224dbe5e6ee69a606.tar.xz
serverdata-3f3280f8a70d9fd73e135ac224dbe5e6ee69a606.zip
Add a weather core, stripped down from Moubootaur Legends
-rw-r--r--db/constants.conf7
-rw-r--r--npc/functions/weather.txt175
-rw-r--r--npc/scripts.conf1
3 files changed, 183 insertions, 0 deletions
diff --git a/db/constants.conf b/db/constants.conf
index c8525c36..97572495 100644
--- a/db/constants.conf
+++ b/db/constants.conf
@@ -4095,6 +4095,13 @@ more than one separator can be used in a row (so 12_3___456 is illegal).
MASK_SPECIAL2: 2048
MASK_SPECIAL3: 4096
+ comment__: "map climate"
+ CLIMATE_NONE: 0
+ CLIMATE_DESERT: 1
+ CLIMATE_WOODLAND: 2
+ CLIMATE_ICELAND: 3
+ CLIMATE_SPECIAL: 4
+
comment__: "Being actions"
ACTION_STAND: 0
ACTION_MOVE: 1
diff --git a/npc/functions/weather.txt b/npc/functions/weather.txt
new file mode 100644
index 00000000..3cf872c8
--- /dev/null
+++ b/npc/functions/weather.txt
@@ -0,0 +1,175 @@
+// TMW2 scripts.
+// Authors:
+// Jesusalva
+// Description:
+// Controls world seasons. RESPECT MASK_* VARS ON CONSTANTS DB
+
+- script #WeatherCore NPC_HIDDEN,{
+ end;
+
+OnInit:
+ // This is weather startup
+ .@init=true;
+ // Bind commands
+ bindatcmd "wsnow", "#WeatherCore::OnSnow", 80, 80, 1;
+ bindatcmd "wrain", "#WeatherCore::OnRain", 80, 80, 1;
+ bindatcmd "wsand", "#WeatherCore::OnSand", 80, 80, 1;
+ bindatcmd "wevil", "#WeatherCore::OnEvil", 80, 80, 1;
+ bindatcmd "wnight", "#WeatherCore::OnNight", 80, 80, 1;
+ bindatcmd "wclear", "#WeatherCore::OnClear", 80, 80, 1;
+ bindatcmd "wreset", "#WeatherCore::OnReset", 99, 99, 1;
+ bindatcmd "wset", "#WeatherCore::OnManual", 99, 99, 1;
+
+
+ // Determine which maps are subject to weather, and how weather works:
+ // eg. it should never snow on a desert, or happen a sandstorm on icelands.
+ .wcore = htnew;
+
+ // Deserts
+ htput(.wcore, "001-1", CLIMATE_DESERT);
+ htput(.wcore, "002-1", CLIMATE_DESERT);
+ htput(.wcore, "003-2", CLIMATE_DESERT);
+ htput(.wcore, "004-1", CLIMATE_DESERT);
+ htput(.wcore, "006-1", CLIMATE_DESERT);
+ htput(.wcore, "023-1", CLIMATE_DESERT);
+ htput(.wcore, "041-1", CLIMATE_DESERT);
+ htput(.wcore, "042-1", CLIMATE_DESERT);
+ htput(.wcore, "043-1", CLIMATE_DESERT);
+
+ // Woodlands
+ htput(.wcore, "007-1", CLIMATE_WOODLAND);
+ htput(.wcore, "008-1", CLIMATE_WOODLAND);
+ htput(.wcore, "009-1", CLIMATE_WOODLAND);
+ htput(.wcore, "010-1", CLIMATE_WOODLAND);
+ htput(.wcore, "011-1", CLIMATE_WOODLAND);
+ htput(.wcore, "012-1", CLIMATE_WOODLAND);
+ htput(.wcore, "013-1", CLIMATE_WOODLAND);
+ htput(.wcore, "014-1", CLIMATE_WOODLAND);
+ htput(.wcore, "015-1", CLIMATE_WOODLAND);
+ htput(.wcore, "016-1", CLIMATE_WOODLAND);
+ htput(.wcore, "017-1", CLIMATE_WOODLAND);
+ htput(.wcore, "018-1", CLIMATE_WOODLAND);
+ htput(.wcore, "025-1", CLIMATE_WOODLAND);
+ htput(.wcore, "026-1", CLIMATE_WOODLAND);
+ htput(.wcore, "027-1", CLIMATE_WOODLAND);
+ htput(.wcore, "028-1", CLIMATE_WOODLAND);
+ htput(.wcore, "029-1", CLIMATE_WOODLAND);
+ htput(.wcore, "051-1", CLIMATE_WOODLAND); // ?
+ htput(.wcore, "052-1", CLIMATE_WOODLAND);
+ htput(.wcore, "055-1", CLIMATE_WOODLAND);
+ htput(.wcore, "057-1", CLIMATE_WOODLAND);
+
+ // Icelands
+ htput(.wcore, "019-1", CLIMATE_ICELAND);
+ htput(.wcore, "020-1", CLIMATE_ICELAND);
+ htput(.wcore, "030-1", CLIMATE_ICELAND);
+ htput(.wcore, "031-1", CLIMATE_ICELAND);
+ htput(.wcore, "033-1", CLIMATE_ICELAND);
+ htput(.wcore, "034-1", CLIMATE_ICELAND);
+ htput(.wcore, "045-1", CLIMATE_ICELAND);
+ htput(.wcore, "046-1", CLIMATE_ICELAND);
+ htput(.wcore, "047-1", CLIMATE_ICELAND);
+
+ // Special
+ htput(.wcore, "099-1", CLIMATE_NONE);
+
+
+ debugmes("[Weather.sys] Total Maps = " + htsize(.wcore));
+ end;
+
+ ///////////////////////////////////////////////////////////////////
+ // "#WeatherCore"::climate(mapid)
+ public function climate {
+ .@v = htget(.wcore, getarg(0), CLIMATE_NONE);
+ return .@v;
+ }
+
+ // "#WeatherCore"::weather(weather{, mapid})
+ public function weather {
+ .@mk=getarg(0);
+ .@m$=getarg(1, getmapname());
+ return getmapmask(.@m$) & .@mk;
+ }
+
+
+ ///////////////////////////////////////////////////////////////////
+ // Function to check stuff
+ // WeatherSwitch ( MASK, MAP )
+ function WeatherSwitch {
+ // Get map
+ getmapxy(.@key$,.@a,.@b,0);
+
+ // Sanitize
+ .@m$ = htget(.wcore, .@key$, "Not found");
+
+ // Change Weather or abort
+ if (.@m$ == "Not found")
+ dispbottom l("Command not permitted on this map! Check npc/functions/weather.conf");
+ else
+ addmapmask(.@key$, getarg(0));
+ return;
+ }
+
+// Some commands, for GMs manually override weather
+OnRain:
+ WeatherSwitch(MASK_RAIN);
+ end;
+
+OnSand:
+ WeatherSwitch(MASK_SANDSTORM);
+ end;
+
+OnSnow:
+ WeatherSwitch(MASK_SNOW);
+ end;
+
+OnNight:
+ WeatherSwitch(MASK_NIGHT);
+ end;
+
+OnEvil:
+ WeatherSwitch(MASK_EVILSANCTUM);
+ end;
+
+OnManual:
+ if (!.@atcmd_numparameters) {
+ dispbottom l("Syntax: @wset <map_mask>");
+ end;
+ }
+
+ // Never allow negative numbers, or to disable map mask 1 (never, EVER, do such insane thing)
+ .@rq = atoi(.@atcmd_parameters$[0]);
+ if (.@rq <= 1 || .@rq % 2 == 1) {
+ dispbottom l("Invalid map mask");
+ end;
+ }
+
+ // <Insert a helpful comment here>
+ getmapxy(.@key$,.@a,.@b,0);
+ .@mk=getmapmask(.@key$);
+ .@mk=.@mk^.@rq;
+ setmapmask(.@key$, .@mk);
+ end;
+
+// Clear works on any map
+OnClear:
+ getmapxy(.@key$,.@a,.@b,0);
+ .@mk=getmapmask(.@key$);
+ if (.@mk & MASK_RAIN)
+ .@mk=.@mk^MASK_RAIN;
+ if (.@mk & MASK_SANDSTORM)
+ .@mk=.@mk^MASK_SANDSTORM;
+ if (.@mk & MASK_SNOW)
+ .@mk=.@mk^MASK_SNOW;
+ if (.@mk & MASK_NIGHT)
+ .@mk=.@mk^MASK_NIGHT;
+ setmapmask(.@key$, .@mk);
+ end;
+
+// Reset the whole map, including season, event and weather masks
+OnReset:
+ getmapxy(.@key$,.@a,.@b,0);
+ setmapmask(.@key$, MASK_NONE);
+ end;
+
+}
diff --git a/npc/scripts.conf b/npc/scripts.conf
index b2535a06..0852925c 100644
--- a/npc/scripts.conf
+++ b/npc/scripts.conf
@@ -48,6 +48,7 @@
"npc/functions/miriam.txt",
"npc/functions/ghost.txt",
"npc/functions/location.txt",
+"npc/functions/weather.txt",
// Items
"npc/items/purification_potion.txt",