diff options
author | Jesusaves <cpntb1@ymail.com> | 2018-06-19 13:14:03 +0000 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2018-06-19 13:14:03 +0000 |
commit | 3e82cbcbf7040277dc46244592b68733fe9e2265 (patch) | |
tree | 7b6a57dd32677df1fee989f4d63eb98a04ca3ed0 | |
parent | 1dfec5e561130796b759e0334ccabf1aad44ea02 (diff) | |
parent | 781d1fd070e7565af741a8606447cd1a98f7f076 (diff) | |
download | serverdata-3e82cbcbf7040277dc46244592b68733fe9e2265.tar.gz serverdata-3e82cbcbf7040277dc46244592b68733fe9e2265.tar.bz2 serverdata-3e82cbcbf7040277dc46244592b68733fe9e2265.tar.xz serverdata-3e82cbcbf7040277dc46244592b68733fe9e2265.zip |
Merge branch 'jesusalva/20180619' into 'master'
Jesusalva/20180619
See merge request TMW2/serverdata!12
-rw-r--r-- | db/constants.conf | 11 | ||||
-rw-r--r-- | npc/003-1/lieutenantdausen.txt | 16 | ||||
-rw-r--r-- | npc/005-1/ayasha.txt | 4 | ||||
-rw-r--r-- | npc/009-1/guards.txt | 8 | ||||
-rw-r--r-- | npc/012-1/guards.txt | 16 | ||||
-rw-r--r-- | npc/functions/weather.txt | 169 | ||||
-rw-r--r-- | npc/scripts.conf | 1 |
7 files changed, 203 insertions, 22 deletions
diff --git a/db/constants.conf b/db/constants.conf index 2eb6e969d..6839210cd 100644 --- a/db/constants.conf +++ b/db/constants.conf @@ -3847,6 +3847,17 @@ constants_db: { SUMMER: 2 AUTUMN: 3 + comment__: "map masks" + MASK_NONE: 1 + MASK_MATTACK: 2 + MASK_EVILSANCTUM: 4 + MASK_NIGHT: 8 + MASK_RAIN: 16 + MASK_SANDSTORM: 32 + MASK_SNOW: 64 + MASK_RESERVED1: 128 + MASK_RESERVED2: 256 + comment__: "speechflags" S_FIRST_BLANK_LINE: 1 S_LAST_BLANK_LINE: 2 diff --git a/npc/003-1/lieutenantdausen.txt b/npc/003-1/lieutenantdausen.txt index 5fb801f10..3246d12fd 100644 --- a/npc/003-1/lieutenantdausen.txt +++ b/npc/003-1/lieutenantdausen.txt @@ -120,8 +120,8 @@ L_MKControl: close; L_MKSmall: - addmapmask "003-1", 2; - addmapmask "004-1", 2; + addmapmask "003-1", MASK_MATTACK; + addmapmask "004-1", MASK_MATTACK; changemusic "003-1", "mythica.ogg"; disablenpc("Mana Stone"); $@SIEGE_TULIM=0; // factor zero @@ -133,8 +133,8 @@ L_MKSmall: close; L_MKMedium: - addmapmask "003-1", 2; - addmapmask "004-1", 2; + addmapmask "003-1", MASK_MATTACK; + addmapmask "004-1", MASK_MATTACK; changemusic "003-1", "eric_matyas_ghouls.ogg"; disablenpc("Mana Stone"); $@SIEGE_TULIM=1; // factor one @@ -146,8 +146,8 @@ L_MKMedium: close; L_MKHuge: - addmapmask "003-1", 2; - addmapmask "004-1", 2; + addmapmask "003-1", MASK_MATTACK; + addmapmask "004-1", MASK_MATTACK; changemusic "003-1", "misuse.ogg"; disablenpc("Mana Stone"); $@SIEGE_TULIM=5; // factor five @@ -302,8 +302,8 @@ OnTimer600000: end; OnTimer630000: - removemapmask "003-1", 2; - removemapmask "004-1", 2; + removemapmask "003-1", MASK_MATTACK; + removemapmask "004-1", MASK_MATTACK; changemusic "003-1", "bartk_adventure.ogg"; // Restore to default enablenpc("Mana Stone"); $@SIEGE_TULIM$=0; diff --git a/npc/005-1/ayasha.txt b/npc/005-1/ayasha.txt index 5697de032..100d533ef 100644 --- a/npc/005-1/ayasha.txt +++ b/npc/005-1/ayasha.txt @@ -131,7 +131,7 @@ L_MKControl: close; L_MKSmall: - addmapmask "005-1", 2; + addmapmask "005-1", MASK_MATTACK; changemusic "005-1", "mythica.ogg"; disablenpc("Mana Stone"); pvpon("005-1"); @@ -223,7 +223,7 @@ OnTimer600000: end; OnTimer630000: - removemapmask "005-1", 2; + removemapmask "005-1", MASK_MATTACK; changemusic "005-1", "bartk_adventure.ogg"; enablenpc("Mana Stone"); killmonsterall("005-1", 0); diff --git a/npc/009-1/guards.txt b/npc/009-1/guards.txt index 9598d4d58..52092d2d7 100644 --- a/npc/009-1/guards.txt +++ b/npc/009-1/guards.txt @@ -30,7 +30,7 @@ L_MKControl: close; L_MKSmall: - addmapmask "009-1", 2; + addmapmask "009-1", MASK_MATTACK; changemusic "009-1", "mythica.ogg"; disablenpc("Mana Stone"); $@SIEGE_HALI=0; // factor zero @@ -42,7 +42,7 @@ L_MKSmall: close; L_MKMedium: - addmapmask "009-1", 2; + addmapmask "009-1", MASK_MATTACK; changemusic "009-1", "eric matyas - ghoulish fun.ogg"; disablenpc("Mana Stone"); $@SIEGE_HALI=1; // factor one @@ -54,7 +54,7 @@ L_MKMedium: close; L_MKHuge: - addmapmask "009-1", 2; + addmapmask "009-1", MASK_MATTACK; changemusic "009-1", "misuse.ogg"; disablenpc("Mana Stone"); $@SIEGE_HALI=5; // factor five @@ -178,7 +178,7 @@ OnTimer600000: end; OnTimer630000: - removemapmask "009-1", 2; + removemapmask "009-1", MASK_MATTACK; changemusic "009-1", "dragon_and_toast.ogg"; // Restore to default enablenpc("Mana Stone"); $@SIEGE_HALI$=0; diff --git a/npc/012-1/guards.txt b/npc/012-1/guards.txt index 556e82150..97e3f531e 100644 --- a/npc/012-1/guards.txt +++ b/npc/012-1/guards.txt @@ -32,8 +32,8 @@ L_Admus: enablenpc "Hurnsguard"; donpcevent "Hurnsguard::OnSet"; donpcevent "Lieutenant Paul::OnSet"; - addmapmask "012-1", 2; - addmapmask "012-1", 8; + addmapmask "012-1", MASK_MATTACK; + addmapmask "012-1", MASK_EVILSANCTUM; pvpon("012-1"); disablenpc "#012-1_22_62"; disablenpc "#012-1_79_17"; @@ -73,7 +73,7 @@ L_MKControl: close; L_MKSmall: - addmapmask "012-1", 2; + addmapmask "012-1", MASK_MATTACK; changemusic "012-1", "mythica.ogg"; disablenpc("Mana Stone"); $@SIEGE_HURNS=0; // factor zero @@ -85,7 +85,7 @@ L_MKSmall: close; L_MKMedium: - addmapmask "012-1", 2; + addmapmask "012-1", MASK_MATTACK; changemusic "012-1", "eric_matyas_ghouls.ogg"; disablenpc("Mana Stone"); $@SIEGE_HURNS=1; // factor one @@ -97,7 +97,7 @@ L_MKMedium: close; L_MKHuge: - addmapmask "012-1", 2; + addmapmask "012-1", MASK_MATTACK; changemusic "012-1", "misuse.ogg"; disablenpc("Mana Stone"); $@SIEGE_HURNS=5; // factor five @@ -221,7 +221,7 @@ OnTimer600000: end; OnTimer630000: - removemapmask "012-1", 2; + removemapmask "012-1", MASK_MATTACK; changemusic "012-1", "dragon_and_toast.ogg"; // Restore to default enablenpc("Mana Stone"); $@SIEGE_HURNS$=0; @@ -455,8 +455,8 @@ OnVictory: removemapflag("012-1", mf_nosave); disablenpc "Hurnsguard"; pvpoff("012-1"); - removemapmask "012-1", 2; - removemapmask "012-1", 8; + removemapmask "012-1", MASK_MATTACK; + removemapmask "012-1", MASK_EVILSANCTUM; //removemapflag("012-1", mf_nocommand); removemapflag("012-1", mf_battleground); enablenpc "#012-1_22_62"; diff --git a/npc/functions/weather.txt b/npc/functions/weather.txt new file mode 100644 index 000000000..cc7285721 --- /dev/null +++ b/npc/functions/weather.txt @@ -0,0 +1,169 @@ +// TMW2 scripts. +// Authors: +// Jesusalva +// Description: +// Controls world seasons. RESPECT MASK_* VARS ON CONSTANTS DB + +000-0,0,0,0 script #WeatherCore NPC_HIDDEN,{ + end; + +/* + * removemapflag("<map name>", <flag>) + * setmapflag("<map name>", <flag>{, <val>}) + * getmapflag("<map name>", <flag>) + + mf_snow: 16 + + mf_jexp: 39 + mf_bexp: 40 + + setmapflag(.@key$, mf_nightenabled); + removemapflag(.@key$, mf_nightenabled); + +*/ + +OnInit: + // 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; + + + // Determine which maps are subject to weather, and how weather works: + // eg. it will never snow on a desert, or a sandstorm on icelands. + .wcore = htnew; + + // Deserts + htput(.wcore, "003-1", "desert"); + htput(.wcore, "004-1", "desert"); + htput(.wcore, "004-2", "desert"); + htput(.wcore, "009-1", "desert"); + htput(.wcore, "010-1", "desert"); + htput(.wcore, "010-2", "desert"); + + // Woodlands + htput(.wcore, "005-1", "woodland"); + htput(.wcore, "012-1", "woodland"); + htput(.wcore, "014-1", "woodland"); + htput(.wcore, "014-2", "woodland"); + htput(.wcore, "014-3", "woodland"); + + // Icelands + htput(.wcore, "001-7", "iceland"); + + // 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)) { + + // PvP Maps are immune to weather changes (eg. during sieges) + // I could use getmapmask, but this is simpler. + if (getmapflag(.@key$, mf_pvp)) + continue; + + // Local variables: .@key$ .@type .@r + .@type$=htget(.wcore, .@key$); + .@r=rand(0,10000); + + // Remove all current masks, and add rain/snow/sand + if (.@type$ == "desert") { + if (.@r < 10) + setmapmask .@key$, MASK_RAIN; + else if (.@r < 100) + setmapmask .@key$, MASK_SANDSTORM; + else + setmapmask .@key$, MASK_NONE; + + } else if (.@type$ == "woodland") { + if (.@r < 100) + setmapmask .@key$, MASK_RAIN; + else if (.@r < 120) + setmapmask .@key$, MASK_SANDSTORM; + else if (.@r < 140) + setmapmask .@key$, MASK_SNOW; + else + setmapmask .@key$, MASK_NONE; + + } else if (.@type$ == "iceland") { + if (.@r < 10) + setmapmask .@key$, MASK_RAIN; + else if (.@r < 100) + setmapmask .@key$, MASK_SNOW; + else + setmapmask .@key$, MASK_NONE; + + } else { + debugmes "Warning warning, blame Saulc! Weather system error on map "+.@key$; + announce("ERROR BLAME SAULC! WEATHER SYSTEM CORRUPTED. KILLING MAP SERVERS.", bc_all); + atcommand "@mapexit"; + } + + // Is it night time? + // For convenience, night time is from 00:15 to 00:45, every hour. + // 2 = GETTIME_MINUTE + if (gettime(2) >= 15 && gettime(2) < 45) { + setmapflag(.@key$, mf_nightenabled); + addmapmask .@key$, MASK_NIGHT; + } else if (getmapmask(.@key$) & MASK_NIGHT) { + removemapflag(.@key$, mf_nightenabled); + removemapmask .@key$, MASK_NIGHT; + } + + } + htidelete(.@hti); + debugmes "[Weather.sys] Weather reloaded"; + end; + + // Function to check stuff + // WeatherSwitch ( MASK ) + 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$, MASK_RAIN); + 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; + +// Clear works on any map +OnClear: + getmapxy(.@key$,.@a,.@b,0); + setmapmask(.@key$, MASK_NONE); + end; + +} diff --git a/npc/scripts.conf b/npc/scripts.conf index e3190f0ed..7b9bfd237 100644 --- a/npc/scripts.conf +++ b/npc/scripts.conf @@ -15,6 +15,7 @@ "npc/functions/string.txt", "npc/functions/time.txt", "npc/functions/timer.txt", +"npc/functions/weather.txt", // These functions need to be loaded before everything else "npc/functions/goodbye.txt", |