diff options
Diffstat (limited to 'npc')
-rw-r--r-- | npc/commands/event.txt | 18 | ||||
-rw-r--r-- | npc/commands/rate-management.txt | 131 |
2 files changed, 148 insertions, 1 deletions
diff --git a/npc/commands/event.txt b/npc/commands/event.txt index a78be0f83..898db8331 100644 --- a/npc/commands/event.txt +++ b/npc/commands/event.txt @@ -14,6 +14,20 @@ function script GlobalEventMenu { return; } + function dropManagement { + clear; + mes l("To get the current rate:"); + mes col(" @rates", 7); + next; + mes l("To set the drop rate:"); + mes col(" @droprate ##Brate##b hours", 7); + next; + mes l("To reset back to normal:"); + mes col(" @droprate default", 7); // note to translators: any non-numerical value will reset so "default" is safe to translate + next; + return; + } + do { clear; @@ -23,7 +37,8 @@ function script GlobalEventMenu { mes l("What do you want to access?"); select - l("Rate management"), + l("Experience Rate management"), + l("Drop 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 @@ -31,6 +46,7 @@ function script GlobalEventMenu { switch (@menu) { case 1: rateManagement; break; + case 2: dropManagement; break; default: return; } diff --git a/npc/commands/rate-management.txt b/npc/commands/rate-management.txt index 0928c576a..3c79e84bb 100644 --- a/npc/commands/rate-management.txt +++ b/npc/commands/rate-management.txt @@ -105,3 +105,134 @@ OnInit: //.original_pk_mode = getbattleflag("pk_mode"); //.original_death_penalty = getbattleflag("death_penalty_type"); } + + +///////////////////////////////////////////////////////////////////////////////// +- script @droprate 32767,{ + end; + + function rateCleanUp { + stopnpctimer; + .hours = 0; + .max_hours = 0; + .current_rate = .original_exp_rate; + setbattleflag("item_rate_common", .org_dcn); + setbattleflag("item_rate_common_boss", .org_dcb); + setbattleflag("item_rate_heal", .org_dhn); + setbattleflag("item_rate_heal_boss", .org_dhb); + setbattleflag("item_rate_use", .org_dun); + setbattleflag("item_rate_use_boss", .org_dub); + setbattleflag("item_rate_equip", .org_den); + setbattleflag("item_rate_equip_boss", .org_deb); + setbattleflag("item_rate_card", .org_dxn); + setbattleflag("item_rate_card_boss", .org_dxb); + charcommand("@reloadmobdb"); // this is on purpose (callable without RID) - no idea what is the purpose + } + + 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", .@new_rate); + setbattleflag("item_rate_common_boss", .@new_rate); + setbattleflag("item_rate_heal", .@new_rate); + setbattleflag("item_rate_heal_boss", .@new_rate); + setbattleflag("item_rate_use", .@new_rate); + setbattleflag("item_rate_use_boss", .@new_rate); + setbattleflag("item_rate_equip", .@new_rate); + setbattleflag("item_rate_equip_boss", .@new_rate); + setbattleflag("item_rate_card", .@new_rate); + setbattleflag("item_rate_card_boss", .@new_rate); + charcommand("@reloadmobdb"); + initnpctimer; // start counting + + dispbottom l("You successfully set the drop rate to @@%. It will reset to @@% (default value) in @@.", + .@new_rate, .org_dcn, 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 == .org_dcn) + { + dispbottom l("Current drop rate is set to @@% (default value).", .current_rate); + } + + else + { + dispbottom l("Current drop rate is set to @@%, and will reset to @@% (default value) in @@.", + .current_rate, .org_dcn, 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).", + .org_dcn); + } + + 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! + .org_dcn = getbattleflag("item_rate_common"); + .org_dcb = getbattleflag("item_rate_common_boss"); + .org_dhn = getbattleflag("item_rate_heal"); + .org_dhb = getbattleflag("item_rate_heal_boss"); + .org_dun = getbattleflag("item_rate_use"); + .org_dub = getbattleflag("item_rate_use_boss"); + .org_den = getbattleflag("item_rate_equip"); + .org_deb = getbattleflag("item_rate_equip_boss"); + .org_dxn = getbattleflag("item_rate_card"); + .org_dxb = getbattleflag("item_rate_card_boss"); + .current_rate = .org_dcn; + + // 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"); +} |