-
-
Save Litro/30d4527dcb7e3e96c278fe5f18dff43c to your computer and use it in GitHub Desktop.
bHPGainRateWhenHit.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From c33f0a5ea60757f48a43b61aaa0bf3edf16fd904 Mon Sep 17 00:00:00 2001 | |
From: Litro <haruna.epic@gmail.com> | |
Date: Sun, 4 Jul 2021 16:39:15 +0700 | |
Subject: [PATCH] * bHPGainRateWhenHit | |
Source: https://raw.githubusercontent.com/AnnieRuru/Release/master/plugins/Request%20%26%20Answer/bHPGainRateWhenHit/bHPGainRateWhenHit_0.5.c | |
--- | |
src/map/battle.cpp | 45 ++++++++++++++++++++++++++++++++++++ | |
src/map/map.hpp | 4 +++- | |
src/map/pc.cpp | 20 ++++++++++++++++ | |
src/map/pc.hpp | 6 +++++ | |
src/map/script_constants.hpp | 1 + | |
src/map/status.cpp | 6 +++++ | |
6 files changed, 81 insertions(+), 1 deletion(-) | |
diff --git a/src/map/battle.cpp b/src/map/battle.cpp | |
index d64082c30..356234140 100644 | |
--- a/src/map/battle.cpp | |
+++ b/src/map/battle.cpp | |
@@ -1410,6 +1410,51 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam | |
if (bl->type == BL_PC) { | |
sd=(struct map_session_data *)bl; | |
+ | |
+ // bHPGainRateWhenHit | |
+ if (sd->hp_gain_rate_chance_weapon && sd->hp_gain_rate_amount_weapon && (flag & BF_WEAPON) && (rnd() % 1000) < sd->hp_gain_rate_chance_weapon) | |
+ { | |
+ if (sd->hp_gain_rate_amount_weapon >= 100) | |
+ { | |
+ pc_heal(sd, (unsigned int)damage, 0, true ); | |
+ return 0; | |
+ } | |
+ else | |
+ { | |
+ pc_heal(sd, (unsigned int)(damage * sd->hp_gain_rate_amount_weapon / 100), 0, true); | |
+ damage -= damage * sd->hp_gain_rate_amount_weapon / 100; | |
+ if(damage < 1) return 0; | |
+ } | |
+ } | |
+ if (sd->hp_gain_rate_chance_magic && sd->hp_gain_rate_amount_magic && (flag & BF_MAGIC) && (rnd() % 1000) < sd->hp_gain_rate_chance_magic) | |
+ { | |
+ if (sd->hp_gain_rate_amount_magic >= 100) | |
+ { | |
+ pc_heal(sd, (unsigned int)damage, 0, true ); | |
+ return 0; | |
+ } | |
+ else | |
+ { | |
+ pc_heal(sd, (unsigned int)(damage * sd->hp_gain_rate_amount_magic / 100), 0, true); | |
+ damage -= damage * sd->hp_gain_rate_amount_magic / 100; | |
+ if(damage < 1) return 0; | |
+ } | |
+ } | |
+ if (sd->hp_gain_rate_chance_misc && sd->hp_gain_rate_amount_misc && (flag & BF_MISC) && (rnd() % 1000) < sd->hp_gain_rate_chance_misc) | |
+ { | |
+ if (sd->hp_gain_rate_amount_misc >= 100) | |
+ { | |
+ pc_heal(sd, (unsigned int)damage, 0, true); | |
+ return 0; | |
+ } | |
+ else | |
+ { | |
+ pc_heal(sd, (unsigned int)(damage * sd->hp_gain_rate_amount_misc / 100), 0, true); | |
+ damage -= damage * sd->hp_gain_rate_amount_misc / 100; | |
+ if(damage < 1) return 0; | |
+ } | |
+ } | |
+ | |
//Special no damage states | |
if(flag&BF_WEAPON && sd->special_state.no_weapon_damage) | |
damage -= damage * sd->special_state.no_weapon_damage / 100; | |
diff --git a/src/map/map.hpp b/src/map/map.hpp | |
index 69d7252f9..fd710c2a1 100644 | |
--- a/src/map/map.hpp | |
+++ b/src/map/map.hpp | |
@@ -544,7 +544,9 @@ enum _sp { | |
SP_WEAPON_ATK_RATE, SP_WEAPON_MATK_RATE, SP_DROP_ADDRACE, SP_DROP_ADDCLASS, SP_NO_MADO_FUEL, // 2083-2087 | |
SP_IGNORE_DEF_CLASS_RATE, SP_REGEN_PERCENT_HP, SP_REGEN_PERCENT_SP, SP_SKILL_DELAY, SP_NO_WALK_DELAY, //2088-2092 | |
SP_LONG_SP_GAIN_VALUE, SP_LONG_HP_GAIN_VALUE, SP_SHORT_ATK_RATE, SP_MAGIC_SUBSIZE, SP_CRIT_DEF_RATE, // 2093-2097 | |
- SP_MAGIC_SUBDEF_ELE, SP_REDUCE_DAMAGE_RETURN // 2098-2099 | |
+ SP_MAGIC_SUBDEF_ELE, SP_REDUCE_DAMAGE_RETURN, // 2098-2099 | |
+ | |
+ SP_HP_GAIN_RATE_WHEN_HIT | |
}; | |
enum _look { | |
diff --git a/src/map/pc.cpp b/src/map/pc.cpp | |
index 326d34b3e..e96dcf7ff 100755 | |
--- a/src/map/pc.cpp | |
+++ b/src/map/pc.cpp | |
@@ -4708,6 +4708,26 @@ void pc_bonus3(struct map_session_data *sd,int type,int type2,int type3,int val) | |
sd->norecover_state_race[type2].rate = type3; | |
sd->norecover_state_race[type2].tick = val; | |
break; | |
+ case SP_HP_GAIN_RATE_WHEN_HIT: | |
+ if (sd->state.lr_flag != 2) | |
+ { | |
+ if ((type2 & BF_WEAPON)) | |
+ { | |
+ sd->hp_gain_rate_chance_weapon = cap_value(sd->hp_gain_rate_chance_weapon + type3, 0, 1000); | |
+ sd->hp_gain_rate_amount_weapon = cap_value(sd->hp_gain_rate_amount_weapon + val, 0, 100); | |
+ } | |
+ if ((type2 & BF_MAGIC)) | |
+ { | |
+ sd->hp_gain_rate_chance_magic = cap_value(sd->hp_gain_rate_chance_magic + type3, 0, 1000); | |
+ sd->hp_gain_rate_amount_magic = cap_value(sd->hp_gain_rate_amount_magic + val, 0, 100); | |
+ } | |
+ if ((type2 & BF_MISC)) | |
+ { | |
+ sd->hp_gain_rate_chance_misc = cap_value(sd->hp_gain_rate_chance_misc + type3, 0, 1000); | |
+ sd->hp_gain_rate_amount_misc = cap_value(sd->hp_gain_rate_amount_misc + val, 0, 100); | |
+ } | |
+ } | |
+ break; | |
default: | |
if (current_equip_combo_pos > 0) { | |
ShowWarning("pc_bonus3: unknown bonus type %d %d %d %d in a combo with item #%u\n", type, type2, type3, val, sd->inventory_data[pc_checkequip( sd, current_equip_combo_pos )]->nameid); | |
diff --git a/src/map/pc.hpp b/src/map/pc.hpp | |
index ea0028927..d78d1eeeb 100644 | |
--- a/src/map/pc.hpp | |
+++ b/src/map/pc.hpp | |
@@ -576,6 +576,12 @@ struct map_session_data { | |
// (^~_~^) Color Nicks End | |
+ int hp_gain_rate_chance_weapon; | |
+ int hp_gain_rate_amount_weapon; | |
+ int hp_gain_rate_chance_magic; | |
+ int hp_gain_rate_amount_magic; | |
+ int hp_gain_rate_chance_misc; | |
+ int hp_gain_rate_amount_misc; | |
int castrate,delayrate,hprate,sprate,aprate,dsprate; | |
int hprecov_rate,sprecov_rate; | |
int matk_rate; | |
diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp | |
index 1fe63c0ee..413e88eee 100644 | |
--- a/src/map/script_constants.hpp | |
+++ b/src/map/script_constants.hpp | |
@@ -822,6 +822,7 @@ | |
export_constant2("bCritDefRate",SP_CRIT_DEF_RATE); | |
export_constant2("bMagicSubDefEle", SP_MAGIC_SUBDEF_ELE); | |
export_constant2("bReduceDamageReturn",SP_REDUCE_DAMAGE_RETURN); | |
+ export_constant2("bHPGainRateWhenHit",SP_HP_GAIN_RATE_WHEN_HIT); | |
/* equip indices */ | |
export_constant(EQI_COMPOUND_ON); | |
diff --git a/src/map/status.cpp b/src/map/status.cpp | |
index e8bf11b82..1ee7d1d31 100644 | |
--- a/src/map/status.cpp | |
+++ b/src/map/status.cpp | |
@@ -5054,6 +5054,12 @@ int status_calc_pc_sub(struct map_session_data* sd, enum e_status_calc_opt opt) | |
sd->hplus_rate = sd->crate_rate = 100; | |
sd->regen.state.block = 0; | |
sd->add_max_weight = 0; | |
+ sd->hp_gain_rate_chance_weapon = 0; | |
+ sd->hp_gain_rate_amount_weapon = 0; | |
+ sd->hp_gain_rate_chance_magic = 0; | |
+ sd->hp_gain_rate_amount_magic = 0; | |
+ sd->hp_gain_rate_chance_misc = 0; | |
+ sd->hp_gain_rate_amount_misc = 0; | |
sd->indexed_bonus = {}; | |
-- | |
2.29.2.windows.2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment