Autopot delay

07/27/2013 00:41 supermando#1
I've been using a timer of interval 1000 ms to use hp/mp pots when needed. Sometimes I get "Still have time to reuse the item". When I change the delay to a higher value like 1500-2000 ms it works fine.

My question is, how most of the bots/autopots use only 1000 ms delay without getting into issues like this ?

Thanks
07/28/2013 15:00 LastThief*#2
try 1001ms
07/29/2013 02:13 supermando#3
It's not exactly 1000ms, it ranges between 1015-1025 ms depending on execution time of the code before actually sending the packet (error checking and other stuff)
08/02/2013 20:05 kevin_owner#4
They are probably not using 1000ms between each potion but something higher like 1100 ms. You just have to find the sweet spot where you don't receive that error anymore.

Another way of doing it would be to still use 1000 ms and check if you get the error message in a response. If so, send the potion casting packet again till it works.
08/02/2013 22:55 lesderid#5
Quote:
Originally Posted by kevin_owner View Post
They are probably not using 1000ms between each potion but something higher like 1100 ms. You just have to find the sweet spot where you don't receive that error anymore.

Another way of doing it would be to still use 1000 ms and check if you get the error message in a response. If so, send the potion casting packet again till it works.
Depending on your connection to the server, sending it, receiving the error and sending it again might take longer than simply finding the sweet spot (which is indeed probably around 1100 ms) and sending it once. Using potions as soon as possible can be quite crucial to keeping a character alive, so I would go for that solution.
08/03/2013 04:23 supermando#6
Quote:
Originally Posted by lesderid View Post
Depending on your connection to the server, sending it, receiving the error and sending it again might take longer than simply finding the sweet spot (which is indeed probably around 1100 ms) and sending it once. Using potions as soon as possible can be quite crucial to keeping a character alive, so I would go for that solution.
For that reason I believe that timers are not reliable, so I tried doing this:
Code:
bool busy = false;
byte SlotHP; // its value is set by UseHP

private void HandleHPUpdate(Packet packet)
{
	if (CurrentPercentHP <= ConfiguredPercentHP && !busy)
	{
		busy = true; // prevent concurrent operations
		UseHP(); // use potion now
	}
}

private void HandleItemUsed(Packet packet)
{
	if (response != 1) // failed to use item
	{
		// busy is never set back to false
		// because I have no idea which slot
		// it was trying to use
		return;
	}
	if (ItemSlotUsed == SlotHP && busy)
	{
		if (CurrentPercentHP <= ConfiguredPercentHP) // hp is still low
		{
			UseHP(1000); //use potion after 1000ms
		}
		else // hp is higher than configured, stop using potions
		{
			busy = false;
			SlotHP = 255;
		}
	}
}
This works well, until it reaches a point where it tries to use a potion too fast (how is that even possible ?) the server then responds with "Still have time to reuse item" and obviously the flag "busy" is never set back to false, so the whole thing is stuck.
11/12/2013 18:51 Skullsoil#7
hmm seems interesting