summaryrefslogtreecommitdiff
path: root/src/map/atcommand.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2013-11-03 01:18:47 +0100
committerHaru <haru@dotalux.com>2013-11-03 01:21:48 +0100
commit649e7b98a7ec4fbf3363597daad3d1c57383051f (patch)
treebe7e05028610601ae574802e6dc2ac46448e4cca /src/map/atcommand.c
parent34b5ad00e2b7a3589040946b7825ef246bfafe99 (diff)
parentfa54cf57ded42d7b0b45a5025a8858a9b52a0074 (diff)
downloadhercules-649e7b98a7ec4fbf3363597daad3d1c57383051f.tar.gz
hercules-649e7b98a7ec4fbf3363597daad3d1c57383051f.tar.bz2
hercules-649e7b98a7ec4fbf3363597daad3d1c57383051f.tar.xz
hercules-649e7b98a7ec4fbf3363597daad3d1c57383051f.zip
Merged Pull Request #195 (@autoloottype)
- Small tweaks to the command, fixed merge conflicts Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/atcommand.c')
-rw-r--r--src/map/atcommand.c118
1 files changed, 108 insertions, 10 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 758ebb0db..ed5852b76 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -5603,16 +5603,16 @@ ACMD(autolootitem)
}
else if (!strcmp(message,"reset"))
action = 4;
- }
-
- if (action < 3) // add or remove
- {
- if ((item_data = itemdb->exists(atoi(message))) == NULL)
- item_data = itemdb->search_name(message);
- if (!item_data) {
- // No items founds in the DB with Id or Name
- clif->message(fd, msg_txt(1189)); // Item not found.
- return false;
+
+ if (action < 3) // add or remove
+ {
+ if ((item_data = itemdb->exists(atoi(message))) == NULL)
+ item_data = itemdb->search_name(message);
+ if (!item_data) {
+ // No items founds in the DB with Id or Name
+ clif->message(fd, msg_txt(1189)); // Item not found.
+ return false;
+ }
}
}
@@ -5680,6 +5680,103 @@ ACMD(autolootitem)
}
/*==========================================
+ * @autoloottype
+ * Credits:
+ * chriser,Aleos
+ *------------------------------------------*/
+ACMD(autoloottype) {
+ int i;
+ uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
+ enum item_types type = -1;
+ int ITEM_NONE = 0;
+
+ if (message && *message) {
+ if (message[0] == '+') {
+ message++;
+ action = 1;
+ } else if (message[0] == '-') {
+ message++;
+ action = 2;
+ } else if (strcmp(message,"reset") == 0) {
+ action = 4;
+ }
+
+ if (action < 3) {
+ // add or remove
+ if (strncmp(message, "healing", 3) == 0)
+ type = IT_HEALING;
+ else if (strncmp(message, "usable", 3) == 0)
+ type = IT_USABLE;
+ else if (strncmp(message, "etc", 3) == 0)
+ type = IT_ETC;
+ else if (strncmp(message, "weapon", 3) == 0)
+ type = IT_WEAPON;
+ else if (strncmp(message, "armor", 3) == 0)
+ type = IT_ARMOR;
+ else if (strncmp(message, "card", 3) == 0)
+ type = IT_CARD;
+ else if (strncmp(message, "petegg", 4) == 0)
+ type = IT_PETEGG;
+ else if (strncmp(message, "petarmor", 4) == 0)
+ type = IT_PETARMOR;
+ else if (strncmp(message, "ammo", 3) == 0)
+ type = IT_AMMO;
+ else {
+ clif->message(fd, msg_txt(1491)); // Item type not found.
+ return false;
+ }
+ }
+ }
+
+ switch (action) {
+ case 1:
+ if (sd->state.autoloottype&(1<<type)) {
+ clif->message(fd, msg_txt(1490)); // You're already autolooting this item type.
+ return false;
+ }
+ sd->state.autoloottype |= (1<<type); // Stores the type
+ sprintf(atcmd_output, msg_txt(1492), itemdb->typename(type)); // Autolooting item type: '%s'
+ clif->message(fd, atcmd_output);
+ break;
+ case 2:
+ if (!(sd->state.autoloottype&(1<<type))) {
+ clif->message(fd, msg_txt(1493)); // You're currently not autolooting this item type.
+ return false;
+ }
+ sd->state.autoloottype &= ~(1<<type);
+ sprintf(atcmd_output, msg_txt(1494), itemdb->typename(type)); // Removed item type: '%s' from your autoloottype list.
+ clif->message(fd, atcmd_output);
+ break;
+ case 3:
+ clif->message(fd, msg_txt(38)); // Invalid location number, or name.
+
+ {
+ // attempt to find the text help string
+ const char *text = atcommand_help_string(info);
+ if (text) clif->messageln(fd, text); // send the text to the client
+ }
+
+ if (sd->state.autoloottype == ITEM_NONE) {
+ clif->message(fd, msg_txt(1495)); // Your autoloottype list is empty.
+ } else {
+ clif->message(fd, msg_txt(1496)); // Item types on your autoloottype list:
+ for(i=0; i < IT_MAX; i++) {
+ if (sd->state.autoloottype&(1<<i)) {
+ sprintf(atcmd_output, " '%s'", itemdb->typename(i));
+ clif->message(fd, atcmd_output);
+ }
+ }
+ }
+ break;
+ case 4:
+ sd->state.autoloottype = ITEM_NONE;
+ clif->message(fd, msg_txt(1497)); // Your autoloottype list has been reset.
+ break;
+ }
+ return true;
+}
+
+/*==========================================
* It is made to snow.
*------------------------------------------*/
ACMD(snow) {
@@ -9383,6 +9480,7 @@ void atcommand_basecommands(void) {
ACMD_DEF(changelook),
ACMD_DEF(autoloot),
ACMD_DEF2("alootid", autolootitem),
+ ACMD_DEF(autoloottype),
ACMD_DEF(mobinfo),
ACMD_DEF(exp),
ACMD_DEF(version),