From f4410fba6b50e6d98ac78faba30e765e55bff938 Mon Sep 17 00:00:00 2001
From: Pokye <98105181+Pokye@users.noreply.github.com>
Date: Sun, 10 Apr 2022 20:56:17 -0300
Subject: [PATCH] Added script command openbank (#6821)

---
 doc/script_commands.txt |  8 ++++++++
 src/map/clif.hpp        |  3 ++-
 src/map/script.cpp      | 22 ++++++++++++++++++++++
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index ee3b6f2726..2cddb7499d 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -8099,6 +8099,14 @@ This feature requires packet version 2017-07-26 or newer.
 
 This function is intended for use in item scripts.
 
+---------------------------------------
+
+*openbank({<char id>})
+
+Opens the Bank UI for the attached player or the given character ID.
+
+This command requires packet version 2015-01-28 or newer.
+
 ---------------------------------------
 \\
 6,1.- Unit-related commands
diff --git a/src/map/clif.hpp b/src/map/clif.hpp
index 8c35083a96..b3d6089050 100644
--- a/src/map/clif.hpp
+++ b/src/map/clif.hpp
@@ -1159,7 +1159,8 @@ enum in_ui_type : int8 {
 };
 
 enum out_ui_type : int8 {
-	OUT_UI_STYLIST = 1,
+	OUT_UI_BANK = 0,
+	OUT_UI_STYLIST,
 	OUT_UI_QUEST = 6,
 	OUT_UI_ATTENDANCE = 7
 };
diff --git a/src/map/script.cpp b/src/map/script.cpp
index 9756a2c227..664b225779 100644
--- a/src/map/script.cpp
+++ b/src/map/script.cpp
@@ -25840,6 +25840,27 @@ BUILDIN_FUNC( open_quest_ui ){
 	return SCRIPT_CMD_SUCCESS;
 }
 
+BUILDIN_FUNC(openbank){
+#if PACKETVER < 20150128
+	ShowError( "buildin_openbank: This command requires PACKETVER 20150128 or newer.\n" );
+	return SCRIPT_CMD_FAILURE;
+#else
+	struct map_session_data* sd = nullptr;
+
+	if (!script_charid2sd(2, sd)) {
+		return SCRIPT_CMD_FAILURE;
+	}
+
+	if( !battle_config.feature_banking ){
+		ShowError( "buildin_openbank: banking is disabled.\n" );
+		return SCRIPT_CMD_FAILURE;
+	}
+
+	clif_ui_open( sd, OUT_UI_BANK, 0 );
+	return SCRIPT_CMD_SUCCESS;
+#endif
+}
+
 #include "../custom/script.inc"
 
 // declarations that were supposed to be exported from npc_chat.cpp
@@ -26553,6 +26574,7 @@ struct script_function buildin_func[] = {
 	BUILDIN_DEF(laphine_upgrade, ""),
 	BUILDIN_DEF(randomoptgroup,"i"),
 	BUILDIN_DEF(open_quest_ui, "??"),
+	BUILDIN_DEF(openbank,"?"),
 #include "../custom/script_def.inc"
 
 	{NULL,NULL,NULL},