Jump to content

Script I just made is not running?


Snowydell

Recommended Posts

Try to be more specific? Maybe post your code? Im guessing you didn't add a manifest or something of that nature.

import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.Area;
 
import java.awt.*;
 
@ScriptManifest(author = "Tyler", info = "Start in Lumbridg Cow Pen", name = "Cow Killer", version = 0, logo = "")
 
public class CowKiller extends Script 
{
//Declare Variables
Area COW_AREA = new Area(3265, 3298, 3253, 3255);
Area BANK_AREA = new Area(3207, 3222, 3210, 3216);
Area STAIRS_AREA = new Area(3203, 3206, 3207, 3210);
NPC cow = npcs.closest("Cow","Cow calf");
 
//WALK FROM COW PEN TO STAIRS
private Position[] PATH_PEN_TO_STAIRS = 
new Position(3255, 3267, 0),
new Position(3250, 3260, 0),
new Position(3252, 3253, 0),
new Position(3256, 3247, 0),
new Position(3259, 3241, 0),
new Position(3259, 3233, 0),
new Position(3255, 3227, 0),
new Position(3249, 3226, 0),
new Position(3243, 3225, 0),
new Position(3235, 3220, 0),
new Position(3225, 3218, 0),
new Position(3218, 3218, 0),
new Position(3215, 3213, 0),
new Position(3206, 3209, 0)
};
//WALK FROM STAIRS TO BANK
private Position[] PATH_STAIRS_TO_BANK = 
new Position(3206, 3215, 2),
new Position(3208, 3220, 2),
};
//WALK FROM BANK TO STAIRS
private Position[] PATH_BANK_TO_STAIRS = 
new Position(3205, 3216, 2),
new Position(3205, 3209, 2),
};
//WALK FROM STAIRS TO PEN
private Position[] PATH_STAIRS_TO_PEN = 
new Position(3206, 3209, 0),
new Position(3215, 3213, 0),
new Position(3218, 3218, 0),
new Position(3225, 3218, 0),
new Position(3235, 3220, 0),
new Position(3243, 3225, 0),
new Position(3249, 3226, 0),
new Position(3255, 3227, 0),
new Position(3259, 3233, 0),
new Position(3259, 3241, 0),
new Position(3256, 3247, 0),
new Position(3252, 3253, 0),
new Position(3250, 3260, 0),
new Position(3255, 3267, 0),
};
 
//OnStart
public void onStart() 
{
log("Welcome to my Cow Killer!");
log("Enjoy the script!");
}
 
//Declare State
private enum State 
{
ATTACK,
WALK_TO_STAIRS_FROM_PEN,
GO_UPSTAIRS1,
GO_UPSTAIRS2,
WALK_TO_BANK,
WALK_TO_STAIRS_FROM_BANK,
GO_DOWNSTAIRS1,
GO_DOWNSTAIRS2,
WALK_TO_PEN,
BANK,
WAIT,
}
 
//Finds State
private State getState() 
{
//ATTACKS
if(!inventory.isFull() && COW_AREA.contains(myPlayer()) && !myPlayer().isUnderAttack()  && !cow.isUnderAttack() && cow != null)
{
return State.ATTACK;
}
//WALK FROM COW PEN TO STAIRS
if(inventory.isFull() && COW_AREA.contains(myPlayer()))
{
return State.WALK_TO_STAIRS_FROM_PEN;
}
//GOES UP FIRST SET OF STAIRS
if(myPosition().getZ() == 0 && STAIRS_AREA.contains(myPlayer()) && inventory.isFull())
{
return State.GO_UPSTAIRS1;
}
//GOES UP SECOND SET OF STAIRS
if(myPosition().getZ() == 1 && STAIRS_AREA.contains(myPlayer()) && inventory.isFull())
{
return State.GO_UPSTAIRS2;
}
//WALKS FROM STAIRS TO BANK
if(myPosition().getZ() == 2 && STAIRS_AREA.contains(myPlayer()) && inventory.isFull())
{
return State.WALK_TO_BANK;
}
//BANKS ITEMS
if(myPosition().getZ() == 2 && BANK_AREA.contains(myPlayer()) && inventory.isFull())
{
return State.BANK;
}
//WALKS FROM BANK BACK TO STAIRS
if(myPosition().getZ() == 2 && BANK_AREA.contains(myPlayer()) && inventory.isEmpty())
{
return State.WALK_TO_STAIRS_FROM_BANK;
}
//GOES DOWN STAIRS TO REACH SECOND FLOOR
if(myPosition().getZ() == 2 && STAIRS_AREA.contains(myPlayer()) && inventory.isEmpty())
{
return State.GO_DOWNSTAIRS1;
}
//GOES DOWN STAIRS TO REACH FIRST FLOOR
if(myPosition().getZ() == 1 && STAIRS_AREA.contains(myPlayer()) && inventory.isEmpty())
{
return State.GO_DOWNSTAIRS2;
}
//WALKS FROM LUMBRIDGE CASTLE TO COW PEN
if(myPosition().getZ() == 0 && STAIRS_AREA.contains(myPlayer()) && inventory.isEmpty())
{
return State.WALK_TO_PEN;
}
return State.WAIT;
}
 
