summaryrefslogtreecommitdiff
path: root/src/map/pc.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/map/pc.c')
-rw-r--r--src/map/pc.c180
1 files changed, 126 insertions, 54 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index ee1fcd7da..8dd216f55 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -249,11 +249,18 @@ int pc_addspiritball(struct map_session_data *sd,int interval,int max)
memmove(sd->spirit_timer+i+1, sd->spirit_timer+i, (sd->spiritball-i)*sizeof(int));
sd->spirit_timer[i] = tid;
sd->spiritball++;
+ pc->addspiritball_sub(sd);
+
+ return 0;
+}
+
+int pc_addspiritball_sub(struct map_session_data *sd)
+{
+ nullpo_ret(sd);
if ((sd->job & MAPID_THIRDMASK) == MAPID_ROYAL_GUARD)
clif->millenniumshield(&sd->bl,sd->spiritball);
else
clif->spiritball(&sd->bl);
-
return 0;
}
@@ -287,14 +294,22 @@ int pc_delspiritball(struct map_session_data *sd,int count,int type)
sd->spirit_timer[i] = INVALID_TIMER;
}
- if(!type) {
- if ((sd->job & MAPID_THIRDMASK) == MAPID_ROYAL_GUARD)
- clif->millenniumshield(&sd->bl,sd->spiritball);
- else
- clif->spiritball(&sd->bl);
+ if (!type) {
+ pc->delspiritball_sub(sd);
}
return 0;
}
+
+int pc_delspiritball_sub(struct map_session_data *sd)
+{
+ nullpo_ret(sd);
+ if ((sd->job & MAPID_THIRDMASK) == MAPID_ROYAL_GUARD)
+ clif->millenniumshield(&sd->bl,sd->spiritball);
+ else
+ clif->spiritball(&sd->bl);
+ return 0;
+}
+
int pc_check_banding(struct block_list *bl, va_list ap)
{
int *c, *b_sd;
@@ -1586,6 +1601,30 @@ int pc_calc_skillpoint(struct map_session_data* sd) {
return skill_point;
}
+void pc_calc_skilltree_clear(struct map_session_data *sd)
+{
+ int i;
+
+ nullpo_retv(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) //Don't touch these
+ sd->status.skill[i].id = 0; //First clear skills.
+ /* permanent skills that must be re-checked */
+ if (sd->status.skill[i].flag == SKILL_FLAG_PERMANENT) {
+ switch (skill->dbs->db[i].nameid) {
+ case NV_TRICKDEAD:
+ if ((sd->job & MAPID_UPPERMASK) != MAPID_NOVICE) {
+ sd->status.skill[i].id = 0;
+ sd->status.skill[i].lv = 0;
+ sd->status.skill[i].flag = 0;
+ }
+ break;
+ }
+ }
+ }
+}
+
/*==========================================
* Calculation of skill level.
*------------------------------------------*/
@@ -1604,22 +1643,7 @@ int pc_calc_skilltree(struct map_session_data *sd)
}
classidx = pc->class2idx(class);
- 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 ) //Don't touch these
- sd->status.skill[i].id = 0; //First clear skills.
- /* permanent skills that must be re-checked */
- if( sd->status.skill[i].flag == SKILL_FLAG_PERMANENT ) {
- switch( skill->dbs->db[i].nameid ) {
- case NV_TRICKDEAD:
- if ((sd->job & MAPID_UPPERMASK) != MAPID_NOVICE) {
- sd->status.skill[i].id = 0;
- sd->status.skill[i].lv = 0;
- sd->status.skill[i].flag = 0;
- }
- break;
- }
- }
- }
+ pc->calc_skilltree_clear(sd);
for (i = 0; i < MAX_SKILL_DB; i++) {
if( sd->status.skill[i].flag != SKILL_FLAG_PERMANENT && sd->status.skill[i].flag != SKILL_FLAG_PERM_GRANTED && sd->status.skill[i].flag != SKILL_FLAG_PLAGIARIZED )
@@ -1746,6 +1770,19 @@ int pc_calc_skilltree(struct map_session_data *sd)
}
} while(flag);
+ pc->calc_skilltree_bonus(sd, classidx);
+
+ return 0;
+}
+
+void pc_calc_skilltree_bonus(struct map_session_data *sd, int classidx)
+{
+ int i;
+ int id = 0;
+
+ nullpo_retv(sd);
+ Assert_retv(classidx >= 0 && classidx < CLASS_COUNT);
+
//
if (classidx > 0 && (sd->job & MAPID_UPPERMASK) == MAPID_TAEKWON
&& sd->status.base_level >= 90 && sd->status.skill_point == 0
@@ -1771,8 +1808,6 @@ int pc_calc_skilltree(struct map_session_data *sd)
sd->status.skill[idx].lv = skill->tree_get_max(id, sd->status.class);
}
}
-
- return 0;
}
//Checks if you can learn a new skill after having leveled up a skill.
@@ -6788,18 +6823,7 @@ int pc_checkbaselevelup(struct map_session_data *sd)
status_calc_pc(sd,SCO_FORCE);
status_percent_heal(&sd->bl,100,100);
- if ((sd->job & MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) {
- sc_start(NULL,&sd->bl,status->skill2sc(PR_KYRIE),100,1,skill->get_time(PR_KYRIE,1));
- sc_start(NULL,&sd->bl,status->skill2sc(PR_IMPOSITIO),100,1,skill->get_time(PR_IMPOSITIO,1));
- sc_start(NULL,&sd->bl,status->skill2sc(PR_MAGNIFICAT),100,1,skill->get_time(PR_MAGNIFICAT,1));
- sc_start(NULL,&sd->bl,status->skill2sc(PR_GLORIA),100,1,skill->get_time(PR_GLORIA,1));
- sc_start(NULL,&sd->bl,status->skill2sc(PR_SUFFRAGIUM),100,1,skill->get_time(PR_SUFFRAGIUM,1));
- if (sd->state.snovice_dead_flag)
- sd->state.snovice_dead_flag = 0; //Reenable steelbody resurrection on dead.
- } else if ((sd->job & MAPID_BASEMASK) == MAPID_TAEKWON) {
- sc_start(NULL,&sd->bl,status->skill2sc(AL_INCAGI),100,10,600000);
- sc_start(NULL,&sd->bl,status->skill2sc(AL_BLESSING),100,10,600000);
- }
+ pc->checkbaselevelup_sc(sd);
clif->misceffect(&sd->bl,0);
npc->script_event(sd, NPCE_BASELVUP); //LORDALFA - LVLUPEVENT
@@ -6810,6 +6834,24 @@ int pc_checkbaselevelup(struct map_session_data *sd)
return 1;
}
+void pc_checkbaselevelup_sc(struct map_session_data *sd)
+{
+ nullpo_retv(sd);
+
+ if ((sd->job & MAPID_UPPERMASK) == MAPID_SUPER_NOVICE) {
+ sc_start(NULL, &sd->bl, status->skill2sc(PR_KYRIE), 100, 1, skill->get_time(PR_KYRIE, 1));
+ sc_start(NULL, &sd->bl, status->skill2sc(PR_IMPOSITIO), 100, 1, skill->get_time(PR_IMPOSITIO, 1));
+ sc_start(NULL, &sd->bl, status->skill2sc(PR_MAGNIFICAT), 100, 1, skill->get_time(PR_MAGNIFICAT, 1));
+ sc_start(NULL, &sd->bl, status->skill2sc(PR_GLORIA), 100, 1, skill->get_time(PR_GLORIA, 1));
+ sc_start(NULL, &sd->bl, status->skill2sc(PR_SUFFRAGIUM), 100, 1, skill->get_time(PR_SUFFRAGIUM, 1));
+ if (sd->state.snovice_dead_flag)
+ sd->state.snovice_dead_flag = 0; //Reenable steelbody resurrection on dead.
+ } else if ((sd->job & MAPID_BASEMASK) == MAPID_TAEKWON) {
+ sc_start(NULL, &sd->bl, status->skill2sc(AL_INCAGI), 100, 10, 600000);
+ sc_start(NULL, &sd->bl, status->skill2sc(AL_BLESSING), 100, 10, 600000);
+ }
+}
+
void pc_baselevelchanged(struct map_session_data *sd) {
int i;
nullpo_retv(sd);
@@ -7597,7 +7639,6 @@ int pc_resetskill(struct map_session_data* sd, int flag)
}
for (i = 1; i < MAX_SKILL_DB; i++) {
- uint16 skill_id = 0;
int lv = sd->status.skill[i].lv;
if (lv < 1) continue;
@@ -7606,19 +7647,7 @@ int pc_resetskill(struct map_session_data* sd, int flag)
if( inf2&(INF2_WEDDING_SKILL|INF2_SPIRIT_SKILL) ) //Avoid reseting wedding/linker skills.
continue;
- skill_id = skill->dbs->db[i].nameid;
-
- // Don't reset trick dead if not a novice/baby
- if (skill_id == NV_TRICKDEAD && (sd->job & MAPID_UPPERMASK) != MAPID_NOVICE) {
- sd->status.skill[i].lv = 0;
- sd->status.skill[i].flag = 0;
- continue;
- }
-
- // do not reset basic skill
- if (skill_id == NV_BASIC && (sd->job & MAPID_UPPERMASK) != MAPID_NOVICE)
- continue;
- if (skill_id == SU_BASIC_SKILL && (sd->job & MAPID_BASEMASK) != MAPID_SUMMONER)
+ if (pc->resetskill_job(sd, i))
continue;
if( sd->status.skill[i].flag == SKILL_FLAG_PERM_GRANTED )
@@ -7673,6 +7702,30 @@ int pc_resetskill(struct map_session_data* sd, int flag)
return skill_point;
}
+bool pc_resetskill_job(struct map_session_data* sd, int index)
+{
+ uint16 skill_id;
+
+ nullpo_retr(false, sd);
+ Assert_retr(false, index >= 0 && index < MAX_SKILL_DB);
+
+ skill_id = skill->dbs->db[index].nameid;
+
+ // Don't reset trick dead if not a novice/baby
+ if (skill_id == NV_TRICKDEAD && (sd->job & MAPID_UPPERMASK) != MAPID_NOVICE) {
+ sd->status.skill[index].lv = 0;
+ sd->status.skill[index].flag = 0;
+ return true;
+ }
+
+ // do not reset basic skill
+ if (skill_id == NV_BASIC && (sd->job & MAPID_UPPERMASK) != MAPID_NOVICE)
+ return true;
+ if (skill_id == SU_BASIC_SKILL && (sd->job & MAPID_BASEMASK) != MAPID_SUMMONER)
+ return true;
+ return false;
+}
+
/*==========================================
* /resetfeel [Komurka]
*------------------------------------------*/
@@ -8035,8 +8088,8 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
}
// changed penalty options, added death by player if pk_mode [Valaris]
- if( battle_config.death_penalty_type
- && (sd->job & MAPID_UPPERMASK) != MAPID_NOVICE // only novices will receive no penalty
+ if (battle_config.death_penalty_type
+ && pc->isDeathPenaltyJob(sd->job)
&& !map->list[sd->bl.m].flag.noexppenalty && !map_flag_gvg2(sd->bl.m)
&& !sd->sc.data[SC_BABY] && !sd->sc.data[SC_CASH_DEATHPENALTY]
) {
@@ -8184,6 +8237,11 @@ int pc_dead(struct map_session_data *sd,struct block_list *src) {
return 1;
}
+bool pc_isDeathPenaltyJob(uint16 job)
+{
+ return (job & MAPID_UPPERMASK) != MAPID_NOVICE; // only novices will receive no penalty
+}
+
void pc_revive(struct map_session_data *sd,unsigned int hp, unsigned int sp) {
nullpo_retv(sd);
if(hp) clif->updatestatus(sd,SP_HP);
@@ -11077,6 +11135,11 @@ int pc_split_atoui64(char* str, uint64* val, char sep, int max)
return i;
}
+bool pc_read_skill_job_skip(short skill_id, int job_id)
+{
+ return skill_id == NV_TRICKDEAD && ((pc->jobid2mapid(job_id) & (MAPID_BASEMASK | JOBL_2)) != MAPID_NOVICE); // skip trickdead for non-novices
+}
+
/**
* Parses the skill tree config file.
*
@@ -11157,8 +11220,8 @@ void pc_read_skill_tree(void)
ShowWarning("pc_read_skill_tree: '%s' can't inherit '%s', skill tree is full!\n", job_name, ijob_name);
break;
}
- if (src->id == NV_TRICKDEAD && ((pc->jobid2mapid(job_id)&(MAPID_BASEMASK | JOBL_2)) != MAPID_NOVICE))
- continue; // skip trickdead for non-novices
+ if (pc->read_skill_job_skip(src->id, job_id))
+ continue;
dst = &pc->skill_tree[job_idx][cur];
dst->inherited = 1;
if (dst->id == 0) {
@@ -12211,6 +12274,8 @@ void pc_defaults(void) {
pc->checkequip = pc_checkequip;
pc->calc_skilltree = pc_calc_skilltree;
+ pc->calc_skilltree_bonus = pc_calc_skilltree_bonus;
+ pc->calc_skilltree_clear = pc_calc_skilltree_clear;
pc->calc_skilltree_normalize_job = pc_calc_skilltree_normalize_job;
pc->clean_skilltree = pc_clean_skilltree;
@@ -12273,6 +12338,7 @@ void pc_defaults(void) {
pc->maxbaselv = pc_maxbaselv;
pc->maxjoblv = pc_maxjoblv;
pc->checkbaselevelup = pc_checkbaselevelup;
+ pc->checkbaselevelup_sc = pc_checkbaselevelup_sc;
pc->checkjoblevelup = pc_checkjoblevelup;
pc->gainexp = pc_gainexp;
pc->nextbaseexp = pc_nextbaseexp;
@@ -12289,6 +12355,7 @@ void pc_defaults(void) {
pc->resetlvl = pc_resetlvl;
pc->resetstate = pc_resetstate;
pc->resetskill = pc_resetskill;
+ pc->resetskill_job = pc_resetskill_job;
pc->resetfeel = pc_resetfeel;
pc->resethate = pc_resethate;
pc->equipitem = pc_equipitem;
@@ -12363,7 +12430,9 @@ void pc_defaults(void) {
pc->delinvincibletimer = pc_delinvincibletimer;
pc->addspiritball = pc_addspiritball;
+ pc->addspiritball_sub = pc_addspiritball_sub;
pc->delspiritball = pc_delspiritball;
+ pc->delspiritball_sub = pc_delspiritball_sub;
pc->addfame = pc_addfame;
pc->fame_rank = pc_fame_rank;
pc->famelist_type = pc_famelist_type;
@@ -12417,6 +12486,7 @@ void pc_defaults(void) {
pc->autosave = pc_autosave;
pc->follow_timer = pc_follow_timer;
pc->read_skill_tree = pc_read_skill_tree;
+ pc->read_skill_job_skip = pc_read_skill_job_skip;
pc->clear_skill_tree = pc_clear_skill_tree;
pc->isUseitem = pc_isUseitem;
pc->show_steal = pc_show_steal;
@@ -12458,4 +12528,6 @@ void pc_defaults(void) {
pc->have_magnifier = pc_have_magnifier;
pc->check_basicskill = pc_check_basicskill;
+
+ pc->isDeathPenaltyJob = pc_isDeathPenaltyJob;
}