summaryrefslogtreecommitdiff
path: root/npc/functions
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-05-06 06:37:49 -0300
committerJesusaves <cpntb1@ymail.com>2021-05-06 06:37:49 -0300
commit395bfa2a136b9d8074ba4712e5febedfde3502ac (patch)
tree89c851c737fd50dc3f3f470f7398028a2751104b /npc/functions
parent9d18bd16fa9598eaa9ab281a936525fe430290c9 (diff)
downloadserverdata-395bfa2a136b9d8074ba4712e5febedfde3502ac.tar.gz
serverdata-395bfa2a136b9d8074ba4712e5febedfde3502ac.tar.bz2
serverdata-395bfa2a136b9d8074ba4712e5febedfde3502ac.tar.xz
serverdata-395bfa2a136b9d8074ba4712e5febedfde3502ac.zip
Rewrite day/night logic. Makes more reliable. Days last drastically longer.
Diffstat (limited to 'npc/functions')
-rw-r--r--npc/functions/weather.txt29
1 files changed, 14 insertions, 15 deletions
diff --git a/npc/functions/weather.txt b/npc/functions/weather.txt
index 729c639ba..d99f0e97e 100644
--- a/npc/functions/weather.txt
+++ b/npc/functions/weather.txt
@@ -6,12 +6,13 @@
// is_night(set=False)
function script is_night {
- // If we're not configuring, retrieve the variable
+ // If we're not configuring, retrieve the variable (cache)
// It is more efficient this way
.@set=getarg(0, false);
if (!.@set)
return $@WEATHER_NIGHT;
+ /*
// Night time depends on season.
// Summer: Day > Night
// Winter: Night > Day
@@ -19,19 +20,15 @@ function script is_night {
//
// But we have TWO SUNS, meaning night is always smaller.
//
- // By default, each period lasts a whole hour, give or take 15 minutes (?)
// 2 = GETTIME_MINUTE
// 3 = GETTIME_HOUR
- if (gettime(3) % 3 == 1) {
- // Summer: 2h30 day. 30m night.
- // Others: 2h15 day. 45m night.
- // Winter: 2h day. 1h night.
- if (season() == SUMMER && gettime(2) <= 30 || season() != WINTER && gettime(2) <= 15)
- return 0;
- return 1;
- } else {
- return 0;
- }
+ // Summer: 5h day. 1h night. (4 cycles)
+ // Others: 3h day. 1h night. (6 cycles)
+ // Winter: 2h day. 1h night. (8 cycles)
+ */
+ // NEW Unified Rule: Day last 3 hours. Night lasts 1 hour. Always.
+ .@t=(season() == SUMMER ? 6 : (season() == WINTER ? 3 : 4));
+ return (gettime(3) % .@t == 1);
}
000-0,0,0,0 script #WeatherCore NPC_HIDDEN,{
@@ -216,7 +213,10 @@ OnMinute45:
// It's 2 messages every 3 hours. (r7.5)
// Player might be on cave, and this will help them tracking time.
.@current=is_night(true);
- if (is_night() && (!.@current || .@init)) {
+ .@update = (.@current != $@WEATHER_NIGHT);
+ if (.@update)
+ $@WEATHER_NIGHT=.@current;
+ if (is_night() && .@update) {
.@c = getunits(BL_PC, .@players, MAX_CYCLE_PC);
for (.@i = 0; .@i < .@c; .@i++) {
attachrid(.@players[.@i]);
@@ -230,7 +230,7 @@ OnMinute45:
//charcommand("@reloadbattleconf"); // Careful!
donpcevent("@exprate::OnInheirtedReload");
//donpcevent("@droprate::OnReload");
- } else if (!is_night() && (.@current || .@init)) {
+ } else if (!is_night() && .@update) {
.@c = getunits(BL_PC, .@players, MAX_CYCLE_PC);
for (.@i = 0; .@i < .@c; .@i++) {
attachrid(.@players[.@i]);
@@ -245,7 +245,6 @@ OnMinute45:
donpcevent("@exprate::OnInheirtedReload");
//donpcevent("@droprate::OnReload");
}
- $@WEATHER_NIGHT=.@current;
debugmes "[Weather.sys] Weather reloaded";
end;