summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/map/atcommand.c6
-rw-r--r--src/map/pc.c72
-rw-r--r--src/map/pc.h3
3 files changed, 60 insertions, 21 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index 0be3154d0..bf7e7d66e 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -8120,7 +8120,8 @@ ACMD_FUNC(stats)
{ "Luk - %3d", 0 },
{ "Zeny - %d", 0 },
{ "Free SK Points - %d", 0 },
- { "JobChangeLvl - %d", 0 },
+ { "JobChangeLvl (2nd) - %d", 0 },
+ { "JobChangeLvl (3rd) - %d", 0 },
{ NULL, 0 }
};
@@ -8143,7 +8144,8 @@ ACMD_FUNC(stats)
output_table[11].value = sd->status.luk;
output_table[12].value = sd->status.zeny;
output_table[13].value = sd->status.skill_point;
- output_table[14].value = sd->change_level;
+ output_table[14].value = sd->change_level_2nd;
+ output_table[15].value = sd->change_level_3rd;
sprintf(job_jobname, "Job - %s %s", job_name(sd->status.class_), "(level %d)");
sprintf(output, msg_txt(53), sd->status.name); // '%s' stats:
diff --git a/src/map/pc.c b/src/map/pc.c
index 56793c9c2..e38a7f01f 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1119,7 +1119,8 @@ int pc_reg_received(struct map_session_data *sd)
{
int i,j;
- sd->change_level = pc_readglobalreg(sd,"jobchange_level");
+ sd->change_level_2nd = pc_readglobalreg(sd,"jobchange_level");
+ sd->change_level_3rd = pc_readglobalreg(sd,"jobchange_level_3rd");
sd->die_counter = pc_readglobalreg(sd,"PC_DIE_COUNTER");
// Cash shop
@@ -1494,8 +1495,7 @@ int pc_clean_skilltree(struct map_session_data *sd)
int pc_calc_skilltree_normalize_job(struct map_session_data *sd)
{
- int skill_point;
- int req_points;
+ int skill_point, novice_skills;
int c = sd->class_;
if (!battle_config.skillup_limit)
@@ -1503,26 +1503,59 @@ int pc_calc_skilltree_normalize_job(struct map_session_data *sd)
skill_point = pc_calc_skillpoint(sd);
+ novice_skills = max_level[pc_class2idx(JOB_NOVICE)][1] - 1;
+
// limit 1st class and above to novice job levels
- req_points = max_level[pc_class2idx(JOB_NOVICE)][1] - 1;
- if(skill_point < req_points)
+ if(skill_point < novice_skills)
+ {
c = MAPID_NOVICE;
-
+ }
// limit 2nd class and above to first class job levels (super novices are exempt)
- if ((sd->class_&JOBL_2) && (sd->class_&MAPID_UPPERMASK) != MAPID_SUPER_NOVICE)
+ else if ((sd->class_&JOBL_2) && (sd->class_&MAPID_UPPERMASK) != MAPID_SUPER_NOVICE)
{
- req_points += (sd->change_level > 0 ? sd->change_level : max_level[pc_class2idx(pc_mapid2jobid(sd->class_&MAPID_BASEMASK, sd->status.sex))][1]) - 1;
+ // regenerate change_level_2nd
+ if (!sd->change_level_2nd)
+ {
+ if (sd->class_&JOBL_THIRD)
+ {
+ // if neither 2nd nor 3rd jobchange levels are known, we have to assume a default for 2nd
+ if (!sd->change_level_3rd)
+ sd->change_level_2nd = max_level[pc_class2idx(pc_mapid2jobid(sd->class_&MAPID_UPPERMASK, sd->status.sex))][1];
+ else
+ sd->change_level_2nd = 1 + skill_point + sd->status.skill_point
+ - (sd->status.job_level - 1)
+ - (sd->change_level_3rd - 1)
+ - novice_skills;
+ }
+ else
+ {
+ sd->change_level_2nd = 1 + skill_point + sd->status.skill_point
+ - (sd->status.job_level - 1)
+ - novice_skills;
+
+ }
+
+ pc_setglobalreg (sd, "jobchange_level", sd->change_level_2nd);
+ }
- if (skill_point < req_points)
+ if (skill_point < novice_skills + (sd->change_level_2nd - 1))
{
c &= MAPID_BASEMASK;
}
// limit 3rd class to 2nd class/trans job levels
else if(sd->class_&JOBL_THIRD)
{
- req_points += max_level[pc_class2idx(pc_mapid2jobid(sd->class_&(MAPID_UPPERMASK|JOBL_UPPER), sd->status.sex))][1] - 1;
+ // regenerate change_level_3rd
+ if (!sd->change_level_3rd)
+ {
+ sd->change_level_3rd = 1 + skill_point + sd->status.skill_point
+ - (sd->status.job_level - 1)
+ - (sd->change_level_2nd - 1)
+ - novice_skills;
+ pc_setglobalreg (sd, "jobchange_level_3rd", sd->change_level_3rd);
+ }
- if (skill_point < req_points)
+ if (skill_point < novice_skills + (sd->change_level_2nd - 1) + (sd->change_level_3rd - 1))
c &= MAPID_UPPERMASK;
}
}
@@ -6657,13 +6690,16 @@ int pc_jobchange(struct map_session_data *sd,int job, int upper)
if ((unsigned short)b_class == sd->class_)
return 1; //Nothing to change.
- // check if we are changing from 1st to 2nd job
- if (b_class&JOBL_2) {
- if (!(sd->class_&JOBL_2))
- sd->change_level = sd->status.job_level;
- else if (!sd->change_level)
- sd->change_level = max_level[pc_class2idx(pc_mapid2jobid(sd->class_&MAPID_BASEMASK, sd->status.sex))][1]; // Assume max level
- pc_setglobalreg (sd, "jobchange_level", sd->change_level);
+
+ // changing from 1st to 2nd job
+ if ((b_class&JOBL_2) && !(sd->class_&JOBL_2) && (b_class&MAPID_UPPERMASK) != MAPID_SUPER_NOVICE) {
+ sd->change_level_2nd = sd->status.job_level;
+ pc_setglobalreg (sd, "jobchange_level", sd->change_level_2nd);
+ }
+ // changing from 2nd to 3rd job
+ else if((b_class&JOBL_THIRD) && !(sd->class_&JOBL_THIRD)) {
+ sd->change_level_3rd = sd->status.job_level;
+ pc_setglobalreg (sd, "jobchange_level_3rd", sd->change_level_3rd);
}
if(sd->cloneskill_id) {
diff --git a/src/map/pc.h b/src/map/pc.h
index a9b995115..8c70984e0 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -392,7 +392,8 @@ struct map_session_data {
int eventtimer[MAX_EVENTTIMER];
unsigned short eventcount; // [celest]
- unsigned char change_level; // [celest]
+ unsigned char change_level_2nd; // job level when changing from 1st to 2nd class [jobchange_level in global_reg_value]
+ unsigned char change_level_3rd; // job level when changing from 2nd to 3rd class [jobchange_level_3rd in global_reg_value]
char fakename[NAME_LENGTH]; // fake names [Valaris]