summaryrefslogtreecommitdiff
path: root/npc/commands
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-04-10 12:10:43 -0300
committerJesusaves <cpntb1@ymail.com>2021-04-10 12:10:43 -0300
commitf0c670be3c6cca5533b842d9b626711bc5d3bf05 (patch)
tree5536fdae50184abff494bc542ea68a71f32cb2db /npc/commands
parent0d5f143b54821ab61430788186647ca60e562600 (diff)
downloadserverdata-f0c670be3c6cca5533b842d9b626711bc5d3bf05.tar.gz
serverdata-f0c670be3c6cca5533b842d9b626711bc5d3bf05.tar.bz2
serverdata-f0c670be3c6cca5533b842d9b626711bc5d3bf05.tar.xz
serverdata-f0c670be3c6cca5533b842d9b626711bc5d3bf05.zip
Add @exprate/@droprate - And drop the legacy stoneboard
Diffstat (limited to 'npc/commands')
-rw-r--r--npc/commands/numa.txt7
-rw-r--r--npc/commands/rate-management.txt231
-rw-r--r--npc/commands/scheduled-broadcasts.txt227
3 files changed, 464 insertions, 1 deletions
diff --git a/npc/commands/numa.txt b/npc/commands/numa.txt
index b8b0a924..da3948b1 100644
--- a/npc/commands/numa.txt
+++ b/npc/commands/numa.txt
@@ -41,21 +41,25 @@ L_Holiday:
"Halloween.", L_HalloweenDebug,
"Easter.", L_EasterDebug;
+// FIXME
L_XmasDebug:
gmlog strcharinfo(0) + " accessed the Xmas debug.";
callfunc "XmasDebug";
goto L_close;
+// FIXME
L_HalloweenDebug:
gmlog strcharinfo(0) + " accessed the Halloween debug.";
callfunc "HalloweenDebug";
goto L_close;
+// FIXME
L_EasterDebug:
gmlog strcharinfo(0) + " accessed the Easter debug.";
callfunc "Easter Debug";
goto L_close;
+// FIXME
L_Event:
if (GM < EVT_DEBUG && GM < G_EVENT) goto L_GM;
gmlog strcharinfo(0) + " accessed the GM event debug.";
@@ -64,9 +68,10 @@ L_Event:
L_StoneBoard:
if (GM < DBG_SCHEDULED && GM < G_SYSOP) goto L_GM;
- callfunc "SBConfig";
+ callfunc "StoneBoard";
goto L_close;
+// FIXME?
L_MOTD:
if (GM < DBG_MOTD && GM < G_SYSOP) goto L_GM;
callfunc "MOTDConfig";
diff --git a/npc/commands/rate-management.txt b/npc/commands/rate-management.txt
new file mode 100644
index 00000000..273ce9ba
--- /dev/null
+++ b/npc/commands/rate-management.txt
@@ -0,0 +1,231 @@
+// Authors: Gumi, Jesusalva
+- script @exprate 32767,{
+ end;
+
+ function rateCleanUp {
+ stopnpctimer;
+ .hours = 0;
+ .max_hours = 0;
+ .current_rate = .original_exp_rate;
+ setbattleflag("base_exp_rate", .original_exp_rate);
+ setbattleflag("quest_exp_rate", .original_quest_rate);
+ charcommand("@reloadmobdb"); // this is on purpose (callable without RID)
+ charcommand("@reloadquestdb");
+ }
+
+ function remainingTime {
+ .@total_seconds = (3600 * .max_hours);
+ .@seconds_elapsed = (3600 * .hours) + (getnpctimer(0) / 1000);
+ .@seconds_remaining = max(1, .@total_seconds - .@seconds_elapsed);
+ return FuzzyTime(time_from_seconds(.@seconds_remaining), 2, 2);
+ }
+
+OnCall:
+ if (!is_evtc())
+ {
+ end;
+ }
+
+ .@special$ = strip(.@atcmd_parameters$[0]); // special value
+ .@new_rate = min(atoi(.@special$), 1000); // or just a regular integer
+ .@hours = min(0x7FFFFFFE, max(1, atoi(strip(.@atcmd_parameters$[1])))); // number of hours
+
+ if (.@new_rate > 0)
+ {
+ // set new exp rate
+ .hours = 0;
+ .max_hours = .@hours;
+ .current_rate = .@new_rate;
+ setbattleflag("base_exp_rate", .@new_rate);
+ setbattleflag("quest_exp_rate", .@new_rate);
+ charcommand("@reloadmobdb");
+ charcommand("@reloadquestdb");
+ initnpctimer; // start counting
+
+ dispbottom l("You successfully set the exp rate to @@%. It will reset to @@% (default value) in @@.",
+ .@new_rate, .original_exp_rate, FuzzyTime(time_from_hours(.max_hours), 2, 2));
+ dispbottom l("You can also manually stop it at any time with: @exprate default");
+ }
+
+ else if (.@new_rate == 0 && .@special$ == "")
+ {
+ // get current exp rate
+ if (.current_rate == .original_exp_rate)
+ {
+ dispbottom l("Current exp rate is set to @@% (default value).", .current_rate);
+ }
+
+ else
+ {
+ dispbottom l("Current exp rate is set to @@%, and will reset to @@% (default value) in @@.",
+ .current_rate, .original_exp_rate, remainingTime());
+
+ dispbottom l("If you meant to reset the exp rate to its default value: @exprate default");
+ }
+ }
+
+ else
+ {
+ // reset
+ rateCleanUp;
+ dispbottom l("Exp rate has been reset to @@% (default value).",
+ .original_exp_rate);
+ }
+
+ end;
+
+OnTimer3600000:
+ // runs every hour
+ if (++.hours == .max_hours)
+ {
+ rateCleanUp;
+ end;
+ }
+ initnpctimer;
+ end;
+
+OnPCLoginEvent:
+ if (.max_hours > 0)
+ {
+ dispbottom col(l("Exp rate is set to @@% for the next @@.",
+ .current_rate, remainingTime()), 6);
+ }
+ end;
+
+OnInit:
+ bindatcmd "exprate", "@exprate::OnCall", 0, 99, 1; // change exp rate
+
+ // WARNING: using @reloadscript will change the "original" value
+ .original_exp_rate = getbattleflag("base_exp_rate");
+ .original_quest_rate = getbattleflag("quest_exp_rate");
+ .current_rate = .original_exp_rate;
+
+ // XXX: maybe in the future:
+ //.original_job_rate = getbattleflag("base_job_rate");
+ //.original_pk_mode = getbattleflag("pk_mode");
+ //.original_death_penalty = getbattleflag("death_penalty_type");
+ end;
+}
+
+
+/////////////////////////////////////////////////////////////////////////////////
+- script @droprate 32767,{
+ end;
+
+ function dropRateReal {
+ return 100; // getbattleflag("item_rate_common") ?
+ }
+
+ function dropRecalc {
+ .@val=getarg(0);
+ return .@val;
+ }
+
+ function rateCleanUp {
+ stopnpctimer;
+ .hours = 0;
+ .max_hours = 0;
+ .current_rate = getbattleflag("item_rate_common");
+ setbattleflag("item_rate_common", dropRateReal());
+ setbattleflag("item_rate_common_boss", dropRateReal());
+ setbattleflag("item_rate_heal", dropRateReal());
+ setbattleflag("item_rate_heal_boss", dropRateReal());
+ setbattleflag("item_rate_use", dropRateReal());
+ setbattleflag("item_rate_use_boss", dropRateReal());
+ setbattleflag("item_rate_equip", dropRateReal());
+ setbattleflag("item_rate_equip_boss", dropRateReal());
+ setbattleflag("item_rate_card", dropRateReal());
+ setbattleflag("item_rate_card_boss", dropRateReal());
+ charcommand("@reloadmobdb"); // this is on purpose (callable without RID) - no idea what is the purpose
+ channelmes("#world", "The Drop Rate Bonus is now over.");
+ }
+
+ function remainingTime {
+ .@total_seconds = (3600 * .max_hours);
+ .@seconds_elapsed = (3600 * .hours) + (getnpctimer(0) / 1000);
+ .@seconds_remaining = max(1, .@total_seconds - .@seconds_elapsed);
+ return FuzzyTime(time_from_seconds(.@seconds_remaining), 2, 2);
+ }
+
+OnCall:
+ if (!is_evtc()) {
+ end;
+ }
+
+ .@special$ = strip(.@atcmd_parameters$[0]); // special value
+ .@new_rate = min(atoi(.@special$), 1000); // or just a regular integer
+ .@hours = min(0x7FFFFFFE, max(1, atoi(strip(.@atcmd_parameters$[1])))); // number of hours
+
+ if (.@new_rate > 0)
+ {
+ // set new exp rate
+ .hours = 0;
+ .max_hours = .@hours;
+ .current_rate = .@new_rate;
+ setbattleflag("item_rate_common", dropRecalc(.@new_rate));
+ setbattleflag("item_rate_common_boss", dropRecalc(.@new_rate));
+ setbattleflag("item_rate_heal", dropRecalc(.@new_rate));
+ setbattleflag("item_rate_heal_boss", dropRecalc(.@new_rate));
+ setbattleflag("item_rate_use", dropRecalc(.@new_rate));
+ setbattleflag("item_rate_use_boss", dropRecalc(.@new_rate));
+ setbattleflag("item_rate_equip", dropRecalc(.@new_rate));
+ setbattleflag("item_rate_equip_boss", dropRecalc(.@new_rate));
+ setbattleflag("item_rate_card", dropRecalc(.@new_rate));
+ setbattleflag("item_rate_card_boss", dropRecalc(.@new_rate));
+ charcommand("@reloadmobdb");
+ initnpctimer; // start counting
+
+ .@msg$=strcharinfo(0)+" modified drop rates to "+str(.@new_rate)+"%. It will only last "+str(FuzzyTime(time_from_hours(.max_hours), 2, 2))+"!";
+
+ announce .@msg$, bc_all;
+ channelmes("#world", .@msg$);
+
+ //dispbottom l("You successfully set the drop rate to @@%. It will reset to @@% (default value) in @@.",
+ // .@new_rate, dropRateReal(), FuzzyTime(time_from_hours(.max_hours), 2, 2));
+ dispbottom l("You can also manually stop it at any time with: @droprate default");
+ } else if (.@new_rate == 0 && .@special$ == "") {
+ // get current exp rate
+ if (.current_rate == dropRateReal()) {
+ atcommand("@rates");
+ dispbottom col(l("Usage of @exprate without argument is deprecated, please use \"@rates\" instead."), 1);
+ } else {
+ dispbottom l("Current drop rate is set to @@%, and will reset to @@% (default value) in @@.",
+ .current_rate, dropRateReal(), remainingTime());
+ dispbottom l("If you meant to reset the drop rate to its default value: @droprate default");
+ }
+ }
+
+ else
+ {
+ // reset
+ rateCleanUp;
+ dispbottom l("Drop rate has been reset to @@% (default value).",
+ dropRateReal());
+ }
+
+ end;
+
+OnTimer3600000:
+ // runs every hour
+ if (++.hours == .max_hours) {
+ rateCleanUp;
+ end;
+ }
+ initnpctimer;
+ end;
+
+OnPCLoginEvent:
+ if (.max_hours > 0) {
+ dispbottom col(l("Drop rate is set to @@% for the next @@.",
+ .current_rate, remainingTime()), 6);
+ }
+ end;
+
+OnInit:
+ bindatcmd "droprate", "@droprate::OnCall", 80, 80, 1; // change drop rate
+
+ // WARNING: using @reloadscript will change the "original" value, use @reloadbattleconf before!
+ .current_rate = getbattleflag("item_rate_common");
+ //force_refreshall();
+ end;
+}
diff --git a/npc/commands/scheduled-broadcasts.txt b/npc/commands/scheduled-broadcasts.txt
new file mode 100644
index 00000000..1801663a
--- /dev/null
+++ b/npc/commands/scheduled-broadcasts.txt
@@ -0,0 +1,227 @@
+// Evol Script
+// Authors: Gumi
+function script StoneBoard {
+
+ function setMessage {
+ do
+ {
+ clear;
+ mes l("Please enter the message:");
+ next;
+ input .@msg$;
+ .@msg$ = strip(.@msg$);
+ if (.@msg$ != "") {
+ return .@msg$;
+ }
+ mes l("The message cannot be empty");
+ next;
+ } while (1);
+ }
+
+ function setInterval {
+ clear;
+ mes l("Please select the interval:");
+ next;
+ menuint
+ l("Every 1 hour"), 1,
+ l("Every 3 hours"), 3,
+ l("Every 5 hours"), 5,
+ l("Every 6 hours"), 6,
+ l("Every 12 hours"), 12,
+ l("Every 24 hours"), 24,
+ l("Never (only on login)"), 0;
+
+ return @menuret;
+ }
+
+ function setMaxRep {
+ if (getarg(0,0) == 0) {
+ return 0;
+ }
+ clear;
+ mes l("Repeat how many times?");
+ next;
+ menuint
+ l("Send only once"), 1,
+ l("Send 2 times"), 2,
+ l("Send 3 times"), 3,
+ l("Send 5 times"), 5,
+ l("Send 10 times"), 10,
+ l("Send 20 times"), 20,
+ l("Send indefinitely"), 0;
+
+ return @menuret;
+ }
+
+ function setOnLogin {
+ if (getarg(0,0) == 0)
+ {
+ return 1;
+ }
+ clear;
+ mes l("Send this message also on login?");
+ next;
+ select
+ l("No"),
+ l("Yes");
+
+ return (@menu - 1);
+ }
+
+ function newBroadcast {
+ do
+ {
+ setnpcdialogtitle l("Scheduled broadcasts - Create new");
+
+ // go through all steps
+ .@msg$ = setMessage();
+ .@int = setInterval();
+ .@max = setMaxRep(.@int);
+ .@login = setOnLogin(.@int);
+
+ // recap
+ clear;
+ mes l("Message:");
+ mes "---";
+ mes .@msg$;
+ mes "---";
+ if (.@int)
+ {
+ mes l("Interval: every @@ hour(s)", .@int);
+ mes l("Repeat: @@ times", .@max ? .@max : "∞");
+ mes l("Sent on login: @@", .@login ? l("yes") : l("no"));
+ }
+ else
+ {
+ mes l("Interval: (none, only sent on login)");
+ mes l("Sent on login: yes");
+ }
+
+ next;
+ select
+ menuimage("actions/cancel", l("Discard")),
+ menuimage("actions/edit", l("Start over")),
+ menuimage("actions/test", l("Start broadcasting")),
+ menuimage("actions/test", l("Start broadcasting, and make an extra broadcast right now"));
+
+ switch (@menu)
+ {
+ case 3:
+ case 4:
+ stopnpctimer "@sched";
+ $@SCHED_Opt[0] = .@login;
+ $@SCHED_Opt[1] = .@int;
+ $@SCHED_Opt[2] = 0;
+ $@SCHED_Opt[3] = .@max;
+ $@SCHED_Opt[4] = 0;
+ $@SCHED_Msg$ = .@msg$;
+ if (.@int)
+ {
+ initnpctimer "@sched";
+ }
+ if (@menu == 4)
+ {
+ announce $@SCHED_Msg$, bc_all;
+ }
+ logmes "Scheduled Broadcast: A new broadcast was added", LOGMES_ATCOMMAND;
+ case 1: return;
+ }
+
+ } while(1);
+ }
+
+ do
+ {
+ clear;
+ setnpcdialogtitle l("Scheduled broadcasts");
+ mes l("This menu allows you to set the scheduled broadcast that is sent to all players at a specific interval.");
+ mes "";
+
+ .@a = $@SCHED_Msg$ != ""; // any active broadcast?
+ mes "---";
+ mes .@a ? $@SCHED_Msg$ : "(" + l("no active broadcast") +")";
+ mes "---";
+ if (.@a)
+ {
+ mes l("Sent on login: @@", ($@SCHED_Opt[0] ? l("yes") : l("no")));
+ if ($@SCHED_Opt[1])
+ {
+ .@next = max(1, ((3600000 * ($@SCHED_Opt[1] - $@SCHED_Opt[4])) - getnpctimer(0, "@sched")));
+ mes l("Interval: every @@ hour(s)", $@SCHED_Opt[1]);
+ mes l("Next broadcast: @@", FuzzyTime(time_from_ms(.@next)));
+ }
+ else
+ {
+ mes l("Interval: (none, only sent on login)");
+ mes l("Next broadcast: (never)");
+ }
+ mes l("Sent: @@ times out of @@", $@SCHED_Opt[2], ($@SCHED_Opt[3] ? $@SCHED_Opt[3] : "∞"));
+ }
+ next;
+
+ select
+ menuimage("actions/abort", l("Abort")),
+ rif(.@a, menuimage("actions/test", l("Manually trigger the current broadcast"))),
+ rif(.@a, menuimage("actions/remove", l("Stop broadcasting"))),
+ rif(!(.@a), menuimage("actions/add", l("Set a new broadcast"))),
+ rif(getarg(0,0), menuimage("actions/home", l("Return to Super Menu")));
+
+ switch (@menu)
+ {
+ case 2: announce $@SCHED_Msg$, bc_all; break;
+ case 3: $@SCHED_Msg$ = ""; break;
+ case 4: newBroadcast; break;
+ default: return;
+ }
+ } while (1);
+}
+
+
+
+- script @sched 32767,{
+ end;
+
+OnTimer3600000:
+ if ($@SCHED_Msg$ == "")
+ {
+ stopnpctimer;
+ end;
+ }
+
+ ++$@SCHED_Opt[4]; // increase hours counter
+ if ($@SCHED_Opt[4] == $@SCHED_Opt[1])
+ {
+ stopnpctimer;
+ ++$@SCHED_Opt[2]; // increase total counter
+ announce $@SCHED_Msg$, bc_all;
+ $@SCHED_Opt[4] = 0; // reset hours counter
+ if ($@SCHED_Opt[2] >= $@SCHED_Opt[3] && $@SCHED_Opt[3] > 0)
+ {
+ $@SCHED_Msg$ = ""; // reset message
+ end;
+ }
+ }
+ initnpctimer;
+ end;
+
+OnCall:
+ if (!is_gm())
+ {
+ end;
+ }
+
+ StoneBoard;
+ closedialog;
+ end;
+
+OnInit:
+ bindatcmd "sched", "@sched::OnCall", 80, 99, 1;
+}
+
+function script StoneBoardRead {
+ if ($@SCHED_Opt[0] && $@SCHED_Msg$ != "")
+ {
+ announce $@SCHED_Msg$, bc_self;
+ }
+ return;
+}