From 2d33d766bd7ea81eb40c15fe45d59ab155b16fde Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 24 Nov 2018 20:40:33 +0300 Subject: Add script command for insert cards into equipped items. enchantitem(, , ) --- doc/script_commands.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 90d4d77cc..b88ff8809 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -10237,3 +10237,14 @@ Update already opened preview window with item from Works for 20181017 RE and main clients or newer. --------------------------------------- + +*enchantitem(, , ); + +Insert card into equipped item in EQI_* slot. +card_slot - can be 0 to 3. +card_id - any card item id. + +returns true if all parameters correct +false in other case. +Works for 20160831 main, 20151118 RE, any zero version +--------------------------------------- -- cgit v1.2.3-70-g09d2 From eaeebdc9ddaa62488a58885c6a20b43d67e43d4a Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 27 Nov 2018 05:40:22 +0300 Subject: Add script command servicemessage. This command will show colored message in chat. This message will be not logged to file and will be not visible over head. --- doc/script_commands.txt | 10 ++++++++++ src/map/script.c | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index b88ff8809..0096cedfd 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -10248,3 +10248,13 @@ returns true if all parameters correct false in other case. Works for 20160831 main, 20151118 RE, any zero version --------------------------------------- + +*servicemessage("", {, }) +*servicemessage("", {, }) + +That command will send a service message to the chat window of the character +specified by account ID or name, or to connected to npc player. +It will not be seen by anyone else. + +Works fro 20170830 RE and main and for any zero clients +--------------------------------------- diff --git a/src/map/script.c b/src/map/script.c index 4760fd4a0..52c0cf75c 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -15678,6 +15678,29 @@ static BUILDIN(message) return true; } +static BUILDIN(servicemessage) +{ + struct map_session_data *sd = NULL; + + if (script_hasdata(st, 4)) { + if (script_isstringtype(st, 4)) + sd = script->nick2sd(st, script_getstr(st, 4)); + else + sd = script->id2sd(st, script_getnum(st, 4)); + } else { + sd = script->rid2sd(st); + } + + if (sd == NULL) + return true; + + const char *message = script_getstr(st, 2); + const int color = script_getnum(st, 3); + clif->serviceMessageColor(sd, color, message); + + return true; +} + /*========================================== * npctalk (sends message to surrounding area) * usage: npctalk(""{, ""{, }}); @@ -25244,6 +25267,7 @@ static void script_parse_builtin(void) BUILDIN_DEF2(atcommand,"charcommand","s"), // [MouseJstr] BUILDIN_DEF(movenpc,"sii?"), // [MouseJstr] BUILDIN_DEF(message,"vs"), // [MouseJstr] + BUILDIN_DEF(servicemessage, "si?"), BUILDIN_DEF(npctalk,"s??"), // [Valaris][Murilo BiO] BUILDIN_DEF(mobcount,"ss"), BUILDIN_DEF(getlook,"i"), -- cgit v1.2.3-70-g09d2 From d17b51770830d9e9e395d1b87b26572d8434fd57 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 14 Dec 2018 06:27:52 +0300 Subject: Add script command expandInventoryAck It send initial response for inventory expanding request. --- doc/script_commands.txt | 19 ++++++++++++++++++- src/map/script.c | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 0096cedfd..5fad09c9f 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -10256,5 +10256,22 @@ That command will send a service message to the chat window of the character specified by account ID or name, or to connected to npc player. It will not be seen by anyone else. -Works fro 20170830 RE and main and for any zero clients +Works for 20170830 RE and main and for any zero clients +--------------------------------------- + +*expandInventoryAck({, }) + +Send initial inventory expansion result. +Normally this function should be called from script label +inventory_expansion::OnInventoryExpandRequest. + +Valid result statuses: + EXPAND_INVENTORY_ASK_CONFIRMATION - force client to ask player about inventory expansion + EXPAND_INVENTORY_FAILED - other failed reason + EXPAND_INVENTORY_OTHER_WORK - failed because player busy with other work + EXPAND_INVENTORY_MISSING_ITEM - failed because missing item + EXPAND_INVENTORY_MAX_SIZE - failed because inventory size already maximum + +ItemId make sense only if result is EXPAND_INVENTORY_ASK_CONFIRMATION +Works for 20181212 zero clients --------------------------------------- diff --git a/src/map/script.c b/src/map/script.c index 8d3de56a5..cf192fce8 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -24860,6 +24860,20 @@ static BUILDIN(enchantitem) return true; } +// send ack to inventory expand request +static BUILDIN(expandInventoryAck) +{ + struct map_session_data *sd = script_rid2sd(st); + if (sd == NULL) + return false; + int itemId = 0; + if (script_hasdata(st, 3)) { + itemId = script_getnum(st, 3); + } + clif->inventoryExpandAck(sd, script_getnum(st, 2), itemId); + return true; +} + /** * Adds a built-in script function. * @@ -25600,6 +25614,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(itempreview, "i"), BUILDIN_DEF(enchantitem, "iii"), + BUILDIN_DEF(expandInventoryAck, "i?"), }; int i, len = ARRAYLENGTH(BUILDIN); RECREATE(script->buildin, char *, script->buildin_count + len); // Pre-alloc to speed up @@ -26023,6 +26038,12 @@ static void script_hardcoded_constants(void) script->set_constant("ITR_NOAUCTION", ITR_NOAUCTION, false, false); script->set_constant("ITR_ALL", ITR_ALL, false, false); + script->constdb_comment("inventory expand ack responds"); + script->set_constant("EXPAND_INV_ASK_CONFIRMATION", EXPAND_INVENTORY_ASK_CONFIRMATION, false, false); + script->set_constant("EXPAND_INV_FAILED", EXPAND_INVENTORY_FAILED, false, false); + script->set_constant("EXPAND_INV_OTHER_WORK", EXPAND_INVENTORY_OTHER_WORK, false, false); + script->set_constant("EXPAND_INV_MISSING_ITEM", EXPAND_INVENTORY_MISSING_ITEM, false, false); + script->set_constant("EXPAND_INV_MAX_SIZE", EXPAND_INVENTORY_MAX_SIZE, false, false); script->constdb_comment("Renewal"); #ifdef RENEWAL -- cgit v1.2.3-70-g09d2 From 16f3fe4fd1eeaa27ad093ea70b0a26054096bdb0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 14 Dec 2018 06:52:34 +0300 Subject: Add script command expandInventoryResult. This function send to client final expand status. --- doc/script_commands.txt | 20 ++++++++++++++++++++ src/map/script.c | 18 ++++++++++++++++++ 2 files changed, 38 insertions(+) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 5fad09c9f..d2f945719 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -10247,6 +10247,7 @@ card_id - any card item id. returns true if all parameters correct false in other case. Works for 20160831 main, 20151118 RE, any zero version + --------------------------------------- *servicemessage("", {, }) @@ -10257,6 +10258,7 @@ specified by account ID or name, or to connected to npc player. It will not be seen by anyone else. Works for 20170830 RE and main and for any zero clients + --------------------------------------- *expandInventoryAck({, }) @@ -10274,4 +10276,22 @@ Valid result statuses: ItemId make sense only if result is EXPAND_INVENTORY_ASK_CONFIRMATION Works for 20181212 zero clients + +--------------------------------------- + +*expandInventoryResult() + +Send final inventory expansion result. +Normally this function should be called from script label +inventory_expansion::OnInventoryExpandConfirmed. + +Valid result values: + EXPAND_INVENTORY_RESULT_SUCCESS - success message + EXPAND_INVENTORY_RESULT_FAILED - other failed reason + EXPAND_INVENTORY_RESULT_OTHER_WORK - failed because player busy with other work + EXPAND_INVENTORY_RESULT_MISSING_ITEM - failed because missing item + EXPAND_INVENTORY_RESULT_MAX_SIZE - failed because inventory size already maximum + +Works for 20181212 zero clients + --------------------------------------- diff --git a/src/map/script.c b/src/map/script.c index cf192fce8..36b316320 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -24874,6 +24874,16 @@ static BUILDIN(expandInventoryAck) return true; } +// send final ack to inventory expand request +static BUILDIN(expandInventoryResult) +{ + struct map_session_data *sd = script_rid2sd(st); + if (sd == NULL) + return false; + clif->inventoryExpandResult(sd, script_getnum(st, 2)); + return true; +} + /** * Adds a built-in script function. * @@ -25615,6 +25625,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(itempreview, "i"), BUILDIN_DEF(enchantitem, "iii"), BUILDIN_DEF(expandInventoryAck, "i?"), + BUILDIN_DEF(expandInventoryResult, "i"), }; int i, len = ARRAYLENGTH(BUILDIN); RECREATE(script->buildin, char *, script->buildin_count + len); // Pre-alloc to speed up @@ -26045,6 +26056,13 @@ static void script_hardcoded_constants(void) script->set_constant("EXPAND_INV_MISSING_ITEM", EXPAND_INVENTORY_MISSING_ITEM, false, false); script->set_constant("EXPAND_INV_MAX_SIZE", EXPAND_INVENTORY_MAX_SIZE, false, false); + script->constdb_comment("inventory expand final responds"); + script->set_constant("EXPAND_INV_RESULT_SUCCESS", EXPAND_INVENTORY_RESULT_SUCCESS, false, false); + script->set_constant("EXPAND_INV_RESULT_FAILED", EXPAND_INVENTORY_RESULT_FAILED, false, false); + script->set_constant("EXPAND_INV_RESULT_OTHER_WORK", EXPAND_INVENTORY_RESULT_OTHER_WORK, false, false); + script->set_constant("EXPAND_INV_RESULT_MISSING_ITEM", EXPAND_INVENTORY_RESULT_MISSING_ITEM, false, false); + script->set_constant("EXPAND_INV_RESULT_MAX_SIZE", EXPAND_INVENTORY_RESULT_MAX_SIZE, false, false); + script->constdb_comment("Renewal"); #ifdef RENEWAL script->set_constant("RENEWAL", 1, false, false); -- cgit v1.2.3-70-g09d2 From c79927b6879f07784ceb19a606483acc791dea80 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 14 Dec 2018 19:35:17 +0300 Subject: Add script command expandInventory This command allow adjust inventory size to positive or negative value. --- doc/script_commands.txt | 10 ++++++++++ src/map/pc.c | 18 ++++++++++++++++++ src/map/pc.h | 1 + src/map/script.c | 11 +++++++++++ 4 files changed, 40 insertions(+) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index d2f945719..5a9894217 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -10295,3 +10295,13 @@ Valid result values: Works for 20181212 zero clients --------------------------------------- + +*expandInventory() + +Adjust player inventory to given value. +Maximum inventory size is MAX_INVENTORY. +Minimum inventory size is FIXED_INVENTORY_SIZE. +For supported clients it send inventory change packet. For old clients, +this change is silent. + +--------------------------------------- diff --git a/src/map/pc.c b/src/map/pc.c index ad8cf2a94..94d8cd0c6 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -12338,6 +12338,23 @@ static bool pc_has_second_costume(struct map_session_data *sd) return false; } +static bool pc_expandInventory(struct map_session_data *sd, int adjustSize) +{ + nullpo_retr(false, sd); + const int invSize = sd->status.inventorySize; + if (adjustSize > MAX_INVENTORY || invSize + adjustSize <= FIXED_INVENTORY_SIZE || invSize + adjustSize > MAX_INVENTORY) { + clif->inventoryExpandResult(sd, EXPAND_INVENTORY_RESULT_MAX_SIZE); + return false; + } + if (pc_isdead(sd) || sd->state.vending || sd->state.buyingstore || sd->chat_id != 0 || sd->state.trading || sd->state.storage_flag || sd->state.prevend) { + clif->inventoryExpandResult(sd, EXPAND_INVENTORY_RESULT_OTHER_WORK); + return false; + } + sd->status.inventorySize += adjustSize; + clif->inventoryExpansionInfo(sd); + return true; +} + static void do_final_pc(void) { @@ -12740,4 +12757,5 @@ void pc_defaults(void) pc->isDeathPenaltyJob = pc_isDeathPenaltyJob; pc->has_second_costume = pc_has_second_costume; + pc->expandInventory = pc_expandInventory; } diff --git a/src/map/pc.h b/src/map/pc.h index cca15e829..bc2fd5a62 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -1185,6 +1185,7 @@ END_ZEROED_BLOCK; /* End */ bool (*check_basicskill) (struct map_session_data *sd, int level); bool (*isDeathPenaltyJob) (uint16 job); bool (*has_second_costume) (struct map_session_data *sd); + bool (*expandInventory) (struct map_session_data *sd, int adjustSize); }; #ifdef HERCULES_CORE diff --git a/src/map/script.c b/src/map/script.c index 36b316320..8dadf6d57 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -24884,6 +24884,16 @@ static BUILDIN(expandInventoryResult) return true; } +// adjust player inventory size to given value positive or negative +static BUILDIN(expandInventory) +{ + struct map_session_data *sd = script_rid2sd(st); + if (sd == NULL) + return false; + script_pushint(st, pc->expandInventory(sd, script_getnum(st, 2))); + return true; +} + /** * Adds a built-in script function. * @@ -25626,6 +25636,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(enchantitem, "iii"), BUILDIN_DEF(expandInventoryAck, "i?"), BUILDIN_DEF(expandInventoryResult, "i"), + BUILDIN_DEF(expandInventory, "i"), }; int i, len = ARRAYLENGTH(BUILDIN); RECREATE(script->buildin, char *, script->buildin_count + len); // Pre-alloc to speed up -- cgit v1.2.3-70-g09d2 From ec05dccfddedf8250f1df61ce94dafb6823dace7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 14 Dec 2018 19:46:43 +0300 Subject: Add script command getInventorySize. This command allow read current max inventory size. --- doc/script_commands.txt | 9 +++++++++ src/map/script.c | 11 +++++++++++ 2 files changed, 20 insertions(+) (limited to 'doc') diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 5a9894217..5171d65f3 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -10303,5 +10303,14 @@ Maximum inventory size is MAX_INVENTORY. Minimum inventory size is FIXED_INVENTORY_SIZE. For supported clients it send inventory change packet. For old clients, this change is silent. +Current max inventory size can be read by function getInventorySize(). + +--------------------------------------- + +*getInventorySize() + +Return current player max inventory size. +This value always smaller or equal to MAX_INVENTORY. +Size can be changed by group of functions expandInventory* --------------------------------------- diff --git a/src/map/script.c b/src/map/script.c index 8dadf6d57..3d3fba867 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -24894,6 +24894,16 @@ static BUILDIN(expandInventory) return true; } +// return current player inventory size +static BUILDIN(getInventorySize) +{ + struct map_session_data *sd = script_rid2sd(st); + if (sd == NULL) + return false; + script_pushint(st, sd->status.inventorySize); + return true; +} + /** * Adds a built-in script function. * @@ -25637,6 +25647,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(expandInventoryAck, "i?"), BUILDIN_DEF(expandInventoryResult, "i"), BUILDIN_DEF(expandInventory, "i"), + BUILDIN_DEF(getInventorySize, ""), }; int i, len = ARRAYLENGTH(BUILDIN); RECREATE(script->buildin, char *, script->buildin_count + len); // Pre-alloc to speed up -- cgit v1.2.3-70-g09d2