Jump to content

Special Attack Weapons


TheScrub

Recommended Posts



import org.osbot.script.Script;

public class Spec_Attacks {
    Script script = Context.script;

    enum SpecWeapon {
        DragonDagger("Dragon dagger", 1215, 25), DragonScim("Dragon scimitar",
                4587, 55), Whip("Abyssal whip", 4151, 50), Magic_Shortbow(
                "Magic shortbow", 861, 55), DragonDaggerP("Dragon dagger(p)",
                1231, 25), DragonBattleaxe("Dragon battleaxe", 1377, 100);
        private final int id;
        private final int specpercent;
        private final String name;

        SpecWeapon(String name, int id, int specpercent) {
            this.name = name;
            this.id = id;
            this.specpercent = specpercent;
        }

        public String getName() {
            return name;
        }

        public int getId() {
            return id;
        }

        public int getSpecPercent() {
            return specpercent;
        }

    }

    public static int possibleSpecsForSpecBar(SpecWeapon Spec) {
        int remanningspec = Context.script.combat.getSpecialPercentage();
        double d = remanningspec / Spec.getSpecPercent();
        long l = Math.round(d);
        String s = String.valueOf(l);
        int specsforafullbar = Integer.parseInt(s);
        return specsforafullbar;

    }

    public static void SwitchWeaponTo(String name, Integer timeout)
            throws InterruptedException {
        String g[] = { "Wear", "Wield" };
        long t = System.currentTimeMillis();
        if (!Context.script.equipmentTab.isWieldingWeapon(name)) {
            for (String option : g) {
                Context.script.client.getInventory().interactWithName(name,
                        option);
            }
            while (!Context.script.equipmentTab.isWieldingWeapon(name)
                    && System.currentTimeMillis() - t < timeout) {
                Context.script.sleep(50);
            }
        }
    }

}

 

import org.osbot.script.Script;

public class Context extends Script {
    public static Script script;

}

use

 

 

in your script you will need to do this i'm using the context class as i got several class's that use api methods so it's easier.

@Override
    public void onStart() {
        Context.script=this;
}

the first parameter is the name of the weapon or could have an Armour wouldn't matter and the 2nd parameter is for the dynamic sleep type thing in the spec attacks class i like 3000ms before it will retry

            if (Spec_Attacks.possibleSpecsForSpecBar(SpecWeapon.DragonDagger)>0){
            Spec_Attacks.SwitchWeaponTo(SpecWeapon.DragonDagger.getName(), 3000);
        }
Edited by TheScrub
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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