diff options
Diffstat (limited to 'world/map')
-rw-r--r-- | world/map/npc/botcheck/_import.txt | 1 | ||||
-rw-r--r-- | world/map/npc/botcheck/announcements.txt | 156 |
2 files changed, 157 insertions, 0 deletions
diff --git a/world/map/npc/botcheck/_import.txt b/world/map/npc/botcheck/_import.txt index 26445239..3702ba87 100644 --- a/world/map/npc/botcheck/_import.txt +++ b/world/map/npc/botcheck/_import.txt @@ -3,3 +3,4 @@ map: botcheck.gat npc: npc/botcheck/_mobs.txt npc: npc/botcheck/_warps.txt +npc: npc/botcheck/announcements.txt diff --git a/world/map/npc/botcheck/announcements.txt b/world/map/npc/botcheck/announcements.txt new file mode 100644 index 00000000..9ddf6ca6 --- /dev/null +++ b/world/map/npc/botcheck/announcements.txt @@ -0,0 +1,156 @@ +//############################################################################ +//# # +//# GM scheduled broadcasts # +//# # +//############################################################################ + +// $@GMSA_STATUS values: +// 0: Broadcasts not running +// 1: Broadcasts running +// $@GMSA_MSG$: the message to be broadcasted +// $@GMSA_TICK: broadcast the message every $@GMSA_TICK hours +// $@GMSA_CURRENT_TICK: internal counter incremented every hour + +botcheck.gat,49,29,0|script|Stone Board|348,{ + +if (!(getgmlevel() >= 60 && getequipid(equip_head) == 725)) + goto L_Close; + +if ($@GMSA_STATUS == 0) + goto L_PrepareBroadcast; +if ($@GMSA_STATUS == 1) + goto L_InfoBroadcast; + +L_InfoBroadcast: + set @next_broadcast_ts, (3600000*($@GMSA_TICK - $@GMSA_CURRENT_TICK) - getnpctimer(0))/1000; + set @next_broadcast_h, @next_broadcast_ts/3600; + set @next_broadcast_m, (@next_broadcast_ts - @next_broadcast_h*3600)/60; + + mes "[GM Scheduled Broadcasts Board]"; + mes "The current message is broadcasted every " + $@GMSA_TICK + " hour(s):"; + mes $@GMSA_MSG$; + next; + if (@next_broadcast_h > 0) + mes "The next broadcast will happen in " + @next_broadcast_h + " hour(s) and " + @next_broadcast_m + " minute(s)."; + if (@next_broadcast_h == 0) + mes "The next broadcast will happen in " + @next_broadcast_m + " minute(s)."; + next; + + set @next_broadcast_ts, 0; + set @next_broadcast_h, 0; + set @next_broadcast_m, 0; + + mes "What do you want to do?"; + menu + "Nothing.", L_Close, + "Nothing but... what is this?", L_Help, + "Stop broadcasting.", L_StopBroadcast, + "Trigger manually the current broadcast.", L_ManualBroadcast; + +L_PrepareBroadcast: + callsub S_Help; + next; + mes "There is no broadcast scheduled."; + mes "Do you want to create one?"; + menu + "No.", L_Close, + "Yes.", L_CreateBroadcast; + +L_CreateBroadcast: + mes "[GM Scheduled Broadcasts Board]"; + mes "Enter the message to broadcast:"; + input $@GMSA_MSG$; + if ($@GMSA_MSG$ == "") + goto L_InvalidBroadcastMessage; + + next; + mes "[GM Scheduled Broadcasts Board]"; + mes "The message will be broadcasted every X hour(s). Enter X:"; + input $@GMSA_TICK; + if ($@GMSA_TICK < 1) + goto L_InvalidBroadcastTick; + + next; + mes "[GM Scheduled Broadcasts Board]"; + mes "The current message will be broadcasted every " + $@GMSA_TICK + " hour(s):"; + mes $@GMSA_MSG$; + next; + mes "Is this correct?"; + menu + "No. I'll retry.", L_CreateBroadcast, + "No", L_Close, + "Yes. Broadcast this. (the first broadcast will happen in " + $@GMSA_TICK + " hour(s).)", L_StartBroadcast, + "Yes. Broadcast this, and make a broadcast right now.", L_StartBroadcast2; + +L_InvalidBroadcastMessage: + mes "[GM Scheduled Broadcasts Board]"; + mes "The message can't be empty. Please retry."; + goto L_CreateBroadcast; + +L_InvalidBroadcastTick: + mes "[GM Scheduled Broadcasts Board]"; + mes "You obviously can't repeat a message every 0 hours. Please retry."; + goto L_CreateBroadcast; + +L_Help: + callsub S_Help; + goto L_Close; + +S_Help: + mes "[GM Scheduled Broadcasts Board]"; + mes "This board allows a GM to schedule a message to be broadcasted every X hours."; + mes "Only one broadcast can be scheduled at once."; + return; + +S_PerformBroadcast: + announce $@GMSA_MSG$, 0; + return; + +L_ManualBroadcast: + callsub S_PerformBroadcast; + mes "Done."; + goto L_Close; + +L_StopBroadcast: + stopnpctimer; + setnpctimer 0; + set $@GMSA_STATUS, 0; + set $@GMSA_MSG$, ""; + set $@GMSA_TICK, 0; + set $@GMSA_CURRENT_TICK, 0; + mes "Done."; + goto L_Close; + +L_StartBroadcast2: + if ($@GMSA_STATUS == 1) + goto L_Abort; + callsub S_PerformBroadcast; +L_StartBroadcast: + if ($@GMSA_STATUS == 1) + goto L_Abort; + set $@GMSA_STATUS, 1; + set $@GMSA_CURRENT_TICK, 0; + initnpctimer; + mes "Done."; + goto L_Close; + +L_Abort: + mes "[GM Scheduled Broadcasts Board]"; + mes "Another GM has created a scheduled broadcast just before you, hence yours will abort."; + goto L_Close; + +L_Close: + set @gmsa_msg$, ""; + set @gmsa_tick, 0; + close; + +OnTimer3600000: + set $@GMSA_CURRENT_TICK, $@GMSA_CURRENT_TICK + 1; + setnpctimer 0; + if ($@GMSA_CURRENT_TICK != $@GMSA_TICK) + end; + callsub S_PerformBroadcast; + set $@GMSA_CURRENT_TICK, 0; + end; + +}
\ No newline at end of file |