SRL Archive - Help and Support

Help with antigas


The Claw

2007-06-16 00:42:24

Well AntiGas in my script isnt working. This is a section of my mining procedures -

{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=|
| |
| Mining - All the mining procedures. |
| |
|=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}

{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-|
| |
| MineCheck - Checks if mining or not. |
| Thx to wizzup for TimeFromMark things. |
| |
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}

procedure MineCheck; //checks if the user is mining or not, by animation. waits until mined
begin
if GetAnimation > 0 then
begin
Writeln('We are mining the rock');
AntiRandom;
MarkTime(IdleMark);
MarkTime(IdleMark2);
MarkTime(IdleMark3);
MarkTime(IdleMark4);
repeat
Idling;
if GasCheck(x, y) then begin HandleGas; Writeln('gas'); end;
if TimeFromMark(IdleMark3) >= 10 then begin AntiRandom; end;
MarkTime(IdleMark3);
Wait(1);
until GetAnimation = -1;
Writeln('Rock has been mined');
AntiRandom;
Exit;
end;
end;

{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-|
| |
| Better rocks - while mining coal, checks to see if mith |
| or addy have respawned. |
| |
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}

function BetterRocks: Boolean;
begin
MineAddy1 := FindClosestObject(AddyRock1);
MineAddy2 := FindClosestObject(AddyRock2);
MineMith1 := FindClosestObject(MithRock1);
MineMith2 := FindClosestObject(MithRock2);
MineMith3 := FindClosestObject(MithRock3);
MineTotal := MineAddy1 + MineAddy2 + MineMith1 + MineMith2 + MineMith3;
if MineTotal > 0 then
begin
Writeln('Found better rocks, sorry coal but your gonna have to wait');
Result := True;
GetMinimapPos(3144, 3146, x, y);
Mouse(x, y, 2, 2, true);
Flag;
Wait(2000 + random(1000));
end else
Result := False;
end;

{-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-|
| |
| MineAddy - Mines the addy rocks |
| |
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-}

procedure MineAddy;
begin
repeat
if not LoggedIn then Exit;
if InvFull then Exit;
AntiRandom;
GetMinimapPos(3146, 3146, x, y);
Mouse(x, y, 3, 3, true);
Flag;
Wait(3000 + random(1000));
MineAddy1 := FindClosestObject(AddyRock1);
if MineAddy1 > 0 then
begin
Writeln('Addy rock 1 found');
repeat
MSCoordsofUID(MineAddy1, 50, x, y);
Wait(500 + random(100));
MMouse(x, y, 2, 2);
until IsUpText('ine');
Mouse(x, y, 2, 2, true);
Flag;
Wait(2000);
MineCheck;
end;
MineAddy2 := FindClosestObject(AddyRock2);
if MineAddy2 > 0 then
begin
Writeln('Addy rock 2 found. Mining.');
repeat
MSCoordsofUID(MineAddy2, 50, x, y);
Wait(500 + random(100));
MMouse(x, y, 2, 2);
until IsUpText('ine');
Mouse(x, y, 2, 2, true);
Flag;
Wait(2000);
MineCheck;
end;
if InvFull then Exit;
until MineAddy1 or MineAddy2 <= 0;
begin
Status('Addy rocks not found');
end;
end;

As you can see, it calls the procedure MineCheck every time it mines an ore, to see if its still mining, and if it is, wait for it. In there I have my antirandoms, and anti gas. If gas is found at x, y its meant to HandleGas which is this -

procedure HandleGas; //thx Sumillion
var
TempMouseSpeed, GasTime: Integer;
begin
Writeln('OMFG Gas found! Run to the hillz!');
TempMouseSpeed := MouseSpeed;
MouseSpeed := 5;
Mouse(MMCX, MMCY, 5, 5, true);
MarkTime(GasTime);
MouseSpeed := TempMouseSpeed;
while (TimeFromMark(GasTime) < 35000) do
if (Random(20) > 15) then
IdleTime(500, 500, 0.4)
else
Wait(1000);
GasAvoided := GasAvoided + 1;
//ReportVars[3] := ReportVars[3] + 1;
end;

but for some reason, it doesnt do that at all. its going through the waiting thing fine, but it just never finds the gas. Its obviously a problem with this line of code:

if GasCheck(x, y) then begin HandleGas; Writeln('gas'); end;

But i cant tell what it is. Im thinking its something to do with the x, y. In this case, x and y are the co-ords that SCAR has stored the location of the rock into. I think thats what you have to do? but yeh not sure.

help greatly appreciated.

Bobarkinator

2007-06-16 01:59:30

I don't know but just today I couldn't find the gas either *worried* they may have changed it somehow. BTW I was using FindGas.

WhiteShadow

2007-06-16 02:49:18

Did you update the (x, y) coords though?

If you haven't noticed after you click the rock, the rock is no longer in the same position on the mainscreen because you moved towards it. You have to make some sort of FollowCoord kinda thing. :)

The Claw

2007-06-16 04:37:46

Ok thx, I've done what WhiteShadow said and it now finds the rock again after its clicked on it, and i know for sure that the co-ords are correct because i have it move the mouse to it after its been found.

It still doesnt find the gas though, maybe its been changed like bob has said:confused:

Bobarkinator

2007-06-16 10:17:48

Ya I'm pretty sure it has because I was also sure that I had the correct coords because I was using KYAB :redface: and it still didn't pick up the the gas. I spotted it just in time to stop my player from mining it.

@WhiteShadow: You play Unreal Tournament? I used and that game rocked so much! I think I still have the install on my computer.

Wizzup?

2007-06-16 10:26:35

I'm pretty sure the gas hasn't changed. :)

The Claw

