summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgumi <mekolat@users.noreply.github.com>2017-01-04 14:08:49 -0500
committergumi <mekolat@users.noreply.github.com>2017-04-19 20:38:38 -0400
commitc0145716732fcfaa81ebcc7c61432e20ea089e62 (patch)
treeb0e96086bccdfa2c207e97217cbc5054e7652dc4
parent5eb1bc31017d78fc120ae7a9e148302ec8a2473b (diff)
downloadserverdata-c0145716732fcfaa81ebcc7c61432e20ea089e62.tar.gz
serverdata-c0145716732fcfaa81ebcc7c61432e20ea089e62.tar.bz2
serverdata-c0145716732fcfaa81ebcc7c61432e20ea089e62.tar.xz
serverdata-c0145716732fcfaa81ebcc7c61432e20ea089e62.zip
add `@exprate` atcommand
-rw-r--r--npc/commands/event.txt41
-rw-r--r--npc/commands/rate-management.txt107
-rw-r--r--npc/scripts.conf1
3 files changed, 140 insertions, 9 deletions
diff --git a/npc/commands/event.txt b/npc/commands/event.txt
index a01162e2..3253702a 100644
--- a/npc/commands/event.txt
+++ b/npc/commands/event.txt
@@ -1,17 +1,40 @@
function script GlobalEventMenu {
- clear;
- setnpcdialogtitle l("Event Management");
- mes l("This menu allows you to manage events and gives access to event-related tools.");
- mes "";
- mes l("There is no event available right now.");
- if (getarg(0,0))
+ function rateManagement {
+ clear;
+ mes l("To get the current rate:");
+ mes col(" @exprate", 7);
+ next;
+ mes l("To set the exp rate:");
+ mes col(" @exprate ##Brate##b hours", 7);
+ next;
+ mes l("To reset back to normal:");
+ mes col(" @exprate default", 7); // note to translators: any non-numerical value will reset so "default" is safe to translate
+ next;
+ return;
+ }
+
+ do
{
+ clear;
+ setnpcdialogtitle l("Event Management");
+ mes l("This menu allows you to manage events and gives access to event-related tools.");
+ mes "";
+ mes l("What do you want to access?");
+
select
- menuimage("actions/home", l("Return to Super Menu"));
- }
+ l("Rate management"),
+ rif(getarg(0,0), menuimage("actions/home", l("Return to Super Menu")));
+
+ //.@c = getarg(0,0) ? 2 : 1; // 1 = back to event menu, 2 = back to super menu
+
+ switch (@menu)
+ {
+ case 1: rateManagement; break;
+ default: return;
+ }
- return;
+ } while (true);
}
diff --git a/npc/commands/rate-management.txt b/npc/commands/rate-management.txt
new file mode 100644
index 00000000..06f1c77b
--- /dev/null
+++ b/npc/commands/rate-management.txt
@@ -0,0 +1,107 @@
+- 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 FuzzyTimeFromSeconds(.@seconds_remaining, 2, 2);
+ }
+
+OnCall:
+ if (getgroupid() < 3)
+ {
+ 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, FuzzyTimeFromHours(.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", 3, 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_item_rate = getbattleflag("item_rate_common");
+ //.original_job_rate = getbattleflag("base_job_rate");
+ //.original_pk_mode = getbattleflag("pk_mode");
+ //.original_death_penalty = getbattleflag("death_penalty_type");
+}
diff --git a/npc/scripts.conf b/npc/scripts.conf
index ec7f0be7..6d39acc5 100644
--- a/npc/scripts.conf
+++ b/npc/scripts.conf
@@ -81,6 +81,7 @@
"npc/commands/motd-debug-text.txt",
"npc/commands/motd.txt",
"npc/commands/scheduled-broadcasts.txt",
+"npc/commands/rate-management.txt",
"npc/commands/event.txt",
"npc/commands/debug-look.txt",
"npc/commands/debug-quest.txt",