summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWushin <pasekei@gmail.com>2015-06-20 17:51:22 -0500
committerWushin <pasekei@gmail.com>2015-06-20 17:51:22 -0500
commitc399d19bda962e5dc2bf79998629d3ec279a9cd1 (patch)
treee428ef99dff34cfce275038af64eb367a489dbed
parent4835eae62fe129ff6ee36d82b56e07913ca19f81 (diff)
parent08809eeb1db043ac72ca8a64f74e9f5ed6a54631 (diff)
downloadtmwa-c399d19bda962e5dc2bf79998629d3ec279a9cd1.tar.gz
tmwa-c399d19bda962e5dc2bf79998629d3ec279a9cd1.tar.bz2
tmwa-c399d19bda962e5dc2bf79998629d3ec279a9cd1.tar.xz
tmwa-c399d19bda962e5dc2bf79998629d3ec279a9cd1.zip
Merge pull request #98 from mekolat/command
npc actions
-rw-r--r--src/map/clif.cpp65
-rw-r--r--src/map/clif.hpp3
-rw-r--r--src/map/map.hpp1
-rw-r--r--src/map/mapflag.cpp2
-rw-r--r--src/map/mapflag.hpp2
-rw-r--r--src/map/mapflag.py2
-rw-r--r--src/map/npc-parse.cpp15
-rw-r--r--src/map/pc.cpp3
-rw-r--r--src/map/script-fun.cpp94
-rwxr-xr-xtools/protocol.py17
10 files changed, 186 insertions, 18 deletions
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index d8e0b7e..35cc463 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
*------------------------------------------
@@ -1137,6 +1155,9 @@ void clif_changemap(dumb_ptr<map_session_data> sd, MapName mapname, int x, int y
fixed_91.x = x;
fixed_91.y = y;
send_fpacket<0x0091, 22>(s, fixed_91);
+
+ if(sd->bl_m->mask > 0)
+ clif_send_mask(sd, sd->bl_m->mask);
}
/*==========================================
@@ -3791,19 +3812,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)
@@ -3836,6 +3854,41 @@ 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);
+}
+
+void clif_send_mask(dumb_ptr<map_session_data> sd, int map_mask)
+{
+ nullpo_retv(sd);
+ if(sd->client_version < 2)
+ return;
+
+ Packet_Fixed<0x0226> fixed_226;
+ fixed_226.mask = map_mask;
+
+ Buffer buf = create_fpacket<0x0226, 10>(fixed_226);
+ send_buffer(sd->sess, buf);
+}
+
/*==========================================
*
*------------------------------------------
diff --git a/src/map/clif.hpp b/src/map/clif.hpp
index 8332fb9..28f58a9 100644
--- a/src/map/clif.hpp
+++ b/src/map/clif.hpp
@@ -106,6 +106,8 @@ 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);
+void clif_send_mask(dumb_ptr<map_session_data>, int);
// trade
void clif_traderequest(dumb_ptr<map_session_data> sd, CharName name);
@@ -178,6 +180,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/map.hpp b/src/map/map.hpp
index 2b638d4..aea35b7 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -505,6 +505,7 @@ struct map_local : map_abstract
MapFlags flag;
Point save;
Point resave;
+ int mask;
Array<dumb_ptr<npc_data>, MAX_NPC_PER_MAP> npc;
};
diff --git a/src/map/mapflag.cpp b/src/map/mapflag.cpp
index 9f3c9ab..22c4878 100644
--- a/src/map/mapflag.cpp
+++ b/src/map/mapflag.cpp
@@ -71,7 +71,7 @@ bool impl_extract(XString str, MapFlag *mf)
{"nowarp"_s, MapFlag::NOWARP},
{"nowarpto"_s, MapFlag::NOWARPTO},
{"nopvp"_s, MapFlag::NOPVP},
- //{"noicewall"_s, MapFlag::NOICEWALL},
+ {"mask"_s, MapFlag::MASK},
{"snow"_s, MapFlag::SNOW},
{"fog"_s, MapFlag::FOG},
{"sakura"_s, MapFlag::SAKURA},
diff --git a/src/map/mapflag.hpp b/src/map/mapflag.hpp
index 3538c56..9223d70 100644
--- a/src/map/mapflag.hpp
+++ b/src/map/mapflag.hpp
@@ -54,7 +54,7 @@ enum class MapFlag
NOWARP = 1 << 13,
NOWARPTO = 1 << 26,
NOPVP = 1 << 14,
- //NOICEWALL = 1 << 15,
+ MASK = 1 << 15,
SNOW = 1 << 16,
FOG = 1 << 17,
SAKURA = 1 << 18,
diff --git a/src/map/mapflag.py b/src/map/mapflag.py
index b0a2f24..728aa81 100644
--- a/src/map/mapflag.py
+++ b/src/map/mapflag.py
@@ -40,7 +40,7 @@ class MapFlags(object):
('NOWARP', 13),
('NOWARPTO', 26),
('NOPVP', 14),
- #('NOICEWALL', 15),
+ ('MASK', 15),
('SNOW', 16),
('FOG', 17),
('SAKURA', 18),
diff --git a/src/map/npc-parse.cpp b/src/map/npc-parse.cpp
index 0a0d682..9ee84d2 100644
--- a/src/map/npc-parse.cpp
+++ b/src/map/npc-parse.cpp
@@ -354,7 +354,7 @@ bool npc_load_mapflag(ast::npc::MapFlag& mapflag)
}
MapName savemap;
- int savex, savey;
+ int savex, savey, mask;
if (mf == MapFlag::NOSAVE)
{
@@ -392,6 +392,19 @@ bool npc_load_mapflag(ast::npc::MapFlag& mapflag)
return false;
}
}
+ else if (mf == MapFlag::MASK)
+ {
+ if (mapflag.vec_extra.data.size() == 1
+ && extract(mapflag.vec_extra.data[0].data, &mask))
+ {
+ m->mask = mask;
+ }
+ else
+ {
+ mapflag.vec_extra.span.error("Unable to extract map mask"_s);
+ return false;
+ }
+ }
else
{
if (mapflag.vec_extra.data.size())
diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index ca636b4..96233e1 100644
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -796,6 +796,9 @@ int pc_authok(AccountId id, int login_id2,
pc_calcstatus(sd, 1);
+ if(sd->bl_m->mask > 0)
+ clif_send_mask(sd, sd->bl_m->mask);
+
// Init Quest Log
clif_sendallquest(sd);
return 0;
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 520936b..2822550 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_;
@@ -2680,6 +2704,50 @@ void builtin_music(ScriptState *st)
clif_change_music(sd, msg);
}
+static
+void builtin_mapmask(ScriptState *st)
+{
+ dumb_ptr<npc_data> nd;
+ dumb_ptr<map_session_data> sd;
+ int map_mask = conv_num(st, &AARG(0));
+
+ if(st->oid)
+ nd = map_id_is_npc(st->oid);
+ if(st->rid)
+ sd = script_rid2sd(st);
+
+ if(HARG(1) && sd != nullptr)
+ sd->bl_m->mask = map_mask;
+ else if(HARG(1) && nd)
+ nd->bl_m->mask = map_mask;
+
+ if (sd == nullptr)
+ return;
+ clif_send_mask(sd, map_mask);
+}
+
+static
+void builtin_getmask(ScriptState *st)
+{
+ dumb_ptr<npc_data> nd;
+ dumb_ptr<map_session_data> sd;
+ int map_mask;
+
+ if(st->oid)
+ nd = map_id_is_npc(st->oid);
+ if(st->rid)
+ sd = script_rid2sd(st);
+
+ if(sd != nullptr)
+ map_mask = sd->bl_m->mask;
+ else if(nd)
+ map_mask = nd->bl_m->mask;
+ else
+ map_mask = -1;
+
+ push_int<ScriptDataInt>(st->stack, map_mask);
+}
+
/*==========================================
* npctalk (sends message to surrounding
* area) [Valaris]
@@ -2689,13 +2757,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);
}
/*==========================================
@@ -3103,6 +3182,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'),
@@ -3149,9 +3229,11 @@ 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(mapmask, "i?"_s, '\0'),
+ BUILTIN(getmask, ""_s, 'i'),
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 e3353de..f7be6e5 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'),
],
@@ -4703,7 +4703,20 @@ def build_context():
Send mob walkpath data to client
''',
)
- # 0x0226 define='SMSG_MAP_MASK',
+ map_user.s(0x0226, 'send map mask',
+ define='SMSG_MAP_MASK',
+ fixed=[
+ at(0, u16, 'packet id'),
+ at(2, u32, 'mask'),
+ at(6, u32, 'unused'),
+ ],
+ fixed_size=10,
+ pre=[NOTHING],
+ post=[PRETTY],
+ desc='''
+ Set map mask
+ ''',
+ )
map_user.s(0x0227, 'change map music',
define='SMSG_MAP_MUSIC',
head=[