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; }
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; }
void pet_set_intimate(struct pet_data *pd, int value) { int intimate; struct map_session_data *sd; nullpo_retv(pd); intimate = pd->pet.intimate; sd = pd->msd; pd->pet.intimate = value; if( (intimate >= battle_config.pet_equip_min_friendly && pd->pet.intimate < battle_config.pet_equip_min_friendly) || (intimate < battle_config.pet_equip_min_friendly && pd->pet.intimate >= battle_config.pet_equip_min_friendly) ) status_calc_pc(sd,SCO_NONE); }
/** * 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; }
static int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) { struct item tmp_item; int nameid,flag; if(pd->pet.equip == 0) return 1; nameid = pd->pet.equip; pd->pet.equip = 0; status_set_viewdata(&pd->bl, pd->pet.class_); clif->send_petdata(NULL, sd->pd, 3, sd->pd->vd.head_bottom); 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); iMap->addflooritem(&tmp_item,1,sd->bl.m,sd->bl.x,sd->bl.y,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,0); } if( pd->s_skill && pd->s_skill->timer != INVALID_TIMER ) { if( pd->s_skill->id ) iTimer->delete_timer(pd->s_skill->timer, pet_skill_support_timer); else iTimer->delete_timer(pd->s_skill->timer, pet_heal_timer); pd->s_skill->timer = INVALID_TIMER; } if( pd->bonus && pd->bonus->timer != INVALID_TIMER ) { iTimer->delete_timer(pd->bonus->timer, pet_skill_bonus_timer); pd->bonus->timer = INVALID_TIMER; } } return 0; }
// スキルポイント割り振り int guild_skillup(struct map_session_data *sd,int skill_num,int flag) { struct guild *g; int idx = skill_num - GD_SKILLBASE; nullpo_retr(0, sd); if(idx < 0 || idx >= MAX_GUILDSKILL) return 0; if(sd->status.guild_id==0 || (g=guild_search(sd->status.guild_id))==NULL) return 0; if(strcmp(sd->status.name,g->master)) return 0; if( (g->skill_point>0 || flag&1) && g->skill[idx].id!=0 && g->skill[idx].lv < guild_skill_get_max(skill_num) ){ intif_guild_skillup(g->guild_id,skill_num,sd->status.account_id,flag); } status_calc_pc (sd, 0); // Celest return 0; }
int pet_data_init(struct map_session_data *sd, struct s_pet *pet) { struct pet_data *pd; int i = 0, interval = 0; nullpo_retr(1,sd); Assert((sd->status.pet_id == 0 || sd->pd == NULL) || sd->pd->master == sd); if(sd->status.account_id != pet->account_id || sd->status.char_id != pet->char_id) { sd->status.pet_id = 0; return 1; } if(sd->status.pet_id != pet->pet_id) { if(sd->status.pet_id) { //Wrong pet?? Set incubate to no and send it back for saving pet->incubate = 1; intif_save_petdata(sd->status.account_id,pet); sd->status.pet_id = 0; return 1; } //The pet_id value was lost? Odd, restore it sd->status.pet_id = pet->pet_id; } i = search_petDB_index(pet->class_,PET_CLASS); if(i < 0) { sd->status.pet_id = 0; return 1; } sd->pd = pd = (struct pet_data *)aCalloc(1,sizeof(struct pet_data)); pd->bl.type = BL_PET; pd->bl.id = npc_get_new_npc_id(); pd->master = sd; pd->petDB = &pet_db[i]; pd->db = mob_db(pet->class_); memcpy(&pd->pet,pet,sizeof(struct s_pet)); status_set_viewdata(&pd->bl,pet->class_); unit_dataset(&pd->bl); pd->ud.dir = sd->ud.dir; pd->bl.m = sd->bl.m; pd->bl.x = sd->bl.x; pd->bl.y = sd->bl.y; unit_calc_pos(&pd->bl,sd->bl.x,sd->bl.y,sd->ud.dir); pd->bl.x = pd->ud.to_x; pd->bl.y = pd->ud.to_y; map_addiddb(&pd->bl); status_calc_pet(pd,SCO_FIRST); pd->last_thinktime = gettick(); pd->state.skillbonus = 0; if(battle_config.pet_status_support) run_script(pet_db[i].pet_script,0,sd->bl.id,0); if(pd->petDB) { if(pd->petDB->pet_friendly_script) status_calc_pc(sd,SCO_NONE); if(battle_config.pet_hungry_delay_rate != 100) interval = pd->petDB->hungry_delay * battle_config.pet_hungry_delay_rate / 100; else interval = pd->petDB->hungry_delay; } if(interval <= 0) interval = 1; pd->pet_hungry_timer = add_timer(gettick() + interval,pet_hungry,sd->bl.id,0); pd->masterteleport_timer = INVALID_TIMER; return 0; }
int pet_data_init(struct map_session_data *sd, struct s_pet *pet) { struct pet_data *pd; int i=0,interval=0; nullpo_retr(1, sd); Assert((sd->status.pet_id == 0 || sd->pd == 0) || sd->pd->msd == sd); if(sd->status.account_id != pet->account_id || sd->status.char_id != pet->char_id) { sd->status.pet_id = 0; return 1; } if (sd->status.pet_id != pet->pet_id) { if (sd->status.pet_id) { //Wrong pet?? Set incuvate to no and send it back for saving. pet->incuvate = 1; intif->save_petdata(sd->status.account_id,pet); sd->status.pet_id = 0; return 1; } //The pet_id value was lost? odd... restore it. sd->status.pet_id = pet->pet_id; } i = search_petDB_index(pet->class_,PET_CLASS); if(i < 0) { sd->status.pet_id = 0; return 1; } sd->pd = pd = (struct pet_data *)aCalloc(1,sizeof(struct pet_data)); pd->bl.type = BL_PET; pd->bl.id = npc_get_new_npc_id(); pd->msd = sd; pd->petDB = &pet_db[i]; pd->db = mob_db(pet->class_); memcpy(&pd->pet, pet, sizeof(struct s_pet)); iStatus->set_viewdata(&pd->bl, pet->class_); unit_dataset(&pd->bl); pd->ud.dir = sd->ud.dir; pd->bl.m = sd->bl.m; pd->bl.x = sd->bl.x; pd->bl.y = sd->bl.y; unit_calc_pos(&pd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); pd->bl.x = pd->ud.to_x; pd->bl.y = pd->ud.to_y; iMap->addiddb(&pd->bl); status_calc_pet(pd,1); pd->last_thinktime = iTimer->gettick(); pd->state.skillbonus = 0; if( battle_config.pet_status_support ) script->run(pet_db[i].pet_script,0,sd->bl.id,0); if( pd->petDB && pd->petDB->equip_script ) status_calc_pc(sd,0); if( battle_config.pet_hungry_delay_rate != 100 ) interval = (pd->petDB->hungry_delay*battle_config.pet_hungry_delay_rate)/100; else interval = pd->petDB->hungry_delay; if( interval <= 0 ) interval = 1; pd->pet_hungry_timer = iTimer->add_timer(iTimer->gettick() + interval, pet_hungry, sd->bl.id, 0); return 0; }