Skip to content

Commit

Permalink
Implemented new item bonuses bRegenPercentHP and bRegenPercentHP
Browse files Browse the repository at this point in the history
  • Loading branch information
Jittapan Pluemsumran committed Aug 31, 2016
1 parent 30fb80a commit a79d065
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
2 changes: 2 additions & 0 deletions doc/item_bonus.txt
Expand Up @@ -155,6 +155,8 @@ bonus2 bHPRegenRate,n,t; Gain n HP every t milliseconds
bonus2 bHPLossRate,n,t; Lose n HP every t milliseconds
bonus2 bSPRegenRate,n,t; Gain n SP every t milliseconds
bonus2 bSPLossRate,n,t; Lose n SP every t milliseconds
bonus2 bRegenPercentHP,n,t; Gain n% of max HP every t milliseconds
bonus2 bRegenPercentSP,n,t; Gain n% of max SP every t milliseconds
bonus bNoRegen,x; Stops HP or SP regeneration (x: 1=HP, 2=SP)

bonus bUseSPrate,n; SP consumption + n%
Expand Down
2 changes: 1 addition & 1 deletion src/map/map.h
Expand Up @@ -469,7 +469,7 @@ enum _sp {
SP_HP_VANISH_RACE_RATE, SP_SP_VANISH_RACE_RATE, SP_ABSORB_DMG_MAXHP, SP_SUB_SKILL, SP_SUBDEF_ELE, // 2074-2078
SP_STATE_NORECOVER_RACE, SP_CRITICAL_RANGEATK, SP_MAGIC_ADDRACE2, SP_IGNORE_MDEF_RACE2_RATE, // 2079-2082
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, //2088
SP_IGNORE_DEF_CLASS_RATE, SP_REGEN_PERCENT_HP, SP_REGEN_PERCENT_SP, //2088-2091
};

enum _look {
Expand Down
28 changes: 28 additions & 0 deletions src/map/pc.c
Expand Up @@ -3413,6 +3413,18 @@ void pc_bonus2(struct map_session_data *sd,int type,int type2,int val)
sd->hp_regen.rate = val;
}
break;
case SP_REGEN_PERCENT_HP: // bonus2 bRegenPercentHP,n,t;
if (sd->state.lr_flag != 2) {
sd->percent_hp_regen.value = type2;
sd->percent_hp_regen.rate = val;
}
break;
case SP_REGEN_PERCENT_SP: // bonus2 bRegenPercentSP,n,t;
if (sd->state.lr_flag != 2) {
sd->percent_sp_regen.value = type2;
sd->percent_sp_regen.rate = val;
}
break;
case SP_ADDRACE2: // bonus2 bAddRace2,mr,x;
PC_BONUS_CHK_RACE2(type2,SP_ADDRACE2);
if(sd->state.lr_flag != 2)
Expand Down Expand Up @@ -10301,6 +10313,22 @@ void pc_regen (struct map_session_data *sd, unsigned int diff_tick)
}
}

if (sd->percent_hp_regen.value) {
sd->percent_hp_regen.tick += diff_tick;
while (sd->percent_hp_regen.tick >= sd->percent_hp_regen.rate) {
hp += (sd->percent_hp_regen.value * sd->status.max_hp);
sd->percent_hp_regen.tick -= sd->percent_hp_regen.rate;
}
}

if (sd->percent_sp_regen.value) {
sd->percent_sp_regen.tick += diff_tick;
while (sd->percent_sp_regen.tick >= sd->percent_sp_regen.rate) {
sp += (sd->percent_sp_regen.value * sd->status.max_sp);
sd->percent_sp_regen.tick -= sd->percent_sp_regen.rate;
}
}

if (hp > 0 || sp > 0)
status_heal(&sd->bl, hp, sp, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion src/map/pc.h
Expand Up @@ -395,7 +395,7 @@ struct map_session_data {
short value;
int rate;
int tick;
} hp_loss, sp_loss, hp_regen, sp_regen;
} hp_loss, sp_loss, hp_regen, sp_regen, percent_hp_regen, percent_sp_regen;
struct {
short class_, rate;
} add_def[MAX_PC_BONUS], add_mdef[MAX_PC_BONUS], add_mdmg[MAX_PC_BONUS];
Expand Down
2 changes: 2 additions & 0 deletions src/map/script_constants.h
Expand Up @@ -664,6 +664,8 @@
script_set_constant("bDropAddClass", SP_DROP_ADDCLASS, false);
script_set_constant("bNoMadoFuel", SP_NO_MADO_FUEL, false);
script_set_constant("bIgnoreDefClassRate", SP_IGNORE_DEF_CLASS_RATE, false);
script_set_constant("bRegenPercentHP", SP_REGEN_PERCENT_HP, false);
script_set_constant("bRegenPercentSP", SP_REGEN_PERCENT_SP, false);

/* equip indices */
export_constant(EQI_HEAD_TOP);
Expand Down

3 comments on commit a79d065

@lucasoli
Copy link

@lucasoli lucasoli commented on a79d065 Aug 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe a typo? The correct commit message should be "bRegenPercentHP and bRegenPercentSP", right?

@aleos89
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't change the commit message. The feature itself is fine though.

@lucasoli
Copy link

@lucasoli lucasoli commented on a79d065 Aug 31, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeap, as you said the feature itself is fine, it's just a typo on commit message. But it's ok!

Please sign in to comment.