diff options
author | Jesusaves <cpntb1@ymail.com> | 2024-02-17 22:20:26 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2024-02-17 22:20:26 -0300 |
commit | 0a6cba4c68521edc6e33cacd6999ab461f8ad6aa (patch) | |
tree | d6ba4e6a0c1a48afe52c3c54c8cf8f34dbbcd792 | |
parent | 93c68457281c56aa719f6f55885040f75d1f03f3 (diff) | |
download | serverdata-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.
-rw-r--r-- | npc/024-11/politics.txt | 7 | ||||
-rw-r--r-- | npc/functions/array.txt | 11 | ||||
-rw-r--r-- | npc/functions/event.txt | 2 | ||||
-rw-r--r-- | npc/functions/scoreboards.txt | 2 | ||||
-rw-r--r-- | npc/functions/util.txt | 6 | ||||
-rw-r--r-- | npc/functions/weather.txt | 4 |
6 files changed, 29 insertions, 3 deletions
diff --git a/npc/024-11/politics.txt b/npc/024-11/politics.txt index efb7fcb80..d33c90c64 100644 --- a/npc/024-11/politics.txt +++ b/npc/024-11/politics.txt @@ -16,14 +16,17 @@ do mesc l("Only elves may run to Town Admin Office in Frostia!"), 1; else mesc l("Hey, you're an elf, cool! But you still cannot run for office here!"), 1; - close; + if (!is_staff()) + close; POL_TownInfo("FROSTIA"); mesc l("Application fee: @@ GP", .applytax); + if (is_staff()) + mesc l("Average user count = %d", GETUSERSAVG()); next; select l("Information"), rif(strcharinfo(0) == $FROSTIA_MAYOR$, l("Manage Town")), - rif(#POL_APPLYWEEK != gettimeparam(GETTIME_WEEKDAY), l("Apply for the office!")), + rif(#POL_APPLYWEEK != gettimeparam(GETTIME_WEEKDAY) && GETUSERSAVG() >= 10, l("Apply for the office!")), l("View Candidate List and cast a vote"), l("[Quit]"); 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; |