From 526a3fa0488829cd71d2765d7788b3b87cac34ee Mon Sep 17 00:00:00 2001 From: Atemo Date: Fri, 18 Nov 2022 15:39:00 +0100 Subject: [PATCH] Added close3 script command (#7439) Thanks to @aleos89 @Lemongrass3110 @vstumpf ! --- doc/script_commands.txt | 6 ++++++ npc/other/Global_Functions.txt | 9 --------- src/map/npc.cpp | 2 ++ src/map/script.cpp | 11 +++++++++-- src/map/script.hpp | 1 + 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 1a9243977a..82e4a74b16 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -1229,6 +1229,12 @@ Don't expect things to run smoothly if you don't make your scripts 'end'. --------------------------------------- +*close3; + +The command is similar to 'close' but the cutin (if any) is cleared after closing. + +--------------------------------------- + *end; This command will stop the execution for this particular script. The two diff --git a/npc/other/Global_Functions.txt b/npc/other/Global_Functions.txt index 3e0ea5d2bf..4e4a2c39f3 100644 --- a/npc/other/Global_Functions.txt +++ b/npc/other/Global_Functions.txt @@ -752,15 +752,6 @@ function script F_GetPlatinumSkills { return; } -////////////////////////////////////////////////////////////////////////////////// -// Shortcut : close button and clear cutin. -////////////////////////////////////////////////////////////////////////////////// -function script close3 { - close2; - cutin "",255; - end; -} - ////////////////////////////////////////////////////////////////////////////////// // Return true if the card is a charm (enchant card), false otherwise. ////////////////////////////////////////////////////////////////////////////////// diff --git a/src/map/npc.cpp b/src/map/npc.cpp index 7e7277ab37..f876e07f12 100644 --- a/src/map/npc.cpp +++ b/src/map/npc.cpp @@ -2286,6 +2286,8 @@ bool npc_scriptcont(struct map_session_data* sd, int id, bool closing){ // close case CLOSE: sd->st->state = END; + if (sd->st->clear_cutin) + clif_cutin(sd,"",255); break; // close2 case STOP: diff --git a/src/map/script.cpp b/src/map/script.cpp index b41d9a2456..cdcb44d16f 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -4977,20 +4977,26 @@ BUILDIN_FUNC(clear) /// close; BUILDIN_FUNC(close) { - TBL_PC* sd; + struct map_session_data* sd; if( !script_rid2sd(sd) ) return SCRIPT_CMD_SUCCESS; + const char* command = script_getfuncname( st ); + if( !st->mes_active ) { st->state = END; // Keep backwards compatibility. - ShowWarning("Incorrect use of 'close' command!\n"); + ShowWarning("buildin_close: Incorrect use of '%s' command!\n", command); script_reportsrc(st); } else { st->state = CLOSE; st->mes_active = 0; } + if( !strcmp(command, "close3") ){ + st->clear_cutin = true; + } + clif_scriptclose(sd, st->oid); return SCRIPT_CMD_SUCCESS; } @@ -26890,6 +26896,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF(clear,""), BUILDIN_DEF(close,""), BUILDIN_DEF(close2,""), + BUILDIN_DEF2(close, "close3", ""), BUILDIN_DEF(menu,"sl*"), BUILDIN_DEF(select,"s*"), //for future jA script compatibility BUILDIN_DEF(prompt,"s*"), diff --git a/src/map/script.hpp b/src/map/script.hpp index b8081a51a3..7bf89257e9 100644 --- a/src/map/script.hpp +++ b/src/map/script.hpp @@ -328,6 +328,7 @@ struct script_state { unsigned op2ref : 1;// used by op_2 unsigned npc_item_flag : 1; unsigned mes_active : 1; // Store if invoking character has a NPC dialog box open. + unsigned clear_cutin : 1; char* funcname; // Stores the current running function name unsigned int id; };