|
@@ -254,83 +254,81 @@ static int npc_cloaked_sub(struct block_list *bl, va_list ap)
|
|
|
/*==========================================
|
|
|
* Disable / Enable NPC
|
|
|
*------------------------------------------*/
|
|
|
-bool npc_enable_target(npc_data* nd, uint32 char_id, int flag)
|
|
|
+bool npc_enable_target(npc_data& nd, uint32 char_id, e_npcv_status flag)
|
|
|
{
|
|
|
- nullpo_ret(nd);
|
|
|
-
|
|
|
- if (char_id > 0 && (flag & 24)) {
|
|
|
+ if (char_id > 0 && (flag & NPCVIEW_CLOAK)) {
|
|
|
map_session_data *sd = map_charid2sd(char_id);
|
|
|
|
|
|
if (!sd) {
|
|
|
- ShowError("npc_enable: Attempted to %s a NPC '%s' on an invalid target %d.\n", (flag & 8) ? "show" : "hide", nd->name, char_id);
|
|
|
+ ShowError("npc_enable: Attempted to %s a NPC '%s' on an invalid target %d.\n", (flag & NPCVIEW_VISIBLE) ? "show" : "hide", nd.name, char_id);
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- unsigned int option = nd->sc.option;
|
|
|
- if (flag&8)
|
|
|
- nd->sc.option &= ~OPTION_CLOAK;
|
|
|
+ unsigned int option = nd.sc.option;
|
|
|
+ if (flag & NPCVIEW_CLOAKOFF)
|
|
|
+ nd.sc.option &= ~OPTION_CLOAK;
|
|
|
else
|
|
|
- nd->sc.option |= OPTION_CLOAK;
|
|
|
+ nd.sc.option |= OPTION_CLOAK;
|
|
|
|
|
|
- auto it = std::find(sd->cloaked_npc.begin(), sd->cloaked_npc.end(), nd->bl.id);
|
|
|
+ auto it = std::find(sd->cloaked_npc.begin(), sd->cloaked_npc.end(), nd.bl.id);
|
|
|
|
|
|
- if (it == sd->cloaked_npc.end() && option != nd->sc.option)
|
|
|
- sd->cloaked_npc.push_back(nd->bl.id);
|
|
|
- else if (it != sd->cloaked_npc.end() && option == nd->sc.option)
|
|
|
+ if (it == sd->cloaked_npc.end() && option != nd.sc.option)
|
|
|
+ sd->cloaked_npc.push_back(nd.bl.id);
|
|
|
+ else if (it != sd->cloaked_npc.end() && option == nd.sc.option)
|
|
|
sd->cloaked_npc.erase(it);
|
|
|
|
|
|
- if (nd->class_ != JT_WARPNPC && nd->class_ != JT_GUILD_FLAG)
|
|
|
- clif_changeoption_target(&nd->bl, &sd->bl);
|
|
|
+ if (nd.class_ != JT_WARPNPC && nd.class_ != JT_GUILD_FLAG)
|
|
|
+ clif_changeoption_target(&nd.bl, &sd->bl);
|
|
|
else {
|
|
|
- if (nd->sc.option&(OPTION_HIDE|OPTION_INVISIBLE|OPTION_CLOAK))
|
|
|
- clif_clearunit_single(nd->bl.id, CLR_OUTSIGHT, sd->fd);
|
|
|
+ if (nd.sc.option&(OPTION_HIDE|OPTION_INVISIBLE|OPTION_CLOAK))
|
|
|
+ clif_clearunit_single(nd.bl.id, CLR_OUTSIGHT, sd->fd);
|
|
|
else
|
|
|
- clif_spawn(&nd->bl);
|
|
|
+ clif_spawn(&nd.bl);
|
|
|
}
|
|
|
- nd->sc.option = option;
|
|
|
+ nd.sc.option = option;
|
|
|
}
|
|
|
else {
|
|
|
- if (flag&1) {
|
|
|
- nd->sc.option &= ~OPTION_INVISIBLE;
|
|
|
- clif_spawn(&nd->bl);
|
|
|
+ if (flag & NPCVIEW_ENABLE) {
|
|
|
+ nd.sc.option &= ~OPTION_INVISIBLE;
|
|
|
+ clif_spawn(&nd.bl);
|
|
|
}
|
|
|
- else if (flag&2)
|
|
|
- nd->sc.option &= ~OPTION_HIDE;
|
|
|
- else if (flag&4)
|
|
|
- nd->sc.option |= OPTION_HIDE;
|
|
|
- else if (flag&8)
|
|
|
- nd->sc.option &= ~OPTION_CLOAK;
|
|
|
- else if (flag&16)
|
|
|
- nd->sc.option |= OPTION_CLOAK;
|
|
|
+ else if (flag & NPCVIEW_HIDEOFF)
|
|
|
+ nd.sc.option &= ~OPTION_HIDE;
|
|
|
+ else if (flag & NPCVIEW_HIDEON)
|
|
|
+ nd.sc.option |= OPTION_HIDE;
|
|
|
+ else if (flag & NPCVIEW_CLOAKOFF)
|
|
|
+ nd.sc.option &= ~OPTION_CLOAK;
|
|
|
+ else if (flag & NPCVIEW_CLOAKON)
|
|
|
+ nd.sc.option |= OPTION_CLOAK;
|
|
|
else { //Can't change the view_data to invisible class because the view_data for all npcs is shared! [Skotlex]
|
|
|
- nd->sc.option |= OPTION_INVISIBLE;
|
|
|
- clif_clearunit_area(&nd->bl,CLR_OUTSIGHT); // Hack to trick maya purple card [Xazax]
|
|
|
+ nd.sc.option |= OPTION_INVISIBLE;
|
|
|
+ clif_clearunit_area(&nd.bl,CLR_OUTSIGHT); // Hack to trick maya purple card [Xazax]
|
|
|
}
|
|
|
- if (nd->class_ != JT_WARPNPC && nd->class_ != JT_GUILD_FLAG) //Client won't display option changes for these classes [Toms]
|
|
|
- clif_changeoption(&nd->bl);
|
|
|
+ if (nd.class_ != JT_WARPNPC && nd.class_ != JT_GUILD_FLAG) //Client won't display option changes for these classes [Toms]
|
|
|
+ clif_changeoption(&nd.bl);
|
|
|
else {
|
|
|
- if (nd->sc.option&(OPTION_HIDE|OPTION_INVISIBLE|OPTION_CLOAK))
|
|
|
- clif_clearunit_area(&nd->bl,CLR_OUTSIGHT);
|
|
|
+ if (nd.sc.option&(OPTION_HIDE|OPTION_INVISIBLE|OPTION_CLOAK))
|
|
|
+ clif_clearunit_area(&nd.bl,CLR_OUTSIGHT);
|
|
|
else
|
|
|
- clif_spawn(&nd->bl);
|
|
|
+ clif_spawn(&nd.bl);
|
|
|
}
|
|
|
- map_foreachinmap(npc_cloaked_sub, nd->bl.m, BL_PC, nd->bl.id); // Because npc option has been updated we remove the npc id from sd->cloaked_npc
|
|
|
+ map_foreachinmap(npc_cloaked_sub, nd.bl.m, BL_PC, nd.bl.id); // Because npc option has been updated we remove the npc id from sd->cloaked_npc
|
|
|
}
|
|
|
|
|
|
- if (flag&11) { // check if player standing on a OnTouchArea
|
|
|
+ if (flag & NPCVIEW_VISIBLE) { // check if player standing on a OnTouchArea
|
|
|
int xs = -1, ys = -1;
|
|
|
- switch (nd->subtype) {
|
|
|
+ switch (nd.subtype) {
|
|
|
case NPCTYPE_SCRIPT:
|
|
|
- xs = nd->u.scr.xs;
|
|
|
- ys = nd->u.scr.ys;
|
|
|
+ xs = nd.u.scr.xs;
|
|
|
+ ys = nd.u.scr.ys;
|
|
|
break;
|
|
|
case NPCTYPE_WARP:
|
|
|
- xs = nd->u.warp.xs;
|
|
|
- ys = nd->u.warp.ys;
|
|
|
+ xs = nd.u.warp.xs;
|
|
|
+ ys = nd.u.warp.ys;
|
|
|
break;
|
|
|
}
|
|
|
if (xs > -1 && ys > -1)
|
|
|
- map_foreachinallarea( npc_enable_sub, nd->bl.m, nd->bl.x-xs, nd->bl.y-ys, nd->bl.x+xs, nd->bl.y+ys, BL_PC, nd );
|
|
|
+ map_foreachinallarea( npc_enable_sub, nd.bl.m, nd.bl.x-xs, nd.bl.y-ys, nd.bl.x+xs, nd.bl.y+ys, BL_PC, &nd );
|
|
|
}
|
|
|
|
|
|
return true;
|