summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/atcommand.c97
-rw-r--r--src/map/mob.c2
-rw-r--r--src/map/pc.c11
-rw-r--r--src/map/pc.h6
4 files changed, 93 insertions, 23 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index d4353a5ab..ab5d632ff 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -6239,32 +6239,87 @@ ACMD_FUNC(autoloot)
ACMD_FUNC(autolootitem)
{
struct item_data *item_data = NULL;
+ int i;
+ int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset
- if (!message || !*message) {
- if (sd->state.autolootid) {
- sd->state.autolootid = 0;
- clif_displaymessage(fd, "Autolootitem has been turned OFF.");
- } else
- clif_displaymessage(fd, "Please, enter item name or it's ID (usage: @alootid <item_name_or_ID>).");
-
- return -1;
+ if (message && *message) {
+ if (message[0] == '+') {
+ message++;
+ action = 1;
+ }
+ else if (message[0] == '-') {
+ message++;
+ action = 2;
+ }
+ else if (!strcmp(message,"reset"))
+ action = 4;
}
- if ((item_data = itemdb_exists(atoi(message))) == NULL)
- item_data = itemdb_searchname(message);
-
- if (!item_data) {
- // No items founds in the DB with Id or Name
- clif_displaymessage(fd, "Item not found.");
- return -1;
+ if (action < 3) // add or remove
+ {
+ if ((item_data = itemdb_exists(atoi(message))) == NULL)
+ item_data = itemdb_searchname(message);
+ if (!item_data) {
+ // No items founds in the DB with Id or Name
+ clif_displaymessage(fd, "Item not found.");
+ return -1;
+ }
}
- sd->state.autolootid = item_data->nameid; // Autoloot Activated
-
- sprintf(atcmd_output, "Autolooting item: '%s'/'%s' (%d)",
- item_data->name, item_data->jname, item_data->nameid);
- clif_displaymessage(fd, atcmd_output);
-
+ switch(action) {
+ case 1:
+ ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
+ if (i != AUTOLOOTITEM_SIZE) {
+ clif_displaymessage(fd, "You're already autolooting this item.");
+ return -1;
+ }
+ ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == 0);
+ if (i == AUTOLOOTITEM_SIZE) {
+ clif_displaymessage(fd, "Your autolootitem list is full. Remove some items first with @autolootid -<item name or ID>.");
+ return -1;
+ }
+ sd->state.autolootid[i] = item_data->nameid; // Autoloot Activated
+ sprintf(atcmd_output, "Autolooting item: '%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
+ clif_displaymessage(fd, atcmd_output);
+ break;
+ case 2:
+ ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
+ if (i == AUTOLOOTITEM_SIZE) {
+ clif_displaymessage(fd, "You're currently not autolooting this item.");
+ return -1;
+ }
+ sd->state.autolootid[i] = 0;
+ sprintf(atcmd_output, "Removed item: '%s'/'%s' {%d} from your autolootitem list.", item_data->name, item_data->jname, item_data->nameid);
+ clif_displaymessage(fd, atcmd_output);
+ break;
+ case 3:
+ sprintf(atcmd_output, "You can have %d items on your autolootitem list.", AUTOLOOTITEM_SIZE);
+ clif_displaymessage(fd, atcmd_output);
+ clif_displaymessage(fd, "To add item to the list, use \"@alootid +<item name or ID>\". To remove item use \"@alootid -<item name or ID>\".");
+ clif_displaymessage(fd, "\"@alootid reset\" will clear your autolootitem list.");
+ ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] != 0);
+ if (i == AUTOLOOTITEM_SIZE) {
+ clif_displaymessage(fd, "Your autolootitem list is empty.");
+ } else {
+ clif_displaymessage(fd, "Items on your autolootitem list:");
+ for(i = 0; i < AUTOLOOTITEM_SIZE; i++)
+ {
+ if (sd->state.autolootid[i] == 0)
+ continue;
+ if (!(item_data = itemdb_exists(sd->state.autolootid[i]))) {
+ ShowDebug("Non-existant item %d on autolootitem list (account_id: %d, char_id: %d)", sd->state.autolootid[i], sd->status.account_id, sd->status.char_id);
+ continue;
+ }
+ sprintf(atcmd_output, "'%s'/'%s' {%d}", item_data->name, item_data->jname, item_data->nameid);
+ clif_displaymessage(fd, atcmd_output);
+ }
+ }
+ break;
+ case 4:
+ memset(sd->state.autolootid, 0, sizeof(sd->state.autolootid));
+ clif_displaymessage(fd, "Your autolootitem list has been reset.");
+ break;
+ }
return 0;
}
/**
diff --git a/src/map/mob.c b/src/map/mob.c
index 7b5e0265c..6f0bd859d 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -1738,7 +1738,7 @@ static void mob_item_drop(struct mob_data *md, struct item_drop_list *dlist, str
if( sd == NULL ) sd = map_charid2sd(dlist->third_charid);
if( sd
- && (drop_rate <= sd->state.autoloot || ditem->item_data.nameid == sd->state.autolootid)
+ && (drop_rate <= sd->state.autoloot || pc_isautolooting(sd, ditem->item_data.nameid))
&& (battle_config.idle_no_autoloot == 0 || DIFF_TICK(last_tick, sd->idletime) < battle_config.idle_no_autoloot)
&& (battle_config.homunculus_autoloot?1:!flag)
#ifdef AUTOLOOT_DISTANCE
diff --git a/src/map/pc.c b/src/map/pc.c
index 386ea68a3..9d7f67f3e 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -8182,6 +8182,17 @@ void pc_overheat(struct map_session_data *sd, int val) {
return;
}
+
+/**
+ * Check if player is autolooting given itemID.
+ */
+bool pc_isautolooting(struct map_session_data *sd, int nameid)
+{
+ int i;
+ ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == nameid);
+ return (i != AUTOLOOTITEM_SIZE);
+}
+
int pc_split_str(char *str,char **val,int num)
{
int i;
diff --git a/src/map/pc.h b/src/map/pc.h
index affe3690b..05cdc9e73 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -25,6 +25,9 @@
//For Warlock
#define MAX_SPELLBOOK 10
+//Max number of items on @autolootid list
+#define AUTOLOOTITEM_SIZE 10
+
struct weapon_data {
int atkmods[3];
// all the variables except atkmods get zero'ed in each call of status_calc_pc
@@ -139,7 +142,7 @@ struct map_session_data {
unsigned int callshop : 1; // flag to indicate that a script used callshop; on a shop
short pmap; // Previous map on Map Change
unsigned short autoloot;
- unsigned short autolootid; // [Zephyrus]
+ unsigned short autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus]
unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish]
struct guild *gmaster_flag;
unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
@@ -838,6 +841,7 @@ void pc_inventory_rental_add(struct map_session_data *sd, int seconds);
int pc_read_motd(void); // [Valaris]
int pc_disguise(struct map_session_data *sd, int class_);
+bool pc_isautolooting(struct map_session_data *sd, int nameid);
/**
* Mechanic (Mado Gear)
**/