diff options
author | mekolat <mekolat@users.noreply.github.com> | 2015-05-21 19:17:03 -0400 |
---|---|---|
committer | mekolat <mekolat@users.noreply.github.com> | 2015-06-20 06:41:30 -0400 |
commit | db20d783fe41bb9b44b92461f9843a31146a5ce7 (patch) | |
tree | f22254f43e8414c2a2a06514a7108ecb917b4b31 | |
parent | 4835eae62fe129ff6ee36d82b56e07913ca19f81 (diff) | |
download | tmwa-db20d783fe41bb9b44b92461f9843a31146a5ce7.tar.gz tmwa-db20d783fe41bb9b44b92461f9843a31146a5ce7.tar.bz2 tmwa-db20d783fe41bb9b44b92461f9843a31146a5ce7.tar.xz tmwa-db20d783fe41bb9b44b92461f9843a31146a5ce7.zip |
npc actions
-rw-r--r-- | src/map/clif.cpp | 18 | ||||
-rw-r--r-- | src/map/clif.hpp | 1 | ||||
-rw-r--r-- | src/map/script-fun.cpp | 25 | ||||
-rwxr-xr-x | tools/protocol.py | 2 |
4 files changed, 45 insertions, 1 deletions
diff --git a/src/map/clif.cpp b/src/map/clif.cpp index d8e0b7e..73315d8 100644 --- a/src/map/clif.cpp +++ b/src/map/clif.cpp @@ -800,6 +800,24 @@ void clif_mob0078(dumb_ptr<mob_data> md, Buffer& buf) buf = create_fpacket<0x0078, 54>(fixed_78); } +void clif_npc_action(dumb_ptr<map_session_data> sd, BlockId npcid, + short command, int id, short x, short y) +{ + nullpo_retv(sd); + if(sd->client_version < 2) + return; + + Packet_Fixed<0x0212> fixed_212; + fixed_212.npc_id = npcid; + fixed_212.command = command; + fixed_212.id = id; + fixed_212.x = x; + fixed_212.y = y; + + Buffer buf = create_fpacket<0x0212, 16>(fixed_212); + send_buffer(sd->sess, buf); +} + /*========================================== * MOB表示2 *------------------------------------------ diff --git a/src/map/clif.hpp b/src/map/clif.hpp index 8332fb9..99d4a2c 100644 --- a/src/map/clif.hpp +++ b/src/map/clif.hpp @@ -106,6 +106,7 @@ 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); +void clif_npc_action(dumb_ptr<map_session_data>, BlockId, short, int, short, short); // 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 520936b..0d19770 100644 --- a/src/map/script-fun.cpp +++ b/src/map/script-fun.cpp @@ -1615,6 +1615,30 @@ void builtin_setnpctimer(ScriptState *st) } static +void builtin_npcaction(ScriptState *st) +{ + dumb_ptr<map_session_data> sd = script_rid2sd(st); + short command = conv_num(st, &AARG(0)); + int id = 0; + short x = HARG(2) ? conv_num(st, &AARG(2)) : 0; + short y = HARG(3) ? conv_num(st, &AARG(3)) : 0; + + if(HARG(1)) + { + if(command == 2) + { + dumb_ptr<npc_data> nd_; + nd_ = npc_name2id(stringish<NpcName>(ZString(conv_str(st, &AARG(1))))); + id = unwrap<BlockId>(nd_->bl_id); + } + else + id = conv_num(st, &AARG(1)); + } + + clif_npc_action(sd, st->oid, command, id, x, y); +} + +static void builtin_setnpcdirection(ScriptState *st) { dumb_ptr<npc_data> nd_; @@ -3103,6 +3127,7 @@ BuiltinFunction builtin_functions[] = BUILTIN(getnpctimer, "i?"_s, 'i'), BUILTIN(setnpctimer, "i?"_s, '\0'), BUILTIN(setnpcdirection, "iii?"_s, '\0'), + BUILTIN(npcaction, "i???"_s, '\0'), BUILTIN(announce, "si"_s, '\0'), BUILTIN(mapannounce, "Msi"_s, '\0'), BUILTIN(getusers, "i"_s, 'i'), diff --git a/tools/protocol.py b/tools/protocol.py index e3353de..23a0719 100755 --- a/tools/protocol.py +++ b/tools/protocol.py @@ -4631,7 +4631,7 @@ def build_context(): at(0, u16, 'packet id'), at(2, block_id, 'npc id'), at(6, u16, 'command'), - at(8, block_id, 'id'), + at(8, u32, 'id'), at(12, u16, 'x'), at(14, u16, 'y'), ], |