int merc_hom_levelup(struct homun_data *hd) { struct s_homunculus *hom; struct h_stats *min, *max; int growth_str, growth_agi, growth_vit, growth_int, growth_dex, growth_luk ; int growth_max_hp, growth_max_sp ; char output[256] ; if (hd->homunculus.level == 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] ; 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 ) { 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 ; }
/** * Make an homonculus evolve, (changing in evolution class and apply bonus) * @param hd : homonculus datas * @return 0:failure, 1:success */ int merc_hom_evolution(struct homun_data *hd) { struct s_homunculus *hom; struct h_stats *max, *min; struct map_session_data *sd; nullpo_ret(hd); if(!hd->homunculusDB->evo_class || hd->homunculus.class_ == hd->homunculusDB->evo_class) { clif_emotion(&hd->bl, E_SWT); return 0 ; } sd = hd->master; if (!sd) return 0; if (!merc_hom_change_class(hd, hd->homunculusDB->evo_class)) { ShowError("merc_hom_evolution: Can't evolve homunc from %d to %d", hd->homunculus.class_, hd->homunculusDB->evo_class); return 0; } //Apply evolution bonuses hom = &hd->homunculus; max = &hd->homunculusDB->emax; min = &hd->homunculusDB->emin; hom->max_hp += rnd_value(min->HP, max->HP); hom->max_sp += rnd_value(min->SP, max->SP); hom->str += 10*rnd_value(min->str, max->str); hom->agi += 10*rnd_value(min->agi, max->agi); hom->vit += 10*rnd_value(min->vit, max->vit); hom->int_+= 10*rnd_value(min->int_,max->int_); hom->dex += 10*rnd_value(min->dex, max->dex); hom->luk += 10*rnd_value(min->luk, max->luk); hom->intimacy = 500; unit_remove_map(&hd->bl, CLR_OUTSIGHT); if(map_addblock(&hd->bl)) return 0; clif_spawn(&hd->bl); clif_emotion(&sd->bl, E_NO1); clif_specialeffect(&hd->bl,568,AREA); //status_Calc flag&1 will make current HP/SP be reloaded from hom structure hom->hp = hd->battle_status.hp; hom->sp = hd->battle_status.sp; status_calc_homunculus(hd,1); if (!(battle_config.hom_setting&0x2)) skill_unit_move(&sd->hd->bl,gettick(),1); // apply land skills immediately return 1 ; }
/** * Shuffle homunculus status * @param hd */ int hom_shuffle(struct homun_data *hd) { struct map_session_data *sd; int lv, i, skillpts; unsigned int exp; struct s_skill b_skill[MAX_HOMUNSKILL]; if (!hom_is_active(hd)) return 0; sd = hd->master; lv = hd->homunculus.level; exp = hd->homunculus.exp; memcpy(&b_skill, &hd->homunculus.hskill, sizeof(b_skill)); skillpts = hd->homunculus.skillpts; //Reset values to level 1. hom_reset_stats(hd); //Level it back up for (i = 1; i < lv && hd->exp_next; i++){ hd->homunculus.exp += hd->exp_next; // Should never happen, but who knows if( !hom_levelup(hd) ) { break; } } if(hd->homunculus.class_ == hd->homunculusDB->evo_class) { //Evolved bonuses struct s_homunculus *hom = &hd->homunculus; struct h_stats *max = &hd->homunculusDB->emax, *min = &hd->homunculusDB->emin; hom->max_hp += rnd_value(min->HP, max->HP); hom->max_sp += rnd_value(min->SP, max->SP); hom->str += 10*rnd_value(min->str, max->str); hom->agi += 10*rnd_value(min->agi, max->agi); hom->vit += 10*rnd_value(min->vit, max->vit); hom->int_+= 10*rnd_value(min->int_,max->int_); hom->dex += 10*rnd_value(min->dex, max->dex); hom->luk += 10*rnd_value(min->luk, max->luk); } hd->homunculus.exp = exp; memcpy(&hd->homunculus.hskill, &b_skill, sizeof(b_skill)); hd->homunculus.skillpts = skillpts; clif_homskillinfoblock(sd); status_calc_homunculus(hd, SCO_NONE); status_percent_heal(&hd->bl, 100, 100); clif_specialeffect(&hd->bl,568,AREA); return 1; }
/** * Make a player spawn a homonculus (call) * @param sd * @return False:failure, True:sucess */ bool hom_call(struct map_session_data *sd) { struct homun_data *hd; if (!sd->status.hom_id) //Create a new homun. return hom_create_request(sd, HM_CLASS_BASE + rnd_value(0, 7)) ; // If homunc not yet loaded, load it if (!sd->hd) return intif_homunculus_requestload(sd->status.account_id, sd->status.hom_id); hd = sd->hd; if (!hd->homunculus.vaporize) return false; //Can't use this if homun wasn't vaporized. if (hd->homunculus.vaporize == HOM_ST_MORPH) return false; // Can't call homunculus (morph state). hom_init_timers(hd); hd->homunculus.vaporize = HOM_ST_ACTIVE; if (hd->bl.prev == NULL) { //Spawn him hd->bl.x = sd->bl.x; hd->bl.y = sd->bl.y; hd->bl.m = sd->bl.m; if(map_addblock(&hd->bl)) return false; clif_spawn(&hd->bl); clif_send_homdata(sd,SP_ACK,0); clif_hominfo(sd,hd,1); clif_hominfo(sd,hd,0); // send this x2. dunno why, but kRO does that [blackhole89] clif_homskillinfoblock(sd); if (battle_config.slaves_inherit_speed&1) status_calc_bl(&hd->bl, SCB_SPEED); hom_save(hd); } else //Warp him to master. unit_warp(&hd->bl,sd->bl.m, sd->bl.x, sd->bl.y,CLR_OUTSIGHT); return true; }
/* Return the value score for given board, zero score means died * b : the board * depth : depth of the recursive search * choice : used to return the final choise of movement * max : current maximum value score */ double value(board_t b, int depth, int *choice, double max) { /* Estimate the value score */ int estimate = imm_value(b); /* Decrease depth if estimation is too low */ if (estimate < max * 0.7) depth--; /* Return estimation at level 0 */ if (depth <= 0) return estimate; /* Adjust next depth according to depth_map */ int next_depth = depth - 1; if (depth > 3) { int zeros = board_count_zero(b); if (next_depth > depth_map[zeros]) next_depth--; } int i; int moved[4]; double maxv = 0; board_t tmp[4] = {0}; int my_choice = QUIT; /* Default choice */ if (!choice) { double v = query_board_value(b, depth); if (v >= 0) return v; } moved[LEFT] = move_left(b, tmp[LEFT]); moved[RIGHT] = move_right(b, tmp[RIGHT]); moved[UP] = move_up(b, tmp[UP]); moved[DOWN] = move_down(b, tmp[DOWN]); /* Estimate the maximum value score */ if (depth > 2) for (i = 0; i < 4; i++) { int v = imm_value(tmp[0]); max = v > max ? v : max; } /* Try all the four direction */ for (i = 0; i < 4; i++) { int c; if (!moved[i]) continue; int sample = 0; //depth < 3 ? 3 : 1; double v = rnd_value(tmp[i], next_depth, max, sample); if (v > maxv) { my_choice = i; maxv = v; max = maxv; } } if (choice) *choice = my_choice; cache_board_value(b, depth, maxv); return maxv; }
/** * 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; }
int elemental_create(struct map_session_data *sd, int class_, unsigned int lifetime) { struct s_elemental ele; struct s_elemental_db *db; int i; nullpo_retr(1,sd); if( (i = elemental_search_index(class_)) < 0 ) return 0; db = &elemental_db[i]; memset(&ele,0,sizeof(struct s_elemental)); ele.char_id = sd->status.char_id; ele.class_ = class_; ele.mode = EL_MODE_PASSIVE; //Initial mode i = db->status.size + 1; //Summon level //[(Caster’s Max HP / 3) + (Caster’s INT x 10) + (Caster’s Job Level x 20)] x [(Elemental Summon Level + 2) / 3] ele.hp = ele.max_hp = (sd->battle_status.max_hp / 3 + sd->battle_status.int_ * 10 + sd->status.job_level * 20) * ((i + 2) / 3); //Caster’s Max SP / 4 ele.sp = ele.max_sp = sd->battle_status.max_sp / 4; //Caster’s [Max SP / (18 / Elemental Summon Skill Level) + (1 ~ 100)] ele.atk = (sd->battle_status.max_sp / (18 / i) + rnd_value(1,100)); //Caster’s [Max SP / (18 / Elemental Summon Skill Level)] ele.atk2 = sd->battle_status.max_sp / (18 / i); //[Elemental Summon Skill Level x (Caster’s INT / 2 + Caster’s DEX / 4)] ele.matk = i * (sd->battle_status.int_ / 2 + sd->battle_status.dex / 4); //150 + [Caster’s DEX / 10] + [Elemental Summon Skill Level x 3 ] ele.amotion = 150 + sd->battle_status.dex / 10 + i * 3; //Caster’s DEF + (Caster’s Base Level / (5 – Elemental Summon Skill Level) ele.def = sd->battle_status.def + sd->status.base_level / (5 - i); //Caster’s MDEF + (Caster’s INT / (5 - Elemental Summon Skill Level) ele.mdef = sd->battle_status.mdef + sd->battle_status.int_ / (5 - i); //Caster’s FLEE + (Caster’s Base Level / (5 – Elemental Summon Skill Level) ele.flee = sd->battle_status.flee + sd->status.base_level / (5 - i); //Caster’s HIT + (Caster’s Base Level) ele.hit = sd->battle_status.hit + sd->status.base_level; //Per individual bonuses switch( db->class_ ) { case ELEMENTALID_AGNI_S: case ELEMENTALID_AGNI_M: case ELEMENTALID_AGNI_L: //ATK + (Summon Agni Skill Level x 20) / HIT + (Summon Agni Skill Level x 10) ele.atk += i * 20; ele.atk2 += i * 20; ele.hit += i * 10; break; case ELEMENTALID_AQUA_S: case ELEMENTALID_AQUA_M: case ELEMENTALID_AQUA_L: //MDEF + (Summon Aqua Skill Level x 10) / MATK + (Summon Aqua Skill Level x 20) ele.mdef += i * 10; ele.matk += i * 20; break; case ELEMENTALID_VENTUS_S: case ELEMENTALID_VENTUS_M: case ELEMENTALID_VENTUS_L: //FLEE + (Summon Ventus Skill Level x 20) / MATK + (Summon Ventus Skill Level x 10) ele.flee += i * 20; ele.matk += i * 10; break; case ELEMENTALID_TERA_S: case ELEMENTALID_TERA_M: case ELEMENTALID_TERA_L: //DEF + (Summon Tera Skill Level x 25) / ATK + (Summon Tera Skill Level x 5) ele.def += i * 25; ele.atk += i * 5; ele.atk2 += i * 5; break; } if( (i = pc_checkskill(sd,SO_EL_SYMPATHY)) > 0 ) { ele.max_hp += ele.max_hp * 5 * i / 100; ele.hp = ele.max_hp; ele.max_sp += ele.max_sp * 5 * i / 100; ele.sp = ele.max_sp; ele.atk += 25 * i; ele.atk2 += 25 * i; ele.matk += 25 * i; } ele.life_time = lifetime; // Request Char Server to create this elemental intif_elemental_create(&ele); return 1; }