/** [Cydh] * Find item(s) that will be obtained by player based on Item Group * @param group_id: The group ID that will be gained by player * @param nameid: The item that trigger this item group * @return val: 0:success, 1:no sd, 2:invalid item group */ char itemdb_pc_get_itemgroup(uint16 group_id, struct map_session_data *sd) { uint16 i = 0; struct s_item_group_db *group; nullpo_retr(1,sd); if (!(group = (struct s_item_group_db *) uidb_get(itemdb_group, group_id))) { ShowError("itemdb_pc_get_itemgroup: Invalid group id '%d' specified.\n",group_id); return 2; } // Get the 'must' item(s) if (group->must_qty) { for (i = 0; i < group->must_qty; i++) if (&group->must[i]) itemdb_pc_get_itemgroup_sub(sd,&group->must[i]); } // Get the 'random' item each random group for (i = 0; i < MAX_ITEMGROUP_RANDGROUP; i++) { uint16 rand; if (!(&group->random[i]) || !group->random[i].data_qty) //Skip empty random group continue; rand = rnd()%group->random[i].data_qty; if (!(&group->random[i].data[rand]) || !group->random[i].data[rand].nameid) continue; itemdb_pc_get_itemgroup_sub(sd,&group->random[i].data[rand]); } return 0; }
/** [Cydh] * Find item(s) that will be obtained by player based on Item Group * @param group_id: The group ID that will be gained by player * @param nameid: The item that trigger this item group * @return val: 0: success, 1: no sd, 2: invalid item group */ char itemdb_pc_get_itemgroup(uint16 group_id, struct map_session_data *sd) { uint16 i = 0; nullpo_retr(1, sd); if (group_id < 1 || group_id >= MAX_ITEMGROUP) { ShowError("itemdb_pc_get_itemgroup: Invalid group id '%d' specified.", group_id); return 2; } //Get the 'must' item(s) if (itemgroup_db[group_id].must_qty) for (i = 0; i < itemgroup_db[group_id].must_qty; i++) if (&itemgroup_db[group_id].must[i] && itemdb_exists(itemgroup_db[group_id].must[i].nameid)) itemdb_pc_get_itemgroup_sub(sd, group_id, &itemgroup_db[group_id].must[i]); //Get the 'random' item each random group for (i = 0; i < MAX_ITEMGROUP_RANDGROUP; i++) { uint16 rand; if (!(&itemgroup_db[group_id].random[i]) || !itemgroup_db[group_id].random[i].data_qty) //Skip empty random group continue; rand = rnd()%itemgroup_db[group_id].random[i].data_qty; //Woops, why is the data empty? Every check should be done when load the item group! So this is bad day for the player :P if (!&itemgroup_db[group_id].random[i].data[rand] || !itemgroup_db[group_id].random[i].data[rand].nameid) continue; if (itemdb_exists(itemgroup_db[group_id].random[i].data[rand].nameid)) itemdb_pc_get_itemgroup_sub(sd, group_id, &itemgroup_db[group_id].random[i].data[rand]); } return 0; }