summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIbrahem Zidan <brahem@aotsw.com>2019-04-29 18:02:23 +0200
committerGitHub <noreply@github.com>2019-04-29 18:02:23 +0200
commitf272422f2dbd015691ecba06a14a18d48e7362da (patch)
treed7c8288fa58915cf684529a47ce73b5cfb68031f
parentb22f47068343f93d1559284cc443542151daad43 (diff)
parent4e089c3c8e3c000e8dad67f8b0a54c714e9256d7 (diff)
downloadhercules-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.
-rw-r--r--conf/messages.conf5
-rw-r--r--doc/atcommands.txt20
-rw-r--r--src/map/atcommand.c35
-rw-r--r--src/map/atcommand.h2
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 {<type>}
+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 {<item type>}
+
+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))