SRL Archive - OSR Help

Custom animation check, need some help


Athylus

2014-07-16 17:51:44

Hey all, making a smelter and want to check wether I am animating. Now pixelshift is a bit off, and same for IsAnimating from reflection. So I decided to make my own custom animation check by counting my inventory items. Here is the code:


procedure CheckAnimation;
var
upperbound, lowerbound, number, amount: Integer;

begin
WriteLn(InvCount);
lowerbound := 2;
upperbound := (InvCount);

number := upperbound;

while (number > lowerbound) do
begin
amount := (InvCount);
WriteLn(amount);
Wait(5555);

if ((InvCount) = amount ) then
WriteLn('retrying');
end;

end;
Now I want it to break the loop and use my bars on the furnace again when my InvCount hasn't changed after 10 seconds. Can't quite get it to work, some help would be cool. Alright, edited it a bit and figured it out by myself. But I want to ask how I can improve this. :)

The Mayor

2014-07-16 21:14:35

From: Athylus
Hey all, making a smelter and want to check wether I am animating. Now pixelshift is a bit off, and same for IsAnimating from reflection. So I decided to make my own custom animation check by counting my inventory items. Here is the code:


procedure CheckAnimation;
var
upperbound, lowerbound, number, amount: Integer;

begin
WriteLn(InvCount);
lowerbound := 2;
upperbound := (InvCount);

number := upperbound;

while (number > lowerbound) do
begin
amount := (InvCount);
WriteLn(amount);
Wait(5555);

if ((InvCount) = amount ) then
WriteLn('retrying');
end;

end;
Now I want it to break the loop and use my bars on the furnace again when my InvCount hasn't changed after 10 seconds. Can't quite get it to work, some help would be cool. Alright, edited it a bit and figured it out by myself. But I want to ask how I can improve this. :)



What you can do if have your 'moving' detecting in a boolean function, which results true if you are moving (i.e. invCount is changing).

I assumed you want to break out of the loop if invCount < 2?


function isMoving(maxTime: integer): boolean;
var
t, startCount: integer;
begin
t := getSystemTime + maxWait; // t is currently [10s] from now

startCount := invCount;

while getSystemTime < t do
begin
result := startCount <> invCount; //if invCount changed then we are moving
if result or (invCount = 2) then
break;
end;

end;

procedure workDatFurnaceLikeABoss;
begin

click furnace; //or however you do it

if not isMoving(10000) then
begin
writeLn('Haven''t worked dat furnace like a boss in 10s - clicking it again');
clickFurnace;
end;

end;

Hoodz

2014-07-16 21:15:59

use R_WaitForAnimation :)

Athylus

2014-07-17 08:46:20

I'd rather not use reflection, but thanks hoodz I didn't know that one exist!

Not sure if u did on purpose for antileech mayor, but maxWait should be maxTime at line 5. Other than that, I love you baby. Thanks for the help!

Why does this repeatedly click the furnace? :\

procedure ClickBar;
var
x, y, SteelBarDTM: Integer;

begin
SteelBarDTM := DTMFromString('mggAAAHicY2NgYMhlYmBIA+IcIC4F4hIgzgRiDkYGBi4gZgJiNiDmAWJ+IJ7Y3s7g7+XBUFGQD2ZP7e5isLGwYOAHmoUNM+LAEAAAZigLCw==');

GameTab(24);

if(ActivatedItem = -1) then
if(FindDTM(SteelBarDTM, x, y, MIX1, MIY1, MIX2, MIY2)) then
begin
MMouse(x, y, 3, 3);
Wait(RandomRange(250, 450));
ClickMouse2(Mouse_Left);
Wait(RandomRange(350, 650));
WriteLn('y');
Exit;
end;
end;

procedure FindFurnace;
var
OCTS, H, L, x, y: Integer;
OHueMod, OSatMod: Extended;

TPointsFurnace: TPointArray;
ATPA: T2DPointArray;

begin
OCTS := GetColorToleranceSpeed;
GetColorSpeed2Modifiers(OHueMod, OSatMod);

SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.53, 0.23);

FindColorsTolerance(TPointsFurnace, 3421240, MSX1, MSY1, MSX2, MSY2, 9);
ATPA := TPAtoATPA(TPointsFurnace, 30);

H := High(ATPA);

for L := 0 to H do
begin
if(Length(ATPA[L]) > 400 ) then
begin
if not(IsMoving) then
begin
MiddleTPAEx(ATPA[L], x, y);
MMouse(x, y, 4, 4);
Wait(RandomRange(250, 300));
ClickMouse2(Mouse_Left);
Flag;
Wait(RandomRange(800, 1200));

if(DidRedClick) then //if we clicked the furnace, then let's select option 'make all'
begin
MMouse(249, 401, 3, 3);
Wait(RandomRange(300, 500));
ClickMouse2(mouse_right);
Wait(RandomRange(235, 546));
ChooseOptionMulti(['Make All', 'ake All', 'll']);
repeat
Wait(300);
AntiBan;
FindNormalRandoms;
until(FindBlackChatMessageMulti(['out of steel', 'run out of', 't of']) or SmeltingAnimation(10000));
end;

end else
Flag;
end;
end;

SetColorToleranceSpeed(OCTS);
SetColorSpeed2Modifiers(OHueMod, OSatMod);

end;

Edit, I tried remaking it. And it works now, this is what I have (thought I'd share for the others who might need it!).

procedure ClickFurnace;
var
ATPA: T2DPointArray;
FurnaceTPA: TPointArray;
x, y, I, H, tmpCTS: Integer;
tmpHue, tmpSat: Extended;
FurnaceBox: TBox;

begin
tmpCTS := GetColorToleranceSpeed();
GetColorSpeed2Modifiers(tmpHue, tmpSat);

SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.36);

if FindColorsSpiralTolerance(MSCX, MSCY, FurnaceTPA, 4144963, MSX1, MSY1, MSX2, MSY2, 4) then
begin

SetColorToleranceSpeed(tmpCTS); // reset here and not at bottom, else we cant find IfUpText
SetColorSpeed2Modifiers(tmpHue, tmpSat); // reset here and not at bottom, else we cant find IfUpText

WriteLn('found furnace');
ATPA := SplitTPAEx(FurnaceTPA, 50, 50);
SortATPASize(ATPA, true);
FilterTPAsBetween(ATPA, 1, 1200);
SMART_DebugATPA(true, atpa);
for I := 0 to High(ATPA) do
repeat
WriteLn('moving mouse');
MiddleTPAEx(ATPA[I], x, y);
MMouse(x, y, 3, 3);
Wait(RandomRange(100, 200));
if (IsUpText('melt')) then
begin
WriteLn('y');
ClickMouse2(mouse_left);
//Wait(RandomRange(200, 350)); // deactivated, else it won't detect redclick
if (DidRedClick) then
begin
WriteLn('clicked');
Exit;
end;
end;
until(DidRedClick);
end;

end;