Pārlūkot izejas kodu

Added script command mercenary_delete (#6334)

Enable to remove mercenary from player.
HAO YAN 3 gadi atpakaļ
vecāks
revīzija
edfb95f39d
2 mainītis faili ar 39 papildinājumiem un 0 dzēšanām
  1. 12 0
      doc/script_commands.txt
  2. 27 0
      src/map/script.cpp

+ 12 - 0
doc/script_commands.txt

@@ -10069,6 +10069,18 @@ This command is typically used in item scripts of mercenary scrolls.
 
 ---------------------------------------
 
+*mercenary_delete {<char id>{,<reply>}};
+
+This command removes the mercenary from a player.
+The parameter 'reply' can be one of the following values:
+
+	0 - Mercenary soldier's duty hour is over, faith increased by 1. (default)
+	1 - Your mercenary soldier has been killed, faith decreased by 1.
+	2 - Your mercenary soldier has been fired.
+	3 - Your mercenary soldier has ran away.
+
+---------------------------------------
+
 *mercenary_heal <hp>,<sp>;
 
 This command works like 'heal', but affects the mercenary of the

+ 27 - 0
src/map/script.cpp

@@ -19784,6 +19784,32 @@ BUILDIN_FUNC(mercenary_create)
 	return SCRIPT_CMD_SUCCESS;
 }
 
+BUILDIN_FUNC(mercenary_delete)
+{
+	struct map_session_data *sd;
+	int type = 0;
+
+	if( !script_charid2sd(2, sd) )
+		return SCRIPT_CMD_FAILURE;
+
+	if( sd->md == nullptr ) {
+		ShowWarning("buildin_mercenary_delete: Tried to delete a non existant mercenary from player '%s' (AID: %u, CID: %u)\n", sd->status.name, sd->status.account_id, sd->status.char_id);
+		return SCRIPT_CMD_FAILURE;
+	}
+
+	if( script_hasdata(st, 3) ) {
+		type = script_getnum(st, 3);
+		if( type < 0 || type > 3 ) {
+			ShowWarning("buildin_mercenary_delete: invalid type value of %d.\n", type);
+			return SCRIPT_CMD_FAILURE;
+		}
+	}
+	
+	mercenary_delete(sd->md, type);
+
+	return SCRIPT_CMD_SUCCESS;
+}
+
 BUILDIN_FUNC(mercenary_heal)
 {
 	struct map_session_data *sd;
@@ -25790,6 +25816,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(checkwall,"s"),
 	BUILDIN_DEF(searchitem,"rs"),
 	BUILDIN_DEF(mercenary_create,"ii"),
+	BUILDIN_DEF(mercenary_delete,"??"),
 	BUILDIN_DEF(mercenary_heal,"ii"),
 	BUILDIN_DEF(mercenary_sc_start,"iii"),
 	BUILDIN_DEF(mercenary_get_calls,"i"),