{$include_once ogLib/lib/core/core.simba} const CLIB_VERSION : string = '1.3.7'; type tAntiban = record __: boolean; end; type tCLib = record __: boolean; end; type tPlayer = record __: boolean; end; type tWalking = record __: boolean; end; type tWeb = record __: boolean; end; var antiban: tAntiban; cLib: tCLib; player: tPlayer; walking: tWalking; web: tWeb; const AGILITY : tCardinalArray = [29580, 3220239]; ATTACK : tCardinalArray = [16918, 1644048]; CONSTITUTION : tCardinalArray = [38262, 5247763]; CONSTRUCTION : tCardinalArray = [54189, 5916465]; COOKING : tCardinalArray = [47376, 2958623]; CRAFTING : tCardinalArray = [33559, 2696483]; DEFENCE : tCardinalArray = [41952, 3552563]; DIVINATION : tCardinalArray = [22933, 2633540]; DUNGEONEERING : tCardinalArray = [58390, 5455656]; FARMING : tCardinalArray = [34536, 3158322]; FIREMAKING : tCardinalArray = [46008, 5256739]; FISHING : tCardinalArray = [54626, 3555911]; FLETCHING : tCardinalArray = [19315, 1642768]; HERBLORE : tCardinalArray = [54427, 3099168]; HUNTER : tCardinalArray = [30306, 1839885]; MAGIC : tCardinalArray = [51211, 2040371]; MINING : tCardinalArray = [16653, 1248522]; PRAYER : tCardinalArray = [23912, 2436403]; RANGED : tCardinalArray = [20999, 1183499]; RUNECRAFTING : tCardinalArray = [33877, 4272937]; SLAYER : tCardinalArray = [54733, 5261117]; SMITHING : tCardinalArray = [31773, 2170654]; STRENGTH : tCardinalArray = [39319, 4533282]; SUMMONING : tCardinalArray = [37582, 3291452]; THIEVING : tCardinalArray = [25506, 1381397]; WOODCUTTING : tCardinalArray = [44243, 1710094]; var meteoriteTimeout: tCountDown; meteoriteSkill: tCardinalArray = ATTACK; function tAntiban.alert(funcMessage: string): boolean; var funcChat: tStringArray; i: int32; begin funcChat := chat.getChat(true); for i := low(funcChat) to high(funcChat) do if (pos(funcMessage, funcChat[i]) <> 0) then exit(true); result := false; end; procedure tAntiban.investigateMeteorite(); var funcClientCenter, funcStartPoint, funcCurrentPoint: tPoint; funcTimeout: tCountDown; funcContinueTextures: glTextureArray; funcChatMessages: tStringArray; i: int32; begin try writeln('Investigating meteorite...'); wait(normalRandom(2000, 3000)); tBank.close(); funcStartPoint := minimap.getLocalPosition(); funcClientCenter := ogl.getClientMidPoint(); mouse.clickAction(funcClientCenter.closest(ogl.getModels(3856085471))[0].randomizePointEllipse(15), 'Investigate'); funcTimeout.setTime(normalRandom(6000, 9000)); repeat funcContinueTextures := ogl.getTextures(91275, 12483092); until (funcTimeout.isFinished()) or (not funcContinueTextures.isEmpty()); if (not funcContinueTextures.isEmpty()) then begin mouse.click(funcClientCenter.closest(ogl.getTextures(meteoriteSkill[0], meteoriteSkill[1]))[0].randomizePointEllipse(7)); wait(normalRandom(900, 1800)); mouse.click(funcClientCenter.closest(funcContinueTextures)[0].randomizePointEllipse(20)); meteoriteTimeout.setTime(180000); funcTimeout.setTime(normalRandom(3000, 4000)); repeat wait(normalRandom(250, 500)); until (funcTimeout.isFinished()) or (ogl.getTextures(91275, 12483092).isEmpty()); writeln('Successfully investigated meteorite!'); end else begin meteoriteTimeout.setTime(normalRandom(7000, 10000)); funcChatMessages := chat.getChat(true); for i := 0 to length(funcChatMessages) do begin if (pos('Whatever this thing contained,', funcChatMessages[i]) <> 0) or (pos('You''ve already claimed', funcChatMessages[i]) <> 0) then begin meteoriteTimeout.setTime(180000); break; end; end; end; except writeln('An error occured while trying to investigate a meteorite. Trying to recover.'); finally walking.walkToLocalPoint(funcStartPoint, 1); wait(normalRandom(3000, 4500)); end; end; function tAntiban.checkRandoms(): boolean; begin if (meteoriteTimeout.isFinished()) and (not ogl.getModels(3856085471).isEmpty()) then begin self.investigateMeteorite(); result := true; end else if (meteoriteTimeout.timeRemaining) and (ogl.getModels(3856085471).isEmpty()) then meteoriteTimeout.setTime(0); end; procedure tAntiban.rotateCamera(funcEndDegrees: int32; funcEndRandom: int32 = 10; funcMaxRotations: int32 = 4); var i: int32; begin for i := 0 to random(funcMaxRotations) do begin minimap.setDegrees(random(0, 360)); wait(random(140)); end; minimap.setDegrees(funcEndDegrees + normalRandom(-funcEndRandom, funcEndRandom)); end; procedure tAntiban.setMeteoriteSkill(funcSkill: tCardinalArray); begin meteoriteSkill := funcSkill; end; function tBank.clickPreset(funcPreset: int32; funcUseHotkey: boolean): boolean; overload; var funcTimeout: tCountDown; begin if (self.hasBank()) then begin if (funcUseHotkey) then typeSend(intToStr(funcPreset), false) else self.clickPreset(funcPreset); funcTimeout.setTime(1400); repeat wait(200); until (funcTimeout.isFinished()) or (not self.hasBank()); result := not self.hasBank(); end else result := false; end; function tBank.close(): boolean; var funcTimeout: tCountDown; begin if (self.hasBank()) then begin funcTimeout.setTime(1500); repeat typeByte(VK_ESCAPE); wait(normalRandom(400, 600)); until (not self.hasBank()) or (funcTimeout.isFinished()); if (self.hasBank()) then mouse.click(ogl.getClientMidPoint().closest(ogl.getTextures(16320, 7086623))[0].randomizePointEllipse(7)) else exit(true); funcTimeout.setTime(1000); repeat wait(100); until (funcTimeout.isFinished()) or (not self.hasBank()); end; exit(self.hasBank()); end; function tBank.hasBank():boolean; override; var funcPointer:pointer; funcPointerIndex, funcPointerSize:uInt32=0; funcX, funcY:int32; begin funcPointer:=glTextures(funcPointerSize)+(36*(funcPointerSize-1)); {if funcPointerSize<1 then exit();} for funcPointerIndex to funcPointerSize-1 do begin if (funcPointer^=714000) and ((funcPointer-36)^=75244) then begin result:=true; break; end; funcPointer:=funcPointer-36; end; exit(result); end; function tBank.open(): boolean; const BANKS : tCardinalArray = [1828922260, 2878626002, 2083337462, 2697527608, 915100373, 3489743445, 4243090208, 2783808500]; BANK_BOOTHS: tCardinalArray = [2697527608]; BANKERS : tCardinalArray = [1828922260]; var funcTimeout: tCountDown; funcClickPoint, funcClientCenter: tPoint; funcBanks, funcBankBooths, funcBankers: glModelArray; begin funcClientCenter := ogl.getClientMidPoint(); funcBankBooths := ogl.getModels(BANK_BOOTHS); if (not funcBankBooths.isEmpty()) then begin funcBankers := ogl.getModels(BANKERS); funcClickPoint := funcClientCenter.closest(funcBankers)[0].closest(funcBankBooths)[0].randomizePointEllipse(25); end else funcClickPoint := funcClientCenter.closest(ogl.getModels(BANKS))[0].randomizePointEllipse(25); mouse.click(funcClickPoint); funcTimeout.setTime(2000); repeat wait(100); until (funcTimeout.isFinished()) or (self.hasBank()); result := self.hasBank(); end; function tLogin.logout(): boolean; var funcClientCenter: tPoint; funcBounds: tBox; funcTimeout: tCountDown; funcTextures: glTextureArray; begin funcBounds := [ogl.getClientWidth() - 10, 0, ogl.getClientWidth(), 10]; funcClientCenter := ogl.getClientMidPoint(); mouse.click(funcBounds); funcBounds := [funcClientCenter.x - 200, funcClientCenter.y - 150, funcClientCenter.x + 200, funcClientCenter.y + 150]; funcTimeout.setTime(5000); repeat funcTextures := ogl.getTextures(91275, 12483092, funcBounds); until (not funcTextures.isEmpty()) or (funcTimeout.isFinished()); if (not funcTextures.isEmpty()) then mouse.click(funcClientCenter.closest(funcTextures)[0].randomizePointEllipse(15)); funcTimeout.setTime(5000); repeat wait(250); until (funcTimeout.isFinished()) or (self.hasLogin()); result := self.hasLogin(); end; function tMinimap.hasFlag(): boolean; begin result := not ogl.getTextures(1275).isEmpty(); end; function tMouse.clickAction(funcClickPoint: TPoint; funcAction: string): boolean var funcTimeout: tCountDown; funcTooltip: string; begin moveMouse(funcClickPoint.x, funcClickPoint.y); funcTimeout.setTime(1000); repeat funcTooltip := self.getTooltip() until (funcTooltip <> '') or (funcTimeout.isFinished()); if (funcTooltip <> '') then begin if (pos(funcAction, funcTooltip) <> 0) then begin self.click(funcClickPoint); result := true; end else result := self.rightClickOption(funcClickPoint, funcAction, normalRandom(300, 650)); exit(result); end; exit(false); end; function tMouse.getTooltip():string; override; var funcID:int32; funcBounds:tBox; funcPointer:pointer; funcPointerIndex, funcPointerSize:uInt32=0; begin funcPointer:=glTextures(funcPointerSize)+(36*(funcPointerSize-1)); if funcPointer<>nil then begin for funcPointerIndex to funcPointerSize div 5 do begin if funcPointer^=15878 then begin funcBounds:=[(funcPointer-88)^,(funcPointer-84)^,(funcPointer+28)^,(funcPointer+32)^]; break; end; funcPointer:=funcPointer-36; end; if funcPointerIndexnil then begin for funcPointerIndex:=0 to funcPointerSize div 2 do begin if pointInBox([(funcPointer+8)^,(funcPointer+12)^],funcBounds) then begin if (result<>'') and (single((funcPointer+68)^)-(single((funcPointer+20)^)+integer((funcPointer+40)^))<>1) then result:=' '+result; result:=char((funcPointer+16)^)+result; end else if result<>'' then break; funcPointer:=funcPointer-96; end; end; end; end; exit(result); end; { Credits to Lucidity for the idea of the getPlayerId function. } function tPlayer.getId(): uInt32; var funcModels: glModelArray; funcPlayerModelBox: tBox; funcClientCenter: tPoint; i: uInt32; begin funcClientCenter := ogl.getClientMidPoint(); funcPlayerModelBox := intToBox(funcClientCenter.x - 60, funcClientCenter.y - 25, funcClientCenter.x + 40, funcClientCenter.y + 40); funcModels := ogl.getModels(funcPlayerModelBox).reverse(); if (length(funcModels)) then begin for i := low(funcModels) to high(funcModels) do if (funcModels[i].TID >= 1000) then result := funcModels[i].ID; end; end; function tPlayer.getExperience(funcIconTextureId: uInt32 = 48705): int32; var funcXpTexture: glTextureArray; funcXpBox: tBox; begin funcXpTexture := ogl.getTextures(funcIconTextureId); if (not funcXpTexture.isEmpty()) then begin funcXpBox := intToBox(funcXpTexture[0].bounds.x1 - 250, funcXpTexture[0].bounds.y1, funcXpTexture[0].bounds.x2, funcXpTexture[0].bounds.y2); result := explode('+', ogl.getChars(funcXpBox).toString())[0].parseInt(); end; end; function tPlayer.isAnimating(funcPlayerId: uInt32; funcTimeout: tCountdown = 0): boolean; var funcIdle: glModelArray; begin if (funcTimeout = 0) then result := (ogl.getModels(funcPlayerId).isEmpty()) else begin repeat funcIdle := ogl.getModels(funcPlayerId); wait(100); until (funcIdle.isEmpty()) or (funcTimeout.isFinished()); result := funcIdle.isEmpty(); end; end; function tProduction.setMake(funcUseHotkey: boolean): boolean; overload; var funcTimeout: tCountDown; begin if (self.hasProduction() = 'production') then begin if (funcUseHotkey) then typeByte(VK_SPACE) else self.setMake(); funcTimeout.setTime(1400); repeat wait(200); until (funcTimeout.isFinished()) or (self.hasProduction() = 'progress'); result := (self.hasProduction() = 'progress'); end else result := false; end; function tProduction.setTool(funcTool: int32; funcUseHotkey: boolean): boolean; overload; var funcTimeout: tCountdown; begin if (self.hasProduction() = 'choose a tool') then begin if (funcUseHotkey) then typeSend(intToStr(funcTool), false) else self.setTool(funcTool - 1); funcTimeout.setTime(1400); repeat wait(200); until (funcTimeout.isFinished()) or (self.hasProduction() <> 'choose a tool'); result := self.hasProduction() <> 'choose a tool'; end else result := false; end; function tWalking.walkToIcon(funcIconTextureId: uInt32; funcRandomX1: int32 = 2; funcRandomX2: int32 = 2; funcRandomY1: int32 = 2; funcRandomY2: int32 = 2): boolean; var funcIconTextures: glTextureArray; begin funcIconTextures := ogl.getTextures(funcIconTextureId); if not funcIconTextures.isEmpty() then mouse.click(ogl.getClientMidPoint().closest(funcIconTextures)[0].adjustPosition(normalRandom(funcRandomX1, funcRandomX2), normalRandom(funcRandomY1, funcRandomY2))); result := not funcIconTextures.isEmpty(); end; procedure tWalking.walkToLocalPoint(funcTargetPoint: tPoint; funcRandom: int32 = 2); var funcStartPoint: tPoint; begin funcStartPoint := minimap.getLocalPosition(); self.walkToRelativePoint(funcTargetPoint.x - funcStartPoint.x, funcTargetPoint.y - funcStartPoint.y, funcRandom); end; procedure tWalking.walkToLocalPoints(funcTargetPoints: tPointArray; funcRandom: int32 = 2); var i: int32; funcTimeout: tCountDown; begin for i := 0 to length(funcTargetPoints) do begin self.walkToLocalPoint(funcTargetPoints[i], funcRandom); funcTimeout.setTime(normalRandom(1500, 2500)); repeat wait(normalRandom(100, 250)); until (funcTimeout.isFinished()) or (minimap.hasFlag()); funcTimeout.setTime(normalRandom(9000, 11000)); repeat wait(normalRandom(100, 250)); until (funcTimeout.isFinished()) or (not minimap.hasFlag()); end; end; procedure tWalking.walkToRelativePoint(funcLowX: int32; funcHighX: int32; funcLowY: int32; funcHighY: int32); begin mouse.click(minimap.getScreenPosition(minimap.getLocalPosition() .adjustPosition(normalRandom(funcLowX, funcHighX), normalRandom(funcLowY, funcHighY)))); end; procedure tWalking.walkToRelativePoint(funcX, funcY: int32; funcRandom: int32 = 2); overload; begin self.walkToRelativePoint(funcX - funcRandom, funcX + funcRandom, funcY - funcRandom, funcY + funcRandom); end; procedure tWalking.walkToRelativePoint(funcTargetPoint: tPoint; funcRandom: int32 = 2); overload; begin self.walkToRelativePoint(funcTargetPoint.x, funcTargetPoint.y, funcRandom); end; procedure tWalking.walkToRelativePoints(funcTargetPoints: tPointArray; funcRandom: int32 = 2); var i: int32; funcTimeout: tCountDown; begin for i := 0 to length(funcTargetPoints) do begin self.walkToRelativePoint(funcTargetPoints[i], funcRandom); funcTimeout.setTime(normalRandom(1500, 2500)); repeat wait(normalRandom(100, 250)); until (funcTimeout.isFinished()) or (minimap.hasFlag()); funcTimeout.setTime(normalRandom(9000, 11000)); repeat wait(normalRandom(100, 250)); until (funcTimeout.isFinished()) or (not minimap.hasFlag()); end; end; function tWeb.proxyRequest(funcUrl: string): string; begin result := getPage('http://static.frement.net/proxy.php?u=' + funcUrl); end; function tWeb.isUpToDate(funcLocalVersion, funcUrl: string; funcUseProxy: boolean = true): boolean; var i: int32; funcRemoteVersion: string; funcRemoteVersionNumbers, funcLocalVersionNumbers: TStringArray; begin if (funcUseProxy) and (pos('https://', funcUrl) <> 0) then funcRemoteVersion := self.proxyRequest(funcUrl) else funcRemoteVersion := getPage(funcUrl); funcRemoteVersionNumbers := explode('.', funcRemoteVersion); funcLocalVersionNumbers := explode('.', funcLocalVersion); for i := low(funcRemoteVersionNumbers) to high(funcRemoteVersionNumbers) do begin if (strToInt(funcRemoteVersionNumbers[i]) <> strToInt(funcLocalVersionNumbers[i])) then exit(false); end; exit(true); end; procedure tWeb.update(funcUrl, funcScriptName: string; funcUseProxy: boolean = true; funcPath: string = '') var funcFile: int32; funcScript, funcFileName: string; begin if (funcUseProxy) and (pos('https://', funcUrl) <> 0) then funcScript := self.proxyRequest(funcUrl) else funcScript := getPage(funcUrl); if (funcPath = '') then funcPath := scriptPath; if (pos('.simba', funcScriptName) <> 0) then funcFileName := funcPath + funcScriptName else funcFileName := funcPath + funcScriptName + '.simba'; funcFile := rewriteFile(funcFileName, true); try writeFileString(funcFile, funcScript) except writeln('Failed to write!'); end; closeFile(funcFile); writeln('Script has been updated, please re-open this file and restart the script.'); terminateScript(); end; procedure cLib.selfUpdate(); begin writeln('[cLib] Checking for updates...'); if (not web.isUpToDate(CLIB_VERSION, 'https://raw.githubusercontent.com/yuri-moens/simba-scripts/master/cLib.version')) then begin writeln('[cLib] Newer version found! Updating...'); web.update('https://raw.githubusercontent.com/yuri-moens/simba-scripts/master/cLib.simba', 'cLib.simba', true, includePath); writeln('[cLib] Library has been updated.'); end else writeln('[cLib] Library is up to date.'); end; function tOGL.setup(funcClientWidth,funcClientHeight:int32=0):boolean;override; begin cLib.selfUpdate(); inherited; end;