Browse Source

open_quest_ui script command (#6662)

* script command to force open the quest UI for the attached player.

Thanks to @Lemongrass3110 !
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
Atemo 3 years ago
parent
commit
73a8d1365e
3 changed files with 29 additions and 0 deletions
  1. 7 0
      doc/script_commands.txt
  2. 1 0
      src/map/clif.hpp
  3. 21 0
      src/map/script.cpp

+ 7 - 0
doc/script_commands.txt

@@ -9712,6 +9712,13 @@ QMARK_PURPLE - Purple Marker
 
 ---------------------------------------
 
+*open_quest_ui {<quest ID>,{<char ID>}};
+
+Opens the quest UI for the attached player or the given character ID.
+Use 0 as the quest ID to open the main quest UI. If the quest ID is not 0 then the quest UI is opened to the given quest. If the quest data is not populated in the client LUB then a message will be displayed saying the quest doesn't exist.
+
+---------------------------------------
+
 ============================
 |9.- Battleground commands.|
 ============================

+ 1 - 0
src/map/clif.hpp

@@ -1160,6 +1160,7 @@ enum in_ui_type : int8 {
 
 enum out_ui_type : int8 {
 	OUT_UI_STYLIST = 1,
+	OUT_UI_QUEST = 6,
 	OUT_UI_ATTENDANCE = 7
 };
 

+ 21 - 0
src/map/script.cpp

@@ -25812,6 +25812,26 @@ BUILDIN_FUNC(randomoptgroup)
 	return SCRIPT_CMD_SUCCESS;
 }
 
+BUILDIN_FUNC( open_quest_ui ){
+	struct map_session_data* sd;
+
+	if (!script_charid2sd(3, sd))
+		return SCRIPT_CMD_FAILURE;
+
+	int quest_id = script_hasdata(st, 2) ? script_getnum(st, 2) : 0;
+
+	if( quest_id != 0 ){
+		int i;
+		ARR_FIND(0, sd->avail_quests, i, sd->quest_log[i].quest_id == quest_id);
+		if (i == sd->avail_quests)
+			ShowWarning("buildin_open_quest_ui: Character %d doesn't have quest %d.\n", sd->status.char_id, quest_id);
+	}
+
+	clif_ui_open( sd, OUT_UI_QUEST, quest_id );
+
+	return SCRIPT_CMD_SUCCESS;
+}
+
 #include "../custom/script.inc"
 
 // declarations that were supposed to be exported from npc_chat.cpp
@@ -26524,6 +26544,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(laphine_synthesis, ""),
 	BUILDIN_DEF(laphine_upgrade, ""),
 	BUILDIN_DEF(randomoptgroup,"i"),
+	BUILDIN_DEF(open_quest_ui, "??"),
 #include "../custom/script_def.inc"
 
 	{NULL,NULL,NULL},