-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core/Spells: Fixed work of sobering spells and other improvements for drunk system. #29745
Conversation
the sobering part has been fixed in master branch by me already. so cherrypick that commit. |
Oh, I don't think the overflow issue is completely resolved here. Unless we hope that no one will ever create a spell with basepoint = (2147483547; 2147483647] |
this has not been a problem throughout all expansions so far so I doubt that this will ever happen. |
Yes, but why do we need doubts if there is ready-made code that solves the problem completely ¯_(ツ)_/¯ |
just change the int32 to int64 and your problems are gone. |
Yes, but why should I do this if ready-made code has already been written that completely solves the problem. Not mine btw xd |
Just tested this pr but doesn't seem to work with the given example: https://youtu.be/4N-zMfxoigQ , maybe I'm missing smth |
You drink a sobering coffee while being completely sober, and as expected, nothing happens |
ah I got it, I have to drink smth before, well now it works: https://youtu.be/gdjO3SZGrRs |
…w in SPELL_EFFECT_INEBRIATE handler.
73e74b0
to
e81c147
Compare
What's going on 😄 |
nothing |
Changes proposed:
The first commit related to
SPELL_EFFECT_INEBRIATE
(100) effect. The problem is that there are not only inebriation but also sobering spells (with basepoint < 0). The current implementation uses an unsigned type, ignoring sobering spells. This leads to a uint8 underflow, resulting in the spell's behavior being completely unexpected: it can both inebriate and sober you up.Example:
.gobject add temp 185914
There is another problem: there are spells with an inebriate effect with basepoint values so large or small that it inevitably leads to uint8 overflow/underflow. For example,
29690
or46874
. As intended,29690
should make you extremely drunk, but in reality, the behavior can be unpredictable each time. If someone keeps casting this spell on you again and again, you will likely notice that sometimes you get drunk and sometimes you sober up.The first commit completely fixes this issues.
The second commit is related to the aura effect
SPELL_AURA_MOD_FAKE_INEBRIATE
(304). The main problem is that the handler of this effect ignores the value of player's actual inebriation. In any case, there was a lot of redundant (duplicate) code here. Now the logic for updating invisibility detect has been moved to a separate method, and all known issues have been fixed.Tests performed:
Builded and tested in-game.