summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2018-04-18 23:00:13 +0300
committerAndrei Karas <akaras@inbox.ru>2018-04-23 07:33:45 +0300
commita0309b09be9ae5ef313227c97bcdddc2383fbb37 (patch)
tree6d0e02fb2823659d8d9bc481df6be76cc41da18a /src
parentd442a7c0bfd05c6c51f7bb7f29ed20926e765f68 (diff)
downloadhercules-a0309b09be9ae5ef313227c97bcdddc2383fbb37.tar.gz
hercules-a0309b09be9ae5ef313227c97bcdddc2383fbb37.tar.bz2
hercules-a0309b09be9ae5ef313227c97bcdddc2383fbb37.tar.xz
hercules-a0309b09be9ae5ef313227c97bcdddc2383fbb37.zip
Move hp recover code from status_calc_pc_ into separate function.
Diffstat (limited to 'src')
-rw-r--r--src/map/status.c19
-rw-r--r--src/map/status.h1
2 files changed, 15 insertions, 5 deletions
diff --git a/src/map/status.c b/src/map/status.c
index a39449b11..972d1eca9 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -2333,6 +2333,18 @@ void status_calc_pc_additional(struct map_session_data* sd, enum e_status_calc_o
return;
}
+void status_calc_pc_recover_hp(struct map_session_data* sd, struct status_data *bstatus)
+{
+ nullpo_retv(sd);
+ nullpo_retv(bstatus);
+
+ if ((sd->job & MAPID_BASEMASK) == MAPID_NOVICE && (sd->job & JOBL_2) == 0
+ && battle_config.restart_hp_rate < 50)
+ bstatus->hp = bstatus->max_hp>>1;
+ else
+ bstatus->hp = APPLY_RATE(bstatus->max_hp, battle_config.restart_hp_rate);
+}
+
//Calculates player data from scratch without counting SC adjustments.
//Should be invoked whenever players raise stats, learn passive skills or change equipment.
int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
@@ -2874,11 +2886,7 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
bstatus->hp = bstatus->max_hp;
bstatus->sp = bstatus->max_sp;
} else {
- if ((sd->job & MAPID_BASEMASK) == MAPID_NOVICE && (sd->job & JOBL_2) == 0
- && battle_config.restart_hp_rate < 50)
- bstatus->hp = bstatus->max_hp>>1;
- else
- bstatus->hp = APPLY_RATE(bstatus->max_hp, battle_config.restart_hp_rate);
+ status->calc_pc_recover_hp(sd, bstatus);
if(!bstatus->hp)
bstatus->hp = 1;
@@ -13658,6 +13666,7 @@ void status_defaults(void)
status->calc_pet_ = status_calc_pet_;
status->calc_pc_ = status_calc_pc_;
status->calc_pc_additional = status_calc_pc_additional;
+ status->calc_pc_recover_hp = status_calc_pc_recover_hp;
status->calc_homunculus_ = status_calc_homunculus_;
status->calc_mercenary_ = status_calc_mercenary_;
status->calc_elemental_ = status_calc_elemental_;
diff --git a/src/map/status.h b/src/map/status.h
index 5a031fa48..5df439237 100644
--- a/src/map/status.h
+++ b/src/map/status.h
@@ -2355,6 +2355,7 @@ struct status_interface {
int (*calc_pet_) (struct pet_data* pd, enum e_status_calc_opt opt);
int (*calc_pc_) (struct map_session_data* sd, enum e_status_calc_opt opt);
void (*calc_pc_additional) (struct map_session_data* sd, enum e_status_calc_opt opt);
+ void (*calc_pc_recover_hp) (struct map_session_data* sd, struct status_data *bstatus);
int (*calc_homunculus_) (struct homun_data *hd, enum e_status_calc_opt opt);
int (*calc_mercenary_) (struct mercenary_data *md, enum e_status_calc_opt opt);
int (*calc_elemental_) (struct elemental_data *ed, enum e_status_calc_opt opt);