Exemple #1
0
/** [Cydh]
 * Gives item(s) to the player based on item group
 * @param sd: Player that obtains item from item group
 * @param group_id: The group ID of item that obtained by player
 * @param *group: struct s_item_group from itemgroup_db[group_id].random[idx] or itemgroup_db[group_id].must[sub_group][idx]
*/
static void itemdb_pc_get_itemgroup_sub(struct map_session_data *sd, uint16 group_id, struct s_item_group *group) {
	uint16 i;
	struct item tmp;

	nullpo_retv(group);

	memset(&tmp, 0, sizeof(tmp));

	tmp.nameid = group->nameid;
	tmp.amount = (itemdb_isstackable(group->nameid)) ? group->amount : 1;
	tmp.bound = group->bound;
	tmp.identify = 1;
	tmp.expire_time = (group->duration) ? (unsigned int)(time(NULL) + group->duration * 60) : 0;
	if (group->isNamed) {
		tmp.card[0] = itemdb_isequip(group->nameid) ? CARD0_FORGE : CARD0_CREATE;
		tmp.card[1] = 0;
		tmp.card[2] = GetWord(sd->status.char_id, 0);
		tmp.card[3] = GetWord(sd->status.char_id, 1);
	}
	//Do loop for non-stackable item
	for (i = 0; i < group->amount; i++) {
		int flag;

		if ((flag = pc_additem(sd,&tmp,tmp.amount,LOG_TYPE_SCRIPT)))
			clif_additem(sd,0,0,flag);
		else if (!flag && group->isAnnounced) {
			char output[CHAT_SIZE_MAX];

			sprintf(output, msg_txt(717), sd->status.name, itemdb_jname(group->nameid), itemdb_jname(sd->itemid));
			clif_broadcast(&sd->bl, output,strlen(output), 0, ALL_CLIENT);
		}
		if (itemdb_isstackable(group->nameid))
			break;
	}
}
// storage data -> DB conversion
int storage_tosql(int account_id,struct storage *p) {
    int i;
    int eqcount=1;
    int noteqcount=1;
    struct itemtemp mapitem;
    for(i=0; i<MAX_INVENTORY; i++) {
        if(p->storage[i].nameid>0) {
            if(itemdb_isequip(p->storage[i].nameid)==1) {
                mapitem.equip[eqcount].flag=0;
                mapitem.equip[eqcount].id = p->storage[i].id;
                mapitem.equip[eqcount].nameid=p->storage[i].nameid;
                mapitem.equip[eqcount].amount = p->storage[i].amount;
                mapitem.equip[eqcount].equip = p->storage[i].equip;
                mapitem.equip[eqcount].identify = p->storage[i].identify;
                mapitem.equip[eqcount].refine = p->storage[i].refine;
                mapitem.equip[eqcount].attribute = p->storage[i].attribute;
                mapitem.equip[eqcount].card[0] = p->storage[i].card[0];
                mapitem.equip[eqcount].card[1] = p->storage[i].card[1];
                mapitem.equip[eqcount].card[2] = p->storage[i].card[2];
                mapitem.equip[eqcount].card[3] = p->storage[i].card[3];
                eqcount++;
            }
            else if(itemdb_isequip(p->storage[i].nameid)==0) {
                mapitem.notequip[noteqcount].flag=0;
                mapitem.notequip[noteqcount].id = p->storage[i].id;
                mapitem.notequip[noteqcount].nameid=p->storage[i].nameid;
                mapitem.notequip[noteqcount].amount = p->storage[i].amount;
                mapitem.notequip[noteqcount].equip = p->storage[i].equip;
                mapitem.notequip[noteqcount].identify = p->storage[i].identify;
                mapitem.notequip[noteqcount].refine = p->storage[i].refine;
                mapitem.notequip[noteqcount].attribute = p->storage[i].attribute;
                mapitem.notequip[noteqcount].card[0] = p->storage[i].card[0];
                mapitem.notequip[noteqcount].card[1] = p->storage[i].card[1];
                mapitem.notequip[noteqcount].card[2] = p->storage[i].card[2];
                mapitem.notequip[noteqcount].card[3] = p->storage[i].card[3];
                noteqcount++;
            }
        }
    }

    memitemdata_to_sql(mapitem, eqcount, noteqcount, account_id,TABLE_STORAGE);

    //printf ("storage dump to DB - id: %d (total: %d)\n", account_id, j);
    return 0;
}
Exemple #3
0
/** [Cydh]
* Gives item(s) to the player based on item group
* @param sd: Player that obtains item from item group
* @param group_id: The group ID of item that obtained by player
* @param *group: struct s_item_group from itemgroup_db[group_id].random[idx] or itemgroup_db[group_id].must[sub_group][idx]
*/
static void itemdb_pc_get_itemgroup_sub(struct map_session_data *sd, struct s_item_group_entry *data) {
	uint16 i;
	struct item tmp;

	nullpo_retv(data);

	memset(&tmp, 0, sizeof(tmp));

	tmp.nameid = data->nameid;
	tmp.amount = (itemdb_isstackable(data->nameid)) ? data->amount : 1;
	tmp.bound = data->bound;
	tmp.identify = 1;
	tmp.expire_time = (data->duration) ? (unsigned int)(time(NULL) + data->duration*60) : 0;
	if (data->isNamed) {
		tmp.card[0] = itemdb_isequip(data->nameid) ? CARD0_FORGE : CARD0_CREATE;
		tmp.card[1] = 0;
		tmp.card[2] = GetWord(sd->status.char_id, 0);
		tmp.card[3] = GetWord(sd->status.char_id, 1);
	}
	// Do loop for non-stackable item
	for (i = 0; i < data->amount; i++) {
		char flag = 0;
#ifdef ENABLE_ITEM_GUID
		tmp.unique_id = data->GUID ? pc_generate_unique_id(sd) : 0; // Generate UID
#endif
		if ((flag = pc_additem(sd, &tmp, tmp.amount, LOG_TYPE_SCRIPT)))
			clif_additem(sd, 0, 0, flag);
		else if (!flag && data->isAnnounced) {
			char output[CHAT_SIZE_MAX];
			sprintf(output, msg_txt(NULL, 717), sd->status.name, itemdb_jname(data->nameid), itemdb_jname(sd->itemid));

			//! TODO: Move this broadcast to proper packet
			intif_broadcast(output, strlen(output) + 1, BC_DEFAULT);
			//clif_broadcast_obtain_special_item();
		}
		if (itemdb_isstackable(data->nameid))
			break;
	}
}
Exemple #4
0
/** [Cydh]
* Gives item(s) to the player based on item group
* @param sd: Player that obtains item from item group
* @param group_id: The group ID of item that obtained by player
* @param *group: struct s_item_group from itemgroup_db[group_id].random[idx] or itemgroup_db[group_id].must[sub_group][idx]
*/
static void itemdb_pc_get_itemgroup_sub(struct map_session_data *sd, struct s_item_group_entry *data) {
	uint16 i, get_amt = 0;
	struct item tmp;

	nullpo_retv(data);

	memset(&tmp, 0, sizeof(tmp));

	tmp.nameid = data->nameid;
	tmp.bound = data->bound;
	tmp.identify = 1;
	tmp.expire_time = (data->duration) ? (unsigned int)(time(NULL) + data->duration*60) : 0;
	if (data->isNamed) {
		tmp.card[0] = itemdb_isequip(data->nameid) ? CARD0_FORGE : CARD0_CREATE;
		tmp.card[1] = 0;
		tmp.card[2] = GetWord(sd->status.char_id, 0);
		tmp.card[3] = GetWord(sd->status.char_id, 1);
	}

	if (!itemdb_isstackable(data->nameid))
		get_amt = 1;
	else
		get_amt = data->amount;

	// Do loop for non-stackable item
	for (i = 0; i < data->amount; i += get_amt) {
		char flag = 0;
		tmp.unique_id = data->GUID ? pc_generate_unique_id(sd) : 0; // Generate GUID
		if ((flag = pc_additem(sd, &tmp, get_amt, LOG_TYPE_SCRIPT))) {
			clif_additem(sd, 0, 0, flag);
			if (pc_candrop(sd, &tmp))
				map_addflooritem(&tmp, tmp.amount, sd->bl.m, sd->bl.x,sd->bl.y, 0, 0, 0, 0, 0);
		}
		else if (!flag && data->isAnnounced)
			intif_broadcast_obtain_special_item(sd, data->nameid, sd->itemid, ITEMOBTAIN_TYPE_BOXITEM);
	}
}