Page 3 of 9

Re: optimizing golden eggs profit

Posted: Thu Dec 23, 2010 7:00 pm
by Alkaiser
fobsauce wrote:I'm also trying to figure out how to teleport on top the of chickens that still need to be fed so you don't have to walk up to them to harvest them. If anyone knows a solution, let me know.
I made a minor change to the target_object function to enable teleporting if target is within 128 units.

Change this:

Code: Select all

				if( distance(self.X, self.Z, obj.X, obj.Z) > 39 ) then
					self:moveInRange(CWaypoint(obj.X, obj.Z), 39, true);
				end
to this:

Code: Select all

				if( distance(self.X, self.Z, obj.X, obj.Z) > 128 ) then
					self:moveInRange(CWaypoint(obj.X, obj.Z), 128, true);
				elseif( distance(self.X, self.Z, obj.X, obj.Z) > 39 ) then
					local offsets = {0x598, 0x4, 0xB0}
					memoryWriteFloatPtr(getProc(), 0x9B8364, offsets, obj.X) -- x value
					offsets = {0x598, 0x4, 0xB8}
					memoryWriteFloatPtr(getProc(), 0x9B8364, offsets, obj.Z) -- z value
				end
It works!

Re: optimizing golden eggs profit

Posted: Thu Dec 23, 2010 11:17 pm
by jduartedj
Really nice,
I still got to test it myself but the feedback is great!

Re: optimizing golden eggs profit

Posted: Fri Dec 24, 2010 1:06 am
by rock5
Even though I probably wont use it, what I like about it is it doesn't teleport to the waypoint but directly to the object. Cool. :)

Re: optimizing golden eggs profit

Posted: Fri Dec 24, 2010 1:19 am
by jduartedj
I decided not to use that specific target_object mod because The "rubber badn" effect has fdifferent limitation in different places, instead I'm only Modding the golden eggs script so its teleports everywhere. I'm almost done Will post it here after!
I also Have a new addon many of you might like.

Re: optimizing golden eggs profit

Posted: Fri Dec 24, 2010 2:26 am
by jduartedj
Ok I've modded the file so far but I'm stuck and can't implement something.
Anyway Here are the files (attached) one is the modded golden eggs file, the other is a teleport addon created by me. This addon is required to run the modded golden eggs file.

Also the code I can't implement properly is:

Code: Select all

			while inventory:itemTotalCount(204789) > 0 and 	player:findNearestNameOrId(112955,feedHenEvalFunc) do
				target = player:getTarget(player:findNearestNameOrId(112955));
				if distance(player.X,player.Z,target.X,target.Z)>10 and feedHenEvalFunc(target.Address) then 
					teleport(target.X,target.Z); --teleport
				end
				player:target_Object(112955,4500,false,true,feedHenEvalFunc) -- Feed Hens
			end
What I wanted to do was for the hen to be targeted before actually feeding it and if the hen is not close to you one would teleport to it and then feed it!

help would be appreciated.
The script works at the moment but doesn't use teleport to feed hens only to go collect feed and to go encourage hens and back from those too ofc.

Re: optimizing golden eggs profit

Posted: Fri Dec 24, 2010 6:47 pm
by jduartedj
I'm gonna need some feedback and further debugging on these scripts, I found it may happen that they get stuck in a chicken and simply don't proceed. Don't know why though... I've set the time in target_object instead of waiting for castbar...

The teleport addon should be ok.

Re: optimizing golden eggs profit

Posted: Sat Dec 25, 2010 8:02 am
by nokirk
love it, it's so cool :) Thx a lot

Re: optimizing golden eggs profit

Posted: Sat Dec 25, 2010 9:18 am
by MinMax
Great idea with the teleport. I tested the egg script.
I have only with the looting of the eggs some problems. Often the char teleports before he has picked up all 3 eggs.

Re: optimizing golden eggs profit

Posted: Sun Dec 26, 2010 10:19 am
by jduartedj
before? is it always on the 3rd? if it is try setting the waittime to 1750 or 2000. I use 1500 because it works 4 me.

any1 getting the bot stuck at collecting eggs?

Re: optimizing golden eggs profit

