From 9cca1e384248bc6f043248066f5bcca284cc5403 Mon Sep 17 00:00:00 2001 From: mekolat Date: Fri, 22 May 2015 09:57:15 -0400 Subject: implement set title packet --- src/map/clif.cpp | 14 ++++++++++++++ src/map/clif.hpp | 1 + src/map/script-fun.cpp | 11 +++++++++++ 3 files changed, 26 insertions(+) (limited to 'src/map') diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 248f74a..6f55f73 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -3782,6 +3782,20 @@ void clif_message(dumb_ptr bl, XString msg) clif_send(buf, bl, SendWho::AREA); } +void clif_npc_send_title(Session *s, BlockId npcid, XString msg) +{ + size_t msg_len = msg.size() + 1; + if (msg_len > 50) + return; + + Packet_Head<0x0228> head_228; + head_228.npc_id = npcid; + head_228.string_length = msg_len; + Buffer buf = create_vpacket<0x0228, 10, 1>(head_228, msg); + + send_buffer(s, buf); +} + /*========================================== * *------------------------------------------ diff --git a/src/map/clif.hpp b/src/map/clif.hpp index 3cc308c..f067017 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -102,6 +102,7 @@ void clif_sitnpc(dumb_ptr nd, DamageType dmg); void clif_sitnpc_towards(dumb_ptr sd, dumb_ptr nd, DamageType dmg); void clif_setnpcdirection(dumb_ptr nd, DIR direction); void clif_setnpcdirection_towards(dumb_ptr sd, dumb_ptr nd, DIR direction); +void clif_npc_send_title(Session *s, BlockId npcid, XString msg); // trade void clif_traderequest(dumb_ptr sd, CharName name); diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 3949627..4ef480a 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2675,6 +2675,16 @@ void builtin_message(ScriptState *st) } +static +void builtin_title(ScriptState *st) +{ + dumb_ptr sd = script_rid2sd(st); + ZString msg = ZString(conv_str(st, &AARG(0))); + if (sd == nullptr) + return; + clif_npc_send_title(sd->sess, st->oid, msg); +} + /*========================================== * npctalk (sends message to surrounding * area) [Valaris] @@ -3145,6 +3155,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(npcareawarp, "xyxyis"_s, '\0'), BUILTIN(message, "Ps"_s, '\0'), BUILTIN(npctalk, "s"_s, '\0'), + BUILTIN(title, "s"_s, '\0'), BUILTIN(getlook, "i"_s, 'i'), BUILTIN(getsavepoint, "i"_s, '.'), BUILTIN(areatimer, "MxyxytE"_s, '\0'), -- cgit v1.2.3-60-g2f50