static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd) { struct item tmp_item; unsigned char flag = 0; pet_lootitem_drop(pd,sd); memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.nameid = pd->petDB->EggID; tmp_item.identify = 1; tmp_item.card[0] = CARD0_PET; tmp_item.card[1] = GetWord(pd->pet.pet_id,0); tmp_item.card[2] = GetWord(pd->pet.pet_id,1); tmp_item.card[3] = pd->pet.rename_flag; if((flag = pc_additem(sd,&tmp_item,1,LOG_TYPE_OTHER))) { clif_additem(sd,0,0,flag); map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0,0); } pd->pet.incubate = 1; unit_free(&pd->bl,CLR_OUTSIGHT); status_calc_pc(sd,SCO_NONE); sd->status.pet_id = 0; return 1; }
static int pet_return_egg(struct map_session_data *sd, struct pet_data *pd) { struct item tmp_item; int flag; pet_lootitem_drop(pd,sd); memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.nameid = pd->petDB->EggID; tmp_item.identify = 1; tmp_item.card[0] = CARD0_PET; tmp_item.card[1] = GetWord(pd->pet.pet_id,0); tmp_item.card[2] = GetWord(pd->pet.pet_id,1); tmp_item.card[3] = pd->pet.rename_flag; if((flag = pc_additem(sd,&tmp_item,1))) { clif_additem(sd,0,0,flag); map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } pd->pet.incuvate = 1; //No need, pet is saved on unit_free below. //intif_save_petdata(sd->status.account_id,&pd->pet); if(pd->state.skillbonus) { pd->state.skillbonus = 0; status_calc_pc(sd,0); } unit_free(&pd->bl,0); sd->status.pet_id = 0; return 1; }
int pet_get_egg(int account_id,int pet_id,int flag) { //This function is invoked when a new pet has been created, and at no other time! struct map_session_data *sd; struct item tmp_item; int i=0,ret=0; if(flag) return 0; sd = map_id2sd(account_id); if(sd == NULL) return 0; i = search_petDB_index(sd->catch_target_class,PET_CLASS); sd->catch_target_class = -1; if(i < 0) { intif_delete_petdata(pet_id); return 0; } memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.nameid = pet_db[i].EggID; tmp_item.identify = 1; tmp_item.card[0] = CARD0_PET; tmp_item.card[1] = GetWord(pet_id,0); tmp_item.card[2] = GetWord(pet_id,1); tmp_item.card[3] = 0; //New pets are not named. if((ret = pc_additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER))) { clif_additem(sd,0,0,ret); map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } return 1; }
/** * Remove a pet's equipment. * @param sd : player requesting * @param pd : pet requesting * @return 0:success, 1:failure */ static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) { struct item tmp_item; unsigned short nameid; unsigned char flag = 0; if(pd->pet.equip == 0) return 1; nameid = pd->pet.equip; pd->pet.equip = 0; status_set_viewdata(&pd->bl, pd->pet.class_); clif_pet_equip_area(pd); memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.nameid = nameid; tmp_item.identify = 1; if((flag = pc_additem(sd,&tmp_item,1,LOG_TYPE_OTHER))) { clif_additem(sd,0,0,flag); map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0,0); } if( battle_config.pet_equip_required ) { // Skotlex: halt support timers if needed if( pd->state.skillbonus ) { pd->state.skillbonus = 0; status_calc_pc(sd,SCO_NONE); } if( pd->s_skill && pd->s_skill->timer != INVALID_TIMER ) { if( pd->s_skill->id ) delete_timer(pd->s_skill->timer, pet_skill_support_timer); else delete_timer(pd->s_skill->timer, pet_heal_timer); pd->s_skill->timer = INVALID_TIMER; } if( pd->bonus && pd->bonus->timer != INVALID_TIMER ) { delete_timer(pd->bonus->timer, pet_skill_bonus_timer); pd->bonus->timer = INVALID_TIMER; } } return 0; }
/** * Is invoked _only_ when a new pet has been created is a product of packet 0x3880 * see mapif_pet_created@int_pet.c for more information. * Handles new pet data from inter-server and prepares item information to add pet egg. * @param account_id : account ID of owner * @param pet_class : class of pet * @param pet_id : pet ID otherwise means failure * @return true : success, false : failure **/ bool pet_get_egg(int account_id, short pet_class, int pet_id ) { struct map_session_data *sd; struct item tmp_item; int i = 0, ret = 0; if( pet_id == 0 || pet_class == 0 ) return false; sd = map_id2sd(account_id); if( sd == NULL ) return false; // i = pet_search_petDB_index(sd->catch_target_class,PET_CLASS); // issue: 8150 // Before this change in cases where more than one pet egg were requested in a short // period of time it wasn't possible to know which kind of egg was being requested after // the first request. [Panikon] i = search_petDB_index(pet_class,PET_CLASS); sd->catch_target_class = -1; if(i < 0) { intif_delete_petdata(pet_id); return false; } memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.nameid = pet_db[i].EggID; tmp_item.identify = 1; tmp_item.card[0] = CARD0_PET; tmp_item.card[1] = GetWord(pet_id,0); tmp_item.card[2] = GetWord(pet_id,1); tmp_item.card[3] = 0; //New pets are not named. if((ret = pc_additem(sd,&tmp_item,1,LOG_TYPE_PICKDROP_PLAYER))) { clif_additem(sd,0,0,ret); map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0,0); } return true; }
//Vaporize a character's homun. If flag, HP needs to be 80% or above. int merc_hom_vaporize(struct map_session_data *sd, int flag) { struct item tmp_item; struct s_homunculus *hom; struct homun_data *hd; int rate; hd = sd->hd; hom = &hd->homunculus; sd->status.lock = 0; if(hom->ditto == 1){ //hd->homunculus.class_ = 2502; //status_set_viewdata(&hd->bl, 2502); //merc_hom_calc_skilltree(hd); rate = 8162; }else{ rate =(hd->homunculus.class_) + 5530; } merc_save(hd); hom->char_id = sd->status.char_id; memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.nameid = rate; tmp_item.identify = 1; tmp_item.card[0] = CARD0_HUN; tmp_item.card[1] = GetWord(hd->homunculus.hom_id,0); tmp_item.card[2] = GetWord(hd->homunculus.hom_id,1); tmp_item.card[3] = 0; if((flag = pc_additem(sd,&tmp_item,1))) { clif_additem(sd,0,0,flag); map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } sd = hd->master; hd->homunculus.intimacy = 0; return unit_remove_map(&hd->bl,CLR_OUTSIGHT); }
/** [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); } }
int merc_hom_dead(struct homun_data *hd, int flag) { struct map_session_data *sd = hd->master; struct s_homunculus *hom; struct item tmp_item; int rate; sd = hd->master; hd = sd->hd; hom = &hd->homunculus; rate =(hd->homunculus.class_) + 5530; merc_save(hd); sd = hd->master; pc_delitem(sd, pc_search_inventory(sd,690), 1, 0, 0); //sd->status.hom_id = 0; sd->status.lock = 0; merc_hom_hungry_timer_delete(hd); hd->homunculus.hp = 0; hom->char_id = sd->status.char_id; memset(&tmp_item,0,sizeof(tmp_item)); tmp_item.nameid = rate; tmp_item.identify = 1; tmp_item.card[0] = CARD0_HUN; tmp_item.card[1] = GetWord(hd->homunculus.hom_id,0); tmp_item.card[2] = GetWord(hd->homunculus.hom_id,1); tmp_item.card[3] = 1; if((flag = pc_additem(sd,&tmp_item,1))) { clif_additem(sd,0,0,flag); map_addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,0,0,0,0); } hd->homunculus.hp = 0; hd->homunculus.intimacy = 0; return unit_remove_map(&hd->bl,CLR_OUTSIGHT); }