// Separate function used for reloading void instance_addnpc(struct instance_data *im) { int i; // First add the NPCs for(i = 0; i < im->cnt_map; i++) map_foreachinarea(instance_addnpc_sub, im->map[i].src_m, 0, 0, map[im->map[i].src_m].xs, map[im->map[i].src_m].ys, BL_NPC, im->map[i].m); // Now run their OnInstanceInit for(i = 0; i < im->cnt_map; i++) map_foreachinarea(instance_npcinit, im->map[i].m, 0, 0, map[im->map[i].m].xs, map[im->map[i].m].ys, BL_NPC, im->map[i].m); }
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; }