summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWushin <pasekei@gmail.com>2015-06-19 21:53:45 -0500
committerWushin <pasekei@gmail.com>2015-06-19 21:53:45 -0500
commit8b4faba9b55ea4a0f3c8f6e5cbcd5fcff3509247 (patch)
treeb80c2b15c93e5c705e1b75e51fdddaeb7b3e94c0
parent6a0c11388cb15cc94bffacaedce8b10f3ac2b6f8 (diff)
parent9cca1e384248bc6f043248066f5bcca284cc5403 (diff)
downloadtmwa-8b4faba9b55ea4a0f3c8f6e5cbcd5fcff3509247.tar.gz
tmwa-8b4faba9b55ea4a0f3c8f6e5cbcd5fcff3509247.tar.bz2
tmwa-8b4faba9b55ea4a0f3c8f6e5cbcd5fcff3509247.tar.xz
tmwa-8b4faba9b55ea4a0f3c8f6e5cbcd5fcff3509247.zip
Merge pull request #110 from mekolat/title
implement set title packet
-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 8b797c2..fd8498c 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -2660,6 +2660,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]
@@ -3130,6 +3140,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