Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.lssbot.scripts.rok.vip;
- import com.lssbot.core.api.device.Device;
- import com.lssbot.core.api.game.Game;
- import com.lssbot.core.api.geometry.BRectangle;
- import com.lssbot.core.api.random.RNG;
- import com.lssbot.core.api.script.AbstractScript;
- import com.lssbot.core.api.script.ExitCodes;
- import com.lssbot.core.api.script.ScriptManifest;
- import com.lssbot.core.api.script.config.Config;
- /**
- * @author Roma on 25.09.2022
- */
- @ScriptManifest(
- game = Game.RISE_OF_KINGDOMS,
- name = "VIP",
- version = 0.0,
- timeoutMinutes = 7,
- author = "LSS Bot",
- description = "<p>Claims VIP rewards and opens the VIP chest</p>"
- )
- public class VIPScript extends AbstractScript {
- private final VIPConfig CONFIG = new VIPConfig();
- private BRectangle buttonGo;
- public VIPScript(Device device) {
- super(device);
- }
- @Override
- public void onStop() {
- if (isGoLevelUpButtonVisible()) {
- pressGoButton();
- } else if (isVIPMenuOpen()) {
- rok().getMenu().close();
- sleepUntil(() -> rok().getViewport().isInCity() || rok().getViewport().isOnMap(), 4000);
- }
- }
- @Override
- public int loop() {
- if (isVIPMenuOpen()) {
- return claimRewards();
- } else if (isGoLevelUpButtonVisible()) {
- pressGoButton();
- } else if (rok().getViewport().isInCity() || rok().getViewport().isOnMap()) {
- if (rok().getViewport().openVIP()) {
- return claimRewards();
- }
- } else {
- rok().getMenu().close();
- return RNG.nextInt(2000, 3000);
- }
- return 0;
- }
- @Override
- public Config getConfig() {
- return CONFIG;
- }
- private int finishClaiming() {
- if (sleepUntil(() -> !isVIPMenuOpen())) {
- getMouse().clickRandomPointOnScreen();
- if (sleepUntil(this::isVIPMenuOpen)) {
- return 2000;
- }
- }
- return 0;
- }
- private int claimRewards() {
- final BRectangle buttonClaimItemRewards = getOpenCV().getAreaMatch(Images.BUTTON_CLAIM_ITEMS, 0.75);
- if (buttonClaimItemRewards != null) {
- device.log("Claiming VIP item rewards");
- getMouse().click(buttonClaimItemRewards);
- return finishClaiming();
- }
- final BRectangle buttonClaimChestExp = getOpenCV().getAreaMatch(Images.BUTTON_CLAIM_CHEST, 0.75);
- if (buttonClaimChestExp != null) {
- device.log("Claiming VIP chest experience");
- getMouse().click(buttonClaimChestExp);
- return finishClaiming();
- }
- return ExitCodes.COMPLETED;
- }
- private void pressGoButton() {
- device.log("Pressing the go button (leveling VIP up)");
- getMouse().click(buttonGo);
- if (sleepUntil(() -> !isGoLevelUpButtonVisible())) {
- sleep(RNG.nextInt(2000, 3000));
- }
- }
- private boolean isVIPMenuOpen() {
- return rok().getMenu().isMenuOpen("VIP");
- }
- private boolean isGoLevelUpButtonVisible() {
- return (buttonGo = getOpenCV().getAreaMatch(Images.BUTTON_GO_LEVEL_UP, 0.7)) != null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement