From 6fd7eab6ba5d836c47847aca618ee02a50967072 Mon Sep 17 00:00:00 2001 From: mekolat Date: Thu, 7 May 2015 19:35:44 -0400 Subject: allow to make npcs sit --- src/map/atcommand.cpp | 27 +++++++++++++++++++++++++++ src/map/clif.cpp | 43 +++++++++++++++++++++++++------------------ src/map/clif.hpp | 1 + src/map/map.hpp | 1 + src/map/npc-parse.cpp | 4 ++++ 5 files changed, 58 insertions(+), 18 deletions(-) (limited to 'src/map') 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 @@ -4156,6 +4156,30 @@ ATCE atcommand_npcmove(Session *, dumb_ptr, return ATCE::OKAY; } +static +ATCE atcommand_npcsit(Session *, dumb_ptr sd, + ZString message) +{ + NpcName character; + dumb_ptr 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 sd, ZString message) @@ -5267,6 +5291,9 @@ Map atcommand_info = {"npcmove"_s, {" "_s, 80, atcommand_npcmove, "Force an NPC to move on the map"_s}}, + {"npcsit"_s, {""_s, + 80, atcommand_npcsit, + "Force an NPC to move on the map"_s}}, {"charpvp"_s, {" "_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 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 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 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 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 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(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 sd, dumb_ptr 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 sd) clif_send(buf, sd, SendWho::AREA); } +void clif_sitnpc(dumb_ptr sd, dumb_ptr 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, IOff0, int, int); // self void clif_emotion(dumb_ptr bl, int type); void clif_emotion_towards(dumb_ptr bl, dumb_ptr target, int type); void clif_sitting(Session *, dumb_ptr sd); +void clif_sitnpc(dumb_ptr sd, dumb_ptr nd, bool area); // trade void clif_traderequest(dumb_ptr 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); -- cgit v1.2.3-70-g09d2