Page 1 of 1
Delay with grab HP from client
Posted: Fri Sep 18, 2015 11:08 am
by Stionowl1943
Hello, i have problem with delay when i try grab HP from client.
It doesnt work instantly, micromacro need about 0.4 sec to correct read this HP or i just make smth wrong?
My script:
Code: Select all
function chHP()
player:update()
HP = (player.HP/player.MaxHP*100)
end
while (true) do
chHP()
if 75 > HP then
print("USED"); inventory:useItem(207969)
yrest(100); chHP(); print("HP = "..HP.."% | 0.1")
yrest(100); chHP(); print("HP = "..HP.."% | 0.2")
yrest(100); chHP(); print("HP = "..HP.."% | 0.3")
yrest(100); chHP(); print("HP = "..HP.."% | 0.4")
yrest(100); chHP(); print("HP = "..HP.."% | 0.5")
yrest(100); chHP(); print("HP = "..HP.."% | 0.6")
yrest(100); chHP(); print("HP = "..HP.."% | 0.7")
yrest(100); chHP(); print("HP = "..HP.."% | 0.8")
end
end
</waypoints>
and result:
Code: Select all
USED
HP = 44.473270552936% | 0.1
HP = 44.473270552936% | 0.2
HP = 44.473270552936% | 0.3
HP = 44.473270552936% | 0.4
HP = 100% | 0.5
HP = 100% | 0.6
HP = 100% | 0.7
HP = 100% | 0.8
Re: Delay with grab HP from client
Posted: Fri Sep 18, 2015 12:18 pm
by rock5
Why not make a loop that waits for the HP to change?
Re: Delay with grab HP from client
Posted: Fri Sep 18, 2015 7:03 pm
by Stionowl1943
This script was only for show example.
In Runes of Magic we have some potions without cooldown and without global cooldown - i can use 10 heal potions in one second for example.
Its reason why i want have instantly reaction. Now it looks like delay about 400ms between client and micromacro with refresh HP.
Example:
Code: Select all
while (true) do
player:update()
HP = (player.HP/player.MaxHP*100)
if 99 > HP then
inventory:useItem(HEAL_POTION)
end
Because of this lag, client use 4 x HEAL_POTION in this 400ms, but one is enough.
I cant add yrest(400) after use, because in this 400ms i can receive dmg and no reaction for this.
Re: Delay with grab HP from client
Posted: Fri Sep 18, 2015 7:14 pm
by lisa
If you are purely trying to test how quickly hp is updated then you would need to alter the test to only have those variables.
If I was to test this I would use a time difference check, use a regenerate skill and print the time difference when the hp changes.
Obviously you would need to have your HP drop lower and have a regenerate skill that only does a small heal as if it tops you to full hp in 2 ticks then you won't get a good result.
Also you don't want to print the results as an ongoing thing because doing prints also do a delay to MM.
So something along these lines.
completely untested.
Code: Select all
function lisa_hptest()
SlashCommand("/script CastSpellByName(\""..GetIdName(490269).."\");") -- priest regen
local start = getTime()
local timestable={}
local lastHP = player.HP
repeat
player:updateHP()
if player.HP ~= lastHP then
table.insert(timestable,deltaTime(getTime(),start))
lastHP = player.HP
end
yrest(10)
until player.HP == player.MaxHP
table.print(timestable)
end
Mind you regenerate has 1sec between each tick, so that won't really test it for you for times below 1 second. hmm
Re: Delay with grab HP from client
Posted: Fri Sep 18, 2015 7:58 pm
by lisa
Ok forget that way to test, go agro yourself a pile of mobs that can hit you, the more you can handle the better, each hit will change HP, then you can run this function, of course a healer would be best suited for this job.
Code: Select all
function lisa_hptest()
local lasttime = getTime()
local timestable={}
local lastHP = player.HP
repeat
player:updateHP()
if player.HP ~= lastHP then
table.insert(timestable,deltaTime(getTime(),lasttime))
lasttime = getTime()
lastHP = player.HP
end
yrest(10)
until player.HP == player.MaxHP
table.print(timestable)
end
You will get prints like this
Command> lisa_hptest()
table: 05335158
1: 0.10798331441826
2: 140.83345841401
Mine were def updated under 400ms, so maybe the item use is what is causing the issue, it uses the item but checks hp again before the item has even been used in game?
Could put a time restraint on reusing the item, so instead of just a hp check add in a time check to be more than 500ms after last use?
Re: Delay with grab HP from client
Posted: Fri Sep 18, 2015 8:17 pm
by lisa
Ok so I took a healer and agroed about 8 high lvl mobs, they were hitting me extremely fast but I was watching my HP on screen and it wasn't adjusting with every hit, seemed to be just under a second but I can't time that accurately from looking but here are my times and they are around 1second each time hp changed, except at the start again it was very fast. So seems to me I started function between hp ticks and so it tells me that MM is getting hp very fast but the game itself only updates every second or so.
Will need to compare to other people's prints to know for sure.
Code: Select all
Command> lisa_hptest()
table: 04FF7350
1: 0.12742031101354
2: 541.16161970652
3: 960.01593833721
4: 1001.0242217373
5: 1000.0847669018
6: 1000.9200178388
7: 980.12135164874
8: 1022.0161780602
9: 1000.0140378309
10: 1000.9842679109
11: 980.08463732184
12: 1020.981697908
13: 1000.0194369966
14: 981.0991405608
15: 1000.0102584149
16: 1020.9611810783
17: 991.01686807355
18: 1012.0741543017
19: 2002.0732796368
20: 1981.1029199768
21: 1020.0201064931
22: 981.00303541097
23: 1019.9391190073
24: 981.11911747397
25: 1019.9974299971
26: 1000.9432342514
27: 980.14078864534
28: 1001.9550379075
29: 1000.078287903
30: 1021.9783839001
31: 2002.0813783854
32: 960.08720732472
33: 1000.9956061589
34: 1000.0550714904
35: 1012.001805481
36: 1011.0180774867
Re: Delay with grab HP from client
Posted: Mon Sep 21, 2015 3:47 am
by lisa
yeah game seems to update HP on a set timer, if you have ever slapped a siege war castle gate in game it only updates HP every 10 seconds.
Re: Delay with grab HP from client
Posted: Mon Sep 21, 2015 12:29 pm
by rock5
One thing to consider is that maybe on the server the hp updates quickly but it's the client that updates at set intervals.
Re: Delay with grab HP from client
Posted: Mon Sep 21, 2015 11:19 pm
by lisa
rock5 wrote:One thing to consider is that maybe on the server the hp updates quickly but it's the client that updates at set intervals.
With the gate scenario it is a long time between updates, might be a special case but the gate might be say 50k HP and with my damage that should be dead in 4-5 seconds but the gate stays that HP for the full 10 seconds and then dies, so in the case of sw gates I think the server/client update at 10 second intervals.
That isn't to say that actual mobs and players update differently to sw gates but with 1 sec intervals it is hard to really tell. There may well be another value in memory that is updated constantly and the value we use is purely blood bar which is only updated every 1 second but to be honest I doubt it.