Hello everyone! I'm trying to make my first task based script, but am experiencing some issues with a task.
I want my EquipGear task to eguip items based on the bots defence level, so everytime I run the task it will check the defence level and based on the defence level he will choose what piece/variable to pick from.
This is my Task superclass:
package Test.account.skills;
import org.osbot.rs07.script.MethodProvider;
public abstract class CombatTask {
protected MethodProvider mp;
public CombatTask(MethodProvider mp) {
this.mp = mp;
}
public abstract boolean canProcess();
public abstract void process();
public void run() {
if (canProcess())
process();
}
}
And this is my EquipGear task:
package Test.account.skills;
import org.osbot.rs07.api.ui.EquipmentSlot;
import org.osbot.rs07.script.MethodProvider;
import org.osbot.rs07.utility.ConditionalSleep;
public class EquipGear extends CombatTask {
public EquipGear(MethodProvider mp) {
super(mp);
}
@Override
public boolean canProcess() { // If the bot isn't wearing a piece or multiple pieces of equipment -> Statement = true.
if (!mp.getEquipment().isWearingItem(EquipmentSlot.AMULET, amuletGear)
|| !mp.getEquipment().isWearingItem(EquipmentSlot.HAT, headGear) ||!mp.getEquipment().isWearingItem(EquipmentSlot.CHEST, bodyGear)
|| !mp.getEquipment().isWearingItem(EquipmentSlot.LEGS, legGear) || !mp.getEquipment().isWearingItem(EquipmentSlot.SHIELD, shieldGear)
|| !mp.getEquipment().isWearingItem(EquipmentSlot.WEAPON, mainHandGear));
mp.log("Isn't wearing set");
return true;
}
@Override
public void process() {
setGear();
if (mp.getInventory().contains(headGear)
&& mp.getInventory().contains(bodyGear) && mp.getInventory().contains(legGear)
&& mp.getInventory().contains(amuletGear) && mp.getInventory().contains(shieldGear)
&& mp.getInventory().contains(mainHandGear)){
mp.log("Equiping " +headGear);
mp.getInventory().interact(headGear,"Wear");
new ConditionalSleep(2500, 500) {
@Override
public boolean condition() throws InterruptedException {
return mp.getEquipment().isWearingItem(EquipmentSlot.HAT, headGear);
}
}.sleep();
mp.getInventory().interact(bodyGear,"Wear");
new ConditionalSleep(2500, 500) {
@Override
public boolean condition() throws InterruptedException {
return mp.getEquipment().isWearingItem(EquipmentSlot.CHEST, bodyGear);
}
}.sleep();
mp.getInventory().interact(legGear,"Wear");
new ConditionalSleep(2500, 500) {
@Override
public boolean condition() throws InterruptedException {
return mp.getEquipment().isWearingItem(EquipmentSlot.LEGS, legGear);
}
}.sleep();
mp.getInventory().interact(amuletGear, "Wear");
new ConditionalSleep(2500, 500) {
@Override
public boolean condition() throws InterruptedException {
return mp.getEquipment().isWearingItem(EquipmentSlot.AMULET, amuletGear);
}
}.sleep();
mp.getInventory().interact(shieldGear, "Wear");
new ConditionalSleep(2500, 500) {
@Override
public boolean condition() throws InterruptedException {
return mp.getEquipment().isWearingItem(EquipmentSlot.SHIELD, shieldGear);
}
}.sleep();
mp.getInventory().interact(mainHandGear,"Wield");
new ConditionalSleep(2500, 500) {
@Override
public boolean condition() throws InterruptedException {
return mp.getEquipment().isWearingItem(EquipmentSlot.WEAPON, mainHandGear);
}
}.sleep();
}
}
}
Is there anyway I can implement something like this?:
if (mp.getSkills().getStatic(Skill.DEFENCE) < 10) {
String headGear = "Iron full helm";
String bodyGear = "Iron platebody";
String legGear = "Iron platelegs";
String amuletGear = "Amulet of power";
String shieldGear = "Iron kiteshield";
String mainHandGear = "Iron scimitar";
}else if (mp.getSkills().getStatic(Skill.DEFENCE)>= 10 && mp.getSkills().getStatic(Skill.DEFENCE) < 20){
String headGear = "Steel full helm";
String bodyGear = "Steel platebody";
String legGear = "Steel platelegs";
String amuletGear = "Amulet of power";
String shieldGear = "Steel kiteshield";
String mainHandGear = "Steel scimitar";
}
I have tried making another class SetGear:
package Test.account.skills;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.MethodProvider;
public class SetGear {
protected MethodProvider mp;
public SetGear(MethodProvider mp) {
this.mp = mp;
}
public void gear() {
if (mp.getSkills().getStatic(Skill.DEFENCE) < 10) {
String headGear = "Iron full helm";
String bodyGear = "Iron platebody";
String legGear = "Iron platelegs";
String amuletGear = "Amulet of power";
String shieldGear = "Iron kiteshield";
String mainHandGear = "Iron scimitar";
}else if (mp.getSkills().getStatic(Skill.DEFENCE)>= 10 && mp.getSkills().getStatic(Skill.DEFENCE) < 20){
String headGear = "Steel full helm";
String bodyGear = "Steel platebody";
String legGear = "Steel platelegs";
String amuletGear = "Amulet of power";
String shieldGear = "Steel kiteshield";
String mainHandGear = "Steel scimitar";
}
}
}
And try to run it inside the EquipGear task like this: (but that didn't work).
SetGear set = new SetGear(MethodProvider mp);
set.gear();
Do I have to make seperate tasks for each level spectrum or can this be implemented in one task?
Can anyone help me out?
Thanks in advance!
Btw: I'm not experienced with programming, I recently watched this course on yt: https://www.youtube.com/watch?v=8cm1x4bC610&t=148s to understand the basics and am now practicing with it.