Posted: Mon Dec 27, 2010 6:09 am
by MinMax
Addendum:
I testet the script with three opened acc´s on my pc. Therefore i need a delay for 1900.
If there´s only one account open, your waittime of 1500 works perfect.

Re: optimizing golden eggs profit

Posted: Mon Dec 27, 2010 9:10 am
by jduartedj
MinMax wrote:Addendum:
I testet the script with three opened acc´s on my pc. Therefore i need a delay for 1900.
If there´s only one account open, your waittime of 1500 works perfect.
mmm I see, I n ow wonder if there is anyway to see how many bots are running? I could auto configure that using an inv. proportional function that increases the time with the number of bots open. I think it's doable.

Code: Select all

waittime_delta = 500/(1.5*n)
this seems to do it, taking n as the number of bots running. so we call target_Object(id,waittime-waittime_delta, ....
this waittime delta gives us a small gain in time but it's exactly what this thread is about, optimizing.

Re: optimizing golden eggs profit

Posted: Mon Dec 27, 2010 9:27 am
by rock5
jduartedj wrote:Also the code I can't implement properly is:

Code: Select all

			while inventory:itemTotalCount(204789) > 0 and 	player:findNearestNameOrId(112955,feedHenEvalFunc) do
				target = player:getTarget(player:findNearestNameOrId(112955));
				if distance(player.X,player.Z,target.X,target.Z)>10 and feedHenEvalFunc(target.Address) then 
					teleport(target.X,target.Z); --teleport
				end
				player:target_Object(112955,4500,false,true,feedHenEvalFunc) -- Feed Hens
			end
I noticed that when you find the hen to feed you use the 'feedHenEvalFunc' but then when you target it, you don't. That could cause problems.
jduartedj wrote:mmm I see, I n ow wonder if there is anyway to see how many bots are running? I could auto configure that using an inv. proportional function that increases the time with the number of bots open. I think it's doable.
That's assuming all PC's perform the same, isn't it? Anyway, I'm confused. player:target_Object has a default wait of 1000ms. I've never had problems collecting eggs with that regardless of the number of clients open. Are you saying that if you use a 'nil' waittime it fails to collect the last egg? Maybe there's something else causing it to fail.

Re: optimizing golden eggs profit

Posted: Mon Dec 27, 2010 9:58 am
by jduartedj
not at all rock5, When using nil it waits until the cast bar is over, but using a certain waittime delta we can decrease that time. p/e: of encouraging a chicken is a result of a cast bar time of 2000ms, It can be set to 1500 that it works too, assuming you have an avg. computer and almost no lag. in this case i'm using waittime_delta = 500.
using the formula would be 333. And like you said I'm assuming all computers are the same but I'm giving it a low rank for all computers because waittime_delta = 500/n works, but i made it waittimedelta = 500/(1.5*n) to be safe, ie, results in lower waittime_delta.

Re: optimizing golden eggs profit

Posted: Mon Dec 27, 2010 11:42 am
by rock5
jduartedj wrote:not at all rock5, When using nil it waits until the cast bar is over, but using a certain waittime delta we can decrease that time.
To tell you the truth, I'm not sure what you mean by delta, but if a castbar appears it will wait until its gone. In that case, a waittime can only be used to extend that time, ie. if a castbar appears for 2000ms then setting the waittime to 1500ms will result in it still waiting for 2000ms. If you set the waittime to 2500ms, then it will wait 2500ms.
jduartedj wrote: p/e: of encouraging a chicken is a result of a cast bar time of 2000ms, It can be set to 1500 that it works too, assuming you have an avg. computer and almost no lag. in this case i'm using waittime_delta = 500.
using the formula would be 333. And like you said I'm assuming all computers are the same but I'm giving it a low rank for all computers because waittime_delta = 500/n works, but i made it waittimedelta = 500/(1.5*n) to be safe, ie, results in lower waittime_delta.
I thought we were talking about eggs. Encouraging the chickens is another matter, it's a special case. Even though the castbar appears for only 2000ms or whatever it is, it's a few more seconds before you can click the next hen, which should give you plenty of time to collect the eggs so I'm not sure what you are trying to accomplish by trying to reduce the waittime. Actually by my calculations your example checks if the hen can be encouraged every 2000ms whereas my script checks every 1500ms.

Re: optimizing golden eggs profit

Posted: Mon Dec 27, 2010 12:53 pm
by jduartedj
What I mean by delta is:

While the cast bar disappears and the bot starts doing something else.
lets say the bot encourages the chicken and then collects it's egg. While the cast bar is on until it is finished and moving to the next step, it takes roughly 2000ms, whereas if you make the time 1500 manually it'll start doing the next task, collecting the egg right away, delta is this diff between the 2000 and the 1500.

But what ur sayin is makeing more sense, I though the cst bar would actually take 2000 ms, but you say it takes 1500 so I think it indeed takes 1500 but the lag/performance/etc makes the value to be bigger.

Anyway does your castbar check take any romscript or aything that takes >500ms to check when you set waittime to nil instead of putting a manual time? Because i think that my "delta" comes from that.

Re: optimizing golden eggs profit

Posted: Mon Dec 27, 2010 12:57 pm
by jduartedj
In another note With the teleport hack I'm getting some bugs like unclickable chickens/eggs and this make the bot get stuck. Any1 else getting this?
EDIT: this first issue was fixed after I made the bot go collect some more feed for that specific chicken.

also sometimes i get a bug in which the object is clickable but the bot just stands there and does nothing as if it couldn't click the chicken, thus also sticking the bot. any ideas on what causes this?
EDIT: sometimes this second issue is automatically fixed when I take the minimized window into focus (restored).

Re: optimizing golden eggs profit

Posted: Mon Dec 27, 2010 9:57 pm
by rock5
jduartedj wrote:What I mean by delta is:

While the cast bar disappears and the bot starts doing something else.
lets say the bot encourages the chicken and then collects it's egg. While the cast bar is on until it is finished and moving to the next step, it takes roughly 2000ms, whereas if you make the time 1500 manually it'll start doing the next task, collecting the egg right away, delta is this diff between the 2000 and the 1500.
So you are saying that by setting the waittime to 1500ms you reduced the time by 500ms? That shouldn't happen because either way target_Object will wait until the castingbar disappears then continue. Are you 100% sure that it reduces the time?
jduartedj wrote:But what ur sayin is makeing more sense, I though the cst bar would actually take 2000 ms, but you say it takes 1500 so I think it indeed takes 1500 but the lag/performance/etc makes the value to be bigger.
No what I was saying was, after it's clicked the hen and collected the first egg, that's how often it checks to see if the next hen is clickable. The way it should work is it should click the first hen, then immediately after the castingbar disappears, collect the first egg. Then it loops 1500ms in the 'while' loop until it can click the next hen. Optimizing the waittime is not really possible as, when I was testing it, I found the time before the next hen is clickable was variable.
jduartedj wrote:Anyway does your castbar check take any romscript or aything that takes >500ms to check when you set waittime to nil instead of putting a manual time? Because i think that my "delta" comes from that.
There are no RoMScript commands in player:target_Object besides the 'UseSkill(1,1)' commands. Actually, if you are looking for delays, if there is a waittime and the castingbar doesn't appear(like what happens with the coop hens), it will try the RoMScript("UseSkill(,1,1)") command again. So having a waittime will cause an extra RoMScript on the second and third hens.

Re: optimizing golden eggs profit

Posted: Tue Dec 28, 2010 9:13 am
by jduartedj
Interesting, you just turned all my beliefs upside down! thankfully! I will have to do a bit of research on that. I understand now.

What is worrying me the most is the pause it makes, as sometimes when it's targeting hens it pauses a while before targeting. sometimes that pause is long and makes the bot get stuck. I'll have a closer look at target_Object function.

Re: optimizing golden eggs profit

Posted: Tue Dec 28, 2010 10:37 am
by jduartedj
On a related note, rock5, if I set the feedbag waittime to nill it doesn't get the bag! it stops at 2000 ms aprox. and tries again. Any thoughts on this? I have to set it to 4000-4500.
But the eggs work fine with nil.

Re: optimizing golden eggs profit

Posted: Tue Dec 28, 2010 10:51 am
by jduartedj
Just a quick update using nill while collecting eggs is proven to be better so:
[attachement removed]
refer to the 1st post for the updated script

Updated the Addon repo.