Skip to content

Commit

Permalink
add player heal packets
Browse files Browse the repository at this point in the history
  • Loading branch information
Helianthella committed Dec 18, 2018
1 parent 07ae3cf commit abf1b26
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
v18.12.18
- add packets that tell ManaPlus to update player HP
v18.12.13
- add support for sending player HP to manaplus
v18.11.11
Expand Down
25 changes: 25 additions & 0 deletions src/map/clif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4121,6 +4121,31 @@ void clif_send_mask(dumb_ptr<map_session_data> sd, int map_mask)
clif_send(buf, sd, SendWho::SELF, wrap<ClientVersion>(2));
}

void clif_send_hp_partial(dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);

Packet_Fixed<0x0232> fixed_232;
fixed_232.account_id = sd->status_key.account_id;
fixed_232.hp = sd->status.hp;

Buffer buf = create_fpacket<0x0232, 10>(fixed_232);
clif_send(buf, sd, SendWho::AREA_WOS, wrap<ClientVersion>(9));
}

void clif_send_hp_full(dumb_ptr<map_session_data> sd)
{
nullpo_retv(sd);

Packet_Fixed<0x0233> fixed_233;
fixed_233.account_id = sd->status_key.account_id;
fixed_233.hp = sd->status.hp;
fixed_233.max_hp = sd->status.max_hp;

Buffer buf = create_fpacket<0x0233, 14>(fixed_233);
clif_send(buf, sd, SendWho::AREA_WOS, wrap<ClientVersion>(9));
}

/*==========================================
*
*------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/map/clif.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ void clif_update_collision(dumb_ptr<map_session_data>, short, short, short, shor
void clif_change_music(dumb_ptr<map_session_data> sd, XString music);
void clif_npc_action(dumb_ptr<map_session_data>, BlockId, short, int, short, short);
void clif_send_mask(dumb_ptr<map_session_data>, int);
void clif_send_hp_partial(dumb_ptr<map_session_data>);
void clif_send_hp_full(dumb_ptr<map_session_data>);

// trade
void clif_traderequest(dumb_ptr<map_session_data> sd, CharName name);
Expand Down
29 changes: 26 additions & 3 deletions src/map/pc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2802,7 +2802,7 @@ int pc_checkbaselevelup(dumb_ptr<map_session_data> sd)
clif_updatestatus(sd, SP::BASELEVEL);
clif_updatestatus(sd, SP::NEXTBASEEXP);
pc_calcstatus(sd, 0);
pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
pc_heal(sd, sd->status.max_hp, sd->status.max_sp, true);

clif_misceffect(sd, 0);
//レベルアップしたのでパーティー情報を更新する
Expand Down Expand Up @@ -3618,7 +3618,7 @@ int pc_setparam(dumb_ptr<block_list> bl, SP type, int val)
clif_updatestatus(sd, SP::STATUSPOINT);
clif_updatestatus(sd, SP::BASEEXP);
pc_calcstatus(sd, 0);
pc_heal(sd, sd->status.max_hp, sd->status.max_sp);
pc_heal(sd, sd->status.max_hp, sd->status.max_sp, true);
break;
case SP::JOBLEVEL:
nullpo_retz(sd);
Expand Down Expand Up @@ -3825,7 +3825,7 @@ int pc_setparam(dumb_ptr<block_list> bl, SP type, int val)
* HP/SP回復
*------------------------------------------
*/
int pc_heal(dumb_ptr<map_session_data> sd, int hp, int sp)
int pc_heal(dumb_ptr<map_session_data> sd, int hp, int sp, bool levelup)
{
nullpo_retz(sd);

Expand Down Expand Up @@ -3855,7 +3855,16 @@ int pc_heal(dumb_ptr<map_session_data> sd, int hp, int sp)
if (sd->status.sp <= 0)
sd->status.sp = 0;
if (hp)
{
clif_updatestatus(sd, SP::HP);

if (hp > 0 && levelup) {
clif_send_hp_full(sd);
} else if (hp > 0) {
clif_send_hp_partial(sd);
}
}

if (sp)
clif_updatestatus(sd, SP::SP);

Expand All @@ -3871,6 +3880,10 @@ int pc_heal(dumb_ptr<map_session_data> sd, int hp, int sp)

return hp + sp;
}
int pc_heal(dumb_ptr<map_session_data> sd, int hp, int sp)
{
return pc_heal(sd, hp, sp, false);
}

/*==========================================
* HP/SP回復
Expand Down Expand Up @@ -3986,7 +3999,14 @@ int pc_itemheal_effect(dumb_ptr<map_session_data> sd, int hp, int sp)
if (sd->status.sp <= 0)
sd->status.sp = 0;
if (hp)
{
clif_updatestatus(sd, SP::HP);

if (hp > 0) {
clif_send_hp_partial(sd);
}
}

if (sp)
clif_updatestatus(sd, SP::SP);

Expand Down Expand Up @@ -4959,7 +4979,10 @@ int pc_natural_heal_hp(dumb_ptr<map_session_data> sd)
}
}
if (bhp != sd->status.hp)
{
clif_updatestatus(sd, SP::HP);
clif_send_hp_partial(sd);
}

sd->inchealhptick = interval_t::zero();

Expand Down
1 change: 1 addition & 0 deletions src/map/pc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ int pc_useitem(dumb_ptr<map_session_data>, IOff0);

int pc_damage(dumb_ptr<block_list>, dumb_ptr<map_session_data>, int);
int pc_heal(dumb_ptr<map_session_data>, int, int);
int pc_heal(dumb_ptr<map_session_data>, int, int, bool);
int pc_itemheal(dumb_ptr<map_session_data> sd, int hp, int sp);
int pc_changelook(dumb_ptr<map_session_data>, LOOK, int);

Expand Down
29 changes: 29 additions & 0 deletions tools/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -4849,6 +4849,35 @@ def build_context():
Set updated collision for a square area
''',
)
map_user.s(0x0232, 'send hp update',
define='SMSG_PLAYER_HP',
fixed=[
at(0, u16, 'packet id'),
at(2, account_id, 'account id'),
at(6, u32, 'hp'),
],
fixed_size=10,
pre=[NOTHING],
post=[PRETTY],
desc='''
Send part of hp info
''',
)
map_user.s(0x0233, 'send full hp',
define='SMSG_PLAYER_HP_FULL',
fixed=[
at(0, u16, 'packet id'),
at(2, account_id, 'account id'),
at(6, u32, 'hp'),
at(10, u32, 'max hp'),
],
fixed_size=14,
pre=[NOTHING],
post=[PRETTY],
desc='''
Send both hp and max hp
''',
)


# TOC_LOGINCHAR
Expand Down

0 comments on commit abf1b26

Please sign in to comment.