2007-06-16 11:06:46

hmm..this is weird then lol. any ideas on how to get it to work wizzup?

Wizzup?

2007-06-16 11:57:26

From: The Claw
hmm..this is weird then lol. any ideas on how to get it to work wizzup?


You can take a look at my mining Funcs in VEM, to get the general idea, I haven't worked with KYAB alot, and I have no clue how it works, so I can't help you on the KYAB side. :)

SKy Scripter

2007-06-16 18:31:10

hmmm havent tested this but maybe it works :)



Function FindFastGas(gx, gy : integer) : boolean;
var
P : TPointArray;
BitMap : Array [1..2] of integer;
i, Ngx, Ngy, cnt : integer;
begin
if (FindColorTolerance(gx, gy, 8296866, gx - 20, gy - 20, gx + 20, gy + 20, 20)) then
begin
FindColorsSpiralTolerance(gx, gy, P, 8296866, gx - 10, gy - 10, gx + 10, gx + 10, 20);
for i := 0 to GetArrayLength(P)-1 do
begin
Ngx := P[i].x;
Ngy := P[i].y;
end;
if (GetArrayLength(P) > 0) then
begin
Ngx := Ngx / GetArrayLength(P);
Ngy := Ngy / GetArrayLength(P);
end else
exit;
for i := 1 to 2 do
begin
Bitmap[i] := BitmapFromString(40, 40, '');
CopyClientToBitmap(Bitmap[i], Ngx - 20, Ngy - 20, Ngx + 20, Ngy + 20);
if i = 2 then break;
Wait(100);
end;
for i := 0 to 40 * 40 do
if (FastGetPixel(Bitmap[1], (i mod 40) + 1, (i div 40) + 1) <> FastGetPixel(Bitmap[2], (i mod 40) + 1, (i div 40) + 1)) then
cnt := cnt + 1;
If (((cnt/1600) * 100) > 10) then
begin
Result := True;
writeln('Found Gas at ' + inttostr(((cnt/1600) * 100))+ '% change');
end;
for i := 1 to 2 do
FreeBitmap(BitMap[i]);
end;
end;

The Claw

2007-06-16 23:16:04

ffs nothings working

would it have anything to do with the fact that the anti gas procedure is above the mining procedure where the co-ords of the rock are defined in? even though the antigas procedure has been called after the co-ords of the rock have been defined.

SKy Scripter

2007-06-16 23:27:04

use a mining procedure that mines the nearest rock but skips the rocks with gas colors thats what helps me, Example:



function ObjPoints(Var P : TPointArray; color, tol: Integer): Boolean;
var
x, y, a, c, i, x1, y1, x2, y2: Integer;
begin
If (Not(FindColorTolerance(x, y, color, 5, 5, 510, 330, tol))) then exit;
Result := True;
SetArrayLength(P, 0);
x1 := 245;
y1 := 165;
x2 := 277;
y2 := 185;
repeat
if (not (Loggedin)) then
Break;
a := a + 1;
if (a = 1) or (a = 3) then
c := c + 1;
for i := 1 to c do
begin
if (a = 1) then
begin
x1 := x1 + 30;
x2 := x2 + 30;
end else
if (a = 2) then
begin
y1 := y1 - 20;
y2 := y2 - 20;
end else
if (a = 3) then
begin
x1 := x1 - 30;
x2 := x2 - 30;
end else
if (a = 4) then
begin
y1 := y1 + 20;
y2 := y2 + 20;
end;
if (x1 = 485) and (x2 = 517) then
x2 := x2 - 2;
if (y1 = 325) and (y2 = 345) then
y2 := y2 - 7;
if (x2 > 515) then
Break;
if (FindColorTolerance(x, y, color, x1, y1, x2, y2, tol)) then
begin
SetArrayLength(P, GetArrayLength(P)+1);
P[GetArrayLength(p)-1].x := x;
P[GetArrayLength(p)-1].y := y;
end;
end;
if (a = 4) then a := 0;
until (x2 > 515);
end;


Function FindOreObj(Var Ox, Oy : Integer; Color, Tol : Integer) : Boolean;
Var
P, T : TPointArray; // By Sky Scripter
i, l, NewColor, mx, my : Integer;
Begin
If (Not(ObjPoints(P, Color, Tol))) Then Exit;
For i := 0 to GetArrayLength(P)-1 do
begin
NewColor := GetColor(P[i].x, P[i].y);
FindColorsSpiralTolerance(P[i].x, P[i].y, T, NewColor, P[i].x - 20, P[i].y - 20,
P[i].x + 20, P[i].y + 20, 40);
For l := 0 to GetArrayLength(T)-1 do
begin
mx := mx + T[l].x;
my := my + T[l].y;
end;
If (GetArrayLength(P)>0) then
begin
mx := mx / GetArrayLength(T);
my := my / GetArrayLength(T);
end;
If (Distance(mx, my, 0, 0) > 5) then
If (Not(FindColorTolerance(ox, oy, 8296866, mx - 20, my - 20, mx + 20, my + 20, 20))) then // gas
begin
MMouse(mx, my, 2, 2);
Wait(100 + Random(112));
If (IsUpTextMulti('Mine', 'ine', 'Min')) then
begin
GetMousePos(ox, oy);
Result := True;
exit;
end;
end;
ox := 0;
oy := 0;
mx := 0;
my := 0;
end;
end;

The Claw

2007-06-16 23:54:20

but the thing is sometimes the gas appears when your halfway through mining the rock which would mess that procedure up (i think). i just found its got nothing to do with what i said a couple of posts up, im thinking its something to do with the height of the rock that im setting it to put the mouse over, using KYAB. down to my last pick now, and its a bronze :(