diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 1b32123eea..808c6274f1 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -6793,6 +6793,13 @@ If no is specified it will display to the area. --------------------------------------- +*cloakonnpcself {""}; +*cloakoffnpcself {""}; + +Same command as above, but an attached player is required. The NPC will only display to the attached player. + +--------------------------------------- + *isnpccloaked {""{,}}; Returns true if the NPC has been cloaked to the attached player or given diff --git a/src/map/script.cpp b/src/map/script.cpp index 1d3e6873a0..e0f25550e4 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -11892,7 +11892,6 @@ BUILDIN_FUNC(enablenpc) { npc_data* nd; e_npcv_status flag = NPCVIEW_DISABLE; - int char_id = script_hasdata(st, 3) ? script_getnum(st, 3) : 0; const char* command = script_getfuncname(st); if (script_hasdata(st, 2)) @@ -11908,9 +11907,9 @@ BUILDIN_FUNC(enablenpc) flag = NPCVIEW_HIDEOFF; else if (!strcmp(command,"hideonnpc")) flag = NPCVIEW_HIDEON; - else if (!strcmp(command,"cloakoffnpc")) + else if (!strcmp(command,"cloakoffnpc") || !strcmp(command,"cloakoffnpcself")) flag = NPCVIEW_CLOAKOFF; - else if (!strcmp(command,"cloakonnpc")) + else if (!strcmp(command,"cloakonnpc") || !strcmp(command,"cloakonnpcself")) flag = NPCVIEW_CLOAKON; else{ ShowError( "buildin_enablenpc: Undefined command \"%s\".\n", command ); @@ -11925,6 +11924,19 @@ BUILDIN_FUNC(enablenpc) return SCRIPT_CMD_FAILURE; } + int char_id = 0; + + if (script_hasdata(st, 3)) + char_id = script_getnum(st, 3); + else if (!strcmp(command,"cloakoffnpcself") || !strcmp(command,"cloakonnpcself")) { + map_session_data* sd; + + if (!script_rid2sd(sd)) + return SCRIPT_CMD_SUCCESS; + + char_id = sd->status.char_id; + } + if (npc_enable_target(*nd, char_id, flag)) return SCRIPT_CMD_SUCCESS; @@ -26212,6 +26224,8 @@ struct script_function buildin_func[] = { BUILDIN_DEF2(enablenpc, "hideonnpc", "?"), BUILDIN_DEF2(enablenpc, "cloakoffnpc", "??"), BUILDIN_DEF2(enablenpc, "cloakonnpc", "??"), + BUILDIN_DEF2(enablenpc, "cloakoffnpcself", "?"), + BUILDIN_DEF2(enablenpc, "cloakonnpcself", "?"), BUILDIN_DEF(sc_start,"iii???"), BUILDIN_DEF2(sc_start,"sc_start2","iiii???"), BUILDIN_DEF2(sc_start,"sc_start4","iiiiii???"),