Added script command mesitemlink (#7565)

Adds a new script command for itemlink generation for usage inside NPC dialogs (mes "").
A few cleanups related to the normal itemlink feature.

Thanks to @Atemo and @aleos89 for their help!

Co-authored-by: Atemo <Atemo@users.noreply.github.com>
Co-authored-by: Aleos <aleos89@users.noreply.github.com>
This commit is contained in:
Lemongrass3110
2023-02-07 10:47:36 +01:00
committed by GitHub
parent 59a722234d
commit f261307bbe
24 changed files with 283 additions and 118 deletions

View File

@@ -26806,6 +26806,37 @@ BUILDIN_FUNC(itemlink)
return SCRIPT_CMD_SUCCESS;
}
BUILDIN_FUNC(mesitemlink){
t_itemid nameid = script_getnum( st, 2 );
std::shared_ptr<item_data> data = item_db.find( nameid );
if( data == nullptr ){
ShowError( "buildin_mesitemlink: Item ID %u does not exists.\n", nameid );
script_pushconststr( st, "" );
return SCRIPT_CMD_FAILURE;
}
bool use_brackets = true;
if( script_hasdata( st, 3 ) ){
use_brackets = script_getnum( st, 3 ) != 0;
}
const char* name = nullptr;
if( script_hasdata( st, 4 ) ){
name = script_getstr( st, 4 );
}
// Create the link, depending on configuration and packet version
std::string itemlstr = item_db.create_item_link_for_mes( data, use_brackets, name );
// Push it to the script engine for further usage
script_pushstrcopy( st, itemlstr.c_str() );
return SCRIPT_CMD_SUCCESS;
}
BUILDIN_FUNC(addfame) {
map_session_data *sd;
@@ -27620,6 +27651,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(item_reform, "??"),
BUILDIN_DEF(item_enchant, "i?"),
BUILDIN_DEF(itemlink, "i?????????"),
BUILDIN_DEF(mesitemlink, "i??"),
BUILDIN_DEF(addfame, "i?"),
BUILDIN_DEF(getfame, "?"),
BUILDIN_DEF(getfamerank, "?"),