// Ask homunculus creation to char server int hom_create_request(struct map_session_data *sd, int class_) { struct s_homunculus homun; struct h_stats *base; int i; nullpo_retr(1, sd); i = hom_search(class_,HOMUNCULUS_CLASS); if(i < 0) return 0; memset(&homun, 0, sizeof(struct s_homunculus)); //Initial data safestrncpy(homun.name, homunculus_db[i].name, NAME_LENGTH-1); homun.class_ = class_; homun.level = 1; homun.hunger = 32; //32% homun.intimacy = 2100; //21/1000 homun.char_id = sd->status.char_id; homun.hp = 10 ; base = &homunculus_db[i].base; homun.max_hp = base->HP; homun.max_sp = base->SP; homun.str = base->str *10; homun.agi = base->agi *10; homun.vit = base->vit *10; homun.int_= base->int_*10; homun.dex = base->dex *10; homun.luk = base->luk *10; // Request homunculus creation intif_homunculus_create(sd->status.account_id, &homun); return 1; }
/** * Changes homunculus class * @param hd * @param class_ old class * @reutrn Fals if the class cannot be changed, True if otherwise */ static bool hom_change_class(struct homun_data *hd, short class_) { int i; i = hom_search(class_,HOMUNCULUS_CLASS); if (i < 0) return false; hd->homunculusDB = &homunculus_db[i]; hd->homunculus.class_ = class_; status_set_viewdata(&hd->bl, class_); hom_calc_skilltree(hd, 1); return true; }
/** * Create homunc structure * @param sd * @param hom */ void hom_alloc(struct map_session_data *sd, struct s_homunculus *hom) { struct homun_data *hd; int i = 0; nullpo_retv(sd); Assert((sd->status.hom_id == 0 || sd->hd == 0) || sd->hd->master == sd); i = hom_search(hom->class_,HOMUNCULUS_CLASS); if(i < 0) { ShowError("hom_alloc: unknown class [%d] for homunculus '%s', requesting deletion.\n", hom->class_, hom->name); sd->status.hom_id = 0; intif_homunculus_requestdelete(hom->hom_id); return; } sd->hd = hd = (struct homun_data*)aCalloc(1,sizeof(struct homun_data)); hd->bl.type = BL_HOM; hd->bl.id = npc_get_new_npc_id(); hd->master = sd; hd->homunculusDB = &homunculus_db[i]; memcpy(&hd->homunculus, hom, sizeof(struct s_homunculus)); hd->exp_next = hexptbl[hd->homunculus.level - 1]; status_set_viewdata(&hd->bl, hd->homunculus.class_); status_change_init(&hd->bl); unit_dataset(&hd->bl); hd->ud.dir = sd->ud.dir; // Find a random valid pos around the player hd->bl.m = sd->bl.m; hd->bl.x = sd->bl.x; hd->bl.y = sd->bl.y; unit_calc_pos(&hd->bl, sd->bl.x, sd->bl.y, sd->ud.dir); hd->bl.x = hd->ud.to_x; hd->bl.y = hd->ud.to_y; map_addiddb(&hd->bl); status_calc_homunculus(hd, SCO_FIRST); status_percent_heal(&hd->bl, 100, 100); hd->hungry_timer = INVALID_TIMER; hd->masterteleport_timer = INVALID_TIMER; }
/** * Homunculus leveled up * @param hd */ int hom_levelup(struct homun_data *hd) { struct s_homunculus *hom; struct h_stats *min = NULL, *max = NULL; int growth_str, growth_agi, growth_vit, growth_int, growth_dex, growth_luk ; int growth_max_hp, growth_max_sp ; int m_class; if ((m_class = hom_class2mapid(hd->homunculus.class_)) == -1) { ShowError("hom_levelup: Invalid class %d. \n", hd->homunculus.class_); return 0; } /// When homunculus is homunculus S, we check to see if we need to apply previous class stats if(m_class&HOM_S && hd->homunculus.level < battle_config.hom_S_growth_level) { int i; if (!hd->homunculus.prev_class) { /// We also need to be sure that the previous class exists, otherwise give it something to work with hd->homunculus.prev_class = 6001; } // Give the homunculus the level up stats database it needs i = hom_search(hd->homunculus.prev_class,HOMUNCULUS_CLASS); if (i < 0) // Nothing should go wrong here, but check anyways return 0; max = &homunculus_db[i].gmax; min = &homunculus_db[i].gmin; } if (((m_class&HOM_REG) && hd->homunculus.level >= battle_config.hom_max_level) || ((m_class&HOM_S) && hd->homunculus.level >= battle_config.hom_S_max_level) || !hd->exp_next || hd->homunculus.exp < hd->exp_next) return 0; hom = &hd->homunculus; hom->level++ ; if (!(hom->level % 3)) hom->skillpts++ ; //1 skillpoint each 3 base level hom->exp -= hd->exp_next ; hd->exp_next = hexptbl[hom->level - 1] ; if (!max) { max = &hd->homunculusDB->gmax; min = &hd->homunculusDB->gmin; } growth_max_hp = rnd_value(min->HP, max->HP); growth_max_sp = rnd_value(min->SP, max->SP); growth_str = rnd_value(min->str, max->str); growth_agi = rnd_value(min->agi, max->agi); growth_vit = rnd_value(min->vit, max->vit); growth_dex = rnd_value(min->dex, max->dex); growth_int = rnd_value(min->int_,max->int_); growth_luk = rnd_value(min->luk, max->luk); //Aegis discards the decimals in the stat growth values! growth_str-=growth_str%10; growth_agi-=growth_agi%10; growth_vit-=growth_vit%10; growth_dex-=growth_dex%10; growth_int-=growth_int%10; growth_luk-=growth_luk%10; hom->max_hp += growth_max_hp; hom->max_sp += growth_max_sp; hom->str += growth_str; hom->agi += growth_agi; hom->vit += growth_vit; hom->dex += growth_dex; hom->int_+= growth_int; hom->luk += growth_luk; if ( battle_config.homunculus_show_growth ) { char output[256] ; sprintf(output, "Growth: hp:%d sp:%d str(%.2f) agi(%.2f) vit(%.2f) int(%.2f) dex(%.2f) luk(%.2f) ", growth_max_hp, growth_max_sp, growth_str/10.0, growth_agi/10.0, growth_vit/10.0, growth_int/10.0, growth_dex/10.0, growth_luk/10.0); clif_disp_onlyself(hd->master,output,strlen(output)); } return 1; }