diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 8f8c0c1a0c..56ced91798 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -10069,6 +10069,18 @@ This command is typically used in item scripts of mercenary scrolls. --------------------------------------- +*mercenary_delete {{,}}; + +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 ,; This command works like 'heal', but affects the mercenary of the diff --git a/src/map/script.cpp b/src/map/script.cpp index e409a482d0..72a7736f07 100644 --- a/src/map/script.cpp +++ b/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"),