int arrowchange(map_session_data * sd, mob_data *targetmd)
{
unsigned short arrows[] = {
1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1762, 1765, 1766, 1767 ,1770, 1772, 1773, 1774
};
unsigned short arrowelem[] = {
ELE_NEUTRAL, ELE_HOLY, ELE_FIRE, ELE_NEUTRAL, ELE_WATER, ELE_WIND, ELE_EARTH, ELE_GHOST, ELE_NEUTRAL, ELE_POISON, ELE_HOLY, ELE_DARK, ELE_NEUTRAL, ELE_HOLY, ELE_NEUTRAL, ELE_NEUTRAL
};
unsigned short arrowatk[] = {
25,30,30,40,30,30,30,30,30,50,50,30,30,50,45,35
};
if (DIFF_TICK(sd->canequip_tick, gettick()) > 0) return 0;
int16 index = -1;
int i,j;
int best = -1; int bestprio = -1;
for (i = 0; i < ARRAYLENGTH(arrows); i++) {
if (index = pc_search_inventory(sd, arrows[i]) >= 0) {
j = arrowatk[i];
if (elemstrong(targetmd, arrowelem[i]))
j += 500;
if (elemallowed(targetmd, arrowelem[i]) && j>bestprio) {
bestprio = j; best = index;
break;
}
}
}
if (best > -1) {
pc_equipitem(sd, best, EQP_AMMO);
return 0;
}else {
char* msg = "I have no arrows to shoot my target!";
saythis(sd, msg, 50);
return 0;
}
}
Suggestion on this part... Better check if item is already equipped. I tried to use 1 arrow only and error message is spamming the chat box because its still equipping the arrow that already equipped.