laphine_synthesis script command update (#7222)
* Added the item ID/name as parameter for laphine_synthesis script command Thanks to @Lemongrass3110 !
This commit is contained in:
parent
177d57ee68
commit
9be64f55dc
@ -8199,14 +8199,14 @@ This feature requires packet version 2015-11-04 or newer.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*laphine_synthesis()
|
||||
*laphine_synthesis({<item id>})
|
||||
*laphine_synthesis({<"item name">})
|
||||
|
||||
Opens the laphine synthesis UI for the attached player.
|
||||
Opens the laphine synthesis UI for <item ID> or <item name> for the attached player.
|
||||
If run from within an item script <item ID> or <item name> is optional.
|
||||
|
||||
This feature requires packet version 2016-06-01 or newer.
|
||||
|
||||
This function is intended for use in item scripts.
|
||||
|
||||
---------------------------------------
|
||||
|
||||
*laphine_upgrade()
|
||||
|
@ -23246,21 +23246,24 @@ void clif_parse_laphine_synthesis( int fd, struct map_session_data* sd ){
|
||||
}
|
||||
}
|
||||
|
||||
int16 index = pc_search_inventory( sd, sd->state.laphine_synthesis );
|
||||
// If triggered from item
|
||||
if( sd->itemid == sd->state.laphine_synthesis ){
|
||||
int16 index = pc_search_inventory( sd, sd->state.laphine_synthesis );
|
||||
|
||||
if( index < 0 ){
|
||||
clif_laphine_synthesis_result( sd, LAPHINE_SYNTHESIS_ITEM );
|
||||
return;
|
||||
}
|
||||
|
||||
if( ( sd->inventory_data[index]->flag.delay_consume & DELAYCONSUME_NOCONSUME ) == 0 ){
|
||||
if( pc_delitem( sd, index, 1, 0, 0, LOG_TYPE_LAPHINE ) != 0 ){
|
||||
if( index < 0 ){
|
||||
clif_laphine_synthesis_result( sd, LAPHINE_SYNTHESIS_ITEM );
|
||||
return;
|
||||
}
|
||||
|
||||
if( ( sd->inventory_data[index]->flag.delay_consume & DELAYCONSUME_NOCONSUME ) == 0 ){
|
||||
if( pc_delitem( sd, index, 1, 0, 0, LOG_TYPE_LAPHINE ) != 0 ){
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for( size_t i = 0; i < count; i++ ){
|
||||
index = server_index( p->items[i].index );
|
||||
int16 index = server_index( p->items[i].index );
|
||||
|
||||
if( pc_delitem( sd, index, p->items[i].count, 0, 0, LOG_TYPE_LAPHINE ) != 0 ){
|
||||
return;
|
||||
|
@ -25959,14 +25959,40 @@ BUILDIN_FUNC( laphine_synthesis ){
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
if( sd->itemid == 0 ){
|
||||
ShowError( "buildin_laphine_synthesis: Called outside of an item script without item id.\n" );
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
t_itemid item_id;
|
||||
|
||||
if( sd->inventory_data[sd->itemindex]->flag.delay_consume == 0 ){
|
||||
ShowError( "buildin_laphine_synthesis: Called from item %u, which is not a consumed delayed.\n", sd->itemid );
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
if( script_hasdata( st, 2 ) ){
|
||||
if( script_isstring( st, 2 ) ){
|
||||
const char* item_name = script_getstr( st, 2 );
|
||||
|
||||
std::shared_ptr<item_data> item = item_db.searchname( item_name );
|
||||
|
||||
if( item == nullptr ){
|
||||
ShowError("buildin_laphine_synthesis: Item \"%s\" does not exist.\n", item_name );
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
item_id = item->nameid;
|
||||
}else{
|
||||
item_id = script_getnum( st, 2 );
|
||||
|
||||
if( !item_db.exists( item_id ) ){
|
||||
ShowError( "buildin_laphine_synthesis: Item ID %u does not exist.\n", item_id );
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if( sd->itemid == 0 ){
|
||||
ShowError( "buildin_laphine_synthesis: Called outside of an item script without item id.\n" );
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
if( sd->inventory_data[sd->itemindex]->flag.delay_consume == 0 ){
|
||||
ShowError( "buildin_laphine_synthesis: Called from item %u, which is not a consumed delayed.\n", sd->itemid );
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
item_id = sd->itemid;
|
||||
}
|
||||
|
||||
if( sd->state.laphine_synthesis != 0 ){
|
||||
@ -25974,10 +26000,10 @@ BUILDIN_FUNC( laphine_synthesis ){
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
std::shared_ptr<s_laphine_synthesis> synthesis = laphine_synthesis_db.find( sd->itemid );
|
||||
std::shared_ptr<s_laphine_synthesis> synthesis = laphine_synthesis_db.find( item_id );
|
||||
|
||||
if( synthesis == nullptr ){
|
||||
ShowError( "buildin_laphine_synthesis: %u is not a valid Laphine Synthesis item.\n", sd->itemid );
|
||||
ShowError( "buildin_laphine_synthesis: %u is not a valid Laphine Synthesis item.\n", item_id );
|
||||
return SCRIPT_CMD_FAILURE;
|
||||
}
|
||||
|
||||
@ -27035,7 +27061,7 @@ struct script_function buildin_func[] = {
|
||||
BUILDIN_DEF(navihide, ""),
|
||||
|
||||
BUILDIN_DEF(getitempos,""),
|
||||
BUILDIN_DEF(laphine_synthesis, ""),
|
||||
BUILDIN_DEF(laphine_synthesis, "?"),
|
||||
BUILDIN_DEF(laphine_upgrade, ""),
|
||||
BUILDIN_DEF(randomoptgroup,"i"),
|
||||
BUILDIN_DEF(open_quest_ui, "??"),
|
||||
|
Loading…
x
Reference in New Issue
Block a user