Exemple #1
0
/**
 * Level up an homunculus skill
 * @param hd
 * @param skill_id
 */
void hom_skillup(struct homun_data *hd, uint16 skill_id)
{
	short idx = 0;
	nullpo_retv(hd);

	if (hd->homunculus.vaporize)
		return;

	if ((idx = hom_skill_get_index(skill_id)) < 0)
		return;
	if (hd->homunculus.skillpts > 0 &&
		hd->homunculus.hskill[idx].id &&
		hd->homunculus.hskill[idx].flag == SKILL_FLAG_PERMANENT && //Don't allow raising while you have granted skills. [Skotlex]
		hd->homunculus.hskill[idx].lv < hom_skill_tree_get_max(skill_id, hd->homunculus.class_)
		)
	{
		hd->homunculus.hskill[idx].lv++;
		hd->homunculus.skillpts-- ;
		status_calc_homunculus(hd, SCO_NONE);
		if (hd->master) {
			clif_homskillup(hd->master, skill_id);
			clif_hominfo(hd->master,hd,0);
			clif_homskillinfoblock(hd->master);
		}
	}
}
Exemple #2
0
/**
* Get max level for homunculus skill
* @param id Skill ID
* @param b_class
* @return Skill Level
*/
int hom_skill_tree_get_max(int skill_id, int b_class){
	int i, skid;
	if ((b_class = hom_class2index(b_class)) < 0)
		return 0;
	for (i = 0; (skid = hskill_tree[b_class][i].id) > 0; i++) {
		if (hom_skill_get_index(skid) < 0)
			return 0;
		if (skill_id == skid)
			return hskill_tree[b_class][i].max;
	}
	return skill_get_max(skill_id);
}
Exemple #3
0
 /**
 * Get required minimum level to learn the skill
 * @param class_ Homunculus class
 * @param skill_id Homunculus skill ID
 * @return Level required or 0 if invalid
 **/
