(* Production ========== The production file contains various methods for interacting with the production interface. The source for this file can be found `here `_. *) (* tProduction.getProduct() ~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tProduction.getProduct():int32; Description: Retrieves the currently selected product. Information: * Returns an int32 relative to the currently selected item. .. note:: - by Obscurity - Last Updated: 2015-07-22 Example: .. code-block:: pascal if production.hasProduction()='production' then ogl.debug('Current production selection: ',production.getProduction()); *) function tProduction.getProduct():int32; var funcPointer:^glTexture; funcPointerIndex, funcProduct:int32; funcPointerSize:uInt32; begin funcPointer:=glTextures(funcPointerSize)+(funcPointerSize-1)*oglTextureSize; for funcPointerIndex to funcPointerSize-3 do begin if funcPointer^.id=360740 then begin if (funcPointer-oglTextureSize)^.id=360740 then funcProduct:=funcPointerIndex else if ((funcPointer-2*oglTextureSize)^.id<>360740) then begin result:=(funcPointerIndex-funcProduct) div 2; break; end; end; funcPointer-=oglTextureSize; end; exit(result); end; (* tProduction.getProgress() ~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tProduction.getProgress():int32; Description: Retrieves the current production progress. Information: * Returns 0..100, relative to the current production progress. .. note:: - by Obscurity - Last Updated: 2015-07-22 Example: .. code-block:: pascal if production.hasProduction()='progress' then ogl.debug('Current progress: ',production.getProgress()); *) function tProduction.getProgress():int32; var funcPointer:^glTexture; funcPointerIndex, funcProduct:int32; funcPointerSize:uInt32; begin funcPointer:=glTextures(funcPointerSize)+(funcPointerSize-1)*oglTextureSize; for funcPointerIndex to funcPointerSize-3 do begin if funcPointer^.id=10710 then result+=funcPointer^.bounds.width() else if result<>0 then break; funcPointer-=oglTextureSize; end; exit(result:=round(result/304*100)); end; (* tProduction.hasProduction() ~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tProduction.hasProduction():boolean; Description: Retrieves if a production interface exists. Information: * Returns 'choose a tool', 'production', 'progress', or '' if unsuccessful. .. note:: - by Obscurity - Last Updated: 2015-07-22 Example: .. code-block:: pascal if production.hasProduction()='progress' then ogl.debug('Hold on just a second...'); *) function tProduction.hasProduction():string; var funcPointer:^glTexture; funcPointerSize:uInt32; begin funcPointer:=glTextures(funcPointerSize)+(funcPointerSize-1)*oglTextureSize; for 0 to funcPointerSize-1 do begin case funcPointer^.id of 1371874..1535741,52284: begin case funcPointer^.id of 1396788:result:='choose a tool'; 1371874..1535741:result:='production'; 52284:result:='progress'; end; break; end; end; funcPointer-=oglTextureSize; end; exit(result); end; (* tProduction.setClose() ~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tProduction.setClose():boolean; Description: If the production interface exists, closes the production screen by either pressing escape or clicking. Information: * Returns true if successful. * Uses the keyboard. * Uses the mouse. .. note:: - by Obscurity - Last Updated: 2015-07-22 Example: .. code-block:: pascal if production.hasProduction()='production' then production.setClose(); *) function tProduction.setClose():boolean; var funcPointer:^glTexture; funcPointerSize:uInt32; funcPoint: TPoint; begin funcPointer:=glTextures(funcPointerSize)+(funcPointerSize-1)*oglTextureSize; for 0 to funcPointerSize-4 do begin case funcPointer^.id of 1371874..1535741: begin if funcPointer^.bounds.width()=290 then begin case random(2) of false:sendKeys(#27,10+normalRandom(0,20)*5,10+normalRandom(0,20)*5); true: begin funcPoint:=(funcPointer-3*oglTextureSize)^.bounds.adjustPosition(48,3,-4,-38).normalizePoint(); clickMouse(funcPoint.x, funcPoint.y, 1); end; end; result:=true; break; end; end; end; funcPointer-=oglTextureSize; end; exit(result); end; (* tProduction.setMake() ~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tProduction.setMake():boolean; Description: If the production interface exists, starts the production process by either pressing space or clicking. Information: * Returns true if successful. * Uses the keyboard. * Uses the mouse. .. note:: - by Obscurity - Last Updated: 2015-07-22 Example: .. code-block:: pascal if production.hasProduction()='production' then production.setMake(); *) function tProduction.setMake():boolean; var funcPointer:^glTexture; funcPointerSize:uInt32; funcPoint: TPoint; begin funcPointer:=glTextures(funcPointerSize)+(funcPointerSize-1)*oglTextureSize; for 0 to funcPointerSize-1 do begin case funcPointer^.id of 18360: if similarColors(funcPointer^.colourID,2432795,oglColourTolerance) then break; 1371874..1535741: begin if funcPointer^.bounds.width()=290 then begin case random(2) of false:sendKeys(#32,10+normalRandom(0,20)*5,10+normalRandom(0,20)*5); true: begin funcPoint:=funcPointer^.bounds.adjustPosition(141,296,81,290).normalizePoint(); clickMouse(funcPoint.x, funcPoint.y, 1); end; end; result:=true; break; end; end; end; funcPointer-=oglTextureSize; end; exit(result); end; (* tProduction.setProduct() ~~~~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tProduction.setProduct(funcProduct:int32):boolean; Description: Sets the product to the desired index. Zero (0) is the first product. If the product is already set to the desired index, the method is ignored. Information: * Returns true if successful. * Uses the mouse. .. note:: - by Obscurity - Last Updated: 2015-07-22 Example: .. code-block:: pascal if production.hasProduction()='production' then production.setProduct(2); *) function tProduction.setProduct(funcProduct:int32):boolean; var funcPointer:^glTexture; funcPointerSize:uInt32; funcProductFound:int32; funcPoint: TPoint; begin funcPointer:=glTextures(funcPointerSize)+oglTextureSize; for 1 to funcPointerSize-2 do begin if funcPointer^.id=360740 then begin case (funcPointer-oglTextureSize)^.id of 3573,360740:; else begin if funcProductFound=funcProduct then begin if (funcPointer+oglTextureSize)^.id<>360740 then begin funcPoint:=funcPointer^.bounds.normalizePoint(); clickMouse(funcPoint.x, funcPoint.y, 1); result:=true; end; break; end; if funcPointer^.colourID<>2177855 then funcProductFound:=funcProductFound+1; end; end; end; funcPointer+=oglTextureSize; end; exit(result); end; (* tProduction.setTool() ~~~~~~~~~~~~~~~~~~~~~ .. code-block:: pascal function tProduction.setTool(funcTool:int32):boolean; Description: Sets the tool to the desired index. Zero (0) is the first tool. If the tool is already set to the desired index, the method is ignored. Information: * Returns true if successful. * Uses the mouse. .. note:: - by Obscurity - Last Updated: 2015-07-22 Example: .. code-block:: pascal if production.hasProduction()='choose a tool' then production.setTool(1); *) function tProduction.setTool(funcTool:int32):boolean; var funcPointer:^glTexture; funcPointerSize:uInt32; funcToolFound:int32; funcPoint: TPoint; begin funcPointer:=glTextures(funcPointerSize)+oglTextureSize; for 1 to funcPointerSize-2 do begin case funcPointer^.id of 1054486,1054496: begin if funcToolFound=funcTool then begin funcPoint:=funcPointer^.bounds.normalizePoint(); clickMouse(funcPoint.x, funcPoint.y, 1); result:=true; break; end; funcToolFound:=funcToolFound+1; end; end; funcPointer+=oglTextureSize; end; exit(result); end; function tProduction.getDropDown(): string; var pInterface: glTextureArray; ddBox: tBox; begin if (pInterface := ogl.getTextures(127666, 198152)).isEmpty() then exit; ddBox := pinterface[0].bounds.adjustPosition(9, 25, 150, - 10); result := ogl.getChars(ddBox).toString(); end; function tProduction.setDropDown(setName: string; timeout: integer = 3000): boolean; var pInterface, ddBoxMenu: glTextureArray; ddBox: tBox; timer: tCountDown; begin if (pInterface := ogl.getTextures(127666, 198152)).isEmpty() or (self.getDropDown() = setName) then exit; ddBox := pinterface[0].bounds.adjustPosition(9, 25, 150, - 10); clickMouse(ddbox.normalizePoint().x, ddbox.normalizePoint().y, 1); timer.setTime(timeout); while (length(ddBoxMenu := ogl.getTextures(2244000)) < 2) do begin wait(50); if timer.isFinished() then exit; end; tmouse.click(setName); wait(50); if self.getDropDown() = setName then exit(true); end;