Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

MaxHits sometimes is incorrect

Post Reply
sibble
Neophyte
Neophyte
Posts: 48
Joined: 21.03.2015 18:12

MaxHits sometimes is incorrect

Post 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
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: MaxHits sometimes is incorrect

Post by Vizit0r »

maxhits of your char or another?
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: MaxHits sometimes is incorrect

Post by drabadan »

Vizit0r wrote:maxhits of your char or another?
Must be another, it's a pretty common issue due to ultima protocol.
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: MaxHits sometimes is incorrect

Post by Vizit0r »

for another chars HP comes at % from 100% (maxhp).
For self - thats real hp from real maxhp.

Maybe thats your problem?
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
sibble
Neophyte
Neophyte
Posts: 48
Joined: 21.03.2015 18:12

Re: MaxHits sometimes is incorrect

Post by sibble »

It's always for another character, not self.
sibble
Neophyte
Neophyte
Posts: 48
Joined: 21.03.2015 18:12

Re: MaxHits sometimes is incorrect

Post 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;
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: MaxHits sometimes is incorrect

Post by Vizit0r »

MaxHits = 100 (%)
return (_hits * 100 / _maxhits); = hits * 100 / 100 = hits.

looks strange.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
sibble
Neophyte
Neophyte
Posts: 48
Joined: 21.03.2015 18:12

Re: MaxHits sometimes is incorrect

Post by sibble »

Image
sibble
Neophyte
Neophyte
Posts: 48
Joined: 21.03.2015 18:12

Re: MaxHits sometimes is incorrect

Post by sibble »

Image
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: MaxHits sometimes is incorrect

Post by Vizit0r »

strange. but i dont know, why server send you 25 as 100%.
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
sibble
Neophyte
Neophyte
Posts: 48
Joined: 21.03.2015 18:12

Re: MaxHits sometimes is incorrect

Post 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 =(
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: MaxHits sometimes is incorrect

Post by Vizit0r »

hard to reproduce?
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
Post Reply