Jump to content

Code being skipped ?


whipz

Recommended Posts

Hey guys; I thought I should re-edit and make it a bit neater;

 

Here is my problem, this bit of code keeps getting skipped.

if (bank.isOpen()) {
			if(inventory.isEmpty()) {
				if (getBank().getWithdrawMode().equals(
						Bank.BankMode.WITHDRAW_NOTE)) {
					getBank().withdrawAll("Raw beef");
					log("Withdrawing Noted Beef");
					sleep(random(750, 1500));
				} else {
					bank.enableMode(Bank.BankMode.WITHDRAW_NOTE);
					log("changing to withdraw note mode");
					sleep(random(750, 1500));
				}
			} else {
					bank.depositAll();
			}
			sleep(random(1000, 2500));

The withdraw as a note method just constantly gets skipped;

 

I have a feeling its to do with my states, which are here;

private State getState() {
		if (!inventory.isFull() && cowArea.contains(myPlayer()))
			return State.PICKUP;
		if (inventory.contains("Raw Beef") && muleArea.contains(myPlayer()))
			return State.TRADE;
		if (!inventory.isFull() && !cowArea.contains(myPlayer()))
			return State.WALKTOPICKUP;
		if (inventory.isFull() && !muleArea.contains(myPlayer()))
			return State.WALKTOMULE;
		return State.WAIT;
	}

and

switch (getState()) {
		case PICKUP:
			doPickUp();
			break;
		case WALKTOMULE:
			getWalking().webWalk(muleArea);
			break;
		case TRADE:
			getNotedItems();
			tradeMule();
			offerItems();
			acceptTrade();
			break;
		case WALKTOPICKUP:
			getWalking().webWalk(cowArea);
			break;
		case STOP:
			this.stop();
			break;
		case WAIT:
			sleep(random(200, 300));
			break;
		}
		return random(200, 300);

	}

See I want to withdraw them as a note obviously so I can trade to my mule; however I think my return state for trade fails as I only want it to be recognized as a noted item; but it obviously just skips back to thinking it needs to walk back to cowarea which is not needed to be done till after its finished the trade method;

 

Any help would be appreciated as im stuck as lol

 

Edited by whipz
Link to comment
Share on other sites

if open()
   if withdrawmode is note
      //withdraw
   else setToNote()
else open()

 

Thanks I have done that with this yet I still seem to have the problem it seems to skip it

if (bank.isOpen()) {
			if(inventory.isEmpty()) {
				if (getBank().getWithdrawMode().equals(
						Bank.BankMode.WITHDRAW_NOTE)) {
					getBank().withdrawAll("Raw beef");
					log("Withdrawing Noted Beef");
					sleep(random(750, 1500));
				} else {
					bank.enableMode(Bank.BankMode.WITHDRAW_NOTE);
					log("changing to withdraw note mode");
					sleep(random(750, 1500));
				}
			} else {
					bank.depositAll();
			}
			sleep(random(1000, 2500));
		} else {
				int rand = random(3);
				if (rand == 1) {
					closestBankBooth.interact("Bank");
					log("Using Bank Booth");
					sleep(random(750, 1500));
					
				} else {
					closestBanker.interact("Bank");
					log("Using NPC Banker");
					sleep(random(750, 1500));
				}
				sleep(random(1000, 2500));
				log("Opening Bank");
			}
		}
	}

what chris said.

 

also, you need to fix your bracketing and your comments. it is making your code more difficult to read than it needs to be

 

Its fine in my ide I just wasnt using the code thing at the top i was just using code in []

 

EDIT:

 

I just realised it could be with my states;

private State getState() {
		if (!inventory.isFull() && cowArea.contains(myPlayer()))
			return State.PICKUP;
		if (inventory.contains("Raw Beef") && muleArea.contains(myPlayer()))
			return State.TRADE;
		if (!inventory.isFull() && !cowArea.contains(myPlayer()))
			return State.WALKTOPICKUP;
		if (inventory.isFull() && !muleArea.contains(myPlayer()))
			return State.WALKTOMULE;
		return State.WAIT;
	}
public int onLoop() throws InterruptedException {
		switch (getState()) {
		case PICKUP:
			doPickUp();
			break;
		case WALKTOMULE:
			getWalking().webWalk(muleArea);
			break;
		case TRADE:
			getNotedItems();
			tradeMule();
			offerItems();
			acceptTrade();
			break;
		case WALKTOPICKUP:
			getWalking().webWalk(cowArea);
			break;
		case STOP:
			this.stop();
			break;
		case WAIT:
			sleep(random(200, 300));
			break;
		}
		return random(200, 300);

	}
Edited by whipz
Link to comment
Share on other sites


if (!inventory.isFull() && !cowArea.contains(myPlayer()))
			return State.WALKTOPICKUP;

Well of course it will run back... inventory isnt full so its switching states

 

 

Yeah I just noticed it before that was the reason for edit; But i cant think of a way to get around it now while still needing to be in the same area to trade the mule;

 

If i was to add to that line that your on now that you quoted and added !bank.isOpen(); would that fix my problem ?

Link to comment
Share on other sites

WalkToPickUp state. You know what i mean

 

just check bank for beef.

 

if contains beef

withdraw

 

then trade to mule

 

I thought that was what you ment; wasnt sure if you wanted me to make another state to check bank haha sorry all new to this stuff; been a long time last time i did it we used nodes;

 

im testing it now (: 

WalkToPickUp state. You know what i mean

 

just check bank for beef.

 

if contains beef

withdraw

 

then trade to mule

 

if (!inventory.isFull() && !bank.isOpen() && !bank.contains("Raw beef")  && !cowArea.contains(myPlayer()))
return State.WALKTOPICKUP;
 
So I have done this now; and now it just sits at the bank with it open;
 
can close opened new thread open sourced
Edited by whipz
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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