int npc_enable(NpcName name, bool flag) { dumb_ptr<npc_data> nd = npc_name2id(name); if (nd == nullptr) { PRINTF("npc_enable(%s, %s) failed.\n"_fmt, name, flag ? "true"_s : "false"_s); return 0; } if (flag) { // 有効化 nd->flag &= ~1; clif_spawnnpc(nd); int xs = 0, ys = 0; if (dumb_ptr<npc_data_script> nd_ = nd->is_script()) { xs = nd_->scr.xs; ys = nd_->scr.ys; } if (flag && (xs > 0 || ys > 0)) map_foreachinarea(std::bind(npc_enable_sub, ph::_1, nd), nd->bl_m, nd->bl_x - xs, nd->bl_y - ys, nd->bl_x + xs, nd->bl_y + ys, BL::PC); } else if (!(nd->flag & 1)) { // 無効化 clif_clearchar(nd, BeingRemoveWhy::GONE); nd->flag |= 1; } return 0; }
int npc_delete(dumb_ptr<npc_data> nd) { nullpo_retr(1, nd); if (nd->bl_prev == nullptr) return 1; clif_clearchar(nd, BeingRemoveWhy::DEAD); map_delblock(nd); return 0; }