MyProjects / Groovy-scripts / Essence Miner.groovy
Essence Miner.groovy
Raw
startup

status = 0
delay = 0


GameTick 

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

int region = client.localPlayer.worldLocation.regionID

if(client.getEnergy() > 20){
	def runEnabled = client.getVarpValue(173) == 1
	if(!runEnabled){
		ccOp(WidgetInfo.MINIMAP_TOGGLE_RUN_ORB.id)
		}
	}

def bankBooth = findNearestObject(10583)
def Aubury = findNearestNPC(2886)
def teleport = findNearestNPC(3087)
def teleport2 = findNearestObject(34779, 34825, 34779)
def teleport3 = findNearestNPC(3086)
def teleport4 = findNearestNPC(3088)
def essence = findNearestObject(34773)

if(status == 0){
	if(region == 12853){
		status = 1
		return
		}
	else{
		status = 4
		return
		}
	}

if(status == 1){
	if(isBankOpen()){
		logChat("status 1 started\: banking")
		deposit(ItemID.PURE_ESSENCE, 200)
		//depositInventory() 
		delay = 3
		status = 2
	}
	if(bankBooth && isPlayerIdle()){
		logChat("status 1 started\: walking to bank")
		gameObjectOp2(bankBooth)
		delay = 3
		}
	}

if(status == 2){
    logChat("status 2 started\: walking to nearby destination")
    x = random(0, 3) + 3258
    y = random(0, 3) + 3406
    walkToWorldPoint(x, y)
    status = 3
}

if(status == 3){
			if(Aubury){
			logChat("status 3 started\: NPC Teleport")
			npcOp4(Aubury)
			delay = 5
			status = 4
		}
	}

if(status == 4){
	if(!inventoryFull()){
		if (client.localPlayer.animationIdleTicks < 2){
		return	
		}
		if(essence){
			logChat("status 4 started\: Mining essence")
			gameObjectOp1(essence)
			delay = 5
			return
			}
	}
	if(inventoryFull()){
		logChat("status 4 started\: Finding teleport")
		npcOp1(teleport)
		gameObjectOp1(teleport2)
		npcOp1(teleport3)
		npcOp1(teleport4)
		delay = 5
		status = 5
		return
	if(region == 12853){
		status = 1
		}
	}
}
	
if(status == 5){
	if(isPlayerIdle() && region == 12853){
		logChat("status 5 started\: go to bank")
		status = 1
	}
	else{
		status = 4
		}	
	}