Page 1 of 1

MaxHits sometimes is incorrect

Posted: 14.09.2015 16:42
by sibble
Debugging a healing script that sometimes doesn't heal when it should, or heals when it shouldn't. At those times, MaxHits returns something really low like 25 when it should be returning 137 (example.)

1 in 100

Re: MaxHits sometimes is incorrect

Posted: 14.09.2015 16:49
by Vizit0r
maxhits of your char or another?

Re: MaxHits sometimes is incorrect

Posted: 14.09.2015 21:57
by drabadan
Vizit0r wrote:maxhits of your char or another?
Must be another, it's a pretty common issue due to ultima protocol.

Re: MaxHits sometimes is incorrect

Posted: 14.09.2015 23:29
by Vizit0r
for another chars HP comes at % from 100% (maxhp).
For self - thats real hp from real maxhp.

Maybe thats your problem?

Re: MaxHits sometimes is incorrect

Posted: 15.09.2015 2:00
by sibble
It's always for another character, not self.

Re: MaxHits sometimes is incorrect

Posted: 15.09.2015 2:02
by sibble
was using this formula for getting % for both self and other

Code: Select all

                var _maxhits = MaxHits;
                var _hits = Hits;
                if (_maxhits > 0 && _hits > 0)
                    return (_hits * 100 / _maxhits);
                else
                    return 0;

Re: MaxHits sometimes is incorrect

Posted: 15.09.2015 14:15
by Vizit0r
MaxHits = 100 (%)
return (_hits * 100 / _maxhits); = hits * 100 / 100 = hits.

looks strange.

Re: MaxHits sometimes is incorrect

Posted: 15.09.2015 18:53
by sibble
Image

Re: MaxHits sometimes is incorrect

Posted: 15.09.2015 18:59
by sibble
Image

Re: MaxHits sometimes is incorrect

Posted: 16.09.2015 15:32
by Vizit0r
strange. but i dont know, why server send you 25 as 100%.

Re: MaxHits sometimes is incorrect

Posted: 17.09.2015 19:40
by sibble
Gone post my script to see if anyone wants to try and reproduce.
Getting incorrect health readings from pets.

Script: http://pastebin.com/Y0NKNHnC

Using: http://sourceforge.net/projects/scriptsdk/files

EDIT: NEW INFORMATION!
I disconnected the profile, reconnected, and script is working!!!
Getting correct readings now!

Stopped script, restarted script. Still working.

It seems reconnect fixed it, but why =(

Re: MaxHits sometimes is incorrect

Posted: 17.09.2015 20:39
by Vizit0r
hard to reproduce?