diff options
-rw-r--r-- | src/map/clif.cpp | 16 | ||||
-rw-r--r-- | src/map/clif.hpp | 1 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 11 | ||||
-rwxr-xr-x | tools/protocol.py | 18 |
4 files changed, 45 insertions, 1 deletions
diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 75c6752..d8e0b7e 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -3820,6 +3820,22 @@ void clif_npc_send_title(Session *s, BlockId npcid, XString msg) send_buffer(s, buf); } +void clif_change_music(dumb_ptr<map_session_data> sd, XString music) +{ + nullpo_retv(sd); + if(sd->client_version < 2) + return; + + size_t msg_len = music.size(); + if (msg_len > 128) + return; + + Packet_Head<0x0227> head_227; + Buffer buf = create_vpacket<0x0227, 4, 1>(head_227, music); + + send_buffer(sd->sess, buf); +} + /*========================================== * *------------------------------------------ diff --git a/src/map/clif.hpp b/src/map/clif.hpp index ccfab08..8332fb9 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -105,6 +105,7 @@ void clif_sitnpc_towards(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data> nd, D void clif_setnpcdirection(dumb_ptr<npc_data> nd, DIR direction); void clif_setnpcdirection_towards(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data> nd, DIR direction); void clif_npc_send_title(Session *s, BlockId npcid, XString msg); +void clif_change_music(dumb_ptr<map_session_data> sd, XString music); // trade void clif_traderequest(dumb_ptr<map_session_data> sd, CharName name); diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index fd8498c..520936b 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2670,6 +2670,16 @@ void builtin_title(ScriptState *st) clif_npc_send_title(sd->sess, st->oid, msg); } +static +void builtin_music(ScriptState *st) +{ + dumb_ptr<map_session_data> sd = script_rid2sd(st); + ZString msg = ZString(conv_str(st, &AARG(0))); + if (sd == nullptr) + return; + clif_change_music(sd, msg); +} + /*========================================== * npctalk (sends message to surrounding * area) [Valaris] @@ -3141,6 +3151,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(message, "Ps"_s, '\0'), BUILTIN(npctalk, "s"_s, '\0'), BUILTIN(title, "s"_s, '\0'), + BUILTIN(music, "s"_s, '\0'), BUILTIN(getlook, "i"_s, 'i'), BUILTIN(getsavepoint, "i"_s, '.'), BUILTIN(areatimer, "MxyxytE"_s, '\0'), diff --git a/tools/protocol.py b/tools/protocol.py index f6612f8..e3353de 100755 --- a/tools/protocol.py +++ b/tools/protocol.py @@ -4704,7 +4704,23 @@ def build_context(): ''', ) # 0x0226 define='SMSG_MAP_MASK', - # 0x0227 define='SMSG_MAP_MUSIC', + map_user.s(0x0227, 'change map music', + define='SMSG_MAP_MUSIC', + head=[ + at(0, u16, 'packet id'), + at(2, u16, 'packet length'), + ], + head_size=4, + repeat=[ + at(0, u8, 'c'), + ], + repeat_size=1, + pre=[NOTHING], + post=[PRETTY], + desc=''' + Change map music + ''', + ) map_user.s(0x0228, 'npc change title', define='SMSG_NPC_CHANGETITLE', head=[ |