From 039a18fa891a78f17dd89e4f92874060cc996fe0 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Mon, 21 Feb 2022 05:03:38 -0300 Subject: Fix some bad Olympics code --- npc/001-14/hocus.txt | 239 ++++++++++++++++++++++++++------------------------- 1 file changed, 122 insertions(+), 117 deletions(-) (limited to 'npc/001-14/hocus.txt') diff --git a/npc/001-14/hocus.txt b/npc/001-14/hocus.txt index 29062ec21..3bc241f5b 100644 --- a/npc/001-14/hocus.txt +++ b/npc/001-14/hocus.txt @@ -4,122 +4,7 @@ // Description: // Magic Olympics -001-14,89,89,0 script Hocus Pocus NPC_BLACKWIZARD,{ - function showScores; - function parseScores; - if ($EVENT$ != "Olympics") cwarp "Save", 0, 0; - mesn; - mesq l("Greetings, %s %s, I am Hocus Pocus the Grandmaster.", academicrank(), strcharinfo(0)); - do - { - next; - select - l("Scoreboards"), - l("Detailed Information"), - l("Thanks for your wise words."); - mes ""; - switch (@menu) { - case 1: - showScores(); - break; - case 2: - mesn; - mesq l("The Magic Olympics consist in twelve challenges with scoreboards."); - next; - mesn; - mesq l("Getting ranked #1 in a challenge yields you 10 points, getting ranked #2 yields you 9 points and so on."); - next; - mesn; - mesq l("Not participating in a challenge yields you zero points. In case of a tie, char creation date will be the decisive factor: Older adventurers will get the preference."); - next; - mesn; - mesq l("You also get points for participation, exchange them with Aurora back in Tulimshar before event ends."); - next; - mesn; - mesq l("The grand winner will get a %s. Both the first and second place will get a tuition at the Magic Academy.", getitemlink(BlackyCat)); - next; - mesn; - mesq l("The Magic Olympics happen roughly quarterly, but not always at the same dates. It begins on a monday and ends on the sunday. It usually happens two weeks after the Mining Union Research Request event."); - break; - } - } while (@menu != 3); - close; - -function t { - return gettimetick(2); -} - -function showScores { - parseScores("General Event Score", "$@moly_n$", "$@moly_v"); - mesc l("Reminder: "), 1; - mesc l("Scores are updated every 6 hours."), 1; - next; - parseScores("Energy Balls Challenge", "$@moly01_n$", "$@moly01_v"); - //parseScores("Boss Fight Challenge", "$@moly02_n$", "$@moly02_v", 0); - //parseScores("Fluffy Hunt Challenge", "$@moly03_n$", "$@moly03_v"); - parseScores("Chanting Challenge", "$@moly04_n$", "$@moly04_v"); - parseScores("Alchemy Master Challenge", "$@moly05_n$", "$@moly05_v"); - parseScores("Magic Power Challenge", "$@moly06_n$", "$@moly06_v"); - parseScores("Mana Exp Challenge", "$@moly07_n$", "$@moly07_v"); - parseScores("Obstacle Race Challenge", "$@moly08_n$", "$@moly08_v", t()); - parseScores("Hocus Commands Challenge", "$@moly09_n$", "$@moly09_v"); - parseScores("Survive! Challenge", "$@moly10_n$", "$@moly10_v", t()); - parseScores("Friendship Challenge", "$@moly11_n$", "$@moly11_v"); - parseScores("Intensive Mage Challenge", "$@moly12_n$", "$@moly12_v"); - mes ""; - mesc l("Reminder: "), 1; - mesc l("Scores close at Sunday 23:59 - No scores will be given for last minute rushes!"), 1; - return; -} - -function SCH { - .@n$ = getarg(0); - .@i = getarg(1); - return getd(sprintf("%s[%d]", .@n$, .@i)); -} - -function parseScores { - .@t$ = getarg(0); - .@n$ = getarg(1); - .@v$ = getarg(2); - .@tm = getarg(3, -1); - mes ""; - mes l("##B%s: TOP 10##b", .@t$); - if (.@tm < 0) { - mes("1."+SCH(.@n$, 0)+" ("+fnum(SCH(.@v$, 0))+")"); - mes("2."+SCH(.@n$, 1)+" ("+fnum(SCH(.@v$, 1))+")"); - mes("3."+SCH(.@n$, 2)+" ("+fnum(SCH(.@v$, 2))+")"); - mes("4."+SCH(.@n$, 3)+" ("+fnum(SCH(.@v$, 3))+")"); - mes("5."+SCH(.@n$, 4)+" ("+fnum(SCH(.@v$, 4))+")"); - mes("6."+SCH(.@n$, 5)+" ("+fnum(SCH(.@v$, 5))+")"); - mes("7."+SCH(.@n$, 6)+" ("+fnum(SCH(.@v$, 6))+")"); - mes("8."+SCH(.@n$, 7)+" ("+fnum(SCH(.@v$, 7))+")"); - mes("9."+SCH(.@n$, 8)+" ("+fnum(SCH(.@v$, 8))+")"); - mes("10."+SCH(.@n$, 9)+" ("+fnum(SCH(.@v$, 9))+")"); - } else { - mes("1."+SCH(.@n$, 0)+" ("+FuzzyTime(.@tm - SCH(.@v$, 0))+")"); - mes("2."+SCH(.@n$, 1)+" ("+FuzzyTime(.@tm - SCH(.@v$, 1))+")"); - mes("3."+SCH(.@n$, 2)+" ("+FuzzyTime(.@tm - SCH(.@v$, 2))+")"); - mes("4."+SCH(.@n$, 3)+" ("+FuzzyTime(.@tm - SCH(.@v$, 3))+")"); - mes("5."+SCH(.@n$, 4)+" ("+FuzzyTime(.@tm - SCH(.@v$, 4))+")"); - mes("6."+SCH(.@n$, 5)+" ("+FuzzyTime(.@tm - SCH(.@v$, 5))+")"); - mes("7."+SCH(.@n$, 6)+" ("+FuzzyTime(.@tm - SCH(.@v$, 6))+")"); - mes("8."+SCH(.@n$, 7)+" ("+FuzzyTime(.@tm - SCH(.@v$, 7))+")"); - mes("9."+SCH(.@n$, 8)+" ("+FuzzyTime(.@tm - SCH(.@v$, 8))+")"); - mes("10."+SCH(.@n$, 9)+" ("+FuzzyTime(.@tm - SCH(.@v$, 9))+")"); - } - dnext; - return; -} - -OnInit: - .distance=5; -// Scoreboards are refreshed every 6 hours -OnHour2359: -OnHour0559: -OnHour1159: -OnHour1759: - if ($EVENT$ != "Olympics") end; +function script HocusScoreNew { .@nb = query_sql("SELECT c.name, i.value FROM `char_reg_num_db` AS i, `char` AS c WHERE i.key='FYMOLY_ENBALL' AND i.char_id=c.char_id ORDER BY i.value DESC LIMIT 10", $@moly01_n$, $@moly01_v); .@nb = query_sql("SELECT c.name, i.value FROM `char_reg_num_db` AS i, `char` AS c WHERE i.key='FYMOLY_ICBOSS' AND i.value > 0 AND i.char_id=c.char_id ORDER BY i.value ASC LIMIT 10", $@moly02_n$, $@moly02_v); // Oddball: less is more .@nb = query_sql("SELECT c.name, i.value FROM `char_reg_num_db` AS i, `char` AS c WHERE i.key='FYMOLY_FLUFFY' AND i.char_id=c.char_id ORDER BY i.value DESC LIMIT 10", $@moly03_n$, $@moly03_v); @@ -246,7 +131,127 @@ OnHour1759: array_push($@moly_v, .@moly_v[.@t]); .@moly_v[.@t] = 0; } while (true); - end; + return; } +///////////////////////////////////////////////////////////////////////////////// +001-14,89,89,0 script Hocus Pocus NPC_BLACKWIZARD,{ + function showScores; + function parseScores; + if ($EVENT$ != "Olympics") cwarp "Save", 0, 0; + mesn; + mesq l("Greetings, %s %s, I am Hocus Pocus the Grandmaster.", academicrank(), strcharinfo(0)); + do + { + next; + select + l("Scoreboards"), + l("Detailed Information"), + l("Thanks for your wise words."); + mes ""; + switch (@menu) { + case 1: + showScores(); + break; + case 2: + mesn; + mesq l("The Magic Olympics consist in twelve challenges with scoreboards."); + next; + mesn; + mesq l("Getting ranked #1 in a challenge yields you 10 points, getting ranked #2 yields you 9 points and so on."); + next; + mesn; + mesq l("Not participating in a challenge yields you zero points. In case of a tie, char creation date will be the decisive factor: Older adventurers will get the preference."); + next; + mesn; + mesq l("You also get points for participation, exchange them with Aurora back in Tulimshar before event ends."); + next; + mesn; + mesq l("The grand winner will get a %s. Both the first and second place will get a tuition at the Magic Academy.", getitemlink(BlackyCat)); + next; + mesn; + mesq l("The Magic Olympics happen roughly quarterly, but not always at the same dates. It begins on a monday and ends on the sunday. It usually happens two weeks after the Mining Union Research Request event."); + break; + } + } while (@menu != 3); + close; + +function t { + return gettimetick(2); +} + +function showScores { + parseScores("General Event Score", "$@moly_n$", "$@moly_v"); + mesc l("Reminder: "), 1; + mesc l("Scores are updated every 6 hours."), 1; + next; + parseScores("Energy Balls Challenge", "$@moly01_n$", "$@moly01_v"); + //parseScores("Boss Fight Challenge", "$@moly02_n$", "$@moly02_v", 0); + //parseScores("Fluffy Hunt Challenge", "$@moly03_n$", "$@moly03_v"); + parseScores("Chanting Challenge", "$@moly04_n$", "$@moly04_v"); + parseScores("Alchemy Master Challenge", "$@moly05_n$", "$@moly05_v"); + parseScores("Magic Power Challenge", "$@moly06_n$", "$@moly06_v"); + parseScores("Mana Exp Challenge", "$@moly07_n$", "$@moly07_v"); + parseScores("Obstacle Race Challenge", "$@moly08_n$", "$@moly08_v", t()); + parseScores("Hocus Commands Challenge", "$@moly09_n$", "$@moly09_v"); + parseScores("Survive! Challenge", "$@moly10_n$", "$@moly10_v", t()); + parseScores("Friendship Challenge", "$@moly11_n$", "$@moly11_v"); + parseScores("Intensive Mage Challenge", "$@moly12_n$", "$@moly12_v"); + mes ""; + mesc l("Reminder: "), 1; + mesc l("Scores close at Sunday 23:59 - No scores will be given for last minute rushes!"), 1; + return; +} + +function SCH { + .@n$ = getarg(0); + .@i = getarg(1); + return getd(sprintf("%s[%d]", .@n$, .@i)); +} + +function parseScores { + .@t$ = getarg(0); + .@n$ = getarg(1); + .@v$ = getarg(2); + .@tm = getarg(3, -1); + mes ""; + mes l("##B%s: TOP 10##b", .@t$); + if (.@tm < 0) { + mes("1."+SCH(.@n$, 0)+" ("+fnum(SCH(.@v$, 0))+")"); + mes("2."+SCH(.@n$, 1)+" ("+fnum(SCH(.@v$, 1))+")"); + mes("3."+SCH(.@n$, 2)+" ("+fnum(SCH(.@v$, 2))+")"); + mes("4."+SCH(.@n$, 3)+" ("+fnum(SCH(.@v$, 3))+")"); + mes("5."+SCH(.@n$, 4)+" ("+fnum(SCH(.@v$, 4))+")"); + mes("6."+SCH(.@n$, 5)+" ("+fnum(SCH(.@v$, 5))+")"); + mes("7."+SCH(.@n$, 6)+" ("+fnum(SCH(.@v$, 6))+")"); + mes("8."+SCH(.@n$, 7)+" ("+fnum(SCH(.@v$, 7))+")"); + mes("9."+SCH(.@n$, 8)+" ("+fnum(SCH(.@v$, 8))+")"); + mes("10."+SCH(.@n$, 9)+" ("+fnum(SCH(.@v$, 9))+")"); + } else { + mes("1."+SCH(.@n$, 0)+" ("+FuzzyTime(.@tm - SCH(.@v$, 0))+")"); + mes("2."+SCH(.@n$, 1)+" ("+FuzzyTime(.@tm - SCH(.@v$, 1))+")"); + mes("3."+SCH(.@n$, 2)+" ("+FuzzyTime(.@tm - SCH(.@v$, 2))+")"); + mes("4."+SCH(.@n$, 3)+" ("+FuzzyTime(.@tm - SCH(.@v$, 3))+")"); + mes("5."+SCH(.@n$, 4)+" ("+FuzzyTime(.@tm - SCH(.@v$, 4))+")"); + mes("6."+SCH(.@n$, 5)+" ("+FuzzyTime(.@tm - SCH(.@v$, 5))+")"); + mes("7."+SCH(.@n$, 6)+" ("+FuzzyTime(.@tm - SCH(.@v$, 6))+")"); + mes("8."+SCH(.@n$, 7)+" ("+FuzzyTime(.@tm - SCH(.@v$, 7))+")"); + mes("9."+SCH(.@n$, 8)+" ("+FuzzyTime(.@tm - SCH(.@v$, 8))+")"); + mes("10."+SCH(.@n$, 9)+" ("+FuzzyTime(.@tm - SCH(.@v$, 9))+")"); + } + dnext; + return; +} + +OnInit: + .distance=5; +// Scoreboards are refreshed every 6 hours +OnHour2359: +OnHour0559: +OnHour1159: +OnHour1759: + if ($EVENT$ != "Olympics") end; + HocusScoreNew(); + end; +} -- cgit v1.2.3-60-g2f50