//Executes State
public int onLoop() throws InterruptedException 
{
switch (getState()) 
{
//ATTACKING
case ATTACK:
cow = npcs.closest("Cow","Cow calf");
cow.interact("Attack");
break;
 
//WALKS FROM COW PEN TO STAIRS
case WALK_TO_STAIRS_FROM_PEN:
localWalker.walkPath(PATH_PEN_TO_STAIRS);
break;
 
//GOES UP FIRST SET OF STAIRS
case GO_UPSTAIRS1:
objects.closest("Staircase").interact("Climb-up");
sleep(random(300, 500));
break;
 
//GOES UP SECOND SET OF STAIRS
case GO_UPSTAIRS2:
objects.closest("Staircase").interact("Climb-up");
sleep(random(300, 500));
break;
 
//WALKS FROM STAIRS TO BANK
case WALK_TO_BANK:
localWalker.walkPath(PATH_STAIRS_TO_BANK);
sleep(random(300, 500));
break;
 
//BANKS ITEMS
case BANK:
bank.open();
sleep(random(450, 500));
bank.depositAll();
sleep(random(300, 500));
bank.close();
break;
 
//WALKS FROM BANK BACK TO STAIRS
case WALK_TO_STAIRS_FROM_BANK:
localWalker.walkPath(PATH_BANK_TO_STAIRS);
sleep(random(300, 500));
break;
 
//GOES DOWN STAIRS TO REACH SECOND FLOOR
case GO_DOWNSTAIRS1:
objects.closest("Staircase").interact("Climb-down");
sleep(random(300, 500));
break;
 
//GOES DOWN STAIRS TO REACH FIRST FLOOR
case GO_DOWNSTAIRS2:
objects.closest("Staircase").interact("Climb-down");
sleep(random(300, 500));
break;
 
//WALKS FROM LUMBRIDGE CASTLE TO COW PEN
case WALK_TO_PEN:
localWalker.walkPath(PATH_STAIRS_TO_PEN);
sleep(random(300, 500));
break;
 
//WAIT
case WAIT:
sleep(random(500, 700));
break;
}
return random(200, 300);
}
 
//On Exit
public void onExit() 
{
log("Thanks for running Oak Cutter!");
}
 
 
public void onPaint(Graphics2D g) 
{
 
}
 
Link to comment
Share on other sites

NPC cow = npcs.closest("Cow","Cow calf");

 

That shouldn't be declared outside a method, remove that and remove 

 

               if(!inventory.isFull() && COW_AREA.contains(myPlayer()) && !myPlayer().isUnderAttack()  && !cow.isUnderAttack() && cow != null)
                {
                        return State.ATTACK;
                }
 
the red part along with it
 
EDIT:
 
Also, try to debug this in onPaint(Graphics2D g)
 
g.drawString(getState().toString(), 15, 15);
 
Just to know which state you are in, it helps alot.
Edited by Czar
  • Like 2
Link to comment
Share on other sites

 

NPC cow = npcs.closest("Cow","Cow calf");

 

That shouldn't be declared outside a method, remove that and remove 

 

               if(!inventory.isFull() && COW_AREA.contains(myPlayer()) && !myPlayer().isUnderAttack()  && !cow.isUnderAttack() && cow != null)
                {
                        return State.ATTACK;
                }
 
the red part along with it
 
EDIT:
 
Also, try to debug this in onPaint(Graphics2D g)
 
g.drawString(getState().toString(), 15, 15);
 
Just to know which state you are in, it helps alot.

 

Thank you so much it's working now :)

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...