/*========================================== * Returns if given item is a player-equippable piece. *------------------------------------------*/ int itemdb_isequip(int nameid) { int type=itemdb_type(nameid); switch (type) { case IT_WEAPON: case IT_ARMOR: case IT_AMMO: return 1; default: return 0; } }
/*========================================== * Specifies if item-type should drop unidentified. *------------------------------------------*/ int itemdb_isidentified(int nameid) { int type=itemdb_type(nameid); switch (type) { case IT_WEAPON: case IT_ARMOR: case IT_PETARMOR: return 0; default: return 1; } }
/** Specifies if item-type should drop unidentified. * @param nameid ID of item */ char itemdb_isidentified(unsigned short nameid) { int type=itemdb_type(nameid); switch (type) { case IT_WEAPON: case IT_ARMOR: case IT_PETARMOR: case IT_SHADOWGEAR: return 0; default: return 1; } }
/*========================================== * Returns if given item's type is stackable. *------------------------------------------ */ int itemdb_isstackable(int nameid) { int type=itemdb_type(nameid); switch(type) { case IT_WEAPON: case IT_ARMOR: case IT_PETEGG: case IT_PETARMOR: return 0; default: return 1; } }
/*========================================== * Returns if given item is a player-equippable piece. *------------------------------------------*/ bool itemdb_isequip(int nameid) { int type = itemdb_type(nameid); switch (type) { case IT_WEAPON: case IT_ARMOR: case IT_AMMO: case IT_SHADOWGEAR: return true; default: return false; } }
/*========================================== * Returns if given item's type is stackable. *------------------------------------------*/ bool itemdb_isstackable(uint16 nameid) { uint8 type = itemdb_type(nameid); switch(type) { case IT_WEAPON: case IT_ARMOR: case IT_PETEGG: case IT_PETARMOR: case IT_SHADOWGEAR: return false; default: return true; } }
/*========================================== * *------------------------------------------ */ int itemdb_isweapon(int nameid) { int type = itemdb_type(nameid); int result; switch(type) { case ITEMTYPE_WEAPON: case ITEMTYPE_BOW: case ITEMTYPE_BOTHHAND: case ITEMTYPE_GUN: result = 1; break; default: result = 0; break; } return result; }
/*========================================== * *------------------------------------------ */ int itemdb_isarmor(int nameid) { int type = itemdb_type(nameid); int result; switch(type) { case ITEMTYPE_ARMOR: case ITEMTYPE_ARMORTM: case ITEMTYPE_ARMORTB: case ITEMTYPE_ARMORMB: case ITEMTYPE_ARMORTMB: case ITEMTYPE_COSTUME: result = 1; break; default: result = 0; break; } return result; }
/*========================================== * *------------------------------------------ */ int itemdb_isequip(int nameid) { int type = itemdb_type(nameid); int result; switch(type) { case ITEMTYPE_HEAL: case ITEMTYPE_SPECIAL: case ITEMTYPE_EVENT: case ITEMTYPE_CARD: case ITEMTYPE_ARROW: case ITEMTYPE_AMMO: case ITEMTYPE_THROWWEAPON: case ITEMTYPE_CASH_POINT_ITEM: case ITEMTYPE_CANNONBALL: result = 0; break; default: result = 1; break; } return result; }
//Does party loot. first_charid holds the charid of the player who has time priority to take the item. int party_share_loot(struct party_data* p, struct map_session_data* sd, struct item* item, int first_charid) { TBL_PC* target = NULL; int i; if (p && p->party.item&2 && (first_charid || !(battle_config.party_share_type&1))) { //item distribution to party members. if (battle_config.party_share_type&2) { // Round Robin TBL_PC* psd; i = p->itemc; do { i++; if (i >= MAX_PARTY) i = 0; // reset counter to 1st person in party so it'll stop when it reaches "itemc" if( (psd = p->data[i].sd) == NULL || sd->bl.m != psd->bl.m || pc_isdead(psd) || (battle_config.idle_no_share && pc_isidle(psd)) ) continue; if (pc_additem(psd,item,item->amount,LOG_TYPE_PICKDROP_PLAYER)) continue; //Chosen char can't pick up loot. //Successful pick. p->itemc = i; target = psd; break; } while (i != p->itemc); } else { // Random pick TBL_PC* psd[MAX_PARTY]; int count = 0; //Collect pick candidates for (i = 0; i < MAX_PARTY; i++) { if( (psd[count] = p->data[i].sd) == NULL || psd[count]->bl.m != sd->bl.m || pc_isdead(psd[count]) || (battle_config.idle_no_share && pc_isidle(psd[count])) ) continue; count++; } while (count > 0) { //Pick a random member. i = rnd()%count; if (pc_additem(psd[i],item,item->amount,LOG_TYPE_PICKDROP_PLAYER)) { // Discard this receiver. psd[i] = psd[count-1]; count--; } else { // Successful pick. target = psd[i]; break; } } } } if (!target) { target = sd; //Give it to the char that picked it up if ((i = pc_additem(sd,item,item->amount,LOG_TYPE_PICKDROP_PLAYER))) return i; } if( p && battle_config.party_show_share_picker && battle_config.show_picker_item_type&(1<<itemdb_type(item->nameid)) ) clif_party_show_picker(target, item); return 0; }
int createdb_start(USER *sd) { int item_c=RFIFOB(sd->fd,5); int item[10],item_amount[10]; int item_s[10]; int len=6; int x; int curitem; int rate; struct item *fl; for(x=0;x<item_c;x++) { curitem=RFIFOB(sd->fd,len)-1; item_s[x]=curitem; item[x]=sd->status.inventory[curitem].id; if(itemdb_type(item[x])<3 || itemdb_type(item[x])>17) { item_amount[x]=RFIFOB(sd->fd,len+1); len+=2; } else { item_amount[x]=1; len+=1; } } sd->creation_works=0; sd->creation_item=0; sd->creation_itemamount=0; sd->creation_rate=0; sd->creation_faileditem=0; sd->creation_failedamount=0; sd->creation_failrate=0; if(item_c) { create_db->foreach(create_db,create_check_sub,sd,item_c,item,item_amount); } else { return 0; } if(sd->creation_works) { for(x=0;x<item_c;x++) { // printf("%d, %d\n",item_s[x],item_amount[x]); pc_delitem(sd,item_s[x],item_amount[x],25); } //rate checking :) rate = rnd(100000); if (sd->creation_rate >= rate) { CALLOC(fl,struct item,1); fl->id=sd->creation_item; fl->dura=itemdb_dura(fl->id); fl->amount=sd->creation_itemamount; pc_additem(sd,fl); FREE(fl); clif_playsound(&sd->bl, 123);//play sound on success clif_sendminitext(sd, "You were successful!",0); } else { //if failed but can recover an item if (sd->creation_failrate >= rate)