Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from manager import *
- from core import Helpers, ImageMatch, ScreenImage, Point2D
- import settings, time, random
- from manager import ActionInstance
- eventMgr = ActionManager('_Event')
- behaviourMgr = BehaviourManager()
- screen = ScreenImage(region=([0, 0], [1924, 968]))
- def Action_ResupplyCorn(instance):
- # Refresh screen image buffer
- screen.refresh()
- # Drag chopped corn to container (Fix a random result position a bit)
- Helpers.loopUntilSuccess(lambda:
- behaviourMgr.mouseDrag(
- ImageMatch(screen.image, 'inventory/stackedchoppedcorn_item.png', tolerance=95, offset=Point2D(30, 0)),
- ImageMatch(screen.image, 'storage/choppedcorn_item.png', tolerance=95)
- ),
- delay = settings.DELAY_BEETWEN_OPERATION
- )
- # Refresh screen image buffer & sleep before next operation
- Helpers.randomSleep(*settings.DELAY_BEETWEN_OPERATION)
- screen.refresh()
- # Drag corn from container to inventory
- Helpers.loopUntilSuccess(lambda:
- behaviourMgr.dragItemFromStorageContainer(
- ImageMatch(screen.image, 'storage/corn_item.png', tolerance=95),
- ImageMatch(screen.image, 'inventory/inventory_group.png', tolerance=90),
- amount = 80
- ),
- delay = settings.DELAY_BEETWEN_OPERATION
- )
- # Refresh screen image buffer & sleep before next operation
- Helpers.randomSleep(*settings.DELAY_BEETWEN_OPERATION)
- screen.refresh()
- # Drag corn from inventory to empty slot in crafting window
- Helpers.loopUntilSuccess(lambda:
- behaviourMgr.craftingWindowDragToEmptySlot(
- screen.image,
- ImageMatch(screen.image, 'inventory/stackedcorn_item.png', offset=Point2D(30, 0))
- ),
- delay = settings.DELAY_BEETWEN_OPERATION
- )
- def Action_OnCreate_ChoppedCorn(instance):
- # Refresh screen image buffer
- screen.refresh()
- # Calculate action duration (-+ thread sleep duraction)
- actionTime = time.time() - float(instance.get('actionTimer') or 0)
- # If there is no corn on crafting window left
- if not ImageMatch(screen.image, 'craftingwindow/corn_icon.png').isValid():
- # Try to resupply corn until success
- Action_ResupplyCorn(instance)
- # Hold on for a sec when timer will be too long
- print(actionTime)
- if actionTime >= 2.3:
- Helpers.randomSleep(4200, 7000)
- else:
- Helpers.randomSleep(100, 700)
- behaviourMgr.craftingWindowCreate(screen.image)
- def Action_OnQueue_ChoppedCorn(instance):
- instance.set('actionTimer', time.time())
- def main():
- sharedInstance = ActionInstance()
- eventMgr.addEvent(Action_OnCreate_ChoppedCorn, 'You create a raw\+chopped corn.', onlyOnce=False, instance=sharedInstance)
- eventMgr.addEvent(Action_OnQueue_ChoppedCorn, 'You start to work with the knife on the corn.', onlyOnce=True, instance=sharedInstance)
- try:
- eventMgr.start(attached=True, interval=[10, 50])
- except KeyboardInterrupt:
- eventMgr.stop()
- if __name__ == '__main__':
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement