PDA

View Full Version : GE Stuff



Element17
05-10-2014, 03:31 PM
Hello I will update this as I write more GE functions witch allow the user to interact with the GE




//****************************
// Checks to see if the GE is open by the red color in the top left
//****************************

function GEOpen: boolean;
var
x, y, t: integer;
begin
t := getSystemTime + randomRange(5000, 8000);
while getSystemTime < t do
begin
if (findColorTolerance(x, y, 1316676, 39, 36, 193, 61, 5)) then
writeLn('GE is open');
result:= true;
exit;
end else
writeLn('Our color was not detected, pick new colors');
TerminateScript;

end;

//*********************************
// Clicks one open buy box in GE
//*********************************

procedure buyGE();
begin
if (not(GEOpen)) then
writeLn('GE is not open');
exit;
if GEOpen then
begin
mouse(102, 169, 15, 15, MOUSE_LEFT); //first buy box
// (259, 170) second buy box
// (158, 166) first sell box
// (319, 169) second sell box
end;
end;

I however get GE is open every time when I run just 'buyGE' anyone know why? Feel free to post other functions and fix these or whatever. I just didn't see them in the include.

rj
05-10-2014, 04:09 PM
Just a tip, why would you want to terminate the script if the GE isn't open -.-

Also in lape you can do


exit(true);


As opposed to


result := true;
exit;

Ian
05-10-2014, 04:12 PM
if (not(GEOpen)) then
writeLn('GE is not open');
exit;


should be


if (not(GEOpen)) then
begin
writeLn('GE is not open');
exit;
end;


or else only the writeLn will run.

same thing for


if (findColorTolerance(x, y, 1316676, 39, 36, 193, 61, 5)) then
writeLn('GE is open');
result:= true;
exit;


should be


if (findColorTolerance(x, y, 1316676, 39, 36, 193, 61, 5)) then
begin
writeLn('GE is open');
result:= true;
exit;
end;

masterBB
05-10-2014, 04:13 PM
fix'd, though I wonder if terminatescript is really what you want to do.

function GEOpen: boolean;
var
x, y, t: integer;
begin
t := getSystemTime + randomRange(5000, 8000);
while getSystemTime < t do
begin
if (findColorTolerance(x, y, 1316676, 39, 36, 193, 61, 5)) then
begin
writeLn('GE is open');
result:= true;
exit;
end;
end;

writeLn('Our color was not detected, pick new colors');
TerminateScript;
end;

e:
In other news, BMWxi is banned for ninja-ing me.

The Mayor
05-10-2014, 06:29 PM
You may find this useful. I started writing some stuff about a year ago but never finished it. I hope this pastes as I'm on phone


program new;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}

const
PLUS_FIVE = 0;
MID_PRICE = 1;
MINUS_FIVE = 2;


procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := ''; { Your username }
password := ''; { Your password }
isActive := true;
world := -1;
end
currentPlayer := 0;
end;

var

{ Offers screen }
bounds: Tbox := intToBox(36,30,539,358);
packBounds: Tbox := intToBox(544,62,741,330);
offerBoxes: TboxArray := grid(3, 2, 149, 109, 156, 120, point(131, 153));
buyBoxes : TboxArray := grid(3, 2, 44, 44, 156, 120, point(101, 163));
sellBoxes: TboxArray := grid(3, 2, 44, 44, 156, 120, point(161, 163));
backPackBoxes: TboxArray := grid(4, 7, 37, 32, 47, 38, point(572, 86));

{ Buying and selling screens }
quantityBoxes: TboxArray := grid(5, 1, 34, 24, 41, 0, point(101, 243));
priceBoxes: TboxArray := [intToBox(301, 231, 335, 255), intToBox(357, 231, 391, 255), intToBox(398, 231, 432, 255), intToBox(454, 231, 488, 255)];
backBox: Tbox := intToBox(67,317,86,323);
confirmBox: Tbox := intToBox(215,316,360,336);
searchBox: Tbox := intToBox(141,121,175,152);

{ In progress screen }
abortBox: Tbox := intToBox(387, 304, 396, 317);
collectBoxes : TboxArray := grid(2, 1, 36, 32, 49, 0, point(454, 327));


function isOpen(waitTime: integer = 0): boolean;
var
t: integer;
begin
t := getSystemTime() + waitTime;

