- Index: src/map/atcommand.c
- ===================================================================
- --- src/map/atcommand.c (revision 14109)
- +++ src/map/atcommand.c (working copy)
- @@ -6074,35 +6074,84 @@
- }
- /*==========================================
- - * @autolootitem
- + * @autolootitem [modified version by Rad]
- + * modified to enable players autoloot 5
- + * different items. Uses array. Counter checks added :p
- + * Sorry if it is too lousy for you :p
- *------------------------------------------*/
- int atcommand_autolootitem(const int fd, struct map_session_data* sd, const char* command, const char* message)
- {
- struct item_data *item_data = NULL;
- + int i, slot=0;
- + char item_name[100];
- - if (!message || !*message) {
- - if (sd->state.autolootid) {
- - sd->state.autolootid = 0;
- + memset(item_name, '\0', sizeof(item_name));
- +
- + if (!message || !*message || (
- + sscanf(message, "\"%99[^\"]\" %d", item_name, &slot) < 1 &&
- + sscanf(message, "%99s %d", item_name, &slot) < 1
- +
- + )) {
- +
- + if (sd->state.autolootactive) {
- + sd->state.autolootactive = 0;
- clif_displaymessage(fd, "Autolootitem have been turned OFF.");
- - } else
- - clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @autolootitem <item_name_or_ID>).");
- + }
- + else
- + clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @alootid <item_name_or_ID> [<slot>]).");
- + clif_displaymessage(fd, "...to see autoloot list, @alootid list");
- + return -1;
- + }
- + if(strcmp(item_name,"list")==0)
- + {
- + clif_displaymessage(fd, "Autoloot items:");
- + for(i=0; i < 5; i++){
- + if(sd->state.autolootid[i] <= 500)
- + sprintf(atcmd_output, "Slot %d: %s",i+1,">>> Free autoloot slot <<<");
- + else{
- + item_data = itemdb_search(sd->state.autolootid[i]);
- + sprintf(atcmd_output, "Slot %d: '%s'",i+1,item_data->name);
- + }
- + clif_displaymessage(fd, atcmd_output);
- + }
- + return 0;
- + }
- +
- + else if ((item_data = itemdb_searchname(item_name)) == NULL &&
- + (item_data = itemdb_exists(atoi(item_name))) == NULL)
- + {
- + clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name.
- return -1;
- }
- +
- + if(slot<1 || slot>5) slot = 1; // check
- + slot = slot - 1;
- +
- + if (slot < 0 || slot >4){ //counter check
- + clif_displaymessage(fd, "Slot # can only be 1~5");
- + return -1;
- + }
- - 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;
- }
- +
- + for(i=0; i < 5; i++){ //to prevent duplicate entry
- + if(item_data->nameid == sd->state.autolootid[i]){
- + sprintf(atcmd_output, "'%s' is already auto-looted in Slot %d.",item_data->name, i+1);
- + clif_displaymessage(fd, atcmd_output);
- + return -1;
- + }
- + }
- - sd->state.autolootid = item_data->nameid; // Autoloot Activated
- + sd->state.autolootid[slot] = item_data->nameid; // Autoloot Activated
- + sd->state.autolootactive = 1;
- - sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d}",
- - item_data->name, item_data->jname, item_data->nameid);
- + sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d} , Stored in slot %d",
- + item_data->name, item_data->jname, item_data->nameid,slot+1);
- clif_displaymessage(fd, atcmd_output);
- return 0;
- Index: src/map/mob.c
- ===================================================================
- --- src/map/mob.c (revision 14109)
- +++ src/map/mob.c (working copy)
- @@ -1719,7 +1719,7 @@
- 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 || mob_processdrop( 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
- @@ -1738,6 +1738,17 @@
- dlist->item = ditem;
- }
- +int mob_processdrop(struct map_session_data * sd, int nameid)
- +{
- + int i;
- + for(i=0; i < 5; i++)
- + {
- + if(nameid == sd->state.autolootid[i])
- + return 1;
- + }
- + return 0;
- +}
- +
- int mob_timer_delete(int tid, unsigned int tick, int id, intptr data)
- {
- struct block_list* bl = map_id2bl(id);
- Index: src/map/mob.h
- ===================================================================
- --- src/map/mob.h (revision 14109)
- +++ src/map/mob.h (working copy)
- @@ -230,6 +230,7 @@
- int mob_dead(struct mob_data *md, struct block_list *src, int type);
- void mob_revive(struct mob_data *md, unsigned int hp);
- void mob_heal(struct mob_data *md,unsigned int heal);
- +int mob_processdrop(struct map_session_data * sd, int nameid);
- #define mob_stop_walking(md, type) unit_stop_walking(&(md)->bl, type)
- #define mob_stop_attack(md) unit_stop_attack(&(md)->bl)
- Index: src/map/pc.h
- ===================================================================
- --- src/map/pc.h (revision 14109)
- +++ src/map/pc.h (working copy)
- @@ -122,7 +122,8 @@
- unsigned ignoreAll : 1;
- unsigned debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS]
- unsigned short autoloot;
- - unsigned short autolootid; // [Zephyrus]
- + unsigned short autolootid[5]; // [Zephyrus]
- + unsigned short autolootactive;
- unsigned noks : 3; // [Zeph Kill Steal Protection]
- bool changemap;
- short pmap; // Previous map on Map Change
alootid_array_v2.diff
Posted by Anonymous on Sun 6th Feb 2011 05:15
raw | new post
view followups (newest first): alootid_array_r14697.diff by Anonymous
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.