From 83a913ba19dbbcabf4d00b27d436fa6b56504881 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Fri, 16 Oct 2020 20:19:43 +0000 Subject: Jukebox This allows players to use @jukebox like @music anywhere And it also adds a classy Jukebox in Hurnscald PUB. First experiment with public functions, don't blame me if it breaks :p Low priority, adding to MR list in order to met deadlines. --- db/constants.conf | 1 + npc/008-2-2/_import.txt | 1 + npc/008-2-2/jukebox.txt | 29 +++++++++++++++++++++++++ npc/commands/music.txt | 17 +++++++++++++-- npc/functions/music.txt | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ npc/scripts.conf | 1 + 6 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 npc/008-2-2/jukebox.txt create mode 100644 npc/functions/music.txt diff --git a/db/constants.conf b/db/constants.conf index 551da2c3..51a00953 100644 --- a/db/constants.conf +++ b/db/constants.conf @@ -4968,6 +4968,7 @@ more than one separator can be used in a row (so 12_3___456 is illegal). NPC_ANWAR: 225 NPC_REBECCA: 226 NPC_PAULINE: 227 + NPC_JUKEBOX: 228 NPC_CONFUSED_TREE: 400 NPC_ALIGE: 401 diff --git a/npc/008-2-2/_import.txt b/npc/008-2-2/_import.txt index 34d628f7..92597add 100644 --- a/npc/008-2-2/_import.txt +++ b/npc/008-2-2/_import.txt @@ -2,6 +2,7 @@ // This file is generated automatically. All manually added changes will be removed when running the Converter. "npc/008-2-2/_warps.txt", "npc/008-2-2/barron.txt", +"npc/008-2-2/jukebox.txt", "npc/008-2-2/kfahr.txt", "npc/008-2-2/ledmitz.txt", "npc/008-2-2/mapflags.txt", diff --git a/npc/008-2-2/jukebox.txt b/npc/008-2-2/jukebox.txt new file mode 100644 index 00000000..6e592c8f --- /dev/null +++ b/npc/008-2-2/jukebox.txt @@ -0,0 +1,29 @@ +// The Mana World Script +// Author: +// Jesusalva +// Hocus Pocus Fidibus +// Description: +// Music box for a classy AFKing experience +// GMs can play on whole map but default to player only + +008-2-2,39,27,0 script #JukeboxHurns NPC_JUKEBOX,{ + mesc l("Select a music"); + .@track="jukebox"::HurnscaldPrompt(); + .@global=ASK_NO; + if (is_evtc()) { + mes "Play music globally?"; + mes "* Selecting \"No\" will play only to yourself (default behavior)"; + .@global=askyesno(); + } + if (.@global == ASK_YES) + "jukebox"::BroadcastMusic(getmap(), .@track); + else + "jukebox"::JukeboxMusic(.@track); + close; + +OnInit: + .distance = 3; + end; +} + + diff --git a/npc/commands/music.txt b/npc/commands/music.txt index e794060f..d2578d1a 100644 --- a/npc/commands/music.txt +++ b/npc/commands/music.txt @@ -21,9 +21,9 @@ OnCall: } // TODO: tmw-like argv splitter - getmapxy .@map$, .@void, .@void, UNITTYPE_PC; // get map + .@map$ = getmap(); - .@key$ = .@atcmd_parameters$[0]; + .@key$ = strtolower(.@atcmd_parameters$[0]); .@m$ = htget(.hash, .@key$, "Not found"); if (.@m$ == "Not found") @@ -34,8 +34,21 @@ OnCall: changemusic .@map$, .@m$ + ".ogg"; end; +OnMyself: + .@key$ = strtolower(.@atcmd_parameters$[0]); + .@m$ = htget(.hash, .@key$, "Not found"); + + if (.@m$ == "Not found") + { + .@m$ = implode(.@atcmd_parameters$[0], " "); + } + + changeplayermusic .@m$ + ".ogg"; + end; + OnInit: bindatcmd "music", "@music::OnCall", 0, 99, 1; + bindatcmd "jukebox", "@music::OnMyself", 0, 50, 0; .hash = htnew; // create hashtable htput(.hash, "forest", "bartk - in the forest of the birches"); diff --git a/npc/functions/music.txt b/npc/functions/music.txt new file mode 100644 index 00000000..c8937583 --- /dev/null +++ b/npc/functions/music.txt @@ -0,0 +1,57 @@ +// The Mana World Script +// Author: +// Jesusalva +// Gumi +// Description: +// Music functions +// +// NOTE: This NPC uses the new public/private function call system to avoid +// the use of doevent. +// Syntax: +// "jukebox"::HurnscaldPrompt(); → Makes a menuint for selecting hurns tracks +// "jukebox"::JukeboxMusic(ID); → Changes music based on prompted ID +// "jukebox"::BroadcastMusic(MAP, ID); → Changes music based on prompted ID + +- script jukebox 32767,{ + end; + +// Helpers +public function JukeboxMusic { + changeplayermusic .MUSIC_ARRAY[getarg(0)]; + return; +} + +public function BroadcastMusic { + changemusic getarg(0), .MUSIC_ARRAY[getarg(1)]; + return; +} + +// public function listing +// * Hurnscald + +public function HurnscaldPrompt { + menuint + "Cancel", -1, + "Forest of Birches", 0, + "Adventure Begins", 1, + "Magick Real", 5; + mes ""; + if (@menuret == -1) + close; + return @menuret; +} + +// Initialize stuff which will be needed +OnInit: + .MUSIC_ARRAY[0] = "bartk - in the forest of the birches.ogg"; + .MUSIC_ARRAY[1] = "bartk - the adventure begins.ogg"; + .MUSIC_ARRAY[2] = "eric matyas - ghoulish fun.ogg"; + .MUSIC_ARRAY[3] = "eric matyas - surreal place.ogg"; + .MUSIC_ARRAY[4] = "ezili - ocean sounds.ogg"; + .MUSIC_ARRAY[5] = "magick - real.ogg"; + end; +} + + + + diff --git a/npc/scripts.conf b/npc/scripts.conf index 1ce33c7e..6f275056 100644 --- a/npc/scripts.conf +++ b/npc/scripts.conf @@ -65,6 +65,7 @@ "npc/functions/lockpicks.txt", "npc/functions/crafting.txt", "npc/functions/referral.txt", +"npc/functions/music.txt", // quest debug "npc/functions/quest-debug/functions.txt", -- cgit v1.2.3-60-g2f50