Advertisement
Guest User

LSS Bot RoK VIP Script Source Code

a guest
Oct 2nd, 2022
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.79 KB | None | 0 0
  1. package com.lssbot.scripts.rok.vip;
  2.  
  3. import com.lssbot.core.api.device.Device;
  4. import com.lssbot.core.api.game.Game;
  5. import com.lssbot.core.api.geometry.BRectangle;
  6. import com.lssbot.core.api.random.RNG;
  7. import com.lssbot.core.api.script.AbstractScript;
  8. import com.lssbot.core.api.script.ExitCodes;
  9. import com.lssbot.core.api.script.ScriptManifest;
  10. import com.lssbot.core.api.script.config.Config;
  11.  
  12. /**
  13.  * @author Roma on 25.09.2022
  14.  */
  15. @ScriptManifest(
  16.         game = Game.RISE_OF_KINGDOMS,
  17.         name = "VIP",
  18.         version = 0.0,
  19.         timeoutMinutes = 7,
  20.         author = "LSS Bot",
  21.         description = "<p>Claims VIP rewards and opens the VIP chest</p>"
  22. )
  23. public class VIPScript extends AbstractScript {
  24.     private final VIPConfig CONFIG = new VIPConfig();
  25.     private BRectangle buttonGo;
  26.  
  27.     public VIPScript(Device device) {
  28.         super(device);
  29.     }
  30.  
  31.     @Override
  32.     public void onStop() {
  33.         if (isGoLevelUpButtonVisible()) {
  34.             pressGoButton();
  35.         } else if (isVIPMenuOpen()) {
  36.             rok().getMenu().close();
  37.             sleepUntil(() -> rok().getViewport().isInCity() || rok().getViewport().isOnMap(), 4000);
  38.         }
  39.     }
  40.  
  41.     @Override
  42.     public int loop() {
  43.         if (isVIPMenuOpen()) {
  44.             return claimRewards();
  45.         } else if (isGoLevelUpButtonVisible()) {
  46.             pressGoButton();
  47.         } else if (rok().getViewport().isInCity() || rok().getViewport().isOnMap()) {
  48.             if (rok().getViewport().openVIP()) {
  49.                 return claimRewards();
  50.             }
  51.         } else {
  52.             rok().getMenu().close();
  53.             return RNG.nextInt(2000, 3000);
  54.         }
  55.         return 0;
  56.     }
  57.  
  58.     @Override
  59.     public Config getConfig() {
  60.         return CONFIG;
  61.     }
  62.  
  63.     private int finishClaiming() {
  64.         if (sleepUntil(() -> !isVIPMenuOpen())) {
  65.             getMouse().clickRandomPointOnScreen();
  66.             if (sleepUntil(this::isVIPMenuOpen)) {
  67.                 return 2000;
  68.             }
  69.         }
  70.         return 0;
  71.     }
  72.  
  73.     private int claimRewards() {
  74.         final BRectangle buttonClaimItemRewards = getOpenCV().getAreaMatch(Images.BUTTON_CLAIM_ITEMS, 0.75);
  75.         if (buttonClaimItemRewards != null) {
  76.             device.log("Claiming VIP item rewards");
  77.             getMouse().click(buttonClaimItemRewards);
  78.             return finishClaiming();
  79.         }
  80.  
  81.         final BRectangle buttonClaimChestExp = getOpenCV().getAreaMatch(Images.BUTTON_CLAIM_CHEST, 0.75);
  82.         if (buttonClaimChestExp != null) {
  83.             device.log("Claiming VIP chest experience");
  84.             getMouse().click(buttonClaimChestExp);
  85.             return finishClaiming();
  86.         }
  87.         return ExitCodes.COMPLETED;
  88.     }
  89.  
  90.     private void pressGoButton() {
  91.         device.log("Pressing the go button (leveling VIP up)");
  92.         getMouse().click(buttonGo);
  93.         if (sleepUntil(() -> !isGoLevelUpButtonVisible())) {
  94.             sleep(RNG.nextInt(2000, 3000));
  95.         }
  96.     }
  97.  
  98.     private boolean isVIPMenuOpen() {
  99.         return rok().getMenu().isMenuOpen("VIP");
  100.     }
  101.  
  102.     private boolean isGoLevelUpButtonVisible() {
  103.         return (buttonGo = getOpenCV().getAreaMatch(Images.BUTTON_GO_LEVEL_UP, 0.7)) != null;
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement