Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Graphics;
- import org.rsbuddy.tabs.Attack;
- import org.rsbuddy.tabs.Equipment;
- import org.rsbuddy.tabs.Prayer;
- import com.rsbuddy.event.listeners.PaintListener;
- import com.rsbuddy.script.ActiveScript;
- import com.rsbuddy.script.Manifest;
- import com.rsbuddy.script.methods.Game;
- import com.rsbuddy.script.methods.Inventory;
- import com.rsbuddy.script.methods.Skills;
- import com.rsbuddy.script.wrappers.Item;
- @Manifest(authors = { "Red_Clown" }, name = "Red's Switcher", keywords = { "" }, version = 0.5, description = "")
- public class ItemSwitcher extends ActiveScript implements PaintListener {
- private int[] prayerPotID = { 2434, 139, 141, 143 };
- private int[] strengthPotID = { 2440, 157, 159, 161 };
- private int[] attackPotID = { 2436, 145, 147, 149 };
- private int[] DDSID = { 1215, 5698, 5680, 1231 };
- private int fullPrayerPotRestore = 0;
- private int prayerPotRestore = 0;
- private int prayerlol = 0;
- private int fullStrengthPotRestore = 0;
- private int strengthPotRestore = 0;
- private int strength = 0;
- private int fullAttackPotRestore = 0;
- private int attackPotRestore = 0;
- private int attacklol = 0;
- private int strengthLvl = 0;
- private int attackLvl = 0;
- private int prayerLvl = 0;
- private int maxHit = 0;
- private int strengthBonus = 0;
- private int baseDamage = 0;
- private int effectiveStrength = 0;
- @Override
- public boolean onStart() {
- if (Game.isLoggedIn()) {
- attackLvl = Skills.getMaxLevel(Skills.ATTACK);
- strengthLvl = Skills.getMaxLevel(Skills.STRENGTH);
- prayerLvl = Skills.getMaxLevel(Skills.PRAYER);
- return true;
- }
- log("Log-in before using");
- return false;
- }
- @Override
- public void onFinish() {
- }
- @Override
- public int loop() {
- if (/* his hp */1 < maxHit) { // need to figure out, perhaps connect to the hi-scores somehow
- CheckStrength();
- CheckAttack();
- if (needToPrayer()) {
- executePrayer();
- }
- SetPrayer();
- DDsSpec();
- }
- return 100;
- }
- private void SetPrayer() {
- if (!Prayer.isQuickPrayersActive()) {
- Prayer.toggleQuickPrayers(true);
- }
- }
- private void CheckStrength() {
- if (Inventory.containsOneOf(strengthPotID)) {
- if (Skills.getCurrentLevel(Skills.STRENGTH) <= strengthPotRestore
- + strengthLvl) {
- Item Pot = Inventory.getItem(strengthPotID);
- if (Pot.interact("Drink")) {
- for (int i = 0; i < 20
- && Skills.getCurrentLevel(Skills.STRENGTH) <= strengthPotRestore
- + strengthLvl; i++) {
- sleep(100, 120);
- }
- }
- }
- }
- }
- private void CheckAttack() {
- if (Inventory.containsOneOf(attackPotID)) {
- if (Skills.getCurrentLevel(Skills.ATTACK) <= attackPotRestore
- + attackLvl) {
- Item Pot = Inventory.getItem(attackPotID);
- if (Pot.interact("Drink")) {
- for (int i = 0; i < 20
- && Skills.getCurrentLevel(Skills.ATTACK) <= attackPotRestore
- + attackLvl; i++) {
- sleep(100, 120);
- }
- }
- }
- }
- }
- private void executePrayer() {
- if (Inventory.containsOneOf(prayerPotID)) {
- if (Skills.getCurrentLevel(Skills.PRAYER) <= prayerPotRestore
- + prayerLvl) {
- Item Pot = Inventory.getItem(prayerPotID);
- if (Pot.interact("Drink")) {
- for (int i = 0; i < 20
- && Skills.getCurrentLevel(Skills.ATTACK) <= prayerPotRestore
- + prayerLvl; i++) {
- sleep(100, 120);
- }
- }
- }
- }
- }
- private boolean needToPrayer() {
- return Skills.getCurrentLevel(Skills.PRAYER) <= prayerPotRestore
- + prayerLvl
- && Inventory.containsOneOf(prayerPotID);
- }
- private void DDsSpec() {
- if (Inventory.containsOneOf(DDSID)) {
- Item DDS = Inventory.getItem(DDSID);
- DDS.interact("Wield");
- for (int i = 0; i < 20 && Inventory.containsOneOf(DDSID); i++) {
- sleep(100, 120);
- }
- if (Attack.getSpecialEnergy() >= 25
- && !Inventory.containsOneOf(DDSID)) {
- Attack.setSpecial(true);
- }
- }
- }
- @Override
- public void onRepaint(Graphics g1) {
- effectiveStrength = (int) (8 + ((strengthLvl + fullStrengthPotRestore) * 1.15) + 3);
- baseDamage = 5 + effectiveStrength * (1 + strengthBonus / 64);
- maxHit = (int) (baseDamage * 1.15);
- if (Inventory.containsOneOf(prayerPotID)) {
- prayerlol = Skills.getMaxLevel(Skills.PRAYER);
- fullPrayerPotRestore = 7 + (prayerlol / 4);
- prayerPotRestore = fullPrayerPotRestore / 2;
- }
- if (Inventory.containsOneOf(attackPotID)) {
- attacklol = Skills.getMaxLevel(Skills.ATTACK);
- fullAttackPotRestore = 5 + ((attacklol / 100) * 15);
- attackPotRestore = fullAttackPotRestore / 2;
- }
- if (Inventory.containsOneOf(strengthPotID)) {
- strength = Skills.getMaxLevel(Skills.STRENGTH);
- fullStrengthPotRestore = 5 + ((strength / 100) * 15);
- strengthPotRestore = fullStrengthPotRestore / 2;
- }
- }
- }
Add Comment
Please, Sign In to add comment