Difference between
modified post f57d by Anonymous on Mon 7th Feb 2011 23:27
original post 8dce7280f by Anonymous on Sun 6th Feb 2011 05:15
Download diff
Show
old version |
new version |
both versions
| 1 | 1 | Index: src/map/atcommand.c | |
| 2 | 2 | =================================================================== | |
| 3 | - | --- src/map/atcommand.c (revision 14109) | |
| 3 | + | --- src/map/atcommand.c (revision 14697) | |
| 4 | 4 | +++ src/map/atcommand.c (working copy) | |
| 5 | - | @@ -6074,35 +6074,84 @@ | |
| 5 | + | @@ -6095,35 +6095,78 @@ | |
| 6 | 6 | } | |
| 7 | 7 | ||
| 8 | 8 | /*========================================== | |
| 9 | - | - * @autolootitem | |
| 9 | + | - * @alootid | |
| 10 | - | + * @autolootitem [modified version by Rad] | |
| 10 | + | + * @alootid [modified version by Rad] | |
| 11 | 11 | + * modified to enable players autoloot 5 | |
| 12 | 12 | + * different items. Uses array. Counter checks added :p | |
| 14 | 13 | *------------------------------------------*/ | |
| 15 | - | int atcommand_autolootitem(const int fd, struct map_session_data* sd, const char* command, const char* message) | |
| 14 | + | ACMD_FUNC(autolootitem) | |
| 16 | 15 | { | |
| 17 | 16 | struct item_data *item_data = NULL; | |
| 18 | 17 | + int i, slot=0; | |
| 19 | 18 | + char item_name[100]; | |
| 20 | 19 | ||
| 21 | 20 | - if (!message || !*message) { | |
| 22 | 21 | - if (sd->state.autolootid) { | |
| 23 | 22 | - sd->state.autolootid = 0; | |
| 24 | 23 | + memset(item_name, '\0', sizeof(item_name)); | |
| 25 | 24 | + | |
| 26 | 25 | + if (!message || !*message || ( | |
| 27 | - | + sscanf(message, "\"%99[^\"]\" %d", item_name, &slot) < 1 && | |
| 26 | + | + sscanf(message, "\"%99[^\"]\" %d", item_name, &slot) < 1 && | |
| 28 | - | + sscanf(message, "%99s %d", item_name, &slot) < 1 | |
| 27 | + | + sscanf(message, "%99s %d", item_name, &slot) < 1)) | |
| 29 | - | + | |
| 28 | + | + { | |
| 32 | 29 | + if (sd->state.autolootactive) { | |
| 33 | 30 | + sd->state.autolootactive = 0; | |
| 34 | - | clif_displaymessage(fd, "Autolootitem have been turned OFF."); | |
| 31 | + | clif_displaymessage(fd, "Autolootitem has been turned OFF."); | |
| 35 | 32 | - } else | |
| 36 | - | - clif_displaymessage(fd, "Please, enter Item name or its ID (usage: @autolootitem <item_name_or_ID>)."); | |
| 33 | + | - clif_displaymessage(fd, "Please, enter item name or it's ID (usage: @alootid <item_name_or_ID>)."); | |
| 34 | + | + } else { | |
| 37 | 37 | + } | |
| 41 | 38 | + return -1; | |
| 42 | 39 | + } | |
| 43 | 40 | ||
| 44 | - | + if(strcmp(item_name,"list")==0) | |
| 41 | + | + if (strcmp(item_name,"list")==0) { | |
| 46 | 42 | + clif_displaymessage(fd, "Autoloot items:"); | |
| 47 | - | + for(i=0; i < 5; i++){ | |
| 43 | + | + for (i=0; i < 5; i++) { | |
| 48 | - | + if(sd->state.autolootid[i] <= 500) | |
| 44 | + | + if (sd->state.autolootid[i] <= 500) { | |
| 49 | - | + sprintf(atcmd_output, "Slot %d: %s",i+1,">>> Free autoloot slot <<<"); | |
| 45 | + | + sprintf(atcmd_output, "Slot %d: %s",i+1,">>> Free autoloot slot <<<"); | |
| 50 | - | + else{ | |
| 46 | + | + } else { | |
| 51 | - | + item_data = itemdb_search(sd->state.autolootid[i]); | |
| 47 | + | + item_data = itemdb_search(sd->state.autolootid[i]); | |
| 52 | - | + sprintf(atcmd_output, "Slot %d: '%s'",i+1,item_data->name); | |
| 48 | + | + sprintf(atcmd_output, "Slot %d: '%s'",i+1,item_data->name); | |
| 53 | 49 | + } | |
| 54 | 50 | + clif_displaymessage(fd, atcmd_output); | |
| 55 | 51 | + } | |
| 56 | 52 | + return 0; | |
| 57 | - | + } | |
| 53 | + | + } else if ((item_data = itemdb_searchname(item_name)) == NULL && | |
| 54 | + | + (item_data = itemdb_exists(atoi(item_name))) == NULL) | |
| 61 | 55 | + { | |
| 62 | 56 | + clif_displaymessage(fd, msg_txt(19)); // Invalid item ID or name. | |
| 63 | 57 | return -1; | |
| 64 | 58 | } | |
| 65 | 59 | + | |
| 66 | - | + if(slot<1 || slot>5) slot = 1; // check | |
| 60 | + | + if (slot < 1 || slot > 5) slot = 1; // check | |
| 67 | 61 | + slot = slot - 1; | |
| 68 | 62 | + | |
| 69 | - | + if (slot < 0 || slot >4){ //counter check | |
| 63 | + | + if (slot < 0 || slot > 4) { //counter check | |
| 70 | - | + clif_displaymessage(fd, "Slot # can only be 1~5"); | |
| 64 | + | + clif_displaymessage(fd, "Slot # can only be 1~5"); | |
| 71 | - | + return -1; | |
| 65 | + | + return -1; | |
| 72 | 66 | + } | |
| 73 | 67 | ||
| 74 | 68 | - if ((item_data = itemdb_exists(atoi(message))) == NULL) | |
| 75 | 69 | - item_data = itemdb_searchname(message); | |
| 76 | 70 | - | |
| 77 | 71 | if (!item_data) { | |
| 78 | 72 | // No items founds in the DB with Id or Name | |
| 79 | 73 | clif_displaymessage(fd, "Item not found."); | |
| 80 | 74 | return -1; | |
| 81 | 75 | } | |
| 82 | 76 | + | |
| 83 | - | + for(i=0; i < 5; i++){ //to prevent duplicate entry | |
| 77 | + | + for (i=0; i < 5; i++) { //to prevent duplicate entry | |
| 84 | - | + if(item_data->nameid == sd->state.autolootid[i]){ | |
| 78 | + | + if (item_data->nameid == sd->state.autolootid[i]) { | |
| 85 | 79 | + sprintf(atcmd_output, "'%s' is already auto-looted in Slot %d.",item_data->name, i+1); | |
| 86 | 80 | + clif_displaymessage(fd, atcmd_output); | |
| 87 | 81 | + return -1; | |
| 89 | 82 | + } | |
| 83 | + | + } | |
| 90 | 84 | ||
| 91 | 85 | - sd->state.autolootid = item_data->nameid; // Autoloot Activated | |
| 92 | 86 | + sd->state.autolootid[slot] = item_data->nameid; // Autoloot Activated | |
| 93 | 87 | + sd->state.autolootactive = 1; | |
| 94 | 88 | ||
| 95 | - | - sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d}", | |
| 89 | + | - sprintf(atcmd_output, "Autolooting item: '%s'/'%s' (%d)", | |
| 96 | 90 | - item_data->name, item_data->jname, item_data->nameid); | |
| 97 | - | + sprintf(atcmd_output, "Autolooting Item: '%s'/'%s' {%d} , Stored in slot %d", | |
| 91 | + | + sprintf(atcmd_output, "Autolooting item: '%s'/'%s' (%d) , Stored in slot %d", | |
| 98 | - | + item_data->name, item_data->jname, item_data->nameid,slot+1); | |
| 92 | + | + item_data->name, item_data->jname, item_data->nameid,slot+1); | |
| 99 | 93 | clif_displaymessage(fd, atcmd_output); | |
| 100 | 94 | ||
| 101 | 95 | return 0; | |
| 102 | 96 | Index: src/map/mob.c | |
| 103 | 97 | =================================================================== | |
| 104 | - | --- src/map/mob.c (revision 14109) | |
| 98 | + | --- src/map/mob.c (revision 14697) | |
| 105 | 99 | +++ src/map/mob.c (working copy) | |
| 106 | - | @@ -1719,7 +1719,7 @@ | |
| 100 | + | @@ -1727,7 +1727,7 @@ | |
| 107 | 101 | if( sd == NULL ) sd = map_charid2sd(dlist->third_charid); | |
| 108 | 102 | ||
| 109 | 103 | if( sd | |
| 110 | 104 | - && (drop_rate <= sd->state.autoloot || ditem->item_data.nameid == sd->state.autolootid) | |
| 111 | 105 | + && (drop_rate <= sd->state.autoloot || mob_processdrop( sd, ditem->item_data.nameid )) | |
| 112 | 106 | && (battle_config.idle_no_autoloot == 0 || DIFF_TICK(last_tick, sd->idletime) < battle_config.idle_no_autoloot) | |
| 113 | 107 | && (battle_config.homunculus_autoloot?1:!flag) | |
| 114 | 108 | #ifdef AUTOLOOT_DISTANCE | |
| 115 | - | @@ -1738,6 +1738,17 @@ | |
| 109 | + | @@ -1746,6 +1746,17 @@ | |
| 116 | 110 | dlist->item = ditem; | |
| 117 | 111 | } | |
| 118 | 112 | ||
| 119 | 113 | +int mob_processdrop(struct map_session_data * sd, int nameid) | |
| 120 | 114 | +{ | |
| 121 | 115 | + int i; | |
| 122 | - | + for(i=0; i < 5; i++) | |
| 116 | + | + for (i=0; i < 5; i++) | |
| 123 | 117 | + { | |
| 124 | - | + if(nameid == sd->state.autolootid[i]) | |
| 118 | + | + if (nameid == sd->state.autolootid[i]) | |
| 125 | 119 | + return 1; | |
| 126 | 120 | + } | |
| 127 | 121 | + return 0; | |
| 128 | 122 | +} | |
| 129 | 123 | + | |
| 130 | 124 | int mob_timer_delete(int tid, unsigned int tick, int id, intptr data) | |
| 131 | 125 | { | |
| 132 | 126 | struct block_list* bl = map_id2bl(id); | |
| 133 | 127 | Index: src/map/mob.h | |
| 134 | 128 | =================================================================== | |
| 135 | - | --- src/map/mob.h (revision 14109) | |
| 129 | + | --- src/map/mob.h (revision 14697) | |
| 136 | 130 | +++ src/map/mob.h (working copy) | |
| 137 | - | @@ -230,6 +230,7 @@ | |
| 131 | + | @@ -247,6 +247,7 @@ | |
| 138 | 132 | int mob_dead(struct mob_data *md, struct block_list *src, int type); | |
| 139 | 133 | void mob_revive(struct mob_data *md, unsigned int hp); | |
| 140 | 134 | void mob_heal(struct mob_data *md,unsigned int heal); | |
| 141 | 135 | +int mob_processdrop(struct map_session_data * sd, int nameid); | |
| 142 | 136 | ||
| 143 | 137 | #define mob_stop_walking(md, type) unit_stop_walking(&(md)->bl, type) | |
| 144 | 138 | #define mob_stop_attack(md) unit_stop_attack(&(md)->bl) | |
| 145 | 139 | Index: src/map/pc.h | |
| 146 | 140 | =================================================================== | |
| 147 | - | --- src/map/pc.h (revision 14109) | |
| 141 | + | --- src/map/pc.h (revision 14697) | |
| 148 | 142 | +++ src/map/pc.h (working copy) | |
| 149 | - | @@ -122,7 +122,8 @@ | |
| 143 | + | @@ -129,7 +129,8 @@ | |
| 150 | 144 | unsigned ignoreAll : 1; | |
| 151 | 145 | unsigned debug_remove_map : 1; // temporary state to track double remove_map's [FlavioJS] | |
| 152 | 146 | unsigned short autoloot; | |
| 153 | 147 | - unsigned short autolootid; // [Zephyrus] | |
| 154 | - | + unsigned short autolootid[5]; // [Zephyrus] | |
| 148 | + | + unsigned short autolootid[5]; // [Zephyrus] [Rad] | |
| 155 | 149 | + unsigned short autolootactive; | |
| 156 | 150 | unsigned noks : 3; // [Zeph Kill Steal Protection] | |
| 157 | 151 | bool changemap; | |
| 158 | 152 | short pmap; // Previous map on Map Change | |
| 159 | 153 |
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.
eathena.kpaste.net RSS