summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormekolat <mekolat@users.noreply.github.com>2015-05-07 19:35:44 -0400
committermekolat <mekolat@users.noreply.github.com>2015-05-19 16:00:59 -0400
commit6fd7eab6ba5d836c47847aca618ee02a50967072 (patch)
tree5b9f700da587944b915ba5b6b28cfdeeee4a9c25
parent20cbf97dbaded8c2bead5b4f1a4838528c63a2a5 (diff)
downloadtmwa-6fd7eab6ba5d836c47847aca618ee02a50967072.tar.gz
tmwa-6fd7eab6ba5d836c47847aca618ee02a50967072.tar.bz2
tmwa-6fd7eab6ba5d836c47847aca618ee02a50967072.tar.xz
tmwa-6fd7eab6ba5d836c47847aca618ee02a50967072.zip
allow to make npcs sit
-rw-r--r--src/map/atcommand.cpp27
-rw-r--r--src/map/clif.cpp43
-rw-r--r--src/map/clif.hpp1
-rw-r--r--src/map/map.hpp1
-rw-r--r--src/map/npc-parse.cpp4
-rwxr-xr-xtools/protocol.py36
6 files changed, 77 insertions, 35 deletions
diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp
index 63a1159..d587bde 100644
--- a/src/map/atcommand.cpp
+++ b/src/map/atcommand.cpp
@@ -4157,6 +4157,30 @@ ATCE atcommand_npcmove(Session *, dumb_ptr<map_session_data>,
}
static
+ATCE atcommand_npcsit(Session *, dumb_ptr<map_session_data> sd,
+ ZString message)
+{
+ NpcName character;
+ dumb_ptr<npc_data> nd = nullptr;
+
+ if (!asplit(message, &character))
+ return ATCE::USAGE;
+
+ nd = npc_name2id(character);
+ if (nd == nullptr)
+ return ATCE::EXIST;
+
+ if(nd->sit == DamageType::SIT)
+ nd->sit = DamageType::STAND;
+ else
+ nd->sit = DamageType::SIT;
+
+ clif_sitnpc(sd, nd, true);
+
+ return ATCE::OKAY;
+}
+
+static
ATCE atcommand_addwarp(Session *s, dumb_ptr<map_session_data> sd,
ZString message)
{
@@ -5267,6 +5291,9 @@ Map<XString, AtCommandInfo> atcommand_info =
{"npcmove"_s, {"<x> <y> <npc-name>"_s,
80, atcommand_npcmove,
"Force an NPC to move on the map"_s}},
+ {"npcsit"_s, {"<npc-name>"_s,
+ 80, atcommand_npcsit,
+ "Force an NPC to move on the map"_s}},
{"charpvp"_s, {"<charname> <channel>"_s,
40, atcommand_charpvp,
"Set the pvp channel of another player"_s}},
diff --git a/src/map/clif.cpp b/src/map/clif.cpp
index 897244e..e48b2fd 100644
--- a/src/map/clif.cpp
+++ b/src/map/clif.cpp
@@ -781,10 +781,6 @@ void clif_mob0078(dumb_ptr<mob_data> md, Buffer& buf)
fixed_78.pos.x = md->bl_x;
fixed_78.pos.y = md->bl_y;
fixed_78.pos.dir = md->dir;
- fixed_78.five1 = 5;
- fixed_78.five2 = 5;
- int level = battle_get_lv(md);
- fixed_78.level = (level > battle_config.max_lv) ? battle_config.max_lv : level;
buf = create_fpacket<0x0078, 54>(fixed_78);
}
@@ -884,11 +880,6 @@ void clif_npc0078(dumb_ptr<npc_data> nd, Buffer& buf)
fixed_78.pos.x = nd->bl_x;
fixed_78.pos.y = nd->bl_y;
fixed_78.pos.dir = nd->dir;
- fixed_78.five1 = 5;
- fixed_78.five2 = 5;
- fixed_78.zero = 0;
- fixed_78.level = 0;
-
buf = create_fpacket<0x0078, 54>(fixed_78);
}
@@ -951,7 +942,7 @@ int clif_spawnnpc(dumb_ptr<npc_data> nd)
if (nd->flag & 1 || nd->npc_class == INVISIBLE_CLASS)
return 0;
-
+ /* manaplus is skipping this packet
Packet_Fixed<0x007c> fixed_7c;
fixed_7c.block_id = nd->bl_id;
fixed_7c.speed = nd->speed;
@@ -961,10 +952,14 @@ int clif_spawnnpc(dumb_ptr<npc_data> nd)
Buffer buf = create_fpacket<0x007c, 41>(fixed_7c);
clif_send(buf, nd, SendWho::AREA);
-
+ */
+ Buffer buf;
clif_npc0078(nd, buf);
clif_send(buf, nd, SendWho::AREA);
+ if(nd->sit == DamageType::SIT)
+ clif_sitnpc(nullptr, nd, true);
+
return 0;
}
@@ -995,15 +990,8 @@ int clif_spawn_fake_npc_for_player(dumb_ptr<map_session_data> sd, BlockId fake_n
fixed_78.opt2 = Opt2::ZERO;
fixed_78.option = Opt0::ZERO;
fixed_78.species = FAKE_NPC_CLASS;
- fixed_78.unused_head_bottom_or_species_again = unwrap<Species>(FAKE_NPC_CLASS);
fixed_78.pos.x = sd->bl_x;
fixed_78.pos.y = sd->bl_y;
- fixed_78.unused_pos_again.x = sd->bl_x;
- fixed_78.unused_pos_again.y = sd->bl_y;
- fixed_78.five1 = 5;
- fixed_78.five2 = 5;
- fixed_78.zero = 0;
- fixed_78.level = 0;
send_fpacket<0x0078, 54>(s, fixed_78);
return 0;
@@ -2374,6 +2362,9 @@ void clif_getareachar_npc(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data> nd)
Buffer buf;
clif_npc0078(nd, buf);
send_buffer(sd->sess, buf);
+
+ if(nd->sit == DamageType::SIT)
+ clif_sitnpc(sd, nd, false);
}
/*==========================================
@@ -3190,6 +3181,22 @@ void clif_sitting(Session *, dumb_ptr<map_session_data> sd)
clif_send(buf, sd, SendWho::AREA);
}
+void clif_sitnpc(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data> nd, bool area)
+{
+ nullpo_retv(nd);
+ nullpo_retv(sd);
+
+ Packet_Fixed<0x008a> fixed_8a;
+ fixed_8a.src_id = nd->bl_id;
+ fixed_8a.damage_type = nd->sit;
+ Buffer buf = create_fpacket<0x008a, 29>(fixed_8a);
+
+ if(area)
+ clif_send(buf, nd, SendWho::AREA);
+ else if(sd)
+ clif_send(buf, sd, SendWho::SELF);
+}
+
/*==========================================
*
*------------------------------------------
diff --git a/src/map/clif.hpp b/src/map/clif.hpp
index 5117ff3..862aed9 100644
--- a/src/map/clif.hpp
+++ b/src/map/clif.hpp
@@ -98,6 +98,7 @@ int clif_useitemack(dumb_ptr<map_session_data>, IOff0, int, int); // self
void clif_emotion(dumb_ptr<block_list> bl, int type);
void clif_emotion_towards(dumb_ptr<block_list> bl, dumb_ptr<block_list> target, int type);
void clif_sitting(Session *, dumb_ptr<map_session_data> sd);
+void clif_sitnpc(dumb_ptr<map_session_data> sd, dumb_ptr<npc_data> nd, bool area);
// trade
void clif_traderequest(dumb_ptr<map_session_data> sd, CharName name);
diff --git a/src/map/map.hpp b/src/map/map.hpp
index ce434fa..b5f8566 100644
--- a/src/map/map.hpp
+++ b/src/map/map.hpp
@@ -324,6 +324,7 @@ struct npc_data : block_list
short n;
Species npc_class;
DIR dir;
+ DamageType sit;
interval_t speed;
NpcName name;
Opt1 opt1;
diff --git a/src/map/npc-parse.cpp b/src/map/npc-parse.cpp
index 4d9fcbd..0a0d682 100644
--- a/src/map/npc-parse.cpp
+++ b/src/map/npc-parse.cpp
@@ -152,6 +152,7 @@ bool npc_load_warp(ast::npc::Warp& warp)
nd->bl_y = y;
nd->dir = DIR::S;
nd->flag = 0;
+ nd->sit = DamageType::STAND;
nd->name = warp.name.data;
nd->npc_class = WARP_CLASS;
@@ -233,6 +234,7 @@ bool npc_load_shop(ast::npc::Shop& shop)
nd->bl_id = npc_get_new_npc_id();
nd->dir = dir;
nd->flag = 0;
+ nd->sit = DamageType::STAND;
nd->name = shop.name.data;
nd->npc_class = npc_class;
nd->speed = 200_ms;
@@ -446,6 +448,7 @@ bool npc_load_script_none(ast::script::ScriptBody& body, ast::npc::ScriptNone& s
nd->bl_id = npc_get_new_npc_id();
nd->dir = DIR::S;
nd->flag = 0;
+ nd->sit = DamageType::STAND;
nd->npc_class = INVISIBLE_CLASS;
nd->speed = 200_ms;
nd->scr.script = std::move(script);
@@ -567,6 +570,7 @@ bool npc_load_script_map(ast::script::ScriptBody& body, ast::npc::ScriptMap& scr
nd->bl_id = npc_get_new_npc_id();
nd->dir = dir;
nd->flag = 0;
+ nd->sit = DamageType::STAND;
nd->npc_class = npc_class;
nd->speed = 200_ms;
nd->scr.script = std::move(script);
diff --git a/tools/protocol.py b/tools/protocol.py
index f13d627..e15d5f0 100755
--- a/tools/protocol.py
+++ b/tools/protocol.py
@@ -2249,27 +2249,29 @@ def build_context():
at(10, opt2, 'opt2'),
at(12, option, 'option'),
at(14, species, 'species'),
- at(16, u16, 'unused hair style'),
+ at(16, u8, 'unused hair style'),
+ at(17, u8, 'unused look'),
at(18, u16, 'unused weapon'),
- at(20, u16, 'unused head bottom or species again'),
- at(22, u16, 'unused shield or part of guild emblem'),
- at(24, u16, 'unused head top or unused part of guild emblem'),
- at(26, u16, 'unused head mid or part of guild id'),
- at(28, u16, 'unused hair color or part of guild id'),
+ at(20, u16, 'unused head bottom'),
+ at(22, u16, 'unused shield'),
+ at(24, u16, 'unused head top'),
+ at(26, u16, 'unused head mid'),
+ at(28, u8, 'unused hair color'),
+ at(29, u8, 'unused'),
at(30, u16, 'unused clothes color'),
- at(32, u16, 'unused 1'),
- at(34, u16, 'unused 2'),
- at(36, pos1, 'unused pos again'),
- at(39, u8, 'unused 4b'),
- at(40, u16, 'unused 5'),
- at(42, u16, 'unused zero 1'),
- at(44, u8, 'unused zero 2'),
+ at(32, u16, 'unused gloves'),
+ at(34, u32, 'unused guild id'),
+ at(38, u16, 'unused guild emblem id'),
+ at(40, u16, 'unused manner'),
+ at(42, u16, 'unused opt3'),
+ at(44, u8, 'unused karma or atk range'),
at(45, u8, 'unused sex'),
at(46, pos1, 'pos'),
- at(49, u8, 'five1'),
- at(50, u8, 'five2'),
- at(51, u8, 'zero'),
- at(52, u16, 'level'),
+ at(49, u8, 'unused2'),
+ at(50, u8, 'unused3'),
+ at(51, u8, 'unused4'),
+ at(52, u8, 'unused5'),
+ at(53, u8, 'unused6'),
],
fixed_size=54,
pre=[BOOT, FINISH, GM, MAGIC, SCRIPT, TIMER, 0x007d, 0x0085, 0x0089, 0x008c, 0x009f, 0x00b8, 0x00b9, 0x00e6, 0x00f7, 0x0143, 0x0146, 0x01d5],