summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/clif.cpp14
-rw-r--r--src/map/clif.hpp1
-rw-r--r--src/map/script-fun.cpp11
-rwxr-xr-xtools/protocol.py20
4 files changed, 45 insertions, 1 deletions
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<block_list> 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<npc_data> nd, DamageType dmg);
void clif_sitnpc_towards(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data> nd, DamageType dmg);
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);
// 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 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<map_session_data> 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'),
diff --git a/tools/protocol.py b/tools/protocol.py
index 86b625f..eae8bb2 100755
--- a/tools/protocol.py
+++ b/tools/protocol.py
@@ -4679,7 +4679,25 @@ def build_context():
)
# 0x0226 define='SMSG_MAP_MASK',
# 0x0227 define='SMSG_MAP_MUSIC',
- # 0x0228 define='SMSG_NPC_CHANGETITLE',
+ map_user.s(0x0228, 'npc change title',
+ define='SMSG_NPC_CHANGETITLE',
+ head=[
+ at(0, u16, 'packet id'),
+ at(2, u16, 'packet length'),
+ at(4, block_id, 'npc id'),
+ at(8, u16, 'string length'),
+ ],
+ head_size=10,
+ repeat=[
+ at(0, u8, 'c'),
+ ],
+ repeat_size=1,
+ pre=[NOTHING],
+ post=[PRETTY],
+ desc='''
+ Change npc title
+ ''',
+ )
# TOC_LOGINCHAR
# login char