Skip to content

Instantly share code, notes, and snippets.

@cydh
Last active April 21, 2020 18:21
Show Gist options
  • Save cydh/da76c4a6a901d15b806eaf31d60774b0 to your computer and use it in GitHub Desktop.
Save cydh/da76c4a6a901d15b806eaf31d60774b0 to your computer and use it in GitHub Desktop.
db/re/item_db.txt | 4 +-
src/map/script_constants.hpp | 2 +
src/map/status.cpp | 119 ++++++++++++++++++++++++++++++++++---------
src/map/status.hpp | 2 +
4 files changed, 100 insertions(+), 27 deletions(-)
diff --git a/db/re/item_db.txt b/db/re/item_db.txt
index 0cc393c1a..815b48215 100644
--- a/db/re/item_db.txt
+++ b/db/re/item_db.txt
@@ -6589,8 +6589,8 @@
12271,Mre_A,Military Ration A,0,2,,70,,,,,0xFFFFFFFF,63,2,,,,,,{ percentheal 5,0; },{},{}
12272,Mre_B,Military Ration B,2,2,,70,,,,,0xFFFFFFFF,63,2,,,,,,{ sc_start SC_HITFOOD,600000,33; },{},{}
12273,Mre_C,Military Ration C,2,2,,70,,,,,0xFFFFFFFF,63,2,,,,,,{ sc_start SC_FLEEFOOD,600000,33; },{},{}
-12274,Gold_Pill_1,Daehwandan,0,0,,10,,,,,0xFFFFFFFF,63,2,,,,,,{ bonus_script "{ bonus bMaxHPrate,5; bonus bHPrecovRate,10; }",3600; percentheal 10,0; },{},{}
-12275,Gold_Pill_2,Taecheongdan,0,0,,10,,,,,0xFFFFFFFF,63,2,,,,,,{ bonus_script "{ bonus bMaxSPrate,5; bonus bSPrecovRate,10; }",3600; percentheal 0,10; },{},{}
+12274,Gold_Pill_1,Daehwandan,0,0,,10,,,,,0xFFFFFFFF,63,2,,,,,,{ sc_start2 SC_INCREASE_MAXHP,3600000,5,10; percentheal 10,0; },{},{}
+12275,Gold_Pill_2,Taecheongdan,0,0,,10,,,,,0xFFFFFFFF,63,2,,,,,,{ sc_start2 SC_INCREASE_MAXSP,3600000,5,10; percentheal 0,10; },{},{}
12276,Mimic_Scroll,Mimic Scroll,2,2,,10,,,,,0xFFFFFFFF,63,2,,,,,,{ mercenary_create 2058,1800000; },{},{}
12277,Disguise_Scroll,Disguise Scroll,2,2,,10,,,,,0xFFFFFFFF,63,2,,,,,,{ mercenary_create 2059,1800000; },{},{}
12278,Alice_Scroll,Alice Scroll,2,2,,10,,,,,0xFFFFFFFF,63,2,,,,,,{ mercenary_create 2060,1800000; },{},{}
diff --git a/src/map/script_constants.hpp b/src/map/script_constants.hpp
index dd9a4f077..6ea81c393 100644
--- a/src/map/script_constants.hpp
+++ b/src/map/script_constants.hpp
@@ -1576,6 +1576,8 @@
export_constant(SC_SP_SHA);
export_constant(SC_SOULCURSE);
export_constant(SC_HELLS_PLANT);
+ export_constant(SC_INCREASE_MAXHP);
+ export_constant(SC_INCREASE_MAXSP);
#ifdef RENEWAL
export_constant(SC_EXTREMITYFIST2);
#endif
diff --git a/src/map/status.cpp b/src/map/status.cpp
index d883e9f72..f0e11a1f0 100644
--- a/src/map/status.cpp
+++ b/src/map/status.cpp
@@ -1147,6 +1147,8 @@ void initChangeTables(void)
StatusIconChangeTable[SC_SPL_MATK] = EFST_SPL_MATK;
StatusIconChangeTable[SC_ATKPOTION] = EFST_PLUSATTACKPOWER;
StatusIconChangeTable[SC_MATKPOTION] = EFST_PLUSMAGICPOWER;
+ StatusIconChangeTable[SC_INCREASE_MAXHP] |= EFST_ATKER_ASPD;
+ StatusIconChangeTable[SC_INCREASE_MAXSP] |= EFST_ATKER_MOVESPEED;
/* Cash Items */
StatusIconChangeTable[SC_FOOD_STR_CASH] = EFST_FOOD_STR_CASH;
@@ -1437,6 +1439,8 @@ void initChangeTables(void)
StatusChangeFlagTable[SC_GEFFEN_MAGIC1] |= SCB_ALL;
StatusChangeFlagTable[SC_GEFFEN_MAGIC2] |= SCB_ALL;
StatusChangeFlagTable[SC_GEFFEN_MAGIC3] |= SCB_ALL;
+ StatusChangeFlagTable[SC_INCREASE_MAXHP] |= SCB_MAXHP|SCB_REGEN;
+ StatusChangeFlagTable[SC_INCREASE_MAXSP] |= SCB_MAXSP|SCB_REGEN;
/* Cash Items */
StatusChangeFlagTable[SC_FOOD_STR_CASH] |= SCB_STR;
@@ -3354,13 +3358,6 @@ static int status_get_hpbonus(struct block_list *bl, enum e_status_bonus type) {
} else if (type == STATUS_BONUS_RATE) {
struct status_change *sc = status_get_sc(bl);
- //Only for BL_PC
- if (bl->type == BL_PC) {
- struct map_session_data *sd = map_id2sd(bl->id);
- bonus += sd->hprate;
- bonus -= 100; //Default hprate is 100, so it should be add 0%
- }
-
//Bonus by SC
if (sc) {
//Increasing
@@ -3386,8 +3383,6 @@ static int status_get_hpbonus(struct block_list *bl, enum e_status_bonus type) {
bonus += (2 + sc->data[SC_RAISINGDRAGON]->val1);
if(sc->data[SC_GT_REVITALIZE])
bonus += sc->data[SC_GT_REVITALIZE]->val2;
- if(sc->data[SC_MUSTLE_M])
- bonus += sc->data[SC_MUSTLE_M]->val1;
if(sc->data[SC_ANGRIFFS_MODUS])
bonus += (5 * sc->data[SC_ANGRIFFS_MODUS]->val1);
if(sc->data[SC_PETROLOGY_OPTION])
@@ -3414,8 +3409,6 @@ static int status_get_hpbonus(struct block_list *bl, enum e_status_bonus type) {
bonus -= sc->data[SC_BEYONDOFWARCRY]->val4;
if(sc->data[SC__WEAKNESS])
bonus -= sc->data[SC__WEAKNESS]->val2;
- if(sc->data[SC_MYSTERIOUS_POWDER])
- bonus -= sc->data[SC_MYSTERIOUS_POWDER]->val1;
if(sc->data[SC_EQC])
bonus -= sc->data[SC_EQC]->val3;
}
@@ -3426,6 +3419,40 @@ static int status_get_hpbonus(struct block_list *bl, enum e_status_bonus type) {
return min(bonus,INT_MAX);
}
+/**
+* HP bonus rate from equipment
+*/
+static int status_get_hpbonus_equip(TBL_PC *sd) {
+ int bonus = 0;
+
+ bonus += sd->hprate;
+
+ return bonus -= 100; //Default hprate is 100, so it should be add 0%
+}
+
+/**
+* HP bonus rate from usable items
+*/
+static int status_get_hpbonus_item(block_list *bl) {
+ int bonus = 0;
+
+ struct status_change *sc = status_get_sc(bl);
+
+ //Bonus by SC
+ if (sc) {
+ if (sc->data[SC_INCREASE_MAXHP])
+ bonus += sc->data[SC_INCREASE_MAXHP]->val1;
+ if (sc->data[SC_MUSTLE_M])
+ bonus += sc->data[SC_MUSTLE_M]->val1;
+
+ if (sc->data[SC_MYSTERIOUS_POWDER])
+ bonus -= sc->data[SC_MYSTERIOUS_POWDER]->val1;
+ }
+
+ // Max rate reduce is -100%
+ return cap_value(bonus, -100, INT_MAX);
+}
+
/**
* Get SP bonus modifiers
* @param bl: block_list that will be checked
@@ -3488,9 +3515,6 @@ static int status_get_spbonus(struct block_list *bl, enum e_status_bonus type) {
struct map_session_data *sd = map_id2sd(bl->id);
uint8 i;
- bonus += sd->sprate;
- bonus -= 100; //Default sprate is 100, so it should be add 0%
-
if((i = pc_checkskill(sd,HP_MEDITATIO)) > 0)
bonus += i;
if((i = pc_checkskill(sd,HW_SOULDRAIN)) > 0)
@@ -3513,12 +3537,6 @@ static int status_get_spbonus(struct block_list *bl, enum e_status_bonus type) {
bonus += sc->data[SC_SERVICE4U]->val2;
if(sc->data[SC_MERC_SPUP])
bonus += sc->data[SC_MERC_SPUP]->val2;
- if(sc->data[SC_LIFE_FORCE_F])
- bonus += sc->data[SC_LIFE_FORCE_F]->val1;
- if(sc->data[SC_VITATA_500])
- bonus += sc->data[SC_VITATA_500]->val2;
- if (sc->data[SC_ENERGY_DRINK_RESERCH])
- bonus += sc->data[SC_ENERGY_DRINK_RESERCH]->val3;
}
// Max rate reduce is -100%
bonus = cap_value(bonus,-100,INT_MAX);
@@ -3527,6 +3545,41 @@ static int status_get_spbonus(struct block_list *bl, enum e_status_bonus type) {
return min(bonus,INT_MAX);
}
+/**
+* SP bonus rate from equipment
+*/
+static int status_get_spbonus_equip(TBL_PC *sd) {
+ int bonus = 0;
+
+ bonus += sd->sprate;
+
+ return bonus -= 100; //Default sprate is 100, so it should be add 0%
+}
+
+/**
+* SP bonus rate from usable items
+*/
+static int status_get_spbonus_item(block_list *bl) {
+ int bonus = 0;
+
+ struct status_change *sc = status_get_sc(bl);
+
+ //Bonus by SC
+ if (sc) {
+ if (sc->data[SC_INCREASE_MAXSP])
+ bonus += sc->data[SC_INCREASE_MAXSP]->val1;
+ if (sc->data[SC_LIFE_FORCE_F])
+ bonus += sc->data[SC_LIFE_FORCE_F]->val1;
+ if (sc->data[SC_VITATA_500])
+ bonus += sc->data[SC_VITATA_500]->val2;
+ if (sc->data[SC_ENERGY_DRINK_RESERCH])
+ bonus += sc->data[SC_ENERGY_DRINK_RESERCH]->val3;
+ }
+
+ // Max rate reduce is -100%
+ return cap_value(bonus, -100, INT_MAX);
+}
+
/**
* Get final MaxHP or MaxSP for player. References: http://irowiki.org/wiki/Max_HP and http://irowiki.org/wiki/Max_SP
* The calculation needs base_level, base_status/battle_status (vit or int), additive modifier, and multiplicative modifier
@@ -3546,13 +3599,21 @@ static unsigned int status_calc_maxhpsp_pc(struct map_session_data* sd, unsigned
level = umax(sd->status.base_level,1);
if (isHP) { //Calculates MaxHP
+ double equip_bonus = 0, item_bonus = 0;
dmax = job_info[idx].base_hp[level-1] * (1 + (umax(stat,1) * 0.01)) * ((sd->class_&JOBL_UPPER)?1.25:(pc_is_taekwon_ranker(sd))?3:1);
dmax += status_get_hpbonus(&sd->bl,STATUS_BONUS_FIX);
+ equip_bonus = (dmax * status_get_hpbonus_equip(sd) / 100);
+ item_bonus = (dmax * status_get_hpbonus_item(&sd->bl) / 100);
+ dmax += equip_bonus + item_bonus;
dmax += (int64)(dmax * status_get_hpbonus(&sd->bl,STATUS_BONUS_RATE) / 100); //Aegis accuracy
}
else { //Calculates MaxSP
+ double equip_bonus = 0, item_bonus = 0;
dmax = job_info[idx].base_sp[level-1] * (1 + (umax(stat,1) * 0.01)) * ((sd->class_&JOBL_UPPER)?1.25:(pc_is_taekwon_ranker(sd))?3:1);
dmax += status_get_spbonus(&sd->bl,STATUS_BONUS_FIX);
+ equip_bonus = (dmax * status_get_spbonus_equip(sd) / 100);
+ item_bonus = (dmax * status_get_spbonus_item(&sd->bl) / 100);
+ dmax += equip_bonus + item_bonus;
dmax += (int64)(dmax * status_get_spbonus(&sd->bl,STATUS_BONUS_RATE) / 100); //Aegis accuracy
}
@@ -4856,6 +4917,7 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct
struct map_session_data *sd;
struct status_change *sc;
int val, skill, reg_flag;
+ int sc_rate;
if( !(bl->type&BL_REGEN) || !regen )
return;
@@ -4864,9 +4926,12 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct
sc = status_get_sc(bl);
val = 1 + (status->vit/5) + (status->max_hp/200);
-
- if( sd && sd->hprecov_rate != 100 )
- val = val*sd->hprecov_rate/100;
+ sc_rate = 100;
+ if (sc) {
+ if (sc->data[SC_INCREASE_MAXHP])
+ sc_rate += sc->data[SC_INCREASE_MAXHP]->val2;
+ }
+ val = (int)(val * ((sd ? sd->hprecov_rate : 100) / 100.) * (sc_rate / 100.));
reg_flag = bl->type == BL_PC ? 0 : 1;
@@ -4876,8 +4941,12 @@ void status_calc_regen(struct block_list *bl, struct status_data *status, struct
if( status->int_ >= 120 )
val += ((status->int_-120)>>1) + 4;
- if( sd && sd->sprecov_rate != 100 )
- val = val*sd->sprecov_rate/100;
+ sc_rate = 100;
+ if (sc) {
+ if (sc->data[SC_INCREASE_MAXSP])
+ sc_rate += sc->data[SC_INCREASE_MAXSP]->val2;
+ }
+ val = (int)(val * ((sd ? sd->sprecov_rate : 100) / 100.) * (sc_rate / 100.));
regen->sp = cap_value(val, reg_flag, SHRT_MAX);
diff --git a/src/map/status.hpp b/src/map/status.hpp
index 134398596..118ddf827 100644
--- a/src/map/status.hpp
+++ b/src/map/status.hpp
@@ -921,6 +921,8 @@ enum sc_type : int16 {
SC_SOULCURSE,
SC_HELLS_PLANT,
+ SC_INCREASE_MAXHP, // EFST_ATKER_ASPD
+ SC_INCREASE_MAXSP, // EFST_ATKER_MOVESPEED
#ifdef RENEWAL
SC_EXTREMITYFIST2, //! NOTE: This SC should be right before SC_MAX, so it doesn't disturb if RENEWAL is disabled
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment