diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 08ddf2b376d..1eefdfcb025 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -10997,13 +10997,15 @@ Opens refinery user interface for the player returns true on success and false on failure --------------------------------------- -*openlapineddukddakboxui() +*openlapineddukddakboxui({}) +*openlapineddukddakboxui({}) Opens lapine ddukddak user interface for the player returns true on success and false on failure --------------------------------------- -*openlapineupgradeui() +*openlapineupgradeui({}) +*openlapineupgradeui({}) Opens lapine ddukddak upgrade user interface for the player returns true on success and false on failure diff --git a/src/map/script.c b/src/map/script.c index d2c911614c2..40936441502 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -27941,16 +27941,41 @@ static BUILDIN(openlapineddukddakboxui) struct map_session_data *sd = script_rid2sd(st); if (sd == NULL) return false; - const int item_id = script_getnum(st, 2); - struct item_data *it = itemdb->exists(item_id); - if (it == NULL) { - ShowError("buildin_openlapineddukddakboxui: Item %d is not valid\n", item_id); + + struct item_data *it = NULL; + if (script_hasdata(st, 2)) { + if (script_isstring(st, 2)) { + const char *item_name = script_getstr(st, 2); + it = itemdb->search_name(item_name); + if (it == NULL) { + ShowError("buildin_openlapineddukddakboxui: Item %s is not valid\n", item_name); + script->reportfunc(st); + script->reportsrc(st); + script_pushint(st, false); + return true; + } + } else { + it = itemdb->exists(script_getnum(st, 2)); + } + } else { + if (sd->itemid > 0) { + it = itemdb->exists(sd->itemid); + } + } + + if (it == NULL || it->lapineddukddak == NULL) { + if (it != NULL) { + ShowError("buildin_openlapineddukddakboxui: Item Id %d is not valid\n", it->nameid); + } else { + ShowError("buildin_openlapineddukddakboxui: Item is NULL\n"); + } script->reportfunc(st); script->reportsrc(st); script_pushint(st, false); return true; } - clif->lapineDdukDdak_open(sd, item_id); + + clif->lapineDdukDdak_open(sd, it->nameid); script_pushint(st, true); return true; } @@ -27962,17 +27987,40 @@ static BUILDIN(openlapineupgradeui) if (sd == NULL) return false; - const int item_id = script_getnum(st, 2); - struct item_data *it = itemdb->exists(item_id); + struct item_data *it = NULL; + if (script_hasdata(st, 2)) { + if (script_isstring(st, 2)) { + const char *item_name = script_getstr(st, 2); + it = itemdb->search_name(item_name); + if (it == NULL) { + ShowError("buildin_openlapineupgradeui: Item %s is not valid\n", item_name); + script->reportfunc(st); + script->reportsrc(st); + script_pushint(st, false); + return true; + } + } else { + it = itemdb->exists(script_getnum(st, 2)); + } + } else { + if (sd->itemid > 0) { + it = itemdb->exists(sd->itemid); + } + } + if (it == NULL || it->lapineupgrade == NULL) { - ShowError("buildin_openlapineupgradeui: Item %d is not valid\n", item_id); + if (it != NULL) { + ShowError("buildin_openlapineddukddakboxui: Item Id %d is not valid\n", it->nameid); + } else { + ShowError("buildin_openlapineddukddakboxui: Item is NULL\n"); + } script->reportfunc(st); script->reportsrc(st); script_pushint(st, false); return true; } - clif->lapineUpgrade_open(sd, item_id); + clif->lapineUpgrade_open(sd, it->nameid); script_pushint(st, true); return true; } @@ -29183,8 +29231,8 @@ static void script_parse_builtin(void) BUILDIN_DEF(identify, "i"), BUILDIN_DEF(identifyidx, "i"), - BUILDIN_DEF(openlapineddukddakboxui, "i"), - BUILDIN_DEF(openlapineupgradeui, "i"), + BUILDIN_DEF(openlapineddukddakboxui, "?"), + BUILDIN_DEF(openlapineupgradeui, "?"), BUILDIN_DEF(callfunctionofnpc, "vs*"),