while getSystemTime() < t do
if (getColor(bounds.x1 + 35, bounds.y1 + 12) = 379903) then
exit(true);
end;

function __isOfferOpen(waitTime: integer = 0): boolean;
var
t: integer;
begin
t := getSystemTime() + waitTime;

while getSystemTime() < t do
if (countColorTolerance(9160169, confirmBox, 100) > 40) then
exit(true);
end;

function __isProgressOpen(waitTime: integer = 0): boolean;
var
t: integer;
begin
t := getSystemTime() + waitTime;

while getSystemTime() < t do
if (getColor(222, 98) = 61385) or (getColor(480, 95) = 45055) then
exit(true);
end;

function close(): boolean;
var
t: integer;
begin
if not isOpen() then
exit(true);

mouseBox(intToBox(528, 37, 535, 44), MOUSE_LEFT);
t := getSystemTime() + randomRange(4000, 5000);
repeat
wait(10);
if not isOpen() then
exit(true);
until (getSystemTime() > t);

end;

function isEmpty(geSlot: integer): boolean;
var
x, y: integer;
begin
result := (findColorTolerance(x, y, 247475, buyBoxes[geSlot - 1], 3) and
findColorTolerance(x, y, 223686, sellBoxes[geSlot - 1], 3));

if result then writeLn('Slot ' + toStr(geSlot) + ' is Empty');
end;

function isBuying(geSlot: integer): boolean;
begin
result := getColor(offerBoxes[geSlot - 1].x1 + 62,offerBoxes[geSlot - 1].y1 + 5) = 379903;

if result then writeLn('Slot ' + toStr(geSlot) + ' is Buying');
end;

function isSelling(geSlot: integer): boolean;
begin
result := ((not isEmpty(geSlot)) and (not isBuying(geSlot)));

if result then writeLn('Slot ' + toStr(geSlot) + ' is Selling');
end;

function isCompleted(geSlot: integer): boolean;
begin
result := (countColorTolerance(1799224, offerBoxes[geSlot - 1], 16) > 1500);
end;

function isAborted(geSlot: integer): boolean;
begin
result := (countColorTolerance(983163, offerBoxes[geSlot - 1], 16) > 1500);
end;

procedure enterAmount(amount: integer);
var
i, ii: integer;
amounts: array[0..3] of extended;
begin

if amount > 10000 then
begin
mouseBox(quantityBoxes[4], MOUSE_LEFT);
if conversationBox.isOpen(1500) then
typeSend(intToStr(amount), true);
end;

amounts[3] := floor(amount / 1000);
amounts[2] := floor(frac(amount / 1000) * 10);
amounts[1] := floor(frac(amount / 100) * 10);
amounts[0] := round(frac(amount / 10) * 10);

for i := 0 to high(amounts) do
begin
ii := 0;
while ii < amounts[i] do
begin
mouseBox(quantityBoxes[i], MOUSE_LEFT);
writeLn('Pressed button ' + toStr(i));
wait(randomRange(250,500));
inc(ii);
end;
end;

end;

