Danilov3s Posted December 16, 2019 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 10 Reputation: 2 Joined: 03/15/14 Last Seen: April 4 Share Posted December 16, 2019 (edited) 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 Thank you! Edited December 16, 2019 by Slim Quote Link to comment Share on other sites More sharing options...
0 Litro Endemic Posted December 21, 2019 Group: Members Topic Count: 25 Topics Per Day: 0.01 Content Count: 283 Reputation: 79 Joined: 06/13/13 Last Seen: June 7, 2023 Share Posted December 21, 2019 cap it to the desired value, use min or max or cap_value function Quote Link to comment Share on other sites More sharing options...
0 Danilov3s Posted December 22, 2019 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 10 Reputation: 2 Joined: 03/15/14 Last Seen: April 4 Author Share Posted December 22, 2019 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 Quote Link to comment Share on other sites More sharing options...
0 Humble_Bee Posted December 24, 2019 Group: Members Topic Count: 54 Topics Per Day: 0.03 Content Count: 112 Reputation: 9 Joined: 09/22/19 Last Seen: July 24, 2022 Share Posted December 24, 2019 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. Quote Link to comment Share on other sites More sharing options...
0 Danilov3s Posted December 24, 2019 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 10 Reputation: 2 Joined: 03/15/14 Last Seen: April 4 Author Share Posted December 24, 2019 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. Quote Link to comment Share on other sites More sharing options...
Question
Danilov3s
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
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)
Thank you!
Edited by SlimLink to comment
Share on other sites
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.