Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {.include projectSW [1.00]\library\projectSW.scar}
- const
- stopFKey = 12;
- continueFKey = 11;
- pauseFKey = 10;
- playerName = 'Gawanaka';
- var
- dtmTree, dtmTrader, PDMark, dtmAxe: Integer;
- nameBox: TBox;
- storedColors: TIntegerArray;
- procedure walkTo(spot: string); forward;
- procedure handleFKeys;
- begin
- if(IsFKeyDown(PauseFKey))then
- begin
- if(TimeFromTimeMark(PDMark) <= 12000)then
- PlaySound(ScriptPath + 'empty.wav');
- while (not(IsFKeyDown(continueFKey)))and(not(IsFKeyDown(stopFKey))) do
- Wait(1);
- end;
- if(IsFKeyDown(StopFKey))then
- TerminateScript;
- end;
- function PlayerDetected: Boolean;
- var
- i, h: Integer;
- TBA: TBooleanArray;
- begin
- TBA:= [ChatboxDetection('', '', 'public', False, False),
- ScreenDetection(nameBox)];
- h:= High(TBA);
- for i:= 0 to h do
- if(not(Result))then
- Result:= TBA[i];
- SetArrayLength(TBA, 0);
- end;
- procedure PDWait(Time: Integer);
- var
- mark: Integer;
- begin
- MarkTime(mark);
- repeat
- Wait(1);
- handleFKeys;
- if(PlayerDetected)then
- if(TimeFromTimeMark(PDMark) >= 12000)then
- begin
- PlaySound(ScriptPath + 'siren.wav');
- MarkTime(PDMark);
- end;
- until(TimeFromTimeMark(mark) >= Time);
- end;
- function playerHasMoved: Boolean;
- var
- i, h: Integer;
- tempColors: TIntegerArray;
- begin
- tempColors:= GetColors(getPoints(mmBox));
- h:= High(tempColors);
- if(h = High(storedColors))then
- for i:= 0 to h do
- if(not(Result))then
- Result:= (tempColors[i] <> storedColors[i])
- else
- Break;
- if((not(Result))and(High(storedColors) = h))then
- Exit;
- SetArrayLength(storedColors, 0);
- SetArrayLength(storedColors, (h + 1));
- for i:= 0 to h do
- storedColors[i]:= tempColors[i];
- SetArrayLength(tempColors, 0);
- end;
- function AxeInBag: Boolean;
- var
- tmpBx: TBox;
- begin
- tmpBx:= GetBagSlot(29);
- with tmpBx do
- Result:= (GetColor((x1 + 4), (y1 + 8)) = 15922678);
- end;
- function BagOpen: Boolean;
- begin
- Result:= (GetColor(236, 27) = 15195854);
- end;
- function BagFull: Boolean;
- begin
- Result:= (GetColor(527, 380) = 9027283);
- end;
- function FindAxe: Integer;
- var
- i: Integer;
- TIA: TIntegerArray;
- begin
- Result:= -1;
- TIA:= [485, 520, 555];
- for i:= 0 to 2 do
- if(GetColor(TIA[i], 369) = 15922678)then
- Result:= i;
- SetArrayLength(TIA, 0);
- end;
- function FindTree(var x, y: Integer; xs, ys, xe, ye: Integer): Boolean;
- var
- i, h: Integer;
- bmpTree: TIntegerArray;
- begin
- bmpTree:= [BitmapFromString(13, 5, 'beNpjYAACN1Ph2hj1jCC' +
- 'V6niVpWXaO5uNO1LV0z1EomyFQ62F1OQ4bFN1zKLUHY2Fkz1lsn1k' +
- '60Jl+qLklmaqbM3XqA2RSnaXcjPkVZVjd8owMgxXcjIWiXWVzPaW7' +
- 'U1QXp6usTFHoy9GOcROxNlQwEKLS1eF0zhc1SHNwMNMPMVFPM9DvD' +
- 'FIpilQuj9aoTpKxc1KRFuZ01STw1KXR9VdzCpBy8VYLMZRNMNdqiZ' +
- 'csTddszFZIz9aJSZAxt1ayMOSz8mMnwEAWV8xYA=='),
- BitmapFromString(13, 5, 'beNoNwckKgkAAAFBvL' +
- 'bSRpqRji43MmEPL2FgdChEnBNMKT0EJ1SGoPiG6BUE/Xe8Jwh/DYs' +
- 'ZRsoSHED739vfiXNcodqVgIHqkrsv5wZpYARojMZqC7VzPPHAPWs8' +
- 'N/KQ489SIqcwsAzlHE2r6BkXSatLczvRb2HvF+L3Dd97zhhI1a/1O' +
- '0dAKyDdH8ci1lMhRUlc5LcF5oT145xBARqSuWsDtvG2UNCaTsO8gm' +
- 'Y8bCVOPfvcWW6cIpxzyBWCk7toValWFHziwJts='),
- BitmapFromString(13, 5, 'beNoNwckKgkAYAGBv' +
- 'LbThNrhvozP6t6loU7i0HAIFg8BeoE5B9P63+j6O+4tsoWVBneBmj' +
- '5/X6HtL7mVQgZj7Qop5xA/9Epw8IJZQLPXj2mhTvc/NZ40/F9Kmag' +
- 'FqZE4RP6B1bGYutUQWKseV0R+8V0XeJ9IzL/VFai5cZaxJIyvzg3I' +
- 'DDipCdAbUJXoXa4+d3eQ48kRVGtnK0NUmMsjeIQwtmRGpBrXJnL6i' +
- 'XUEuO8y2OmAe3Bl15twPruggZw==')];
- h:= High(bmpTree);
- for i:= 0 to h do
- begin
- if(not(Result))then
- Result:= FindBitmapToleranceIn(bmpTree[i], x, y, xs, ys, xe, ye, 33);
- FreeBitmap(bmpTree[i]);
- end;
- SetArrayLength(bmpTree, 0);
- end;
- function FindDwarf(var x, y: Integer; xs, ys, xe, ye: Integer): Boolean;
- var
- i, h: Integer;
- bmpDwarf: TIntegerArray;
- begin
- bmpDwarf:= [BitmapFromString(8, 6, 'beNoBkABv/29rYFtISUxUYWNr' +
- 'Wl1ld3mCw8PMzc7aaG98YFlBWlpcZU0/VD0wmW1StX9ernxcJioud' +
- 'XV3EAkFTTAeQiwfjmFErnhUjlc1kpKVTE1NFAoBFAYAKxoPa0gwWz' +
- 'QcLA0AlpaZY2VoJBsTEgEAFwcALBQAMxIALwwANi0lqaqsOzEpEAA' +
- 'AGwsAMxkDNBIAMREAc1VKKX0='),
- BitmapFromString(8, 6, 'beNpLzg4N9HBwDgmLyA4ITs3M' +
- 'blq79sy27bdikmtC/R0DAmKiXOy9zQw6EoMWFMTNyotRUtPLyCjn4' +
- '2B10ZazVpevC3OZlRVS52fa1DTV2cVXiJNRiJVBXZw/3sEgUE9GnZ' +
- 'uhtXVmRFSGgoSwACODCBuDuhCDngCDFjeDgYbqtOlrTHU0+RgYJLg' +
- 'Y9MSYgeI6/AxpADP5JiQ='),
- BitmapFromString(8, 6, 'beNoLz/Z297C0DvHxzXbzTI2N' +
- 'a5ox48yChbcCw2u83Rzd3GL8beydDAwqQoN6k+PaE2PkFPWio8t52' +
- 'Flt1ORMlOXzfVzaY0PyXUyLiqZa2/jyczDyszIoifAHWxi4a8oocz' +
- 'GUls709c+QERXmY2QQYmVQ5mfQ4GNQ5WTQUlZtaVmjp6bJw8Agysm' +
- 'gIcysycegxssQBQAgTSLr'),
- BitmapFromString(8, 6, 'beNrzz3Zx9DAxC3F1y3ZwSg0J' +
- 'berqOjNx0i0v/xoXe0cHhxgPM3sbbYMc36CGqLjqiBhpOb3g4HJuN' +
- 'lYzJTl9eflUV5fq0JBUO9OMjKlmZr587Ix8LAzyQvw+xgaOqjLynA' +
- 'xZWTPdPDIkhYV5GRkEWBnk+RhUeBmUOBjUFFQrKtZoKWtyMzAIczC' +
- 'oCDGr8jIo8zAEAgBniyDH'),
- BitmapFromString(8, 6, 'beNpzzrQyd9fRC7K2yTSzSHb3' +
- 'aCgtPVFdc83eucrKzMHMLMpWz85YVT/GMSDHJybDK0pcUtfNrZSLl' +
- 'VVPVk5DWj7U2jnDIyjU1CQiYpKeng8PGyMPC4MUP7+Dtr65vIw0B0' +
- 'NU1DQb2zRRAWFuRgY+FgZpHgZ5bgYZdgZFadXUtJUqchpcDAwC7Az' +
- 'y/MxAcTkuBlcAP0wdXg==')];
- h:= High(bmpDwarf);
- for i:= 0 to High(bmpDwarf) do
- begin
- if(not(Result))then
- Result:= FindBitmapToleranceIn(bmpDwarf[i], x, y, xs, ys, xe, ye, 33);
- FreeBitmap(bmpDwarf[i]);
- end;
- SetArrayLength(bmpDwarf, 0);
- end;
- function GetTreeSpot: Integer;
- var
- x, y, i, h: Integer;
- TIA: TIntegerArray;
- begin
- TIA:= [164, 184, 204, 224, 244, 264, 284];
- h:= High(TIA);
- Result:= -1;
- if(FindTree(x, y, 151, 186, 164, 291))then
- for i:= h downto h do
- if(TIA[i] = y)then
- begin
- Result:= i;
- Break;
- end;
- SetArrayLength(TIA, 0);
- end;
- function getChopSpot: Integer;
- var
- dtmChopSpot, x, y: Integer;
- begin
- Result:= -1;
- dtmChopSpot:= DTMFromString('78DA63D461626058C080029C1C2DC1342394C' +
- 'FC80754330155CDB9E35B51D56860AA99D2558CAAC602A8A61F55' +
- '4D4FA026AA1A63A09AE5A86AAE9D5E8BAA4618538DA8391F8A1A0' +
- '0B7EB0CDB');
- if(FindDTM(dtmChopSpot, x, y, mmBox.X1, mmBox.Y1, mmBox.X2, mmBox.Y2))then
- if((x = 556)and(InRange(y, 160, 166)))then
- Result:= (y - 160);
- FreeDTM(dtmChopSpot);
- end;
- procedure WalkToTreeSpot;
- var
- theSpot, x, y, tempTime, PHNM, phmMark: Integer;
- begin
- theSpot:= (Random(7) + 1);
- if(GetTreeSpot = theSpot)then
- Exit;
- if(FindTree(x, y, 3, 24, 250, 444))then
- begin
- SWClick((x + 60), ((y - 72) + (theSpot * 20)), 0, 0, 0, 0, 1, True, 'clientCorner');
- MarkTime(tempTime);
- repeat
- if((TimeFromTimeMark(tempTime) >= 2000)or(PHNM > 10))then
- Break;
- if((TimeFromTimeMark(phmMark) = 0)or(TimeFromTimeMark(phmMark) >= 50))then
- begin
- if(not(PlayerHasMoved))then
- Inc(PHNM)
- else
- PHNM:= 0;
- MarkTime(phmMark);
- end;
- PDWait(1);
- until(InRange(getChopSpot, 0, 6));
- MarkTime(tempTime);
- while (FindAxe <> 2) do
- begin
- ScrollQuickItemBarEx(29);
- PDWait(1);
- if(TimeFromTimeMark(tempTime) >= 5000)then
- Break;
- end;
- end;
- if(PHNM < 10)then
- begin
- PHNM:= 0;
- MarkTime(phmMark);
- repeat
- PDWait(1);
- if(TimeFromTimeMark(phmMark) > 66)then
- begin
- if(not(PlayerHasMoved))then
- Inc(PHNM)
- else
- PHNM:= 0;
- MarkTime(phmMark);
- end;
- if(not(InRange(getChopSpot, 0, 6)))then
- Break;
- until(PHNM > 2);
- PDWait(10);
- end;
- if(not(InRange(getChopSpot, 0, 6)))then
- WalkToTreeSpot
- else
- PDWait(50);
- end;
- procedure SellLogs;
- var
- i, i2, x, y: Integer;
- tempTM: Integer;
- begin
- handleFKeys;
- if(BagFull)then
- begin
- if(FindDwarf(x, y, 180, 58, 379, 259))then
- begin
- MarkTime(tempTM);
- while (GetColor(53, 364) <> 15987699) do
- begin
- if(FindDwarf(x, y, 180, 58, 379, 259))then
- SWClick(x + 4, y + 18, 0, 0, 0, 0, 1, True, 'clientCorner');
- if(TimeFromTimeMark(tempTM) >= 5000)then
- SellLogs;
- PDWait(1);
- end;
- SWClick(61, 370, 0, 0, 0, 0, 1, True, 'clientCorner');
- MarkTime(tempTM);
- while (not(GetColor(238, 199) = 5535633)) do
- begin
- if(TimeFromTimeMark(tempTM) >= 5000)then
- SellLogs;
- PDWait(1);
- end;
- SWClick(533, 383, 0, 0, 0, 0, 2, True, 'clientCorner');
- SWClick(389, 381, 0, 0, 0, 0, 1, True, 'clientCorner');
- SWClick(493, 383, 0, 0, 0, 0, 2, True, 'clientCorner');
- SWClick(389, 381, 0, 0, 0, 0, 1, True, 'clientCorner');
- for i:= 1 to 9 do
- begin
- for i2:= 1 to 3 do
- SWClick(462, 377, 0, 0, 0, 0, 1, True, 'clientCorner');
- for i2:= 1 to 3 do
- begin
- case i2 of
- 1: SWClick(573, 381, 0, 0, 0, 0, 2, True, 'clientCorner');
- 2: SWClick(533, 381, 0, 0, 0, 0, 2, True, 'clientCorner');
- 3: SWClick(493, 381, 0, 0, 0, 0, 2, True, 'clientCorner');
- end;
- SWClick(389, 379, 0, 0, 0, 0, 1, True, 'clientCorner');
- end;
- end;
- SWClick(409, 147, 0, 0, 0, 0, 1, True, 'clientCorner');
- WalkTo('Tree');
- end;
- end else
- WalkTo('Tree');
- end;
- procedure WalkTo(spot: string);
- var
- x, y, i, ttl, dstnc, nwAngl, olAngl: Integer;
- s, drctn: string;
- cBx, sBox: TBox;
- cPtMM, cPt, wPt: TPoint;
- TPA: TPointArray;
- walkBoxArr: TBoxArray;
- b: Boolean;
- begin
- sBox:= IntToBox(walkingSpot[140].x1, walkingSpot[140].y1, walkingSpot[220].x2, walkingSpot[220].y2);
- cBx:= GetAreaBoxByID(180);
- cPt:= IntToPoint((cBx.x1 + 9), (cBx.y1 + 9));
- cPtMM:= IntToPoint (533, 174);
- dstnc:= (Distance(wsBox.x1, wsBox.y1, wsBox.x2, wsBox.y2) / 2);
- s:= Lowercase(spot);
- repeat
- case s of
- 'tree': b:= FindDTM(dtmTree, x, y, mmBox.x1, mmBox.y1, mmBox.x2, mmBox.y2);
- 'trader': b:= FindDTM(dtmTrader, x, y, mmBox.x1, mmBox.y1, mmBox.x2, mmBox.y2);
- end;
- if(b)then
- begin
- drctn:= Lowercase(mmCoordsToDirection(x, y));
- if(drctn = 'center')then
- if(Distance(cPtMM.x, cPtMM.y, x, y) < 12)then
- Break;
- nwAngl:= GetAngle(cPtMM, IntToPoint(x, y));
- if(nwAngl <> olAngl)then
- begin
- wPt:= GetTPointByXYDA(cPt, dstnc, nwAngl);
- TPA:= TPointLine(cPt, wPt);
- PickEveryXTPointFromTPA(4, TPA);
- walkBoxArr:= GetAreaBoxsByTPA(TPA);
- SkipTBoxsByArea(walkBoxArr, sBox, False);
- ttl:= GetArrayLength(walkBoxArr);
- olAngl:= nwAngl;
- end;
- if(ttl > 0)then
- begin
- i:= Random(ttl);
- ClickMouse((walkBoxArr[i].x1 + 9), (walkBoxArr[i].y1 + 9), True);
- end;
- PDWait(1);
- end;
- PDWait(1);
- until(False);
- ClickMouse((wsCBox.X1 + 5), (wsCBox.Y1 + 5), True);
- SetArrayLength(walkBoxArr, 0);
- SetArrayLength(TPA, 0);
- case s of
- 'tree': WalkToTreeSpot;
- 'trader': SellLogs;
- end;
- end;
- procedure Cut;
- var
- x, y, tempTM, tempSpot, tmpETM, ET: Integer;
- begin
- while (FindAxe < 0) do
- begin
- ScrollQuickItemBarEx(29);
- PDWait(1);
- end;
- if(FindTree(x, y, 3, 24, 250, 444))then
- if(not(InRange(getChopSpot, 0, 6)))then
- WalkToTreeSpot;
- repeat
- if(BagFull)then
- Break;
- SWClick(555, 369, 0, 0, 0, 0, 1, False, 'clientCorner')
- FindTree(x, y, 151, 186, 164, 291);
- SWClick((x + 5), y, 0, 0, 0, 0, 1, True, 'clientCorner');
- SWClick(488, 263, 0, 0, 0, 0, 1, True, 'clientCorner');
- MarkTime(tempTM);
- while ((not(BagOpen))and(TimeFromTimeMark(tempTM) < 2000)) do
- PDWait(1);
- if(TimeFromTimeMark(tempTM) >= 2000)then
- Cut;
- MarkTime(tempTM);
- while ((BagOpen)and(TimeFromTimeMark(tempTM) < 5500)) do
- PDWait(1);
- if(BagOpen)then
- begin
- SWClick(236, 29, 0, 0, 0, 0, 1, True, 'clientCorner');
- MarkTime(tempTM);
- while (BagOpen) do
- begin
- MarkTime(tmpETM);
- PDWait(1);
- ET:= (TimeFromTimeMark(tmpETM) - 1);
- if((TimeFromTimeMark(tempTM) - ET) >= 10000)then
- TerminateScript;
- end;
- tempSpot:= GetTreeSpot;
- if((getChopSpot < 6)and(getChopSpot > 0))then
- SendArrow(2)
- else
- SendArrow(0);
- MarkTime(tempTM);
- repeat
- if(TimeFromTimeMark(tempTM) >= 500)then
- Break;
- PDWait(1);
- until(tempSpot = (GetTreeSpot + 1))or(tempSpot = (GetTreeSpot - 1));
- WalkToTreeSpot;
- Cut;
- end else
- if(TimeFromTimeMark(tempTM) >= 5500)then
- begin
- if(not(FindTree(x, y, 151, 186, 164, 291)))then
- if(FindTree(x, y, 3, 24, 250, 444))then
- WalkToTreeSpot
- else
- TerminateScript;
- end;
- PDWait(1);
- until(BagFull);
- WalkTo('Trader');
- end;
- function ReadyForUsing: Boolean;
- var
- bmp, i, x, y, tmr, bs: Integer;
- box: TBox;
- b: Boolean;
- begin
- bs:= -1;
- for i:= 0 to 3 do
- CloseMenu;
- OpenMenu('Inventory');
- MarkTime(tmr);
- repeat
- if(TimeFromTimeMark(tmr) > 1000)then
- Break;
- b:= MenuOpen('Inventory');
- Wait(10);
- until(b);
- if(b)then
- begin
- if(FindDTM(dtmAxe, x, y, bBox.X1, bBox.Y1, bBox.X2, bBox.Y2))then
- bs:= CoordsToBagSlot(x, y);
- if(bs <> 29)then
- if(InRange(bs, 0, 28))then
- begin
- box:= GetBagSlot(29);
- KeyDown(18);
- ClickMouse((box.x1 + 12), (box.y1 + 12), True);
- KeyUp(18);
- MarkTime(tmr);
- repeat
- if(TimeFromTimeMark(tmr) > 1000)then
- Break;
- b:= MenuOpen('Item View');
- Wait(10);
- until(b);
- if(not(b))then
- begin
- DragItem(bs, 29);
- MarkTime(tmr);
- repeat
- if(TimeFromTimeMark(tmr) > 2000)then
- Break;
- b:= FindItemInBagSlot(dtmAxe, 29, 'DTM');
- Wait(10);
- until(b);
- if(not(b))then
- Exit;
- end else
- Exit;
- end else
- Exit;
- end else
- Exit;
- if(b)then
- begin
- for i:= 0 to 2 do
- MoveMouse(4, 24);
- Wait(100);
- bmp:= BitmapFromString(0, 0, '');
- CopyClientToBitmap(bmp, bBox.X1, bBox.Y1, bBox.X2, bBox.Y2);
- if(MD5(BitmapToString(bmp)) <> '49d2c066e8bbae661006710d107d0ec2')then
- begin
- FreeBitmap(bmp);
- Exit;
- end;
- FreeBitmap(bmp);
- end;
- if(b)then
- begin
- MarkTime(tmr);
- repeat
- if(TimeFromTimeMark(tmr) > 2000)then
- Break;
- ScrollQuickItemBarEx(29);
- Wait(100);
- b:= FindItemInQuickBarSlot(dtmAxe, 29, 'DTM');
- until(b);
- CloseMenu;
- if(not(b))then
- Exit;
- end;
- AddToReport('chopspot: ' + IntToStr(getChopSpot));
- if(b)then
- if(not(InRange(getChopSpot, 0, 6)))then
- Exit;
- Result:= True;
- end;
- procedure ScriptTerminate;
- begin
- PlaySound(ScriptPath + 'empty.wav');
- FreeDTM(dtmTrader);
- FreeDTM(dtmTree);
- FreeDTM(dtmAxe);
- SetArrayLength(storedColors, 0);
- SetClientPos(False);
- StopProjectSW;
- end;
- begin
- dtmAxe:= DTMFromString('78DA63BCC8C0C0F08201052498F3836946289' +
- 'FF128907882AAE6DBD74FA86A1E02891FA86A8C043850D59C0612' +
- '0F51D5ECDFB90AAE8609A6E615AA9A3BB76FC2D53003310000FE1' +
- '12B');
- dtmTree:= DTMFromString('78DA636466626038C88002A22283C0342394C' +
- 'F0852731455CDDED86454352C40353B50D558DB48A2AAE105AA59' +
- '8066CEAEA5A86AFE02594B50D59C3AB207450D00C38B0C22');
- dtmTrader:= DTMFromString('78DA63B4606260E86740013D819A609A11CA6' +
- '7D400AA9980AA664A5731AA1A1DA09A05A86A9C1C2D51D59800D5' +
- '2C4355F3FCFE56143500603E0904');
- nameBox:= nameCoordinates(playerName);
- StartProjectSW;
- ActivateClient;
- Wait(1000);
- if(not(ReadyForUsing))then
- TerminateScript;
- repeat
- handleFKeys;
- Cut;
- PDWait(1);
- until(IsFKeyDown(StopFKey));
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement