From e322c69d27d3db8c7141d27fa8baf0745de2eae4 Mon Sep 17 00:00:00 2001 From: Dastgir Pojee Date: Fri, 18 Oct 2013 10:57:06 +0530 Subject: [PATCH 1/3] Since our neighbours added it, we too wanted this feature. Topic:http://hercules.ws/board/topic/2540-add-rathena-new-aloot-type/ --- conf/atcommand.conf | 1 + conf/groups.conf | 1 + conf/messages.conf | 15 ++++++ doc/atcommands.txt | 10 ++++ src/map/atcommand.c | 114 ++++++++++++++++++++++++++++++++++++++++++++ src/map/pc.c | 15 ++++-- src/map/pc.h | 2 + 7 files changed, 154 insertions(+), 4 deletions(-) diff --git a/conf/atcommand.conf b/conf/atcommand.conf index fc2a1af738a..df497206701 100644 --- a/conf/atcommand.conf +++ b/conf/atcommand.conf @@ -56,6 +56,7 @@ aliases: { accinfo: ["accountinfo"] itemreset: ["clearinventory"] channel: ["main"] + autoloottype: ["aloottype"] } /* List of commands that should not be logged at all */ diff --git a/conf/groups.conf b/conf/groups.conf index 7c97352dcda..9403e34f671 100644 --- a/conf/groups.conf +++ b/conf/groups.conf @@ -120,6 +120,7 @@ groups: ( noks: true autoloot: true alootid: true + autoloottype: true autotrade: true request: true go: true diff --git a/conf/messages.conf b/conf/messages.conf index 3a16d8054a9..ae96152f033 100644 --- a/conf/messages.conf +++ b/conf/messages.conf @@ -1532,5 +1532,20 @@ 1487: Character cannot be disguised while in monster form. 1488: Transforming into monster is not allowed in Guild Wars. +// @autoloottype +1489: Item type not found. +1490: You're already autolooting this item type. +1491: Your autoloottype list has all item types. You can remove some items with @autoloottype -. +1492: Autolooting item type: '%s' {%d} +1493: You're currently not autolooting this item type. +1494: Removed item type: '%s' {%d} from your autoloottype list. +1495: To add an item type to the list, use "@aloottype +". To remove an item type, use "@aloottype -". +1496: Type List: healing = 0, usable = 2, etc = 3, weapon = 4, armor = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10 +1497: "@aloottype reset" will clear your autoloottype list. +1498: Your autoloottype list is empty. +1499: Item types on your autoloottype list: +1500: Your autoloottype list has been reset. + + //Custom translations import: conf/import/msg_conf.txt diff --git a/doc/atcommands.txt b/doc/atcommands.txt index 42b085cd6db..c70570d8cdc 100644 --- a/doc/atcommands.txt +++ b/doc/atcommands.txt @@ -337,6 +337,16 @@ By default, 10 items can be autolooted at one time. --------------------------------------- +@autoloottype <+/- type name/ID> +@autoloottype reset + +Starts or stops autolooting a specified item type. +Type List: healing = 0, usable = 2, etc = 3, weapon = 4, armor = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10 +Typing "reset" will clear the autoloot item list. + +--------------------------------------- + + @mobsearch Locates and displays the position of a certain mob on the current map. diff --git a/src/map/atcommand.c b/src/map/atcommand.c index cc29fa1bb03..a3b55a6a74f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5727,6 +5727,8 @@ ACMD(autolootitem) int i; int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset + nullpo_retr(-1, sd); + if (message && *message) { if (message[0] == '+') { message++; @@ -5813,6 +5815,117 @@ ACMD(autolootitem) } return true; } + +/*========================================== + * @autoloottype + * Flags: + * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC, + * 16: IT_WEAPON, 32: IT_ARMOR, 64: IT_CARD, 128: IT_PETEGG, + * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME + * 262144: IT_CASH + *------------------------------------------ + * Credits: + * chriser + * Aleos + *------------------------------------------*/ +ACMD(autoloottype){ + uint8 i = 0, action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset + enum item_types type = -1; + int ITEM_NONE = 0, ITEM_MAX = 1533; + + nullpo_retr(-1, sd); + + if (message && *message) { + if (message[0] == '+') { + message++; + action = 1; + } + else if (message[0] == '-') { + message++; + action = 2; + } + else if (!strcmp(message,"reset")) + action = 4; + } + + if (action < 3) { // add or remove + if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0)) + type = IT_HEALING; + else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2)) + type = IT_USABLE; + else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3)) + type = IT_ETC; + else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 4)) + type = IT_WEAPON; + else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 5)) + type = IT_ARMOR; + else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6)) + type = IT_CARD; + else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7)) + type = IT_PETEGG; + else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8)) + type = IT_PETARMOR; + else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10)) + type = IT_AMMO; + else { + clif->message(fd, msg_txt(1489)); // Item type not found. + + return false; + } + } + + switch (action) { + case 1: + if (sd->state.autoloottype&(1<message(fd, msg_txt(1490)); // You're already autolooting this item type. + return false; + } + if (sd->state.autoloottype == ITEM_MAX) { + clif->message(fd, msg_txt(1491)); // Your autoloottype list has all item types. You can remove some items with @autoloottype -. + return false; + } + sd->state.autolootingtype = 1; // Autoloot Activated + sd->state.autoloottype |= (1<typename(type), type); // Autolooting item type: '%s' {%d} + clif->message(fd, atcmd_output); + break; + case 2: + if (!(sd->state.autoloottype&(1<message(fd, msg_txt(1493)); // You're currently not autolooting this item type. + return false; + } + sd->state.autoloottype &= ~(1<typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list. + clif->message(fd, atcmd_output); + if (sd->state.autoloottype == ITEM_NONE) + sd->state.autolootingtype = 0; + break; + case 3: + clif->message(fd, msg_txt(1495)); // To add an item type to the list, use "@aloottype +". To remove an item type, use "@aloottype -". + clif->message(fd, msg_txt(1496)); // Type List: healing = 0, usable = 2, etc = 3, weapon = 4, armor = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10 + clif->message(fd, msg_txt(1497)); // "@aloottype reset" will clear your autoloottype list. + if (sd->state.autoloottype == ITEM_NONE) + clif->message(fd, msg_txt(1498)); // Your autoloottype list is empty. + else { + clif->message(fd, msg_txt(1499)); // Item types on your autoloottype list: + while (i < IT_MAX) { + if (sd->state.autoloottype&(1<typename(i), i); + clif->message(fd, atcmd_output); + } + i++; + } + } + break; + case 4: + sd->state.autoloottype = ITEM_NONE; + sd->state.autolootingtype = 0; + clif->message(fd, msg_txt(1500)); // Your autoloottype list has been reset. + break; + } + return 0; +} + /** * No longer available, keeping here just in case it's back someday. [Ind] **/ @@ -9598,6 +9711,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), diff --git a/src/map/pc.c b/src/map/pc.c index 157d9e28a36..f3f55413738 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9346,11 +9346,18 @@ void pc_overheat(struct map_session_data *sd, int val) { */ bool pc_isautolooting(struct map_session_data *sd, int nameid) { - int i; - if( !sd->state.autolooting ) + uint8 i = 0; + bool j = false; + + if (!sd->state.autolooting && !sd->state.autolootingtype) return false; - ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == nameid); - return (i != AUTOLOOTITEM_SIZE); + + if (sd->state.autolooting) + ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == nameid); + if (sd->state.autolootingtype && sd->state.autoloottype&(1< Date: Thu, 31 Oct 2013 00:08:56 +0530 Subject: [PATCH 2/3] Several Changes to autoloottype command. --- src/map/atcommand.c | 81 ++++++++++++++++++++------------------------- src/map/pc.c | 14 ++++---- src/map/pc.h | 1 - 3 files changed, 43 insertions(+), 53 deletions(-) diff --git a/src/map/atcommand.c b/src/map/atcommand.c index a3b55a6a74f..605572aad3f 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5727,8 +5727,6 @@ ACMD(autolootitem) int i; int action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset - nullpo_retr(-1, sd); - if (message && *message) { if (message[0] == '+') { message++; @@ -5740,16 +5738,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; + } } } @@ -5829,11 +5827,10 @@ ACMD(autolootitem) * Aleos *------------------------------------------*/ ACMD(autoloottype){ - uint8 i = 0, action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset + int i; + uint8 action = 3; // 1=add, 2=remove, 3=help+list (default), 4=reset enum item_types type = -1; int ITEM_NONE = 0, ITEM_MAX = 1533; - - nullpo_retr(-1, sd); if (message && *message) { if (message[0] == '+') { @@ -5846,31 +5843,30 @@ ACMD(autoloottype){ } else if (!strcmp(message,"reset")) action = 4; - } - if (action < 3) { // add or remove - if ((strncmp(message, "healing", 3) == 0) || (atoi(message) == 0)) - type = IT_HEALING; - else if ((strncmp(message, "usable", 3) == 0) || (atoi(message) == 2)) - type = IT_USABLE; - else if ((strncmp(message, "etc", 3) == 0) || (atoi(message) == 3)) - type = IT_ETC; - else if ((strncmp(message, "weapon", 3) == 0) || (atoi(message) == 4)) - type = IT_WEAPON; - else if ((strncmp(message, "armor", 3) == 0) || (atoi(message) == 5)) - type = IT_ARMOR; - else if ((strncmp(message, "card", 3) == 0) || (atoi(message) == 6)) - type = IT_CARD; - else if ((strncmp(message, "petegg", 4) == 0) || (atoi(message) == 7)) - type = IT_PETEGG; - else if ((strncmp(message, "petarmor", 4) == 0) || (atoi(message) == 8)) - type = IT_PETARMOR; - else if ((strncmp(message, "ammo", 3) == 0) || (atoi(message) == 10)) - type = IT_AMMO; - else { - clif->message(fd, msg_txt(1489)); // Item type not found. - - return false; + if (action < 3) { // add or remove + if ((atoi(message) == 0) ||(strncmp(message, "healing", 3) == 0)) + type = IT_HEALING; + else if ((atoi(message) == 2) || (strncmp(message, "usable", 3) == 0)) + type = IT_USABLE; + else if ((atoi(message) == 3) || (strncmp(message, "etc", 3) == 0)) + type = IT_ETC; + else if ((atoi(message) == 4) || (strncmp(message, "weapon", 3) == 0)) + type = IT_WEAPON; + else if ((atoi(message) == 5) || (strncmp(message, "armor", 3) == 0)) + type = IT_ARMOR; + else if ((atoi(message) == 6) || (strncmp(message, "card", 3) == 0)) + type = IT_CARD; + else if ((atoi(message) == 7) || (strncmp(message, "petegg", 4) == 0)) + type = IT_PETEGG; + else if ((atoi(message) == 8) || (strncmp(message, "petarmor", 4) == 0)) + type = IT_PETARMOR; + else if ((atoi(message) == 10) || (strncmp(message, "ammo", 3) == 0)) + type = IT_AMMO; + else { + clif->message(fd, msg_txt(1489)); // Item type not found. + return false; + } } } @@ -5884,7 +5880,6 @@ ACMD(autoloottype){ clif->message(fd, msg_txt(1491)); // Your autoloottype list has all item types. You can remove some items with @autoloottype -. return false; } - sd->state.autolootingtype = 1; // Autoloot Activated sd->state.autoloottype |= (1<typename(type), type); // Autolooting item type: '%s' {%d} clif->message(fd, atcmd_output); @@ -5897,8 +5892,6 @@ ACMD(autoloottype){ sd->state.autoloottype &= ~(1<typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list. clif->message(fd, atcmd_output); - if (sd->state.autoloottype == ITEM_NONE) - sd->state.autolootingtype = 0; break; case 3: clif->message(fd, msg_txt(1495)); // To add an item type to the list, use "@aloottype +". To remove an item type, use "@aloottype -". @@ -5908,18 +5901,16 @@ ACMD(autoloottype){ clif->message(fd, msg_txt(1498)); // Your autoloottype list is empty. else { clif->message(fd, msg_txt(1499)); // Item types on your autoloottype list: - while (i < IT_MAX) { + for(i=0; i < IT_MAX; i++){ if (sd->state.autoloottype&(1<typename(i), i); clif->message(fd, atcmd_output); } - i++; } } break; case 4: sd->state.autoloottype = ITEM_NONE; - sd->state.autolootingtype = 0; clif->message(fd, msg_txt(1500)); // Your autoloottype list has been reset. break; } diff --git a/src/map/pc.c b/src/map/pc.c index f3f55413738..7966e49abda 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9346,18 +9346,18 @@ void pc_overheat(struct map_session_data *sd, int val) { */ bool pc_isautolooting(struct map_session_data *sd, int nameid) { - uint8 i = 0; + int i = 0; bool j = false; - if (!sd->state.autolooting && !sd->state.autolootingtype) + if (sd->state.autoloottype && sd->state.autoloottype&(1<state.autolooting) return false; - if (sd->state.autolooting) - ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == nameid); - if (sd->state.autolootingtype && sd->state.autoloottype&(1<state.autolootid[i] == nameid); - return (i != AUTOLOOTITEM_SIZE || j ); + return (i != AUTOLOOTITEM_SIZE); } /** diff --git a/src/map/pc.h b/src/map/pc.h index bbea0e121aa..bb7bff3758f 100644 --- a/src/map/pc.h +++ b/src/map/pc.h @@ -162,7 +162,6 @@ struct map_session_data { unsigned short autolootid[AUTOLOOTITEM_SIZE]; // [Zephyrus] unsigned short autoloottype; unsigned int autolooting : 1; //performance-saver, autolooting state for @alootid - unsigned int autolootingtype : 1; //performance-saver, autolooting state for @autoloottype unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish] unsigned int gmaster_flag : 1; unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not. From fa54cf57ded42d7b0b45a5025a8858a9b52a0074 Mon Sep 17 00:00:00 2001 From: Dastgir Pojee Date: Fri, 1 Nov 2013 10:27:12 +0530 Subject: [PATCH 3/3] Removed type_id and some unused variables from @autoloottype --- conf/messages.conf | 11 +++++------ src/map/atcommand.c | 45 +++++++++++++++++---------------------------- src/map/pc.c | 1 - 3 files changed, 22 insertions(+), 35 deletions(-) diff --git a/conf/messages.conf b/conf/messages.conf index ae96152f033..22ed991e244 100644 --- a/conf/messages.conf +++ b/conf/messages.conf @@ -1533,14 +1533,13 @@ 1488: Transforming into monster is not allowed in Guild Wars. // @autoloottype -1489: Item type not found. 1490: You're already autolooting this item type. -1491: Your autoloottype list has all item types. You can remove some items with @autoloottype -. -1492: Autolooting item type: '%s' {%d} +1491: Item type not found. +1492: Autolooting item type: '%s' 1493: You're currently not autolooting this item type. -1494: Removed item type: '%s' {%d} from your autoloottype list. -1495: To add an item type to the list, use "@aloottype +". To remove an item type, use "@aloottype -". -1496: Type List: healing = 0, usable = 2, etc = 3, weapon = 4, armor = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10 +1494: Removed item type: '%s' from your autoloottype list. +1495: To add an item type to the list, use "@aloottype +". To remove an item type, use "@aloottype -". +1496: Type List: healing, usable, etc, weapon, armor, card, petegg, petarmor, ammo 1497: "@aloottype reset" will clear your autoloottype list. 1498: Your autoloottype list is empty. 1499: Item types on your autoloottype list: diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 605572aad3f..980f61ad99b 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -5816,21 +5816,14 @@ ACMD(autolootitem) /*========================================== * @autoloottype - * Flags: - * 1: IT_HEALING, 2: IT_UNKNOWN, 4: IT_USABLE, 8: IT_ETC, - * 16: IT_WEAPON, 32: IT_ARMOR, 64: IT_CARD, 128: IT_PETEGG, - * 256: IT_PETARMOR, 512: IT_UNKNOWN2, 1024: IT_AMMO, 2048: IT_DELAYCONSUME - * 262144: IT_CASH - *------------------------------------------ * Credits: - * chriser - * Aleos + * 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, ITEM_MAX = 1533; + int ITEM_NONE = 0; if (message && *message) { if (message[0] == '+') { @@ -5845,26 +5838,26 @@ ACMD(autoloottype){ action = 4; if (action < 3) { // add or remove - if ((atoi(message) == 0) ||(strncmp(message, "healing", 3) == 0)) + if (strncmp(message, "healing", 3) == 0) type = IT_HEALING; - else if ((atoi(message) == 2) || (strncmp(message, "usable", 3) == 0)) + else if (strncmp(message, "usable", 3) == 0) type = IT_USABLE; - else if ((atoi(message) == 3) || (strncmp(message, "etc", 3) == 0)) + else if (strncmp(message, "etc", 3) == 0) type = IT_ETC; - else if ((atoi(message) == 4) || (strncmp(message, "weapon", 3) == 0)) + else if (strncmp(message, "weapon", 3) == 0) type = IT_WEAPON; - else if ((atoi(message) == 5) || (strncmp(message, "armor", 3) == 0)) + else if (strncmp(message, "armor", 3) == 0) type = IT_ARMOR; - else if ((atoi(message) == 6) || (strncmp(message, "card", 3) == 0)) + else if (strncmp(message, "card", 3) == 0) type = IT_CARD; - else if ((atoi(message) == 7) || (strncmp(message, "petegg", 4) == 0)) + else if (strncmp(message, "petegg", 4) == 0) type = IT_PETEGG; - else if ((atoi(message) == 8) || (strncmp(message, "petarmor", 4) == 0)) + else if (strncmp(message, "petarmor", 4) == 0) type = IT_PETARMOR; - else if ((atoi(message) == 10) || (strncmp(message, "ammo", 3) == 0)) + else if (strncmp(message, "ammo", 3) == 0) type = IT_AMMO; else { - clif->message(fd, msg_txt(1489)); // Item type not found. + clif->message(fd, msg_txt(1491)); // Item type not found. return false; } } @@ -5876,12 +5869,8 @@ ACMD(autoloottype){ clif->message(fd, msg_txt(1490)); // You're already autolooting this item type. return false; } - if (sd->state.autoloottype == ITEM_MAX) { - clif->message(fd, msg_txt(1491)); // Your autoloottype list has all item types. You can remove some items with @autoloottype -. - return false; - } sd->state.autoloottype |= (1<typename(type), type); // Autolooting item type: '%s' {%d} + sprintf(atcmd_output, msg_txt(1492), itemdb->typename(type)); // Autolooting item type: '%s' clif->message(fd, atcmd_output); break; case 2: @@ -5890,12 +5879,12 @@ ACMD(autoloottype){ return false; } sd->state.autoloottype &= ~(1<typename(type), type); // Removed item type: '%s' {%d} from your autoloottype list. + 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(1495)); // To add an item type to the list, use "@aloottype +". To remove an item type, use "@aloottype -". - clif->message(fd, msg_txt(1496)); // Type List: healing = 0, usable = 2, etc = 3, weapon = 4, armor = 5, card = 6, petegg = 7, petarmor = 8, ammo = 10 + clif->message(fd, msg_txt(1495)); // To add an item type to the list, use "@aloottype +". To remove an item type, use "@aloottype -". + clif->message(fd, msg_txt(1496)); // Type List: healing, usable, etc, weapon, armor, card, petegg, petarmor, ammo clif->message(fd, msg_txt(1497)); // "@aloottype reset" will clear your autoloottype list. if (sd->state.autoloottype == ITEM_NONE) clif->message(fd, msg_txt(1498)); // Your autoloottype list is empty. @@ -5903,7 +5892,7 @@ ACMD(autoloottype){ clif->message(fd, msg_txt(1499)); // Item types on your autoloottype list: for(i=0; i < IT_MAX; i++){ if (sd->state.autoloottype&(1<typename(i), i); + sprintf(atcmd_output, " '%s'", itemdb->typename(i)); clif->message(fd, atcmd_output); } } diff --git a/src/map/pc.c b/src/map/pc.c index 7966e49abda..90a3db853b6 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -9347,7 +9347,6 @@ void pc_overheat(struct map_session_data *sd, int val) { bool pc_isautolooting(struct map_session_data *sd, int nameid) { int i = 0; - bool j = false; if (sd->state.autoloottype && sd->state.autoloottype&(1<