SRL Archive - OSR Help

Help with my eating procedure :)


jkrules22

2012-03-30 20:53:00

Ok so Im making a eating procedure for my goblin killing script and I cant get it to eat and im not sure waht exactly Im doing wrong…



Procedure EatTuna;
Var
TunaDTM:Integer;
I, x, y:Integer;
Begin;
TunaDTM:= DTMFromString('m6wAAAHic42ZgYHBiYmAwBWJrIHYGYi8gDgBiXyD2gYo5ArElED8Hqn8DxB+B+AMQvwDiZ0D8AIhvIdFPgDjSz4ehNi8HyGIiAhMPGEnASAAAOVwPSA==');
GameTab(tab_Inv);
FindDTM(TunaDTM, x, y, MIX1, MIY1, MIX2, MIY2);
if FindDTM(TunaDTM, x, y, MIX1, MIY1, MIX2, MIY2) Then
Mouse(x ,y, 5, 5, true);
Wait(100);
WriteLn('Eatin Tuna');
End;


ty all for the help in advanced :P

tehq

2012-03-30 20:59:47

try something like this first to test your DTM
var NumbTuna : Integer;

begin
NumbTuna := CountItems('dtm', tunaDTM, []);
WriteLn(NumbTuna);
end;
edit: also, change

From: jkrules22




Mouse(x ,y, 5, 5, true);


to
 Mouse(x, y, 5, 5, mouse_left);

Final edit: You should also use WaitFindDTM instead and delete the first FindDTM. Only use the if … then one

jkrules22

2012-03-30 21:08:25

Ok so I tried that and Im asuming since it said:
0
Successfully executed.
The following DTMs were not freed: [2]

That my dtm is wrong?
And Im not sure what to do with the DTMs were not freed

tehq

2012-03-30 21:11:41

Just add
FreeDTM(TunaDTM);
right before the end; to free the DTM

Try making a new DTM of the tuna and keep using the piece of code i posted until it returns a number. :)

ogustuce

2012-03-30 21:13:32

u dont really need dtm, first: tell it when to eat with hppercent in ur main loop. and try a procedure like this


procedure eat;
var
i:integer ;
begin
repeat
for i := 5 to 9 do // slots in inv it will look for (make it 1 to 28 for full inv)
begin
InvMouse(I, 3);
if IsUpText('una') then //with this, u dont need dtm
begin
ClickMouse2(True);
Wait(RandomRange(500, 1000));
end;
end;
until (HPPercent > 95); //will repeat the process until hp % is above 95%

and in ur main loop, to tell ur script when to eat, do something like this:


if (hppercent < 50) then //this means if hp % is below 50% then begin eat procedure
begin
eat;
end;

hope this helped u =)

putonajonny

2012-03-30 21:13:51

From: jkrules22
Ok so I tried that and Im asuming since it said:
0
Successfully executed.
The following DTMs were not freed: [2]

That my dtm is wrong?
And Im not sure what to do with the DTMs were not freed


This means you need to remake your DTM since it isn't finding it..

jkrules22

2012-03-30 21:37:23

Ok I may sound like a noob but… Ive re-did my DTM like 3 or 4 times now and its still not finding my dtm..Any suggestions? and I know this is getting a little ahead of myself since Im having trouble with my dtm but I also wanted to make it so when i do have a working dtm and it cant finds it, it makes it go though my banking procedure.




Edit: I didnt see ogustuce's post, Ill try doing that then get back to ya.


Edit again: Yay Tyvm that worked!
Now is there a way to make it if theres no tuna in inv. it will run my bank procedure?



Btw my new procedure looks like this:


Procedure EatTuna;
Var
I:Integer;
Begin
GameTab(tab_Inv);
Repeat
for I := 1 to 26 do
Begin
InvMouse(I, 3);
if IsUpText('Tuna') then
Begin
ClickMouse2(True);
Wait(RandomRange(1500, 2000));
End;
End;
until (HPPercent > 90);
End;



My new problem is that it eats like my whole inv..Im not sure what i have wrong in there but i do have it at until (HPPercent > 90), also Can someone explain how I would make it check for food and if no food it starts my banking procedure?

tehq

2012-03-31 07:37:37

I will edit this post later on how to fix it when im on my computer.

E: Smidqe beat me to it :p

Smidqe

2012-03-31 08:10:34

From: jkrules22


Procedure EatTuna;
Var
I:Integer;
Begin
GameTab(tab_Inv);
Repeat
for I := 1 to 26 do
Begin
InvMouse(I, 3);
if IsUpText('Tuna') then
Begin
ClickMouse2(True);
Wait(RandomRange(1500, 2000));
End;
End;
until (HPPercent > 90);
End;



My new problem is that it eats like my whole inv..Im not sure what i have wrong in there but i do have it at until (HPPercent > 90)


Repeat..until loop is unnecessary in that procedure so you can remove that, what I suggest is that you break out of from for to do loop if the HPPercent is over 90 like this:

Procedure EatTuna;
Var
I:Integer;
Begin
GameTab(tab_Inv);
for I := 1 to 26 do
Begin
if (HPPercent > 90) then
break;
InvMouse(I, 3);
if IsUpText('Tuna') then
Begin
ClickMouse2(True);
Wait(RandomRange(1500, 2000));
End;
End;
End;
What it does it first checks the HPPercent and if it's lower than 90 percent then it'll click the tuna, if percentage is > 90 then it'll break from the loop.

jkrules22

2012-03-31 18:04:34

Thanks