Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- ========== Settings ================
- Settings:setCompareDimension(true, 960)
- Settings:setScriptDimension(true, 960)
- Settings:set("MinSimilarity", 0.75)
- counters = {
- buy = 0,
- fail = 0,
- success = 0
- }
- regions = {
- defeatedReady = Region(241, 172, 223, 77),
- drop = Region(574, 43, 153, 153),
- dropAd = Region(485, 358, 224, 78),
- energy = Region(137, 143, 141, 137),
- energyBuy = Region(390, 392, 178, 68),
- energyClose = Region(820, 44, 100, 92),
- energyConfirm = Region(402, 352, 158, 68),
- label = Region(340, 173, 292, 93),
- replay = Region(245, 269, 231, 84),
- resurrect = Region(484, 262, 232, 95),
- start = Region(772, 412, 188, 128)
- }
- logFileName = scriptPath() .. "log.txt"
- log = io.open(logFileName, "a+")
- -- ========== main program ===========
- function updateStopMessage()
- setStopMessage("success: " .. counters["success"] .. ", fails: " .. counters["fail"] .. ", buys: " .. counters["buy"])
- end
- function waitAndClick(region, image, delay)
- region:waitClick(image, delay)
- end
- function buyEnergy()
- waitAndClick(regions["energy"], "energyPiece.png", 2)
- waitAndClick(regions["energyBuy"], "energyBuy.png", 2)
- waitAndClick(regions["energyConfirm"], "energyConfirm.png", 3)
- waitAndClick(regions["energyClose"], "close.png", 20)
- counters["buy"] = counters["buy"] + 1
- log:write("energy purchase. Total is " .. counters["buy"] .. "\n")
- updateStopMessage()
- end
- math.randomseed(os.time())
- while (true) do
- waitAndClick(regions["start"], "startButton.png", 3)
- battleWait = 120
- toast('start')
- while (true) do
- wait(battleWait)
- snapshot()
- local victoryRes = regions["label"]:exists("victoryLabel.png", 2)
- local failRes = regions["resurrect"]:exists("resurrectNo.png", 2)
- delay = math.random(5, 20)
- if (victoryRes) then
- toast('success, click after ' .. delay)
- counters["success"] = counters["success"] + 1
- log:write("success. Total success is " .. counters["success"] .. "\n")
- updateStopMessage()
- wait(delay)
- waitAndClick(regions["label"], "victoryLabel.png", 5)
- waitAndClick(regions["drop"], "close.png", 15)
- local adExists = regions["dropAd"]:exists("dropAdNo.png", 6)
- if (adExists) then
- waitAndClick(regions["dropAd"], "dropAdNo.png", 2)
- end
- waitAndClick(regions["replay"], "victoryReplay.png", 5)
- local energyRes = regions["energy"]:exists("energyPiece.png", 5)
- if (energyRes) then
- buyEnergy()
- waitAndClick(regions["replay"], "victoryReplay.png", 5)
- end
- battleWait = 120
- elseif (failRes) then
- toast('fail, click after ' .. delay)
- counters["fail"] = counters["fail"] + 1
- log:write("fail. Total fail is " .. counters["fail"] .. "\n")
- updateStopMessage()
- wait(delay)
- waitAndClick(regions["resurrect"], "resurrectNo.png", 5)
- wait(3)
- local wasFreeRes = regions["resurrect"]:exists("resurrectNo.png", 6)
- if (wasFreeRes) then
- waitAndClick(regions["resurrect"], "resurrectNo.png", 2)
- end
- waitAndClick(regions["label"], "defeatedLabel.png", 5)
- waitAndClick(regions["defeatedReady"], "defeatedReady.png", 5)
- waitAndClick(regions["start"], "startButton.png", 5)
- local energyRes = regions["energy"]:exists("energyPiece.png", 5)
- if (energyRes) then
- buyEnergy()
- waitAndClick(regions["start"], "startButton.png", 5)
- end
- battleWait = 120
- else
- toast('not ready yet, wait 30s')
- battleWait = 30
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement