diff options
author | mekolat <mekolat@users.noreply.github.com> | 2016-04-24 14:15:28 -0400 |
---|---|---|
committer | mekolat <mekolat@users.noreply.github.com> | 2016-04-24 14:15:28 -0400 |
commit | adda881817c349e141a7b3f9c43fb98932a63803 (patch) | |
tree | 95330adc85016873f711265383a2c60cdecfdd7e /src/map/pc.cpp | |
parent | b19a8149a4400180427cf9acbd1498151ccb22c7 (diff) | |
parent | 6fac3210f0de07ab1ff483875ac517a3eea7367a (diff) | |
download | tmwa-adda881817c349e141a7b3f9c43fb98932a63803.tar.gz tmwa-adda881817c349e141a7b3f9c43fb98932a63803.tar.bz2 tmwa-adda881817c349e141a7b3f9c43fb98932a63803.tar.xz tmwa-adda881817c349e141a7b3f9c43fb98932a63803.zip |
Merge pull request #213 from mekolat/params
fixes for magic-v3
Diffstat (limited to 'src/map/pc.cpp')
-rw-r--r-- | src/map/pc.cpp | 189 |
1 files changed, 133 insertions, 56 deletions
diff --git a/src/map/pc.cpp b/src/map/pc.cpp index d65297b..63b1497 100644 --- a/src/map/pc.cpp +++ b/src/map/pc.cpp @@ -3535,6 +3535,16 @@ int pc_readparam(dumb_ptr<block_list> bl, SP type) case SP::ELTTYPE: val = static_cast<int>(battle_get_element(bl).element); break; + case SP::INVISIBLE: + if (sd) + val = bool(sd->status.option & Opt0::INVISIBILITY); + if (nd) + val = bool(nd->flag & 1); + break; + case SP::HIDDEN: + if (sd) + val = bool(sd->status.option & Opt0::HIDE); + break; } return val; @@ -3544,17 +3554,33 @@ int pc_readparam(dumb_ptr<block_list> bl, SP type) * script用PCステータス設定 *------------------------------------------ */ -int pc_setparam(dumb_ptr<map_session_data> sd, SP type, int val) +int pc_setparam(dumb_ptr<block_list> bl, SP type, int val) { - int i = 0, up_level = 50; + nullpo_retz(bl); + dumb_ptr<map_session_data> sd; + dumb_ptr<npc_data> nd; + dumb_ptr<mob_data> md; - nullpo_retz(sd); + if (bl->bl_type == BL::PC) + sd = bl->is_player(); + else if (bl->bl_type == BL::MOB) + md = bl->is_mob(); + else if (bl->bl_type == BL::NPC) + nd = bl->is_npc(); + else + return 0; + + int i = 0; switch (type) { case SP::BASELEVEL: + nullpo_retz(sd); + // TODO: mob mutation if (val > sd->status.base_level) { + if (val > MAX_LEVEL) + val = MAX_LEVEL; for (i = 1; i <= (val - sd->status.base_level); i++) sd->status.status_point += (sd->status.base_level + i + 14) / 4; @@ -3569,46 +3595,56 @@ int pc_setparam(dumb_ptr<map_session_data> sd, SP type, int val) pc_heal(sd, sd->status.max_hp, sd->status.max_sp); break; case SP::JOBLEVEL: - up_level -= 40; - if (val >= sd->status.job_level) + nullpo_retz(sd); + if (val > sd->status.job_level) { - if (val > up_level) - val = up_level; + if (val > MAX_LEVEL) + val = MAX_LEVEL; sd->status.skill_point += (val - sd->status.job_level); - sd->status.job_level = val; - sd->status.job_exp = 0; - clif_updatestatus(sd, SP::JOBLEVEL); - clif_updatestatus(sd, SP::NEXTJOBEXP); - clif_updatestatus(sd, SP::JOBEXP); clif_updatestatus(sd, SP::SKILLPOINT); - pc_calcstatus(sd, 0); clif_misceffect(sd, 1); } - else - { - sd->status.job_level = val; - sd->status.job_exp = 0; - clif_updatestatus(sd, SP::JOBLEVEL); - clif_updatestatus(sd, SP::NEXTJOBEXP); - clif_updatestatus(sd, SP::JOBEXP); - pc_calcstatus(sd, 0); - } - clif_updatestatus(sd, type); + sd->status.job_level = val; + sd->status.job_exp = 0; + clif_updatestatus(sd, SP::JOBLEVEL); + clif_updatestatus(sd, SP::NEXTJOBEXP); + clif_updatestatus(sd, SP::JOBEXP); + pc_calcstatus(sd, 0); break; case SP::CLASS: - sd->status.species = wrap<Species>(val); - clif_changelook(sd, LOOK::BASE, val); + // TODO: mob class change + if (sd) + { + sd->status.species = wrap<Species>(val); + clif_changelook(sd, LOOK::BASE, val); + } + else if (nd) + { + if (unwrap<Species>(nd->npc_class) != val) + { + nd->npc_class = wrap<Species>(val); + npc_enable(nd->name, 0); + npc_enable(nd->name, 1); + } + } return 0; case SP::SKILLPOINT: + nullpo_retz(sd); sd->status.skill_point = val; + clif_updatestatus(sd, type); break; case SP::STATUSPOINT: + nullpo_retz(sd); sd->status.status_point = val; + clif_updatestatus(sd, type); break; case SP::ZENY: + nullpo_retz(sd); sd->status.zeny = val; + clif_updatestatus(sd, type); break; case SP::BASEEXP: + nullpo_retz(sd); if (pc_nextbaseexp(sd) > 0) { sd->status.base_exp = val; @@ -3616,8 +3652,10 @@ int pc_setparam(dumb_ptr<map_session_data> sd, SP type, int val) sd->status.base_exp = 0; pc_checkbaselevelup(sd); } + clif_updatestatus(sd, type); break; case SP::JOBEXP: + nullpo_retz(sd); if (pc_nextjobexp(sd) > 0) { sd->status.job_exp = val; @@ -3625,48 +3663,69 @@ int pc_setparam(dumb_ptr<map_session_data> sd, SP type, int val) sd->status.job_exp = 0; pc_checkjoblevelup(sd); } + clif_updatestatus(sd, type); break; case SP::SEX: - switch (val) - { - case 0: - sd->sex = sd->status.sex = SEX::FEMALE; - break; - case 1: - sd->sex = sd->status.sex = SEX::MALE; - break; - default: - sd->sex = sd->status.sex = SEX::NEUTRAL; - break; - } - for (IOff0 j : IOff0::iter()) { - if (sd->status.inventory[j].nameid - && bool(sd->status.inventory[j].equip) - && !pc_isequip(sd, j)) - pc_unequipitem(sd, j, CalcStatus::LATER); + SEX sex = SEX::NEUTRAL; + if (val == 0) + sex = SEX::FEMALE; + if (val == 1) + sex = SEX::MALE; + + if (nd) + { + nd->sex = sex; + npc_enable(nd->name, 0); + npc_enable(nd->name, 1); + } + else if (sd) + { + sd->sex = sd->status.sex = sex; + for (IOff0 j : IOff0::iter()) + { + if (sd->status.inventory[j].nameid + && bool(sd->status.inventory[j].equip) + && !pc_isequip(sd, j)) + pc_unequipitem(sd, j, CalcStatus::LATER); + } + pc_calcstatus(sd, 0); + chrif_save(sd); + clif_fixpcpos(sd); + } } - pc_calcstatus(sd, 0); - chrif_save(sd); - clif_fixpcpos(sd); break; case SP::WEIGHT: + nullpo_retz(sd); sd->weight = val; + clif_updatestatus(sd, type); break; case SP::MAXWEIGHT: + nullpo_retz(sd); sd->max_weight = val; + clif_updatestatus(sd, type); break; case SP::HP: + nullpo_retz(sd); + // TODO: mob mutation sd->status.hp = val; + clif_updatestatus(sd, type); break; case SP::MAXHP: + nullpo_retz(sd); + // TODO: mob mutation sd->status.max_hp = val; + clif_updatestatus(sd, type); break; case SP::SP: + nullpo_retz(sd); sd->status.sp = val; + clif_updatestatus(sd, type); break; case SP::MAXSP: + nullpo_retz(sd); sd->status.max_sp = val; + clif_updatestatus(sd, type); break; case SP::STR: case SP::AGI: @@ -3674,25 +3733,43 @@ int pc_setparam(dumb_ptr<map_session_data> sd, SP type, int val) case SP::INT: case SP::DEX: case SP::LUK: + nullpo_retz(sd); + // TODO: mob mutation pc_statusup2(sd, type, (val - sd->status.attrs[sp_to_attr(type)])); break; case SP::PARTNER: - dumb_ptr<block_list> p_bl; - if (val < 2000000 && val >= 150000) + if (sd) { - dumb_ptr<map_session_data> p_sd = nullptr; - if ((p_sd = map_nick2sd(map_charid2nick(wrap<CharId>(val)))) != nullptr) - p_bl = map_id2bl(p_sd->bl_id); + dumb_ptr<block_list> p_bl; + if (val < 2000000 && val >= 150000) + { + dumb_ptr<map_session_data> p_sd = nullptr; + if ((p_sd = map_nick2sd(map_charid2nick(wrap<CharId>(val)))) != nullptr) + p_bl = map_id2bl(p_sd->bl_id); + } + else + p_bl = map_id2bl(wrap<BlockId>(val)); + if (val < 1) + pc_divorce(sd); + else + p_bl ? pc_marriage(sd, p_bl->is_player()) : 0; } + break; + case SP::INVISIBLE: + if (sd) + pc_invisibility(sd, (val > 0) ? 1 : 0); + else if (nd) + npc_enable(nd->name, (val > 0) ? false : true); + break; + case SP::HIDDEN: + nullpo_retz(sd); + if (val == 1) + sd->status.option |= Opt0::HIDE; else - p_bl = map_id2bl(wrap<BlockId>(val)); - if (val < 1) - pc_divorce(sd); - else - p_bl ? pc_marriage(sd, p_bl->is_player()) : 0; + sd->status.option &= ~Opt0::HIDE; + clif_changeoption(sd); break; } - clif_updatestatus(sd, type); return 0; } |