diff options
-rw-r--r-- | doc/script_commands.txt | 27 | ||||
-rw-r--r-- | src/map/script.c | 85 |
2 files changed, 111 insertions, 1 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt index 9777038a4..82471aed8 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -4977,7 +4977,32 @@ will be used. --------------------------------------- -*cleanarea("<map name>", <x1>, <y1>, <x2>, <y2>) +*makeitem2(<item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,{"<map name>",<X>,<Y>,<range>}) +*makeitem2("<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,{"<map name>",<X>,<Y>,<range>}) + +This script command work like 'makeitem', but it has additional parameters +to expand the usage of the scritp command. + +Parameter List: + itemid - ID / Name of an item + amount - Amount you want produced (Value: 1~MAX_AMOUNT) + - if item type is Armor/Wepaon/PetEgg/PetArmor, amount will be limit to 1 + identify - Item to be identified (1) or not (0) + refine - Refine count of item. (Value: 0 ~ MAX_REFINE) + attribute - Item is broken (1) or not (0) + card1,2,3,4 - Card IDs that compound on each slot + +Optional Parameter List: + map name - Map name (Default to attached player map) + X,Y - The coordinate of item will be dropped + If value = 0, it's drop random across the map + If value = -1, its drop around player + range - Range of item drop around player. (Value: 1 ~ battle_config.area_size, Default: 3) + Default value will be used if no player are attached to the script. + +--------------------------------------- + +*cleanarea("<map name>",<x1>,<y1>,<x2>,<y2>) *cleanmap("<map name>") These commands will clear all items lying on the ground on the specified diff --git a/src/map/script.c b/src/map/script.c index 3a81c8075..24faa6756 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8016,6 +8016,90 @@ BUILDIN(makeitem) return true; } +/*========================================== +* makeitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>,{"<map name>",<X>,<Y>,<range>}; +*------------------------------------------*/ +BUILDIN(makeitem2) +{ + struct map_session_data *sd = NULL; + struct item_data *i_data; + int nameid = 0, amount; + int16 x, y, m = -1, range; + struct item item_tmp; + + if (script_isstringtype(st, 2)) { + const char *name = script_getstr(st, 2); + struct item_data *item_data = itemdb->search_name(name); + if (item_data == NULL) + nameid = item_data->nameid; + } else { + nameid = script_getnum(st, 2); + } + + i_data = itemdb->exists(nameid); + if (i_data == NULL) { + ShowError("makeitem2: Unknown item %d requested.\n", nameid); + return true; + } + + if (script_hasdata(st, 11)) { + m = map->mapname2mapid(script_getstr(st, 11)); + } else { + sd = script->rid2sd(st); + if (sd == NULL) + return true; + m = sd->bl.m; + } + + if (m == -1) { + ShowError("makeitem2: Nonexistant map requested.\n"); + return true; + } + + x = (script_hasdata(st, 12) ? script_getnum(st, 12) : 0); + y = (script_hasdata(st, 13) ? script_getnum(st, 13) : 0); + + // pick random position on map + if (x <= 0 || x >= map->list[m].xs || y <= 0 || y >= map->list[m].ys) { + sd = map->id2sd(st->rid); + if ((x < 0 || y < 0) && sd == NULL) { + x = 0; + y = 0; + map->search_freecell(NULL, m, &x, &y, -1, -1, 1); + } else { + range = (script_hasdata(st, 14) ? cap_value(script_getnum(st, 14), 1, battle_config.area_size) : 3); + map->search_freecell(&sd->bl, sd->bl.m, &x, &y, range, range, 0); // Locate spot next to player. + } + } + + // if equip or weapon or egg type only drop one. + switch (i_data->type) { + case IT_ARMOR: + case IT_WEAPON: + case IT_PETARMOR: + case IT_PETEGG: + amount = 1; + break; + default: + amount = cap_value(script_getnum(st, 3), 1, MAX_AMOUNT); + break; + } + + memset(&item_tmp, 0, sizeof(item_tmp)); + item_tmp.nameid = nameid; + item_tmp.identify = script_getnum(st, 4); + item_tmp.refine = cap_value(script_getnum(st, 5), 0, MAX_REFINE); + item_tmp.attribute = script_getnum(st, 6); + item_tmp.card[0] = (short)script_getnum(st, 7); + item_tmp.card[1] = (short)script_getnum(st, 8); + item_tmp.card[2] = (short)script_getnum(st, 9); + item_tmp.card[3] = (short)script_getnum(st, 10); + + map->addflooritem(NULL, &item_tmp, amount, m, x, y, 0, 0, 0, 0); + + return true; +} + /// Counts / deletes the current item given by idx. /// Used by buildin_delitem_search /// Relies on all input data being already fully valid. @@ -20749,6 +20833,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(getnameditem,"vv"), BUILDIN_DEF2(grouprandomitem,"groupranditem","i"), BUILDIN_DEF(makeitem,"visii"), + BUILDIN_DEF(makeitem2,"viiiiiiii????"), BUILDIN_DEF(delitem,"vi?"), BUILDIN_DEF(delitem2,"viiiiiiii?"), BUILDIN_DEF2(enableitemuse,"enable_items",""), |