{ priceBoxes[0..4]
{ -5%, MID, custom, +5% }
function enterPrice(amount: integer): boolean;
begin
case amount of
0: mouseBox(priceBoxes[0], MOUSE_LEFT);
1:
2: mouseBox(priceBoxes[3], MOUSE_LEFT);
end else

// custom amount

mouseBox(priceBoxes[2]

begin

end;

end;



function sell(packSlot, price, amount: integer): boolean;
var
i, nextSlot: integer;
begin
if not isOpen(1000) then
begin
print('function sell(): Cannot sell item as the GE isn''t open');
exit(false);
end;

for i := 1 to 6 do
if isEmpty(i) then
begin
nextSlot := i;
break;
end else
if i = 6 then
begin
writeLn('function sell(): Cannot sell item as there are no empty offer slots');
exit(false);
end;

if isItemIn(backPackBoxes[packSlot - 1]) then
mouseBox(backPackBoxes[packSlot - 1], MOUSE_LEFT)
else
begin
writeLn('function sell(): No item in pack slot: ' + intToStr(packSlot));
exit(false);
end;

if __isOfferOpen(3000) then
begin
enterAmount(amount);
enterPrice(price);
mouseBox(confirmBox, MOUSE_LEFT);
end;

result:= isSelling(nextSlot);
end;


function buy(item: string; amount, price: integer): boolean;
var
i, nextSlot: integer;
begin
if not isOpen() then
begin
print(' function buy(); The GE isnt open');
exit(false);
end;

for i := 1 to 6 do
if isEmpty(i) then
begin
nextSlot := i;
break;
end else
if i = 6 then
begin
writeLn('function buy(): Cannot buy item as there are no empty offer slots');
exit(false);
end;

mouseBox(buyBoxes[i - 1], MOUSE_LEFT);

if __isOfferOpen(3000) then
begin
mouseBox(searchBox, MOUSE_LEFT);
if conversationBox.isOpen(3000) then
begin
typeSend(item, false);
wait(randomRange(750, 1250));
mouseBox(intToBox(0, 10, 50, 20), MOUSE_LEFT); // click item

if not conversationBox.isOpen(3000) then
begin
enterAmount(amount);
enterPrice(price);
mouseBox(confirmBox, MOUSE_LEFT);
end;

result := isBuying(i);
end;
end;
end;

function abort(geSlot: integer): boolean;
begin
if isEmpty(geSlot) then
begin
writeLn('function abort(): Cannot abort as offer slot ' + toStr(geSlot) + ' is empty');
exit(false);
end;

if isAborted(geSlot) then
begin
writeLn('function abort(): Cannot abort as offer slot ' + toStr(geSlot) + ' is already aborted');
exit(false);
end;

if isCompleted(geSlot) then
begin
writeLn('function abort(): Cannot abort as offer slot ' + toStr(geSlot) + ' is already completed');
exit(false);
end;

mouseBox(offerBoxes[geSlot - 1], MOUSE_LEFT);

if __isProgressOpen(3000) then
begin
mouseBox(abortBox, MOUSE_LEFT);
wait(randomRange(500, 1250));
mouseBox(backBox, MOUSE_LEFT);
wait(randomRange(500, 1250));
result := isAborted(geSlot);
end;

if result then writeLn('Offer successfully aborted');
end;

function collect(geSlot: integer): boolean;
var
b, i, x, y: integer;
begin

if isEmpty(geSlot) then
begin
writeLn('function collect(): Cannot collect as offer slot ' + toStr(geSlot) + ' is empty');
exit(false);
end;

mouseBox(offerBoxes[GEslot - 1], MOUSE_LEFT);

if not __isProgressOpen(3000) then
exit;

for i := 0 to 1 do
if findColor(x, y, 65536, collectBoxes[i]) then
inc(b);

if b < 1 then
begin
writeLn('function collect(): Cannot collect as offer slot ' + toStr(GESlot) + ' collect boxes are empty');
mouseBox(backBox, MOUSE_LEFT);
exit(false);
end;

for i := 0 to b - 1 do
begin
mouseBox(collectBoxes[i], MOUSE_LEFT);
result := not __isProgressOpen(3000);
end;

end;

procedure drawBoxes();
begin
{ Offers screen }
{ smartImage.drawBox(bounds, false, clRed);
smartImage.drawBox(packbounds, false, clRed);
smartImage.drawBoxes(offerBoxes, false, clYellow);
smartImage.drawBoxes(buyBoxes, false, clRed);
smartImage.drawBoxes(sellBoxes, false, clBlue);
smartImage.drawBoxes(backPackBoxes, false, clGreen); }

{ Buying and selling screens }
{ smartImage.drawBox(searchBox, false, clRed);
smartImage.drawBox(confirmBox, false, clBlue);
smartImage.drawBoxes(quantityBoxes, false, clGreen);
smartImage.drawBoxes(priceBoxes, false, clGreen);}
smartImage.drawBox(backBox, false, clRed);

{ In progress screen }
smartImage.drawBox(abortBox, false, clBlue);
smartImage.drawBoxes(collectBoxes, false, clGreen);
end;




var
i: integer;
begin

clearDebug();
smartEnableDrawing := true;
disableSRLDebug := false;
smartPlugins := ['OpenGL32.dll','d3d9.dll'];
setupSRL();
declarePlayers();

players[currentPlayer].login();

drawBoxes();



for i:= 1 to 6 do
begin
//collect(i);
end;



end.

Element17
05-11-2014, 01:58 PM
Thanks for the input guys and I only had terminate in there because I was testing the functions. That looks really nice!