Jump to content

Casting Reanimation spells on arceuus spell book


Recommended Posts

Posted
private void castReanimateSpell(MagicSpell spellToCast) throws InterruptedException
	{
		ArrayList<RS2Widget> allWidgets= new ArrayList<RS2Widget>();
		allWidgets.addAll(widgets.getAll());
		
		String spellNameFixer = spellToCast.toString();
		//the string starts out all caps. we want only first letter of each word to be caps.
		spellNameFixer = spellNameFixer.toLowerCase();
		//now we replace the underscore with a space
		spellNameFixer = spellNameFixer.replace('_', ' ');
		String[] storageArray = spellNameFixer.split(" ");
		String finalName = "";
		//build the final string out of the string array. while capatalizing the first
		// letter of each word
		for(String s : storageArray)
		{
			char temp = s.charAt(0);
			temp = Character.toUpperCase(temp);
			s = Character.toString(temp) + s.substring(1);
			finalName = finalName + s + " ";
			
		}
		//remove the last white space.
		//for some reason all the widget names start with this sequence.
		String temp = finalName.trim();
		finalName = "<col=00ff00>" + temp;
		
		//log("looking for spell " + finalName);
		if(magic.canCast(spellToCast))
		{
			//log("we can cast the spell");
			if(getTabs().getOpen() != Tab.MAGIC)
			{
				log("opening magic tab");
				getTabs().open(Tab.MAGIC);
				sleep(random(400,600));
			}
			ArrayList<RS2Widget> spellWidgetList = new ArrayList<RS2Widget>();
			spellWidgetList.addAll( widgets.getAll());
			
			for(RS2Widget rw : allWidgets)
			{
				if(rw != null && rw.isVisible() && rw.getSpellName().length() > 1)
				{
					if(rw.getSpellName().equals(finalName))
					{
						//log("selecting spell: " + finalName);
						rw.interact("Reanimate");
						sleep(random(50,80));
						break;
					}
					sleep(random(10,20));
				}
				
			}
		}
	}

hey guys, i noticed that it wasn't really possible to use the current cast spell function with the reanimation spells in the arceuus spell book so i made a function that would select the spell. please let me know if this helps, if my code is disgusting , or if its already been done and i just haven't found it yet. thanks! :)

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