diff options
author | mekolat <mekolat@users.noreply.github.com> | 2015-05-07 19:35:44 -0400 |
---|---|---|
committer | mekolat <mekolat@users.noreply.github.com> | 2015-05-19 16:00:59 -0400 |
commit | 6fd7eab6ba5d836c47847aca618ee02a50967072 (patch) | |
tree | 5b9f700da587944b915ba5b6b28cfdeeee4a9c25 /src | |
parent | 20cbf97dbaded8c2bead5b4f1a4838528c63a2a5 (diff) | |
download | tmwa-6fd7eab6ba5d836c47847aca618ee02a50967072.tar.gz tmwa-6fd7eab6ba5d836c47847aca618ee02a50967072.tar.bz2 tmwa-6fd7eab6ba5d836c47847aca618ee02a50967072.tar.xz tmwa-6fd7eab6ba5d836c47847aca618ee02a50967072.zip |
allow to make npcs sit
Diffstat (limited to 'src')
-rw-r--r-- | src/map/atcommand.cpp | 27 | ||||
-rw-r--r-- | src/map/clif.cpp | 43 | ||||
-rw-r--r-- | src/map/clif.hpp | 1 | ||||
-rw-r--r-- | src/map/map.hpp | 1 | ||||
-rw-r--r-- | src/map/npc-parse.cpp | 4 |
5 files changed, 58 insertions, 18 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); |