summaryrefslogtreecommitdiff
path: root/npc/functions/weather.txt
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-09-23 22:12:24 -0300
committerJesusaves <cpntb1@ymail.com>2021-09-23 22:12:24 -0300
commit220aa50297dedb4b9d2138ac63cf09f4c92d39f2 (patch)
treed79e17a61cc00da150d3b51302bfb3e0ad39a280 /npc/functions/weather.txt
parent902274e23c9b945bb457b90820b292f9c9cc6290 (diff)
downloadserverdata-220aa50297dedb4b9d2138ac63cf09f4c92d39f2.tar.gz
serverdata-220aa50297dedb4b9d2138ac63cf09f4c92d39f2.tar.bz2
serverdata-220aa50297dedb4b9d2138ac63cf09f4c92d39f2.tar.xz
serverdata-220aa50297dedb4b9d2138ac63cf09f4c92d39f2.zip
Global hotfix for monster long respawn rate based on total player count.
Up to 22 players, spawn rates can become 4× faster. This is based on the historical average of the previous day/night cycle. It refreshes during the day/night cycle change and keeps the -30% bonus at night.
Diffstat (limited to 'npc/functions/weather.txt')
-rw-r--r--npc/functions/weather.txt22
1 files changed, 19 insertions, 3 deletions
diff --git a/npc/functions/weather.txt b/npc/functions/weather.txt
index 91e9bfe5e..9c6111bf9 100644
--- a/npc/functions/weather.txt
+++ b/npc/functions/weather.txt
@@ -49,6 +49,8 @@ OnInit:
// This is weather startup
.@init=true;
$@WEATHER_NIGHT=is_night(true);
+ .tpc=0;
+ .tcl=0;
// Bind commands
bindatcmd "wsnow", "#WeatherCore::OnSnow", 80, 80, 1;
bindatcmd "wrain", "#WeatherCore::OnRain", 80, 80, 1;
@@ -115,6 +117,8 @@ OnMinute45:
end;
//debugmes "[Weather.sys] Starting to regen";
+ .tpc+=getusers(1);
+ .tcl+=1;
.@hti = htiterator(.wcore);
for(.@key$ = htinextkey(.@hti); hticheck(.@hti); .@key$ = htinextkey(.@hti)) {
@@ -214,8 +218,20 @@ OnMinute45:
// Player might be on cave, and this will help them tracking time.
.@current=is_night(true);
.@update = (.@current != $@WEATHER_NIGHT);
- if (.@update)
+ if (.@update) {
$@WEATHER_NIGHT=.@current;
+ if (.tcl > 0) {
+ .tpc = .tpc / .tcl;
+ // Monsters spawn faster based on average player count of previous
+ // cycle, 2% faster per player, capped at 2/3 of the lowest rate
+ // Default lowest is 70%, so it can go down up to 45% reduction
+ // For a total of (70-45 = 25%) or monsters spawning 4× faster
+ // when server is at "full" load (22 players or so)
+ .@bon = min(.tpc * 2, min($BCONFN_SPAWN, $BCONFD_SPAWN) * 2 / 3);
+ }
+ .tpc=0;
+ .tcl=0;
+ }
if (is_night() && .@update) {
.@c = getunits(BL_PC, .@players, MAX_CYCLE_PC);
for (.@i = 0; .@i < .@c; .@i++) {
@@ -225,7 +241,7 @@ OnMinute45:
message(.@players[.@i], "The night falls.");
detachrid();
}
- setbattleflag("mob_spawn_delay", $BCONFN_SPAWN);
+ setbattleflag("mob_spawn_delay", $BCONFN_SPAWN - .@bon);
setbattleflag("monster_hp_rate", $BCONFN_MOBHP);
//charcommand("@reloadbattleconf"); // Careful!
donpcevent("@exprate::OnInheirtedReload");
@@ -239,7 +255,7 @@ OnMinute45:
message(.@players[.@i], "The day rises.");
detachrid();
}
- setbattleflag("mob_spawn_delay", $BCONFD_SPAWN);
+ setbattleflag("mob_spawn_delay", $BCONFD_SPAWN - .@bon);
setbattleflag("monster_hp_rate", $BCONFD_MOBHP);
//charcommand("@reloadbattleconf"); // Careful!
donpcevent("@exprate::OnInheirtedReload");