Jump to content

Check runes for magic spell


Recommended Posts

Posted

I'm trying to check if the bot has the required runes to cast a spell.

Right now I'm using 

getMagic().canCast(Spell spell)

However this clicks the magic tab every time it checks.

I figured there's code that checks for the requirements behind "cancast" somewhere but I can't find it in the API docs.

Any help?

 

tldr; How do I check if I have the required runes for a spell without using getMagic().canCast() as that open the magic tab every time.

Posted

I'm trying to check if the bot has the required runes to cast a spell.

Right now I'm using 

getMagic().canCast(Spell spell)

However this clicks the magic tab every time it checks.

I figured there's code that checks for the requirements behind "cancast" somewhere but I can't find it in the API docs.

Any help?

 

tldr; How do I check if I have the required runes for a spell without using getMagic().canCast() as that open the magic tab every time.

 

Check if your inventory contains the runes...

private boolean canTeleportToVarrock(){
  return getInventory().contains("Fire rune") && 
         getInventory().contains("Law rune") &&
         getInventory().getAmount("Air rune") >= 3; 
}
Posted (edited)

 

Check if your inventory contains the runes...

private boolean canTeleportToVarrock(){
  return getInventory().contains("Fire rune") && 
         getInventory().contains("Law rune") &&
         getInventory().getAmount("Air rune") >= 3; 
}

 

 

 

Try this;

private boolean isSupplied(){
                	 if(inventory.getAmount(YOUR RUNES HERE) > Required amount of runes for the spell -1) {
                         return true;
                	 
                 }else{
                         return false;
                 }
             }

then you could do something like -->

if (isSupplied()==true);
    //do shit here

 

Yeah well.. that was the obvious solution, I was hoping at first that the spells enum from the API would contain the information on what runes each spell requires

and would take such approach.

 

Since it didn't find the spells enum containing the required runes data I searched the API for another solution and found getMagic().canCast().

That one works but keeps opening my magic tab.

So since the code must be available somewhere in the API I'd like to figure out where so I can use it rather than having to write it all myself.

Edited by lisabe96
Posted

Yeah well.. that was the obvious solution, I was hoping at first that the spells enum from the API would contain the information on what runes each spell requires

and would take such approach.

 

Since it didn't find the spells enum containing the required runes data I searched the API for another solution and found getMagic().canCast().

That one works but keeps opening my magic tab.

So since the code must be available somewhere in the API I'd like to figure out where so I can use it rather than having to write it all myself.

 

It will most likely be based on the widgets in the spell tab. The spells will have different widget values when they are highlighted (can cast) and when they are not. Therefore using this method you need to change to the spell tab to check it. The only other alternative is to check your supplies in the inventory & equipment.

Posted

It will most likely be based on the widgets in the spell tab. The spells will have different widget values when they are highlighted (can cast) and when they are not. Therefore using this method you need to change to the spell tab to check it. The only other alternative is to check your supplies in the inventory & equipment.

Alright thanks, guess I'll have to write it myself after all then VSuShjF.gif

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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