SRL Archive - OSR Help

Finding the next rock


ownedlikenoob

2010-07-07 22:08:05


if(FindObjCustom(X, Y, ['Mine','ne Ro','e Roc','Rocks'], [Rune,Rune2,Rune3], 3)) then
case (Random(2)) of
1: Begin
WriteLn('Found Rock, Mining');
I:=0
Mouse(x,y,5,2,False);
wait(100+random(200));
ChooseOption('Mine');
Repeat
Wait(300+random(200));
Until(Not(FindObjCustom(X, Y, ['Mine','ne Ro','e Roc','Rocks'], [Rune,Rune2,Rune3], 3)));
end;

Ok, So basically it finds the color, Clicks it then it waits 300 - 500 miliseconds until the color of the rock is gone, (meaning it has been mined.) The only thing is, that there are two rocks there, and if they are both there it clicks on one and waits untill it is gone and then it ends up just waiting forever because it still sees the color of the second rock…

I'm trying to think of a way to fix this, But i'm drawing a blank right now… Any ideas?

YoHoJo

2010-07-08 00:13:30

Do what my miner does.
Either

1) Wait until the inventory count has risen (Meaning you obtained the ore, so you can go on)
OR
2) Set a time limit of how long at most it should take to mine thee rock ex:30 seconds. After 30 seconds are up, just make it search for another rock again.

I suggest you take a look at my PMS Power Miner script and see how I did it.
Of course those aren't the only ways and people will suggest other ideas too.

ownedlikenoob

2010-07-08 00:24:48

From: YoHoJo
Do what my miner does.
Either

1) Wait until the inventory count has risen (Meaning you obtained the ore, so you can go on)
OR
2) Set a time limit of how long at most it should take to mine thee rock ex:30 seconds. After 30 seconds are up, just make it search for another rock again.

I suggest you take a look at my PMS Power Miner script and see how I did it.
Of course those aren't the only ways and people will suggest other ideas too.


I like the first suggestion, Just how would I get the script to know it just got something in the inventory? i see in your script you did a plusone variable. But I can't fully decipher your script :p much too advance for me haha.

YoHoJo

2010-07-08 00:25:51

If you could please post the code from my script (I'm lazy I know) where I did all of that stuff I can explain it to you.
(I'll edit this message with the answer after you post it, I'm really close to 5000 posts and don't want to make too many right now :] )

Read under this post, frement simplified it.
Just do an inventory count before clicking the rock, and store it as a variable ( I called mine PlusOne).
The just click the rock, and repeat some antirandoms/antiban/whatever and make that loop stop when your inventory count is > PlusOne)


Sorry very confusing, I blow.
Simpler:

1) Sore your current inventory count and call it BeforeMine (or whatever you want). Then click rock, and loop antiban/antirandom/whatever you want/ and continually check to see when your inventory count is > BeforeMine. Then you stop the loop

OR

1) Sore your current inventory count + 1 and call it PlusOne(or whatever you want). Then click rock, and loop antiban/antirandom/whatever you want/ and continually check to see when your inventory count is => PlusOne. Then you stop the loop

Both pretty much do the same thing. First one is better I guess.

Frement

2010-07-08 00:27:22

LastCount := InvCount; //this before you start mining
if (LastCount < InvCount) then begin
Result := True;
end;

ownedlikenoob

2010-07-08 00:29:27

From: YoHoJo
If you could please post the code from my script (I'm lazy I know) where I did all of that stuff I can explain it to you.
(I'll edit this message with the answer after you post it, I'm really close to 5000 posts and don't want to make too many right now :] )




{*******************************************************************************
Function MineRock(WutRock:Integer):Boolean;
By: YoHoJo
Description: Mines rock, uses ATPAs, waits until ore recieved or timer reached
*******************************************************************************}
Function MineRock(WutRock:Integer):Boolean;
var I,PlusOne,tMine:Integer;
RockInFoI: TIntegerArray;
RockInFoE: TExtendedArray;
RockPts:TPointArray;
RockPtsBox: T2DPointArray;
RockPt: TPoint;
HighRock:Integer;
Begin
If Not(LoggedIn) Then Exit;
StatsGuise('Searching For Rock: '+ IntToStr(InvCount));
If OreInLast Then Exit;
Case WutRock of
1: Begin RockInFoE:=[0.01 , 2.25]; RockInFoI:=[3701475, 10]; End;
2: Begin RockInFoE:=[0.03 , 0.09]; RockInFoI:=[4088717, 9]; End;
3: Begin RockInFoE:=[0.19, 0.13]; RockInFoI:=[9013905, 11]; End;
4: Begin RockInFoE:=[0.13 , 0.18]; RockInFoI:=[2567749, 6]; End;
End;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(RockInFoE[0],RockInFoE[1]);
FindColorsSpiralTolerance(MSCX,MSCY,RockPts,RockInfoI[0],MSX1,MSY1,MSX2,MSY2,RockInfoI[1]);
SetColorSpeed2Modifiers(0.2,0.2);
ColorToleranceSpeed(1);
RockPtsBox:= TPAtoATPAEx(RockPts,20,20);
//SortTPAFrom(RockPts, Point(MSCX, MSCY));
SortATPAFrom(RockPtsBox,Point(MSCX,MSCY));
HighRock:=High(RockPtsBox);
For I:=0 To HighRock Do
Begin
If Not(LoggedIn) Then Break;
If GetArrayLength(RockPtsBox[I])>10 Then
Begin
If YDebug Then DebugATPA(RockPtsBox,'');
RockPt:= MiddleTPA(RockPtsBox[I]);
If CheckAndClick(RockPt.x,RockPt.y) Then
Begin
Result:=True;
MarkTime(tMine);
StatsGuise('Mining Rock: '+ IntToStr(InvCount));
Players[CurrentPlayer].Loc:='Mining';
PlusOne:=InvCount+1;
Repeat
If Not(LoggedIn) Then Break;
Wait(200);
If Random(2) = 0 Then
Begin
RT:=GetSystemTime;
If FindNormalRandoms Then
IncEx(WeMined,GetSystemTime - RT);
End;
If Random(50)=1 Then SleepAndMoveMouse(500+Random(100));
//If (Not(IsMoving)) Then Begin Writeln('a'); Break; End;
Until (InvCount = PlusOne) Or (TimeFromMark(tMine) > ((Players[CurrentPlayer].Integers[2]*1000) + Random(500)));
Exit;
End;
End;
Wait(250+Random(100));
End;
End;

ownedlikenoob

2010-07-08 12:19:10

Thanks to both of you :) I got it working now.