[orion] Mining using runebook

If you make a Client-side script you can publish it here for other players to use
Post Reply
davethemage
Expert Scribe
Posts: 38
Joined: Sun Aug 09, 2020 2:13 pm

[orion] Mining using runebook

Post by davethemage »

Using the base orion mining script this will use a runebook. set your max weight, and id of your books (use _info and point to book) also if your book is not full set number of runes in each book.
This moves your ore to a BOH. If you want to use a portable thing then grab from other scripts and replace in "moveore" function.

Code: Select all

var config = {
   "maxWeight"        : (Player.MaxWeight(400)-10), //Max Weight to unload
   "pickaxe"          : "0x0F39", //Pickaxe type(pickaxe, shovel etc)
   "ore"            : "0x19B9",
   "toolQty"          : 1,        //To keep in bag
   "tileOffset"       : 1,     // Radius to dig (X+-2, Y+-2)
};

var rBooks = {
 1 : {"bSNum" : '0x40516626', "iStops" : 16},
 2 : {"bSNum" : '0x40516ACA', "iStops" : 16}, 
 3 : {"bSNum" : '0x4051688D', "iStops" : 16}, 
 4 : {"bSNum" : '0x40516718', "iStops" : 16}, 
 5 : {"bSNum" : '0x405164BC', "iStops" : 16}, 
 }
 
 var bNumber = { // change to 5,15, 25, ect if you want to use recall
 1: {"btn" : 7}, 2: {"btn" : 17}, 3: {"btn" : 27}, 4: {"btn" : 37}, 5: {"btn" : 47}, 6: {"btn" : 57},
 7: {"btn" : 67}, 8: {"btn" : 77}, 9: {"btn" : 87}, 10: {"btn" : 97}, 11: {"btn" : 107}, 12: {"btn" : 117},
 13: {"btn" : 127}, 14: {"btn" : 137}, 15: {"btn" : 147}, 16: {"btn" : 157},
}


function Astart()
{   
   init();   
   while(!Player.Dead())
   {
      for(var rBook in rBooks)
      {
			var numbStops =  rBooks[rBook]['iStops'];
      		for (i = 0; i <= numbStops -1; i++)
      		{      
           	Orion.Print(bNumber[i +1]['btn']);
       		//Move to new location
				NextLocation(rBooks[rBook]['bSNum'], bNumber[i +1]['btn']);
          	for (var x = -config['tileOffset']; x <= config['tileOffset']; x++)
         			{
            			for (var y = -config['tileOffset']; y <= config['tileOffset']; y++)
            			{
              			MoveOre(); //make sure bag in empty
               			mine(x,y);
            			}
         			}
        	} 
      } 
   } 
}

function mine(x,y)
{
   while(!Player.Dead())
   {
       if(checkTool())
       {
          if(Orion.ValidateTargetTileRelative('mine', x, y))
          {
             if(Orion.HaveTarget())
                Orion.CancelWaitTarget();
	             Orion.UseType(config['pickaxe']);   
   		          Orion.WaitJournal('Where do you wish', Orion.Now(), Orion.Now()+2000, 'me|sys');
      		      Orion.TargetTileRelative('mine', x, y, Player.Z());                          
          		var result = Orion.WaitJournal('You put some|You loosen some|There is no metal|Try mining|is too far|no line of| cannot be seen| mine that', Orion.Now(), (Orion.Now() + 7000), 'me|sys');          
              	if(result && (result.FindTextID()==6 || result.FindTextID()==7))
             	{
             		break;
             	}
             	if(result && result.FindTextID()==2)
             	{
                	Orion.Wait(300);
                	break;
             	}             
	          }else{
   		          break;
      		    }       
       	}else{ //Not enough tools
          	break;
       	}
   }
}

function MoveOre()
{ 
  var findItems0 = Orion.FindType('0x19B9|0x1779', '0xFFFF', 'backpack', 'item');

	for(items in findItems0)
	{
		Orion.DragItem(findItems0[items], 0);
		Orion.Wait('300');
		Orion.DropDraggedItem('0x41C448BA'); //move to my boh. change if you want to move to a pet.
		Orion.Wait('500');
	}
}

function checkTool()
{   
   var tools = Orion.FindType(config['pickaxe'], -1, 'backpack');
   if(tools && tools.length >= config['toolQty'])
   {
      return true;
   }else{
      Orion.Print("[e] Not enough tools");      
      Orion.PlayWav("Alarm");
      Orion.PauseScript();            
      return false;
   }
}

function init()
{   

   if(Player.WarMode())
   	{
      Player.WarMode(false)
	   Orion.Print("Initialization...");
	 }
}

function NextLocation(rBook, iButton)
{
	Orion.UseObject(rBook);
	Orion.Wait(500);
	if (Orion.WaitForGump(1000))
	{
		var gump0 = Orion.GetGump(any,'0x554B87F3');
		if ((gump0 !== null) && (!gump0.Replayed()) && (gump0.ID() === '0x554B87F3'))
		{
			gump0.Select(Orion.CreateGumpHook(iButton));
			Orion.Wait(5000);
		}
	}
		
}
Last edited by davethemage on Sun Sep 26, 2021 2:32 am, edited 1 time in total.
IGN: Edwin Roach
MagicUser
Adept Scribe
Posts: 47
Joined: Mon Nov 03, 2014 2:24 pm
Location: PST

Re: [orion] Mining using runebook

Post by MagicUser »

Hmm, I see you are using dictionaries... very nice. I did notice your recall piece doesn't handle failure or other gumps being opened.
Consider using following instead. It will at least help prevent a pm ruining everything.

Code: Select all

var gump0 = Orion.GetGump(any,'0x554B87F3');
Respectfully,
Paroxysmus ILV Master Spellcaster
davethemage
Expert Scribe
Posts: 38
Joined: Sun Aug 09, 2020 2:13 pm

Re: [orion] Mining using runebook

Post by davethemage »

Nice. Ya i usually don't have any gumps open when i'm mining so it hasn't been a problem.

Would this also eliminate the need for:

if ((gump0 !== null) && (!gump0.Replayed()) && (gump0.ID() === '0x554B87F3')) ?
IGN: Edwin Roach
MagicUser
Adept Scribe
Posts: 47
Joined: Mon Nov 03, 2014 2:24 pm
Location: PST

Re: [orion] Mining using runebook

Post by MagicUser »

No, because the way you got gump is by selecting the last opened gump. If a gump is opened between "useobject" and GetGump (there is a 1000 ms possible pause and believe me its a lot more possible than it sounds). Before I realized what was going on, I had quite a few pms that gummed my farming script. Just a pm being sent to you will be used as a GetGump('last'). pms, backpacks, paperdolls, keyrings... you have to be super careful or the last gump will not be the runebook and then you're just sitting there.
Respectfully,
Paroxysmus ILV Master Spellcaster
MagicUser
Adept Scribe
Posts: 47
Joined: Mon Nov 03, 2014 2:24 pm
Location: PST

Re: [orion] Mining using runebook

Post by MagicUser »

Oh, I reread your question. You still need at least most of that line (I do for safety).

if ((gump0 !== null) && (!gump0.Replayed()) && (gump0.ID() === '0x554B87F3')) ?
gump0 !== null -> gump found.
!gump0.Replayed() -> hasn't been answered yet.
gump0.ID() === '0x554B87F3') -> is the right one.

Its important to check if the gump was found and that it wasn't answered, but you already know its the right gump id. So I suppose you don't technically need that last part, but you should include the rest of it.
Respectfully,
Paroxysmus ILV Master Spellcaster
Post Reply