Jump to content

smile

Helpers
  • Posts

    74
  • Joined

  • Last visited

  • Days Won

    5

Posts posted by smile

  1. import com.epicbot.api.shared.APIContext;
    import com.epicbot.api.shared.GameType;
    import com.epicbot.api.shared.entity.NPC;
    import com.epicbot.api.shared.entity.Player;
    import com.epicbot.api.shared.script.LoopScript;
    import com.epicbot.api.shared.script.ScriptManifest;
    import com.epicbot.api.shared.util.Random;
    import com.epicbot.api.shared.util.paint.frame.PaintFrame;
    import com.epicbot.api.shared.util.time.Time;
    import java.awt.*;
    
    //Script Manifest stuff for your script selector
    @ScriptManifest(name = "sCowKiller", gameType = GameType.OS)
    public class main extends LoopScript {
        //instantiate variable to be used later.
        private Player local_Player;
        private long startTime;
        private State state;
        private String playerState;
        private int strengthLevel;
        private int percentTNL;
        private NPC cowNPC;
    
        @Override
        public boolean onStart(String... strings) {
            //when the script starts, startTime is set equal to the current millisecond which is used for the runtime later on.
            startTime = System.currentTimeMillis();
            System.out.println("Starting sCowKiller!");
            return true;
        }
        @Override
        protected void onPause() {
            playerState = "Script is paused";
            getAPIContext().mouse().moveOffScreen();
        }
        //An enum of all the States
        private enum State {
            QUERYING,
            FIGHTING,
            ENABLING_RUN
        }
        // A getter for the player's state and defining what causes the state to change
        private State getPlayerState() {
    
            if (getAPIContext().client().isLoggedIn() && getAPIContext().localPlayer().get() != null) {
                local_Player = getAPIContext().localPlayer().get();
                if (local_Player.getAnimation() != -1) {
                    state = State.FIGHTING;
                } else if (local_Player.getAnimation() == -1) {
                    state = State.QUERYING;
                } else if (!getAPIContext().walking().isRunEnabled()) {
                    state = State.ENABLING_RUN;
                }
            }
            return state;
        }
        private NPC getCowNPC() {
            return getAPIContext().npcs().query()
                    //what we're querying for
                    .nameMatches("Cow")
                    .notInCombat()
                    .animation(-1)
                    .reachable()
                    .results()
                    .nearest();
        }
        private void attack() {
            cowNPC.click();
            getAPIContext().mouse().moveOffScreen();
        }
        // The actual loop method
        @Override
        protected int loop() {
            if (!getAPIContext().client().isLoggedIn()) {
                return 500;
            }
            switch (getPlayerState()) { // switch case for setting player state
                case FIGHTING:
                    playerState = "Fighting";
                    break;
                case QUERYING:
                    playerState = "Querying";
                    break;
                case ENABLING_RUN:
                    playerState = "Enabling run";
                default:
                    playerState = "ERROR";
                    break;
            }
            //shit for determining skill XP/Time to level/etc
            strengthLevel = getAPIContext().skills().strength().getCurrentLevel();
            percentTNL = getAPIContext().skills().strength().getPercentToNextLevel();
    
            if (getAPIContext().localPlayer().getInteracting() == null) {
                cowNPC = getCowNPC();
                // if the local player is not interacting
                if (cowNPC != null && !cowNPC.isDead()) { //if the cow npc query is not dead
    
                    attack(); // do the attack method
                    if (local_Player.getInteracting() != null) { // if our player is interacting
                        Time.sleep(6000, () -> cowNPC.isDead()); // sleep until cow npc is dead
                    }
                    if (local_Player.isMoving() || cowNPC.isInteractingWithMe() || local_Player.getInteracting() == null) {
                        if (!getAPIContext().walking().isRunEnabled()) {
                            if (getAPIContext().walking().getRunEnergy() >= Random.nextInt(55,100)) {
                                getAPIContext().walking().setRun(true);
                            }
                        } else if (getAPIContext().walking().isRunEnabled()) {
                            if (getAPIContext().walking().getRunEnergy() <= Random.nextInt(10,15)) {
                                getAPIContext().walking().setRun(false);
                            }
                        }
                    }
                }
            }
            return 200;
        }
        // paint shit.
        @Override
        protected void onPaint(Graphics2D g, APIContext ctx) {
            if (!getAPIContext().client().isLoggedIn()) {
                Time.sleep(15_000, () -> getAPIContext().client().isLoggedIn());
            }
            if (getAPIContext().client().isLoggedIn()) {
                PaintFrame frame = new PaintFrame();
                frame.setTitle("sCowKiller");
                frame.addLine("Runtime: ", Time.getFormattedRuntime(startTime)); // we use startTime here from the very beginning
                frame.addLine("State: ", playerState); //we get whatever the player's state is equal to and print it onto the paint.
                frame.addLine("", "");
                frame.addLine("Current Strength level: ", strengthLevel);
                frame.addLine("% to next level", percentTNL);
                frame.draw(g, 0, 90, ctx); //drawing the actual frame.
                g.setColor(new Color(208, 189, 155, 255));
                g.fillRect(11, 468, 120, 15); //name covering stuff, honestly might remove it cuz kinda pointless? Dunno
            }
        }
    }
    • Thanks 2
    • Haha 1
    • Sad 3
  2. Bug Description: Gets Stuck when exiting a completed game, doesn't try to click on the bank chest/on the minimap
    How to recreate the bug: Nothing 100% recreatable yet, so far it's only when you complete a game and are exiting. Will update if I find a better way to recreate
    Screenshots/Videos/GIF:

    image.png.fb0850167f495f58d0f01e34a41ba0c0.png

  3. Bug Description: GUI doesn't open on script start
    How to recreate: Start Simple Fighter from script selector, the paint will come up but no GUI
    GIF: 

    Logger output:

    [08:46:20.831][STDOUT][277] Opening gui loop
    [08:46:20.837][STDOUT][277] Opening GUI
    [08:46:21.839][STDERR][277] Exception in thread "Thread-Bot4-19" 
    [08:46:21.841][STDERR][277] java.lang.NoSuchMethodError: com.epicbot.api.shared.util.time.Time.sleep(II)V
    [08:46:21.843][STDERR][277]     at proSimpleFighter.openGUI(proSimpleFighter.java:118)
    [08:46:21.844][STDERR][277]     at proSimpleFighter.loop(proSimpleFighter.java:45)
    [08:46:21.847][STDERR][277]     at com.epicbot.api.shared.script.LoopScript$LoopTask.run(dz:96)
    [08:46:21.848][STDERR][277]     at com.epicbot.api.shared.script.ScriptTaskContainer.runTask(pu:137)
    [08:46:21.849][STDERR][277]     at com.epicbot.api.shared.script.ScriptTaskContainer.run(pu:142)
    [08:46:21.850][STDERR][277]     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    [08:46:21.851][STDERR][277]     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    [08:46:21.852][STDERR][277]     at java.lang.Thread.run(Thread.java:748)

  4. Pro Smither - Have the bot use the "withdraw X" option instead of right clicking on the item and then doing "withdraw X" when doing bronze bars because right now it just right clicks on "withdraw X" on the item and adds more clicks than there needs to be.
    Pro Smither - Have the bot use hotkeys when using the furnace so it doesn't need to use the mouse more efficient that way :classic_smile:

×
×
  • Create New...