Browse Source

Fixed an issue with npc_enable_target (#7695)

Fixed #7694 

Thanks to @eppc0330
Atemo 2 years ago
parent
commit
0fbe8c3ecd
1 changed files with 9 additions and 5 deletions
  1. 9 5
      src/map/npc.cpp

+ 9 - 5
src/map/npc.cpp

@@ -1035,8 +1035,9 @@ bool npc_enable_target(npc_data& nd, uint32 char_id, e_npcv_status flag)
 	}
 	}
 	else {
 	else {
 		if (flag & NPCVIEW_ENABLE) {
 		if (flag & NPCVIEW_ENABLE) {
-			nd.sc.option &= ~OPTION_HIDE;
 			nd.is_invisible = false;
 			nd.is_invisible = false;
+			clif_spawn(&nd.bl);
+			nd.sc.option &= ~OPTION_HIDE;
 		}
 		}
 		else if (flag & NPCVIEW_HIDEOFF)
 		else if (flag & NPCVIEW_HIDEOFF)
 			nd.sc.option &= ~OPTION_HIDE;
 			nd.sc.option &= ~OPTION_HIDE;
@@ -1050,8 +1051,11 @@ bool npc_enable_target(npc_data& nd, uint32 char_id, e_npcv_status flag)
 			nd.sc.option |= OPTION_HIDE;
 			nd.sc.option |= OPTION_HIDE;
 			nd.is_invisible = true;
 			nd.is_invisible = true;
 		}
 		}
-		if (nd.class_ != JT_WARPNPC && nd.class_ != JT_GUILD_FLAG)	//Client won't display option changes for these classes [Toms]
+		if (nd.class_ != JT_WARPNPC && nd.class_ != JT_GUILD_FLAG) {	//Client won't display option changes for these classes [Toms]
 			clif_changeoption(&nd.bl);
 			clif_changeoption(&nd.bl);
+			if (nd.is_invisible)
+				clif_clearunit_area(&nd.bl,CLR_OUTSIGHT);  // Hack to trick maya purple card [Xazax]
+		}
 		else {
 		else {
 			if (nd.sc.option&(OPTION_HIDE|OPTION_CLOAK))
 			if (nd.sc.option&(OPTION_HIDE|OPTION_CLOAK))
 				clif_clearunit_area(&nd.bl,CLR_OUTSIGHT);
 				clif_clearunit_area(&nd.bl,CLR_OUTSIGHT);
@@ -4621,14 +4625,14 @@ const char* npc_parse_duplicate( char* w1, char* w2, char* w3, char* w4, const c
 	}
 	}
 	strdb_put(npcname_db, nd->exname, nd);
 	strdb_put(npcname_db, nd->exname, nd);
 
 
-	if( type != NPCTYPE_SCRIPT )
-		return end;
-
 	// copy the original npc state
 	// copy the original npc state
 	if (dnd->state != NPCVIEW_ENABLE)
 	if (dnd->state != NPCVIEW_ENABLE)
 		npc_enable_target(*nd, 0, dnd->state);
 		npc_enable_target(*nd, 0, dnd->state);
 	nd->state = dnd->state;
 	nd->state = dnd->state;
 
 
+	if( type != NPCTYPE_SCRIPT )
+		return end;
+
 	//-----------------------------------------
 	//-----------------------------------------
 	// Loop through labels to export them as necessary
 	// Loop through labels to export them as necessary
 	for (i = 0; i < nd->u.scr.label_list_num; i++) {
 	for (i = 0; i < nd->u.scr.label_list_num; i++) {