From 4e089c3c8e3c000e8dad67f8b0a54c714e9256d7 Mon Sep 17 00:00:00 2001 From: Emistry Haoyan Date: Sat, 13 Apr 2019 23:35:50 +0800 Subject: Update dropall atcommand drop item based on type. - Enable to drop items based on item type. --- conf/messages.conf | 5 +++++ doc/atcommands.txt | 20 +++++++++++++++++--- src/map/atcommand.c | 35 ++++++++++++++++++++++++++++++----- src/map/atcommand.h | 2 +- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/conf/messages.conf b/conf/messages.conf index 2f790b13f..772b882c9 100644 --- a/conf/messages.conf +++ b/conf/messages.conf @@ -1569,5 +1569,10 @@ 1498: You can't add a party bound item to a character without party! 1499: You can't add a guild bound item to a character without guild! +// @dropall +1500: Usage: @dropall {} +1501: Type List: (default) all = -1, healing = 0, usable = 2, etc = 3, weapon = 4, armor = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10, delayed-consumable = 11, cash = 18 +1502: %d items are dropped! + //Custom translations import: conf/import/msg_conf.txt diff --git a/doc/atcommands.txt b/doc/atcommands.txt index b455d9151..dd8ad0969 100644 --- a/doc/atcommands.txt +++ b/doc/atcommands.txt @@ -692,9 +692,23 @@ Repairs all broken items in your inventory. --------------------------------------- -@dropall - -Drops all inventory and equipped items onto the floor. +@dropall {} + +Drops all items based on the item type. + +Valid item types: + -1 = All Items (default) + 0 = Healing Items + 2 = Useable Items + 3 = Etc Items + 4 = Weapons + 5 = Armors + 6 = Cards + 7 = Pet Eggs + 8 = Pet Armors + 10 = Ammunition Items + 11 = Delayed-Consumable Items + 18 = Cash Items --------------------------------------- diff --git a/src/map/atcommand.c b/src/map/atcommand.c index a9bbff7bd..9ed56545c 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5277,18 +5277,43 @@ ACMD(follow) } /*========================================== - * @dropall by [MouseJstr] - * Drop all your possession on the ground + * @dropall by [MouseJstr] and [Xantara] + * Drop all your possession on the ground based on item type *------------------------------------------*/ ACMD(dropall) { + int type = -1; + int count = 0; + + if (message[0] != '\0') { + type = atoi(message); + if (!((type >= IT_HEALING && type <= IT_DELAYCONSUME) || type == IT_CASH || type == -1)) { + clif->message(fd, msg_fd(fd, 1500)); + clif->message(fd, msg_fd(fd, 1501)); + return false; + } + } + for (int i = 0; i < sd->status.inventorySize; i++) { if (sd->status.inventory[i].amount) { - if(sd->status.inventory[i].equip != 0) - pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC|PCUNEQUIPITEM_FORCE); - pc->dropitem(sd, i, sd->status.inventory[i].amount); + struct item_data *item_data = itemdb->exists(sd->status.inventory[i].nameid); + if (item_data == NULL) { + ShowWarning("Non-existant item %d on dropall list (account_id: %d, char_id: %d)\n", sd->status.inventory[i].nameid, sd->status.account_id, sd->status.char_id); + continue; + } + if (!pc->candrop(sd, &sd->status.inventory[i])) + continue; + if (type == -1 || type == item_data->type) { + if (sd->status.inventory[i].equip != 0) + pc->unequipitem(sd, i, PCUNEQUIPITEM_RECALC | PCUNEQUIPITEM_FORCE); + count += sd->status.inventory[i].amount; + pc->dropitem(sd, i, sd->status.inventory[i].amount); + } } } + + sprintf(atcmd_output, msg_fd(fd, 1502), count); // %d items are dropped! + clif->message(fd, atcmd_output); return true; } diff --git a/src/map/atcommand.h b/src/map/atcommand.h index 1783e5dc6..4fbf6b93a 100644 --- a/src/map/atcommand.h +++ b/src/map/atcommand.h @@ -41,7 +41,7 @@ struct config_setting_t; * Defines **/ #define ATCOMMAND_LENGTH 50 -#define MAX_MSG 1500 +#define MAX_MSG 1503 #define msg_txt(idx) atcommand->msg(idx) #define msg_sd(sd,msg_number) atcommand->msgsd((sd),(msg_number)) #define msg_fd(fd,msg_number) atcommand->msgfd((fd),(msg_number)) -- cgit v1.2.3-60-g2f50