uint8 hom_skill_get_min_level(int class_, uint16 skill_id) {
	short class_idx = hom_class2index(class_), skill_idx = -1;
	uint8 i;

	if (class_idx == -1 || (skill_idx = hom_skill_get_index(skill_id)) == -1)
		return 0;
	ARR_FIND(0, MAX_HOM_SKILL_REQUIRE, i, hskill_tree[class_idx][i].id == skill_id);
	if (i == MAX_HOM_SKILL_REQUIRE)
		return 0;

	return hskill_tree[class_idx][i].need_level;
}
Exemple #4
0
/**
* Check skill from homunculus
* @param hd
* @param skill_id
* @return Skill Level or 0 if invalid or unlearned skill
*/
short hom_checkskill(struct homun_data *hd,uint16 skill_id)
{
	int idx = hom_skill_get_index(skill_id);
	if (idx < 0) // Invalid skill
		return 0;

	if (!hd || !&hd->homunculus)
		return 0;

	if (hd->homunculus.hskill[idx].id == skill_id)
		return (hd->homunculus.hskill[idx].lv);

	return 0;
}
Exemple #5
0
/**
* Calculates homunculus skill tree
* @param hd
* @param flag_envolve
*/
void hom_calc_skilltree(struct homun_data *hd, int flag_evolve)
{
	int i, skill_id = 0;
	int f = 1;
	short c = 0;

	nullpo_retv(hd);

	/* load previous homunculus form skills first. */
	if (hd->homunculus.prev_class != 0 && (c = hom_class2index(hd->homunculus.prev_class)) >= 0) {
		for (i = 0; i < MAX_SKILL_TREE && (skill_id = hskill_tree[c][i].id) > 0; i++) {
			int idx = hom_skill_get_index(skill_id);
			if (idx < 0)
				continue;
			if (hd->homunculus.hskill[idx].id)
				continue; //Skill already known.
			if (!battle_config.skillfree) {
				int j;
				for (j = 0; j < MAX_HOM_SKILL_REQUIRE; j++) {
					if (hskill_tree[c][i].need[j].id &&
						hom_checkskill(hd,hskill_tree[c][i].need[j].id) < hskill_tree[c][i].need[j].lv)
					{
						f = 0;
						break;
					}
				}
			}
			if (f)
				hd->homunculus.hskill[idx].id = skill_id;
		}
		f = 1;
	}


	if ((c = hom_class2index(hd->homunculus.class_)) < 0)
		return;

	for (i = 0; i < MAX_SKILL_TREE && (skill_id = hskill_tree[c][i].id) > 0; i++) {
		int intimacy;
		int idx = hom_skill_get_index(skill_id);
		if (idx < 0)
			continue;
		if (hd->homunculus.hskill[idx].id)
			continue; //Skill already known.
		intimacy = (flag_evolve) ? 10 : hd->homunculus.intimacy;
		if (intimacy < hskill_tree[c][i].intimacylv)
			continue;
		if (!battle_config.skillfree) {
			int j;
			for (j = 0; j < MAX_HOM_SKILL_REQUIRE; j++) {
				if (hskill_tree[c][i].need[j].id &&
					hom_checkskill(hd,hskill_tree[c][i].need[j].id) < hskill_tree[c][i].need[j].lv)
				{
					f = 0;
					break;
				}
			}
		}
		if (f)
			hd->homunculus.hskill[idx].id = skill_id;
	}

	if (hd->master)
		clif_homskillinfoblock(hd->master);
}
Exemple #6
0
/**
* Calculates homunculus skill tree
* @param hd
* @param flag_envolve
*/
void hom_calc_skilltree(struct homun_data *hd, bool flag_evolve) {
	uint8 i;
	short c = 0;

	nullpo_retv(hd);

	/* load previous homunculus form skills first. */
	if (hd->homunculus.prev_class != 0 && (c = hom_class2index(hd->homunculus.prev_class)) >= 0) {
		for (i = 0; i < MAX_HOM_SKILL_TREE; i++) {
			uint16 skill_id;
			short idx = -1;
			bool fail = false;
			if (!(skill_id = hskill_tree[c][i].id) || (idx = hom_skill_get_index(skill_id)) == -1)
				continue;
			if (hd->homunculus.hskill[idx].id)
				continue; //Skill already known.
			if (!battle_config.skillfree) {
				uint8 j;
				if (hskill_tree[c][i].need_level > hd->homunculus.level)
					continue;
				for (j = 0; j < MAX_HOM_SKILL_REQUIRE; j++) {
					if (hskill_tree[c][i].need[j].id &&
						hom_checkskill(hd,hskill_tree[c][i].need[j].id) < hskill_tree[c][i].need[j].lv)
					{
						fail = true;
						break;
					}
				}
			}
			if (!fail)
				hd->homunculus.hskill[idx].id = skill_id;
		}
	}


	if ((c = hom_class2index(hd->homunculus.class_)) < 0)
		return;

	for (i = 0; i < MAX_HOM_SKILL_TREE; i++) {
		unsigned int intimacy = 0;
		uint16 skill_id;
		short idx = -1;
		bool fail = false;
		if (!(skill_id = hskill_tree[c][i].id) || (idx = hom_skill_get_index(skill_id)) == -1)
			continue;
		if (hd->homunculus.hskill[idx].id)
			continue; //Skill already known.
		intimacy = (flag_evolve) ? 10 : hd->homunculus.intimacy;
		if (intimacy < hskill_tree[c][i].intimacy * 100)
			continue;
		if (!battle_config.skillfree) {
			uint8 j;
			if (hskill_tree[c][i].need_level > hd->homunculus.level)
				continue;
			for (j = 0; j < MAX_HOM_SKILL_REQUIRE; j++) {
				if (hskill_tree[c][i].need[j].id &&
					hom_checkskill(hd,hskill_tree[c][i].need[j].id) < hskill_tree[c][i].need[j].lv)
				{
					fail = true;
					break;
				}
			}
		}
		if (!fail)
			hd->homunculus.hskill[idx].id = skill_id;
	}

	if (hd->master)
		clif_homskillinfoblock(hd->master);
}