diff options
author | Ibrahem Zidan <brahem@aotsw.com> | 2019-04-29 18:02:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-29 18:02:23 +0200 |
commit | f272422f2dbd015691ecba06a14a18d48e7362da (patch) | |
tree | d7c8288fa58915cf684529a47ce73b5cfb68031f /src | |
parent | b22f47068343f93d1559284cc443542151daad43 (diff) | |
parent | 4e089c3c8e3c000e8dad67f8b0a54c714e9256d7 (diff) | |
download | hercules-f272422f2dbd015691ecba06a14a18d48e7362da.tar.gz hercules-f272422f2dbd015691ecba06a14a18d48e7362da.tar.bz2 hercules-f272422f2dbd015691ecba06a14a18d48e7362da.tar.xz hercules-f272422f2dbd015691ecba06a14a18d48e7362da.zip |
Merge pull request #2439 from Emistry/atcommand_dropall
Update dropall atcommand drop item based on type.
Diffstat (limited to 'src')
-rw-r--r-- | src/map/atcommand.c | 35 | ||||
-rw-r--r-- | src/map/atcommand.h | 2 |
2 files changed, 31 insertions, 6 deletions
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)) |