From 2eebafb70330e37dd69a384ce0af52570b4956c2 Mon Sep 17 00:00:00 2001 From: HAO YAN Date: Wed, 20 Oct 2021 21:45:07 +0800 Subject: [PATCH] Enable makeitem to display DropEffect (#6303) Enable item to special effect if the item has DropEffect flag. --- doc/script_commands.txt | 13 +++++++------ src/map/map.cpp | 1 + src/map/script.cpp | 40 ++++++++++++++++++++++++++++------------ 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 60354d9a94..8e17aad92c 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -4902,8 +4902,8 @@ Example to get Crimson Weapon with Ghost property: --------------------------------------- -*makeitem ,,"",,; -*makeitem "",,"",,; +*makeitem ,,"",,{,}; +*makeitem "",,"",,{,}; This command will create an item on the specified cell of a map. @@ -4914,13 +4914,14 @@ given amount, not multiple stacks of 1. Like 'getitem', it also accepts an 'english name' field from the database and creates Apples if the name isn't found. If the map name is given as "this", the map the invoking character is on will be used. +If flag is set to true, it will show a pillar effect on the ground when dropped, depending on the item database's DropEffect flag. --------------------------------------- -*makeitem2 ,,"",,,,,,,,,; -*makeitem2 "",,"",,,,,,,,,; -*makeitem3 ,,"",,,,,,,,,,,,; -*makeitem3 "",,"",,,,,,,,,,,,; +*makeitem2 ,,"",,,,,,,,,{,}; +*makeitem2 "",,"",,,,,,,,,{,}; +*makeitem3 ,,"",,,,,,,,,,,,{,}; +*makeitem3 "",,"",,,,,,,,,,,,{,}; This command will create an item on the specified cell of a map. See 'makeitem' for further details. diff --git a/src/map/map.cpp b/src/map/map.cpp index c25da5ff88..94e0553de4 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -1839,6 +1839,7 @@ bool map_closest_freecell(int16 m, int16 *x, int16 *y, int type, int flag) * @param third_charid : 3rd player that could loot the item (3rd charid that could loot for third_get_charid duration) * @param flag: &1 MVP item. &2 do stacking check. &4 bypass droppable check. * @param mob_id: Monster ID if dropped by monster + * @param canShowEffect: enable pillar effect on the dropped item (if set in the database) * @return 0:failure, x:item_gid [MIN_FLOORITEM;MAX_FLOORITEM]==[2;START_ACCOUNT_NUM] *------------------------------------------*/ int map_addflooritem(struct item *item, int amount, int16 m, int16 x, int16 y, int first_charid, int second_charid, int third_charid, int flags, unsigned short mob_id, bool canShowEffect) diff --git a/src/map/script.cpp b/src/map/script.cpp index 1de0aebf5e..2a08a640ad 100644 --- a/src/map/script.cpp +++ b/src/map/script.cpp @@ -7870,8 +7870,8 @@ BUILDIN_FUNC(grouprandomitem) { } /** -* makeitem ,,"",,; -* makeitem "",,"",,; +* makeitem ,,"",,{,}; +* makeitem "",,"",,{,}; */ BUILDIN_FUNC(makeitem) { t_itemid nameid; @@ -7879,6 +7879,7 @@ BUILDIN_FUNC(makeitem) { const char *mapname; int m; struct item item_tmp; + bool canShowEffect = false; if( script_isstring(st, 2) ){ const char *name = script_getstr(st, 2); @@ -7912,7 +7913,10 @@ BUILDIN_FUNC(makeitem) { x = script_getnum(st,5); y = script_getnum(st,6); - if(strcmp(mapname,"this")==0) { + if (script_hasdata(st, 7)) + canShowEffect = script_getnum(st, 7) != 0; + + if (strcmp(mapname, "this")==0) { TBL_PC *sd; if (!script_rid2sd(sd)) return SCRIPT_CMD_SUCCESS; //Failed... @@ -7927,16 +7931,16 @@ BUILDIN_FUNC(makeitem) { else item_tmp.identify = itemdb_isidentified(nameid); - map_addflooritem(&item_tmp,amount,m,x,y,0,0,0,4,0); + map_addflooritem(&item_tmp, amount, m, x, y, 0, 0, 0, 4, 0, canShowEffect); return SCRIPT_CMD_SUCCESS; } /** - * makeitem2 ,,"",,,,,,,,,; - * makeitem2 "",,"",,,,,,,,,; + * makeitem2 ,,"",,,,,,,,,{,}; + * makeitem2 "",,"",,,,,,,,,{,}; * - * makeitem3 ,,"",,,,,,,,,,,,; - * makeitem3 "",,"",,,,,,,,,,,,; + * makeitem3 ,,"",,,,,,,,,,,,{,}; + * makeitem3 "",,"",,,,,,,,,,,,{,}; */ BUILDIN_FUNC(makeitem2) { t_itemid nameid; @@ -7946,6 +7950,7 @@ BUILDIN_FUNC(makeitem2) { struct item item_tmp; struct item_data *id; const char *funcname = script_getfuncname(st); + bool canShowEffect = false; if( script_isstring( st, 2 ) ){ const char *name = script_getstr( st, 2 ); @@ -8013,9 +8018,20 @@ BUILDIN_FUNC(makeitem2) { int res = script_getitem_randomoption(st, nullptr, &item_tmp, funcname, 14); if (res != SCRIPT_CMD_SUCCESS) return res; + + if (script_hasdata(st, 17)) { + if (script_getnum(st, 17) != 0) + canShowEffect = script_getnum(st, 17) != 0; + } + } + else { + if (script_hasdata(st, 14)) { + if (script_getnum(st, 14) != 0) + canShowEffect = script_getnum(st, 14) != 0; + } } - map_addflooritem(&item_tmp,amount,m,x,y,0,0,0,4,0); + map_addflooritem(&item_tmp, amount, m, x, y, 0, 0, 0, 4, 0, canShowEffect); } else return SCRIPT_CMD_FAILURE; @@ -25332,8 +25348,8 @@ struct script_function buildin_func[] = { BUILDIN_DEF(getitem2,"viiiiiiii?"), BUILDIN_DEF(getnameditem,"vv"), BUILDIN_DEF2(grouprandomitem,"groupranditem","i?"), - BUILDIN_DEF(makeitem,"visii"), - BUILDIN_DEF(makeitem2,"visiiiiiiiii"), + BUILDIN_DEF(makeitem,"visii?"), + BUILDIN_DEF(makeitem2,"visiiiiiiiii?"), BUILDIN_DEF(delitem,"vi?"), BUILDIN_DEF2(delitem,"storagedelitem","vi?"), BUILDIN_DEF2(delitem,"guildstoragedelitem","vi?"), @@ -25897,7 +25913,7 @@ struct script_function buildin_func[] = { BUILDIN_DEF2(getitem2,"getitem3","viiiiiiiirrr?"), BUILDIN_DEF2(getitem2,"getitembound3","viiiiiiiiirrr?"), BUILDIN_DEF2(rentitem2,"rentitem3","viiiiiiiirrr?"), - BUILDIN_DEF2(makeitem2,"makeitem3","visiiiiiiiiirrr"), + BUILDIN_DEF2(makeitem2,"makeitem3","visiiiiiiiiirrr?"), BUILDIN_DEF2(delitem2,"delitem3","viiiiiiiirrr?"), BUILDIN_DEF2(countitem,"countitem3","viiiiiiirrr?"),