Jump to content
omgwizzle

First time scripting, script repeatedly clicking starting tile.

Recommended Posts

Quote

package scripts.TestWoodCutter; import org.tribot.api.General; import org.tribot.api.input.Mouse; import org.tribot.api2007.*; import org.tribot.api2007.types.RSNPC; import org.tribot.api2007.types.RSTile; import org.tribot.script.Script; import org.tribot.script.ScriptManifest; import static org.tribot.api.General.random; /** * Created by Letlo on 7/12/2016. */ @ScriptManifest(authors = "Omgwizzle", name = "scripts.idk", category = "Combat") public class idk extends Script { private RSNPC[] npc; private RSNPC nearest; private RSTile SAFE; private boolean False = false; public int randomness; @Override public void run() { startScript(); while (loop()) { } } private void startScript() { Mouse.setSpeed(105); SAFE = Player.getPosition(); } public boolean loop() { if (False) { } else { attack(SAFE); } return true; } public void attack(RSTile startTile) { npc = NPCs.findNearest(15, 2515); nearest = npc[0]; if (!Player.getRSPlayer().isInCombat() && !nearest.isInCombat()) { randomness = 1 + General.random(1, 99); if (nearest.isOnScreen()) { if ((randomness > 50)) { nearest.click("Attack"); sleep(1500, 2250); } else { Mouse.click(nearest.getModel().getTriangles()[0].getBounds().getLocation(), 1); sleep(1500, 2250); } } else { Camera.turnToTile(nearest.getPosition()); } } else if (Player.getPosition() != startTile) { Walking.walkTo(startTile); sleep(600, 940); } } }

Trying to get my script to attack a monster with a safespot. If my character is not on the safespot I want the script to click back on the tile, but even when on the tile it only clicks that.

Share this post


Link to post
Share on other sites
29 minutes ago, omgwizzle said:

Trying to get my script to attack a monster with a safespot. If my character is not on the safespot I want the script to click back on the tile, but even when on the tile it only clicks that.

Try reposting your code into a code formatting rather than quote formatting

Share this post


Link to post
Share on other sites
package scripts.TestWoodCutter;

import org.tribot.api.General;
import org.tribot.api.input.Mouse;
import org.tribot.api2007.*;
import org.tribot.api2007.types.RSNPC;
import org.tribot.api2007.types.RSTile;
import org.tribot.script.Script;
import org.tribot.script.ScriptManifest;

import static org.tribot.api.General.random;


/**
 * Created by Letlo on 7/12/2016.
 */


@ScriptManifest(authors = "Omgwizzle", name = "scripts.idk", category = "Combat")
public class idk extends Script {


    private RSNPC[] npc;
    private RSNPC nearest;
    private RSTile SAFE;
    private boolean False = false;
    public int randomness;


    @Override
    public void run() {
        startScript();
        while (loop()) {

        }
    }

    private void startScript() {

        Mouse.setSpeed(105);
        SAFE = Player.getPosition();

    }


    public boolean loop() {

        if (False) {

        } else {
            attack(SAFE);

        }
        return true;
    }

    public void attack(RSTile startTile) {
        npc = NPCs.findNearest(15, 2515);
        nearest = npc[0];
        if (!Player.getRSPlayer().isInCombat() && !nearest.isInCombat()) {
            randomness = 1 + General.random(1, 99);
            if (nearest.isOnScreen()) {
                if ((randomness > 50)) {
                    nearest.click("Attack");
                    sleep(1500, 2250);
                }
                else {
                    Mouse.click(nearest.getModel().getTriangles()[0].getBounds().getLocation(), 1);
                    sleep(1500, 2250);
                }
            } else {
                Camera.turnToTile(nearest.getPosition());
            }
        } else if (Player.getPosition() != startTile) {
            Walking.walkTo(startTile);
            sleep(600, 940);

        }

    }
}

Sorry, I didn't notice the code quote

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Our picks

    • This release will:

      Fix key event handling issue


      Fix other event handling issue


      Fix RSServer hook


      Update world hopper to have it use OCR, thanks to Todd


      Use proper disposal of old Graphics objects


      Reformat code


      Rearrange code


      Organize code imports


      Apply around 8000 automated code refactorings


      Make preparations for Java 9


      Fix 11 various bugs


      Add more reliable debugging support


      Fix mouseEntered/Exited event dispatching bug


      Fix minimap walking bug where it opens the map


      Fix broken hooks for today's game update
        • Thanks
        • Like
      • 51 replies
    • This update will:

      Fix GE inventory item positioning bug


      Fix broken object hooks
        • Like
      • 27 replies
    • This release will:

      Fix some ClosedChannelException bug


      Fix bug in RSObject#getAllTiles


      Add game tab support for "Kourend Favour"
        • Like
      • 15 replies
    • This release will:

      Fix Settings UI placement bug


      Fix game object location bug


      Fix small layout bug making the client shift up and down


      Fix client crashing bug where loading the client with a small display area will cause the client to crash


      Fix annoying Linux bug relating to painting events and peers


      Fix settings saving bug where settings are saved to disk more often than they should


      Fix RSInterface#isBeingDrawn bug affecting a limited amount of people


      Drop Java 1.7 bytecode version for 1.8


      Important: Since the downloadable RS client uses Java 7, it will no longer be compatible with Looking Glass. To make up for this, we will add support for using other clients such as RuneLite (at a later date).


      This change was necessary to allow us to use Java 8 syntax. It also paves the way for Java 9/10/11 support.
        • Like
      • 40 replies
    • This update will:

      Fix the RSMenuNode bug which also fixes the bug with bank opening


      Fix the incorrect object positions bug


      Fix and re-enable the LG Objects API Accelerator


      Fix the RSObject#getAllTiles bug
        • Like
      • 22 replies
  • Recently Browsing   0 members

    No registered users viewing this page.

×