Skip to content

Commit

Permalink
Homunculus skill tree fix.
Browse files Browse the repository at this point in the history
~ Thank Philippe Girard

Signed-off-by: Cydh Ramdh <house.bad@gmail.com>
  • Loading branch information
cydh committed Feb 15, 2015
1 parent 9d3d342 commit f1d7cc5
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/map/homunculus.c
Expand Up @@ -260,45 +260,47 @@ int hom_delete(struct homun_data *hd, int emote)
*/
void hom_calc_skilltree(struct homun_data *hd, int flag_evolve)
{
int i, skill_id = 0;
int f = 1;
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_SKILL_TREE && (skill_id = hskill_tree[c][i].id) > 0; i++) {
short idx = hom_skill_get_index(skill_id);
if (idx < 0)
for (i = 0; i < MAX_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) {
int j;
uint8 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;
fail = true;
break;
}
}
}
if (f)
if (!fail)
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;
short idx = hom_skill_get_index(skill_id);
if (idx < 0)
for (i = 0; i < MAX_SKILL_TREE; i++) {
unsigned int intimacy;
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.
Expand All @@ -311,12 +313,12 @@ void hom_calc_skilltree(struct homun_data *hd, int flag_evolve)
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;
fail = true;
break;
}
}
}
if (f)
if (!fail)
hd->homunculus.hskill[idx].id = skill_id;
}

Expand Down Expand Up @@ -1468,7 +1470,7 @@ static bool read_homunculus_skilldb_sub(char* split[], int columns, int current)
short class_idx, idx = -1;
int minJobLevelPresent = 0;

if (columns == 14)
if (columns == 15)
minJobLevelPresent = 1; // MinJobLvl has been added

// check for bounds [celest]
Expand Down Expand Up @@ -1506,7 +1508,7 @@ int read_homunculus_skilldb(void)
int i;
memset(hskill_tree,0,sizeof(hskill_tree));
for(i = 0; i<ARRAYLENGTH(filename); i++){
sv_readdb(db_path, filename[i], ',', 13, 15, -1, &read_homunculus_skilldb_sub, i);
sv_readdb(db_path, filename[i], ',', 14, 15, -1, &read_homunculus_skilldb_sub, i);
}
return 0;
}
Expand Down

0 comments on commit f1d7cc5

Please sign in to comment.