Browse Source

Added setquest, erasequest, completequest, checkquest atcommand (#4692)

@ setquest : self explaining
@ erasequest : self explaining
@ completequest : give and complete the quest
@ checkquest : display the quest status HAVEQUEST, HUNTING, PLAYTIME
Atemo 5 years ago
parent
commit
73fe0d26b7
3 changed files with 85 additions and 0 deletions
  1. 12 0
      conf/msg_conf/map_msg.conf
  2. 9 0
      doc/atcommands.txt
  3. 64 0
      src/map/atcommand.cpp

+ 12 - 0
conf/msg_conf/map_msg.conf

@@ -1706,5 +1706,17 @@
 1503: You've entered a PK Zone.
 1504: You've entered a PK Zone (safe until level %d).
 
+// @setquest, @erasequest, @completequest
+1505: Usage: %s <quest ID>
+1506: Quest %d not found in DB.
+1507: Character already has quest %d.
+1508: Character doesn't have quest %d.
+
+// @checkquest
+1509: Checkquest value for quest %d
+1510: >    HAVEQUEST : %d
+1511: >    HUNTING   : %d
+1512: >    PLAYTIME  : %d
+
 //Custom translations
 import: conf/msg_conf/import/map_msg_eng_conf.txt

+ 9 - 0
doc/atcommands.txt

@@ -1766,3 +1766,12 @@ Bans or unbans a player from the specified channel.
 Binds or unbinds your global chat with the specified channel, which sends all global messages to the specified channel.
 
 ---------------------------------------
+
+@setquest <quest ID>
+@erasequest <quest ID>
+@completequest <quest ID>
+@checkquest <quest ID>
+
+Changes/checks the status of the specified quest ID.
+
+---------------------------------------

+ 64 - 0
src/map/atcommand.cpp

@@ -10131,6 +10131,66 @@ ACMD_FUNC(resurrect) {
 	return 0;
 }
 
+ACMD_FUNC(quest) {
+	uint8 i;
+	int quest_id = 0;
+	nullpo_retr(-1, sd);
+	memset(atcmd_output, '\0', sizeof(atcmd_output));
+
+	if (!message || !*message || sscanf(message, "%11d", &quest_id) < 1 || quest_id == 0) {
+		sprintf(atcmd_output, msg_txt(sd,1505), command); // Usage: %s <quest ID>
+		clif_displaymessage(fd, atcmd_output);
+		return -1;
+	}
+	if (!quest_search(quest_id)) {
+		sprintf(atcmd_output,  msg_txt(sd,1506), quest_id); // Quest %d not found in DB.
+		clif_displaymessage(fd, atcmd_output);
+		return -1;
+	}
+
+	const char* type[] = { "setquest", "erasequest", "completequest", "checkquest" };
+	ARR_FIND( 0, ARRAYLENGTH(type), i, strcmpi(command+1, type[i]) == 0 );
+
+	switch(i) {
+	case 0:
+		if (quest_check(sd, quest_id, HAVEQUEST) >= 0) {
+			sprintf(atcmd_output,  msg_txt(sd,1507), quest_id); // Character already has quest %d.
+			clif_displaymessage(fd, atcmd_output);
+			return -1;
+		}
+		quest_add(sd, quest_id);
+		pc_show_questinfo(sd);
+		break;
+	case 1:
+		if (quest_check(sd, quest_id, HAVEQUEST) < 0) {
+			sprintf(atcmd_output,  msg_txt(sd,1508), quest_id); // Character doesn't have quest %d.
+			clif_displaymessage(fd, atcmd_output);
+			return -1;
+		}
+		quest_delete(sd, quest_id);
+		pc_show_questinfo(sd);
+		break;
+	case 2:
+		if (quest_check(sd, quest_id, HAVEQUEST) < 0)
+			quest_add(sd, quest_id);
+		if (quest_check(sd, quest_id, HAVEQUEST) < 2)
+			quest_update_status(sd, quest_id, Q_COMPLETE);
+		pc_show_questinfo(sd);
+		break;
+	case 3:
+		sprintf(atcmd_output, msg_txt(sd,1509), quest_id); // Checkquest value for quest %d
+		clif_displaymessage(fd, atcmd_output);
+		sprintf(atcmd_output, msg_txt(sd,1510), quest_check(sd, quest_id, HAVEQUEST));	// HAVEQUEST : %d
+		clif_displaymessage(fd, atcmd_output);
+		sprintf(atcmd_output, msg_txt(sd,1511), quest_check(sd, quest_id, HUNTING));	// HUNTING   : %d
+		clif_displaymessage(fd, atcmd_output);
+		sprintf(atcmd_output, msg_txt(sd,1512), quest_check(sd, quest_id, PLAYTIME));	// PLAYTIME  : %d
+		clif_displaymessage(fd, atcmd_output);
+		break;
+	}
+	return 0;
+}
+
 #include "../custom/atcommand.inc"
 
 /**
@@ -10433,6 +10493,10 @@ void atcommand_basecommands(void) {
 		ACMD_DEFR(changedress, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
 		ACMD_DEFR(camerainfo, ATCMD_NOCONSOLE|ATCMD_NOAUTOTRADE),
 		ACMD_DEFR(resurrect, ATCMD_NOCONSOLE),
+		ACMD_DEF2("setquest", quest),
+		ACMD_DEF2("erasequest", quest),
+		ACMD_DEF2("completequest", quest),
+		ACMD_DEF2("checkquest", quest),
 	};
 	AtCommandInfo* atcommand;
 	int i;