MyProjects / Groovy-scripts / Shop Hopper.groovy
Shop Hopper.groovy
Raw
startup

delay = random(1, 3)
instruction = 0
world = 8
random = new Random()
worldList = [302,303,304,305,306,307,309,310,311,312,313,314,315,317,320,321,322,323,324,325,327,328,329,330,331,332,333,334,336,337,338,339,340,341.342,343,344,346,347,348,350,351,352,354,355,356,357,358,359,360,362,367,368,370,374,375,376,377,378,386,387,388,389,390,395,421,422,424,443,444,445,446,463,464,465,466,477,478,479,480,481,482,484,485,486,487,488,489,490,491,492,493,494,495,496,505,506,507,508,509,510,511,512,513,514,515,516,517,518,519,520,521,522,523,542,545,531,532,534,535,580]


GameTick

if(delay > 0) {
	delay--
	return
}

if (client.localPlayer.animationIdleTicks < 2){
	return
	}

def bankBooth = findNearestObject(10355, 10356)
def Aemad = findNearestNPC(8682)
def shop = findNearestObject(1710)
def widget = client.getWidget(19660801)


if(instruction == 0){
	if(isBankOpen()){
		logChat("Instruction 0 started: banking")
		deposit(ItemID.PAPYRUS, 200)
		//depositInventory() 
		if(isInInventory(ItemID.COINS_995)==false){
		//deposit(ItemID.PAPYRUS, 200)
			withdraw(ItemID.COINS_995, 999999999)
		}
		delay = 3
		instruction = 1
		return
		}	
	if(bankBooth && isPlayerIdle()){
		logChat("Instruction 0 started: walking to bank")
		gameObjectOp2(bankBooth)
		}
	}

if (instruction == 1) {
	logChat("Instruction 1 started: walking to point 1")
	x = random(0, 3) + 2607
	y = random(0, 3) + 3322
	walkToWorldPoint(x, y)
	instruction = 2
}

if (instruction == 2 && getPlayerLocation().getY() <= 3328){
	logChat("Instruction 2 started: walking to point 2")
	x = random(0, 1) + 2608
	y = random(0, 1) + 3312
	walkToWorldPoint(x, y)
	instruction = 3
}

if (instruction == 3 && getPlayerLocation().getY() <= 3314){
	logChat("Instruction 3 started: walking to point 3")
	x = random(0, 2) + 2614
	y = random(0, 2) + 3297
	walkToWorldPoint(x, y)
	instruction = 4
}

if(instruction == 4 && isPlayerIdle()){
	if(Aemad){
		logChat("Instruction 4 started: Open trade with NPC")
		npcOp3(Aemad)
		delay = 3
		instruction = 5
		return
		}
	}

if(instruction == 5){
			if(widget){
				logChat("Instruction 5 started: Buy Products")
				doAction(MenuAction.CC_OP.id, 5, 10, 19660816)
				delay = 5
				instruction = 6
				return
			}
	}

if(instruction == 6){
	if(inventoryFull()){
		logChat("Instruction 6 started: enough items, proceed to bank")
		delay = 3
		instruction = 0
		}
	else{
		logChat("IninventoryFullstruction 6 started: no items in stock, time to world hop!")
		gameObjectOp2(bankBooth)
		instruction = 7
		return
		}
	}

if(instruction == 7){
	logChat("Instruction 7 started: Trying to worldhop")
	//hop(worldList[random(0, worldList.size() - 1)])	
	if (hop){
    hop(worldList[world])
    world = world + 1
    logChat("Instruction 7 extra info: Hopping to world " + world-1)
    instruction = 8
		return
		}
	}

if(instruction == 8){
	if(isPlayerIdle()){
		logChat("Instruction 8 started: switch back to inventory")
		doAction(MenuAction.CC_OP.id, 1, -1, WidgetInfo.RESIZABLE_VIEWPORT_INVENTORY_TAB.id)
		instruction = 4
		return
	}
}