Jump to content

Check runes for magic spell


lisabe96

Recommended Posts

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.

Link to comment
Share on other sites

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; 
}
Link to comment
Share on other sites

 

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

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...