Jump to content
  • 0

Avoid MATK Overflow


Danilov3s

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   2
  • Joined:  03/15/14
  • Last Seen:  

Hey all! Greetings,

Recently I've been trying to avoid the MATK infamous overflow when it reaches the maximum, but no success at all.

I tried protecting the values from getting bigger than SHRT_MAX (32727) but still nothing changed

I tried poking aroud in the status.cpp, and found that when it executes this piece of code at line 5239
 

if (bl->type&BL_PC && sd->matk_rate != 100) {
            status->matk_max = status->matk_max * sd->matk_rate/100;
            status->matk_min = status->matk_min * sd->matk_rate/100;
}

And the matk_max is greater than 30097, the result is 87 (I'm not 100% sure about these values, but they're approximated)

I've also tried changing the matk_min and matk_max to int, but I'm not sure if I did it right..

This is what I mean by "overflow" (the values just go negative)

Spoiler

lRRhP1j.png

Thank you!

Edited by Slim
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  283
  • Reputation:   76
  • Joined:  06/13/13
  • Last Seen:  

cap it to the desired value, use min or max or cap_value function 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   2
  • Joined:  03/15/14
  • Last Seen:  

On 12/21/2019 at 7:50 AM, Litro Endemic said:

cap it to the desired value, use min or max or cap_value function 

Doesn't work, tried setting the status->matk_max before the formula but it still "overflow". I don't even know if the correct name is overflow

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.03
  • Content Count:  112
  • Reputation:   9
  • Joined:  09/22/19
  • Last Seen:  

Try looking for this in status.cpp:

 

Spoiler

if(sd->matk_rate < 0)
        sd->matk_rate = 0;

And try adding right below it:
 

Spoiler

if(sd->matk_rate > yourdesiredmaxvalue)
        sd->matk_rate = yourdesiredmaxvalue;

Doing something like this for regen had worked for me in making a cap. If that doesn't work, I'll probably offer a few other things to try, but I'm relatively new to messing with code as well.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  9
  • Reputation:   2
  • Joined:  03/15/14
  • Last Seen:  

14 hours ago, Humble_Bee said:

Try looking for this in status.cpp:

 

  Hide contents

if(sd->matk_rate < 0)
        sd->matk_rate = 0;

And try adding right below it:
 

  Hide contents

if(sd->matk_rate > yourdesiredmaxvalue)
        sd->matk_rate = yourdesiredmaxvalue;

Doing something like this for regen had worked for me in making a cap. If that doesn't work, I'll probably offer a few other things to try, but I'm relatively new to messing with code as well.

Thank you for your suggestion, but I got it working already...

I've changed the data types from both min and max to unsigned int, and changed every place that modify these values to cast it to int instead of short, and changed the caps from SHRT_MAX to USHRT_MAX. Also did some improvements in some formulas, like instead of using matk_max = matx_max + something, just matk_max += something; And last I changed the piece of code that calls clif to do a check whether the initial matk is 0 and reduce the max matk by 1.

 

 

80029830_549048075946703_4567140683512545280_n.png

80307890_2913796508644014_1521707930880049152_n.png

80469536_555482131968484_4104355870014439424_n.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...