diff options
author | mekolat <mekolat@users.noreply.github.com> | 2015-05-23 10:17:10 -0400 |
---|---|---|
committer | mekolat <mekolat@users.noreply.github.com> | 2015-06-20 06:49:37 -0400 |
commit | ef9eb6bde90ec1d9d175b6481935cb3bd67d6c6c (patch) | |
tree | 2deb6c5804f9dae3157848f775e9a2ed233d3db0 | |
parent | db20d783fe41bb9b44b92461f9843a31146a5ce7 (diff) | |
download | tmwa-ef9eb6bde90ec1d9d175b6481935cb3bd67d6c6c.tar.gz tmwa-ef9eb6bde90ec1d9d175b6481935cb3bd67d6c6c.tar.bz2 tmwa-ef9eb6bde90ec1d9d175b6481935cb3bd67d6c6c.tar.xz tmwa-ef9eb6bde90ec1d9d175b6481935cb3bd67d6c6c.zip |
add clif_message_towards
-rw-r--r-- | src/map/clif.cpp | 31 | ||||
-rw-r--r-- | src/map/clif.hpp | 1 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 23 |
3 files changed, 43 insertions, 12 deletions
diff --git a/src/map/clif.cpp b/src/map/clif.cpp index 73315d8..db5ecd2 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -3809,19 +3809,16 @@ RecvResult clif_parse_GlobalMessage(Session *s, dumb_ptr<map_session_data> sd) return rv; } -void clif_message(dumb_ptr<block_list> bl, XString msg) +static +void clif_message_sub(Buffer& buf, dumb_ptr<block_list> bl, XString msg) { size_t msg_len = msg.size() + 1; if (msg_len + 16 > 512) return; - nullpo_retv(bl); - Packet_Head<0x008d> head_8d; head_8d.block_id = bl->bl_id; - Buffer buf = create_vpacket<0x008d, 8, 1>(head_8d, msg); - - clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); + buf = create_vpacket<0x008d, 8, 1>(head_8d, msg); } void clif_npc_send_title(Session *s, BlockId npcid, XString msg) @@ -3854,6 +3851,28 @@ void clif_change_music(dumb_ptr<map_session_data> sd, XString music) send_buffer(sd->sess, buf); } +void clif_message_towards(dumb_ptr<map_session_data> sd, dumb_ptr<block_list> bl, XString msg) +{ + nullpo_retv(bl); + nullpo_retv(sd); + + if(!sd) + return; + + Buffer buf; + clif_message_sub(buf, bl, msg); + clif_send(buf, sd, SendWho::SELF, MIN_CLIENT_VERSION); +} + +void clif_message(dumb_ptr<block_list> bl, XString msg) +{ + nullpo_retv(bl); + + Buffer buf; + clif_message_sub(buf, bl, msg); + clif_send(buf, bl, SendWho::AREA, MIN_CLIENT_VERSION); +} + /*========================================== * *------------------------------------------ diff --git a/src/map/clif.hpp b/src/map/clif.hpp index 99d4a2c..cd499de 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -179,6 +179,7 @@ void clif_resurrection(dumb_ptr<block_list> bl, int type); int clif_specialeffect(dumb_ptr<block_list> bl, int type, int flag); // special effects [Valaris] void clif_message(dumb_ptr<block_list> bl, XString msg); // messages (from mobs/npcs) [Valaris] +void clif_message_towards(dumb_ptr<map_session_data> sd, dumb_ptr<block_list> bl, XString msg); int clif_GM_kick(dumb_ptr<map_session_data> sd, dumb_ptr<map_session_data> tsd, int type); diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp index 0d19770..2b72fc4 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -2713,13 +2713,24 @@ void builtin_music(ScriptState *st) static void builtin_npctalk(ScriptState *st) { - dumb_ptr<npc_data> nd = map_id_is_npc(st->oid); - RString str = conv_str(st, &AARG(0)); + dumb_ptr<npc_data> nd; + RString str = conv_str(st, &AARG(1)); - if (nd) - { - clif_message(nd, str); + dumb_ptr<npc_data> nd_ = npc_name2id(stringish<NpcName>(ZString(conv_str(st, &AARG(0))))); + assert (nd_ && nd_->npc_subtype == NpcSubtype::SCRIPT); + nd = nd_->is_script(); + + + if(HARG(2)){ + CharName player = stringish<CharName>(ZString(conv_str(st, &AARG(2)))); + dumb_ptr<map_session_data> pl_sd = map_nick2sd(player); + if (pl_sd == nullptr) + return; + clif_message_towards(pl_sd, nd, str); } + + else + clif_message(nd, str); } /*========================================== @@ -3174,7 +3185,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(npcwarp, "xys"_s, '\0'), BUILTIN(npcareawarp, "xyxyis"_s, '\0'), BUILTIN(message, "Ps"_s, '\0'), - BUILTIN(npctalk, "s"_s, '\0'), + BUILTIN(npctalk, "ss?"_s, '\0'), BUILTIN(title, "s"_s, '\0'), BUILTIN(music, "s"_s, '\0'), BUILTIN(getlook, "i"_s, 'i'), |