Skip to content

Commit

Permalink
Merge pull request #3322 from skyleo/fix-temporary-skills-not-clearing
Browse files Browse the repository at this point in the history
Fix reproduceskill and cloneskill being used in checks when being zero
  • Loading branch information
MishimaHaruna authored Sep 29, 2024
2 parents 71fc107 + 39f8bf7 commit aec44c1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/map/pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1657,7 +1657,8 @@ static void pc_calc_skilltree_clear(struct map_session_data *sd)

for (i = 0; i < MAX_SKILL_DB; i++) {
if (sd->status.skill[i].flag == SKILL_FLAG_PLAGIARIZED || sd->status.skill[i].flag == SKILL_FLAG_PERM_GRANTED
|| sd->status.skill[i].id == sd->cloneskill_id || sd->status.skill[i].id == sd->reproduceskill_id) //Don't touch these
|| (sd->cloneskill_id != 0 && sd->status.skill[i].id == sd->cloneskill_id)
|| (sd->reproduceskill_id != 0 && sd->status.skill[i].id == sd->reproduceskill_id)) //Don't touch these
continue;
sd->status.skill[i].id = 0; //First clear skills.
/* permanent skills that must be re-checked */
Expand Down Expand Up @@ -1693,10 +1694,17 @@ static int pc_calc_skilltree(struct map_session_data *sd)
pc->calc_skilltree_clear(sd);

for (int i = 0; i < MAX_SKILL_DB; i++) {
if ((sd->status.skill[i].flag >= SKILL_FLAG_REPLACED_LV_0 && sd->status.skill[i].id != sd->cloneskill_id && sd->status.skill[i].id != sd->reproduceskill_id)
|| sd->status.skill[i].flag == SKILL_FLAG_TEMPORARY) {
if (sd->status.skill[i].flag >= SKILL_FLAG_REPLACED_LV_0) {
bool is_cloneskill = sd->cloneskill_id != 0 && sd->status.skill[i].id == sd->cloneskill_id;
bool is_reproduceskill = sd->reproduceskill_id != 0 && sd->status.skill[i].id == sd->reproduceskill_id;
if (is_cloneskill || is_reproduceskill)
continue; // Plagiarized and Reproduce Skills are kept.

// Restore original level of skills after deleting earned skills.
sd->status.skill[i].lv = (sd->status.skill[i].flag == SKILL_FLAG_TEMPORARY) ? 0 : sd->status.skill[i].flag - SKILL_FLAG_REPLACED_LV_0;
sd->status.skill[i].lv = sd->status.skill[i].flag - SKILL_FLAG_REPLACED_LV_0;
sd->status.skill[i].flag = SKILL_FLAG_PERMANENT;
} else if (sd->status.skill[i].flag == SKILL_FLAG_TEMPORARY) {
sd->status.skill[i].lv = 0;
sd->status.skill[i].flag = SKILL_FLAG_PERMANENT;
}
}
Expand Down

0 comments on commit aec44c1

Please sign in to comment.