Jump to content

Help me with my monkfish script:)


mikemouse2

Recommended Posts

Bank booths are objects.

				RS2Object bankBooth = closestObjectForName("Bank Booth");
				client.moveCameraToEntity(bankBooth);
				sleep(random(300,600));
				bankBooth.interact("Bank");
				sleep(random(500,800));

If you want to use an NPC banker, just do NPC and closestNPCForName("Banker");

 

 

ALSO

 

When you write a switch statement

            case FISHING:
            case  WALKING_TO_FISH_AREA:
            case  DOING_NOTHING:

Will all do the same thing, it's the same as saying case FISHING && WALKING etc, so if you're trying to switch states, make sure you have break; in there so you define what state does what.

 

Also, in your onLoop(), you want to outline when you're in what state:

if(fullInventory()) {

  if(inBank()) {

    state = bank

  } else {

    state = walking;

  }

} else {

  if(inFishingArea()) {

    state = fishing;

  } else {

    state = walking;

  }

}

I'm so noob, keep editing my post..

		case WALKING_TO_BANK:
			return walkToBank();
		break;



		int walkToBank() {
			if(BANK_AREA.contains(player)){
                NPC bankbooth = closestNPC(BANK_BOOTH_ID);                
                if(bank.isOpen()){
                    bank.depositAllExcept(303);
                    whatAmIDoing = I_AM.DOING_NOTHING;
                    
                }else{
                
                    if(bankbooth != null){
                        if(bankbooth.isVisible()){
                            bankbooth.interact("Bank");
                            sleep(random(700,800));
                        }else{
                            client.moveCameraToEntity(bankbooth);
                        }
                    }
                }
            }
			return 1000;
		}
Edited by thelegacy0
  • Like 1
Link to comment
Share on other sites

 

Bank booths are objects.

				RS2Object bankBooth = closestObjectForName("Bank Booth");
				client.moveCameraToEntity(bankBooth);
				sleep(random(300,600));
				bankBooth.interact("Bank");
				sleep(random(500,800));

If you want to use an NPC banker, just do NPC and closestNPCForName("Banker");

 

 

ALSO

 

When you write a switch statement

            case FISHING:
            case  WALKING_TO_FISH_AREA:
            case  DOING_NOTHING:

Will all do the same thing, it's the same as saying case FISHING && WALKING etc, so if you're trying to switch states, make sure you have break; in there so you define what state does what.

 

Also, in your onLoop(), you want to outline when you're in what state:

if(fullInventory()) {

  if(inBank()) {

    state = bank

  } else {

    state = walking;

  }

} else {

  if(inFishingArea()) {

    state = fishing;

  } else {

    state = walking;

  }

}

I'm so noob, keep editing my post..

		case WALKING_TO_BANK:
			return walkToBank();
		break;



		int walkToBank() {
			if(BANK_AREA.contains(player)){
                NPC bankbooth = closestNPC(BANK_BOOTH_ID);                
                if(bank.isOpen()){
                    bank.depositAllExcept(303);
                    whatAmIDoing = I_AM.DOING_NOTHING;
                    
                }else{
                
                    if(bankbooth != null){
                        if(bankbooth.isVisible()){
                            bankbooth.interact("Bank");
                            sleep(random(700,800));
                        }else{
                            client.moveCameraToEntity(bankbooth);
                        }
                    }
                }
            }
			return 1000;
		}

 

I would  do this all differently. What this does is force the script to do things that you can't control and are solely instance like and volatile.

 

What you should do is only change states in the switch statement. 

 

When you start your script, you should have an IDLE state so that your script passes off the state for the first time and you go from there.

 

I use a pre execution method, which is what I call it, because it's the method I run before I update the script and perform actions.

ScriptState sState = State.IDLE;

public void preExectutionRun(){

if(sState.equals(State.IDLE){

if(player inventory is full){

if(player is in bank){

sState = State.BANK_ITEMS;


}

if(player is in fishing area){

sState = State.GO_TO_BANK

}


}

}
//etc for if the inventory isn't full and 
//you have if statements for checking if
//you are in bank or fishing area.

}

Then I use a switch statement to carry out the script actions. Within this switch function I can be VERY VERY specific in when it switches states and when to Queue for the next state.

 

Drawn out example here.

 

http://pastebin.com/ZpNMSh7K

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...