Skip to content

Commit

Permalink
Fixes Overheat behavior (#5455)
Browse files Browse the repository at this point in the history
* Fixes #5395.
* Fixes Overheat not properly accounting for the Mechanic during battle calculations.
* Minor cleanups and improvements.
Thanks to @LotusRO!
Co-authored-by: Lemongrass3110 <lemongrass@kstp.at>
  • Loading branch information
aleos89 committed Oct 19, 2020
1 parent ef33ba1 commit 323db7e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 15 deletions.
9 changes: 3 additions & 6 deletions src/map/battle.cpp
Expand Up @@ -1351,7 +1351,7 @@ bool battle_status_block_damage(struct block_list *src, struct block_list *targe
*/
int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Damage *d,int64 damage,uint16 skill_id,uint16 skill_lv)
{
struct map_session_data *sd = NULL;
struct map_session_data *sd = NULL, *tsd = BL_CAST(BL_PC, src);
struct status_change *sc;
struct status_change_entry *sce;
int div_ = d->div_, flag = d->flag;
Expand Down Expand Up @@ -1435,7 +1435,6 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
#endif

if( damage ) {
struct map_session_data *tsd = BL_CAST(BL_PC, src);
if( sc->data[SC_DEEPSLEEP] ) {
damage += damage / 2; // 1.5 times more damage while in Deep Sleep.
status_change_end(bl,SC_DEEPSLEEP,INVALID_TIMER);
Expand Down Expand Up @@ -1689,8 +1688,6 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
if (sc->data[SC_UNLIMITEDHUMMINGVOICE] && flag&BF_MAGIC)
damage += damage * sc->data[SC_UNLIMITEDHUMMINGVOICE]->val3 / 100;

map_session_data *tsd = (map_session_data *)src;

if (tsd && (sce = sc->data[SC_SOULREAPER])) {
if (rnd()%100 < sce->val2 && tsd->soulball < MAX_SOUL_BALL) {
clif_specialeffect(src, 1208, AREA);
Expand Down Expand Up @@ -1725,7 +1722,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
damage = div_;
}

if (sd && pc_ismadogear(sd)) {
if (tsd && pc_ismadogear(tsd)) {
short element = skill_get_ele(skill_id, skill_lv);

if( !skill_id || element == ELE_WEAPON ) { //Take weapon's element
Expand All @@ -1739,7 +1736,7 @@ int64 battle_calc_damage(struct block_list *src,struct block_list *bl,struct Dam
element = status_get_attack_sc_element(src,status_get_sc(src));
else if( element == ELE_RANDOM ) //Use random element
element = rnd()%ELE_ALL;
pc_overheat(sd, (element == ELE_FIRE ? 3 : 1));
pc_overheat(tsd, (element == ELE_FIRE ? 3 : 1));
}

return damage;
Expand Down
12 changes: 6 additions & 6 deletions src/map/pc.cpp
Expand Up @@ -11503,14 +11503,14 @@ bool pc_setstand(struct map_session_data *sd, bool force){
* @param heat: Amount of Heat to adjust
**/
void pc_overheat(struct map_session_data *sd, int16 heat) {
struct status_change_entry *sce = NULL;
int16 limit[] = { 150, 200, 280, 360, 450 };
uint16 skill_lv;

nullpo_retv(sd);

skill_lv = cap_value(pc_checkskill(sd, NC_MAINFRAME), 0, 4);
if ((sce = sd->sc.data[SC_OVERHEAT_LIMITPOINT])) {
status_change_entry *sce = sd->sc.data[SC_OVERHEAT_LIMITPOINT];

if (sce) {
static std::vector<int16> limit = { 150, 200, 280, 360, 450 };
uint16 skill_lv = cap_value(pc_checkskill(sd, NC_MAINFRAME), 0, limit.size()-1);

sce->val1 += heat;
sce->val1 = cap_value(sce->val1, 0, 1000);
if (sd->sc.data[SC_OVERHEAT])
Expand Down
6 changes: 3 additions & 3 deletions src/map/status.cpp
Expand Up @@ -14440,8 +14440,8 @@ TIMER_FUNC(status_change_timer){

case SC_OVERHEAT_LIMITPOINT:
if (--(sce->val1) >= 0) { // Cooling
int16 limit[] = { 150, 200, 280, 360, 450 };
uint16 skill_lv = (sd ? pc_checkskill(sd, NC_MAINFRAME) : 0);
static std::vector<int16> limit = { 150, 200, 280, 360, 450 };
uint16 skill_lv = (sd ? cap_value(pc_checkskill(sd, NC_MAINFRAME), 0, limit.size()-1) : 0);

This comment has been minimized.

Copy link
@SBFONT

SBFONT Oct 21, 2020

Debug uint16

Error : 'initializing': conversion from 'size_t' to 'uint16', possible loss of data


if (sc && sc->data[SC_OVERHEAT])
status_change_end(bl,SC_OVERHEAT,INVALID_TIMER);
Expand All @@ -14453,7 +14453,7 @@ TIMER_FUNC(status_change_timer){
break;

case SC_OVERHEAT: {
int damage = status->max_hp / 100; // Suggestion 1% each second
uint32 damage = status->max_hp / 100; // Suggestion 1% each second

if (damage >= status->hp)
damage = status->hp - 1; // Do not kill, just keep you with 1 hp minimum
Expand Down

0 comments on commit 323db7e

Please sign in to comment.