Extended @alootid command to support multiple items (default: 10).
git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@15489 54d463be-8e91-2dee-dedb-b68131a5f0ec
This commit is contained in:
parent
9a1965d2e4
commit
7b975aa4ba
@ -6239,32 +6239,87 @@ ACMD_FUNC(autoloot)
|
|||||||
ACMD_FUNC(autolootitem)
|
ACMD_FUNC(autolootitem)
|
||||||
{
|
{
|
||||||
struct item_data *item_data = NULL;
|
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 (message && *message) {
|
||||||
if (sd->state.autolootid) {
|
if (message[0] == '+') {
|
||||||
sd->state.autolootid = 0;
|
message++;
|
||||||
clif_displaymessage(fd, "Autolootitem has been turned OFF.");
|
action = 1;
|
||||||
} else
|
}
|
||||||
clif_displaymessage(fd, "Please, enter item name or it's ID (usage: @alootid <item_name_or_ID>).");
|
else if (message[0] == '-') {
|
||||||
|
message++;
|
||||||
return -1;
|
action = 2;
|
||||||
|
}
|
||||||
|
else if (!strcmp(message,"reset"))
|
||||||
|
action = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (action < 3) // add or remove
|
||||||
|
{
|
||||||
if ((item_data = itemdb_exists(atoi(message))) == NULL)
|
if ((item_data = itemdb_exists(atoi(message))) == NULL)
|
||||||
item_data = itemdb_searchname(message);
|
item_data = itemdb_searchname(message);
|
||||||
|
|
||||||
if (!item_data) {
|
if (!item_data) {
|
||||||
// No items founds in the DB with Id or Name
|
// No items founds in the DB with Id or Name
|
||||||
clif_displaymessage(fd, "Item not found.");
|
clif_displaymessage(fd, "Item not found.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sd->state.autolootid = item_data->nameid; // Autoloot Activated
|
switch(action) {
|
||||||
|
case 1:
|
||||||
sprintf(atcmd_output, "Autolooting item: '%s'/'%s' (%d)",
|
ARR_FIND(0, AUTOLOOTITEM_SIZE, i, sd->state.autolootid[i] == item_data->nameid);
|
||||||
item_data->name, item_data->jname, 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);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -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 == NULL ) sd = map_charid2sd(dlist->third_charid);
|
||||||
|
|
||||||
if( sd
|
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.idle_no_autoloot == 0 || DIFF_TICK(last_tick, sd->idletime) < battle_config.idle_no_autoloot)
|
||||||
&& (battle_config.homunculus_autoloot?1:!flag)
|
&& (battle_config.homunculus_autoloot?1:!flag)
|
||||||
#ifdef AUTOLOOT_DISTANCE
|
#ifdef AUTOLOOT_DISTANCE
|
||||||
|
11
src/map/pc.c
11
src/map/pc.c
@ -8182,6 +8182,17 @@ void pc_overheat(struct map_session_data *sd, int val) {
|
|||||||
|
|
||||||
return;
|
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 pc_split_str(char *str,char **val,int num)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -25,6 +25,9 @@
|
|||||||
//For Warlock
|
//For Warlock
|
||||||
#define MAX_SPELLBOOK 10
|
#define MAX_SPELLBOOK 10
|
||||||
|
|
||||||
|
//Max number of items on @autolootid list
|
||||||
|
#define AUTOLOOTITEM_SIZE 10
|
||||||
|
|
||||||
struct weapon_data {
|
struct weapon_data {
|
||||||
int atkmods[3];
|
int atkmods[3];
|
||||||
// all the variables except atkmods get zero'ed in each call of status_calc_pc
|
// 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
|
unsigned int callshop : 1; // flag to indicate that a script used callshop; on a shop
|
||||||
short pmap; // Previous map on Map Change
|
short pmap; // Previous map on Map Change
|
||||||
unsigned short autoloot;
|
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]
|
unsigned short autobonus; //flag to indicate if an autobonus is activated. [Inkfish]
|
||||||
struct guild *gmaster_flag;
|
struct guild *gmaster_flag;
|
||||||
unsigned int prevend : 1;//used to flag wheather you've spent 40sp to open the vending or not.
|
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_read_motd(void); // [Valaris]
|
||||||
int pc_disguise(struct map_session_data *sd, int class_);
|
int pc_disguise(struct map_session_data *sd, int class_);
|
||||||
|
bool pc_isautolooting(struct map_session_data *sd, int nameid);
|
||||||
/**
|
/**
|
||||||
* Mechanic (Mado Gear)
|
* Mechanic (Mado Gear)
|
||||||
**/
|
**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user