summaryrefslogtreecommitdiff
path: root/npc/functions
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2024-02-17 22:20:26 -0300
committerJesusaves <cpntb1@ymail.com>2024-02-17 22:20:26 -0300
commit0a6cba4c68521edc6e33cacd6999ab461f8ad6aa (patch)
treed6ba4e6a0c1a48afe52c3c54c8cf8f34dbbcd792 /npc/functions
parent93c68457281c56aa719f6f55885040f75d1f03f3 (diff)
downloadserverdata-0a6cba4c68521edc6e33cacd6999ab461f8ad6aa.tar.gz
serverdata-0a6cba4c68521edc6e33cacd6999ab461f8ad6aa.tar.bz2
serverdata-0a6cba4c68521edc6e33cacd6999ab461f8ad6aa.tar.xz
serverdata-0a6cba4c68521edc6e33cacd6999ab461f8ad6aa.zip
I wasn't lying, ThinkSome - add the necessary functions so I can keep my word.
[01:05] ThinkStorage: Jesusalva when will we be able to take Frostia office...? [01:07] Jesusalva: When we consistently have 20+ players online, I believe Start tracking the average player activity within the weather system.
Diffstat (limited to 'npc/functions')
-rw-r--r--npc/functions/array.txt11
-rw-r--r--npc/functions/event.txt2
-rw-r--r--npc/functions/scoreboards.txt2
-rw-r--r--npc/functions/util.txt6
-rw-r--r--npc/functions/weather.txt4
5 files changed, 24 insertions, 1 deletions
diff --git a/npc/functions/array.txt b/npc/functions/array.txt
index d433abd71..fb9c33807 100644
--- a/npc/functions/array.txt
+++ b/npc/functions/array.txt
@@ -215,6 +215,17 @@ function script array_difference {
+// array_avg(<array>)
+// return the average of every element of the array
+
+function script array_avg {
+ .@size = getarraysize(getarg(0));
+ .@suma = array_sum(getarg(0));
+ return .@suma / .@i;
+}
+
+
+
// array_shift(<array>)
// returns the first element of the array and removes it, while shifting left
diff --git a/npc/functions/event.txt b/npc/functions/event.txt
index 37832a316..e99a57410 100644
--- a/npc/functions/event.txt
+++ b/npc/functions/event.txt
@@ -191,7 +191,7 @@ OnTimer90000:
}
// Handle Siege season
- if ($EVENT$ == "Siege" && (.users >= 3 || $@GM_OVERRIDE) && !$@MK_SCENE && !$@GM_EVENT && rand2(99999) < .users) {
+ if ($EVENT$ == "Siege" && (.users >= 3 || $@GM_OVERRIDE) && !$@MK_SCENE && !$@GM_EVENT && rand2(199999) < .users) {
$@SIEGE_ABORTED = false;
.@towns = rand2(1, 15);
kamibroadcast("Monster King! Seize and destroy some towns!", "Moubootaur");
diff --git a/npc/functions/scoreboards.txt b/npc/functions/scoreboards.txt
index 7a7ba2e4a..19d93ca09 100644
--- a/npc/functions/scoreboards.txt
+++ b/npc/functions/scoreboards.txt
@@ -467,6 +467,8 @@ function script HallOfGame {
mes l("Planted Trees: %s", fnum($TREE_PLANTED));
mes l("Players Killed in PvP: %s", fnum($PLAYERS_KILLED));
mes l("Monsters Killed in PvE: %s", fnum($MONSTERS_KILLED));
+ if (is_staff())
+ mesc l("Average user count = %d", GETUSERSAVG());
mes "";
.@s$=(season() == WINTER ? l("Winter") : .@s$);
.@s$=(season() == AUTUMN ? l("Autumn") : .@s$);
diff --git a/npc/functions/util.txt b/npc/functions/util.txt
index 9f1ba71d3..84782e448 100644
--- a/npc/functions/util.txt
+++ b/npc/functions/util.txt
@@ -1222,6 +1222,12 @@ function script TOP3AVERAGELVL {
return ($@hoblvl_value[0]+$@hoblvl_value[1]+$@hoblvl_value[2])/3;
}
+// Returns the average online activity
+// GETUSERSAVG( - )
+function script GETUSERSAVG {
+ return array_avg($@PLAYER_ACTIVITY);
+}
+
// Grants newcomers exp boost. Returns bonus %
// NewcomerEXPDROPUP( - )
function script NewcomerEXPDROPUP {
diff --git a/npc/functions/weather.txt b/npc/functions/weather.txt
index 5816284de..bf530b114 100644
--- a/npc/functions/weather.txt
+++ b/npc/functions/weather.txt
@@ -49,6 +49,7 @@ OnInit:
// This is weather startup
.@init=true;
$@WEATHER_NIGHT=is_night(true);
+ array_pad($@PLAYER_ACTIVITY, 96, 0);
.tpc=0;
.tcl=0;
// Bind commands
@@ -117,6 +118,9 @@ OnMinute00:
OnMinute15:
OnMinute30:
OnMinute45:
+ // Update the online average activity
+ .@idx = (gettime(GETTIME_HOUR) * 4) + (gettime(GETTIME_MINUTE) / 15);
+ $@PLAYER_ACTIVITY[.@idx] = getusers(1);
// There is no weather in test servers
if (debug && !$@GM_OVERRIDE)
end;