Ericthecmh 184 Share Posted November 22, 2014 Another simple script, added some stuff to the previous one. Added in this tutorial: Accessing Skills Interacting with tabs WIdgets (also known as interfaces in other bots) Dialogues (clickToContinue) Code: import java.awt.*; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.event.EventHandler; import org.dreambot.api.methods.event.PaintEvent; import org.dreambot.api.methods.skills.Skill; import org.dreambot.api.methods.tabs.Tab; import org.dreambot.api.methods.widget.Widget; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.utilities.impl.Condition; import org.dreambot.api.utilities.impl.Filter; import org.dreambot.api.wrappers.interactive.NPC; import org.dreambot.api.wrappers.widgets.WidgetChild; @ScriptManifest(author="Ericthecmh", category= Category.COMBAT, name="Chicken Killer", version=0.1, description="Simple tutorial script showing how to kill chickens") public class ChickenKiller extends AbstractScript{ public void onStart(){ log("Welcome to a boring Chicken Killer script!"); //Use log to print to the console } @Override public int onLoop() throws InterruptedException { getClient().disableIdleMouse(); // Click away level up messages getDialogues().clickContinue(); // Get my defence level if(getSkills().getRealLevel(Skill.DEFENCE) > 15){ // If I've reached my goal, stop this.stop(); }else if(getSkills().getRealLevel(Skill.STRENGTH) > 15 && getPlayerSettings().getConfig(43) != 3){ // 3 is defensive style // Switch to defensive // Open combat tab if(getTabs().getOpen() == Tab.COMBAT || getCombat().openTab()){ Widget combatTab = getWidgets().getWidget(593); if(combatTab.isVisible()) { // 15 is the child widget for the fourth (defensive) option combatTab.getChild(15).interact(); } } }else if(getSkills().getRealLevel(Skill.ATTACK) > 15 && getPlayerSettings().getConfig(43) != 1){ // 1 is my aggressive style // Switch to aggressive if(getTabs().getOpen() == Tab.COMBAT || getCombat().openTab()){ WidgetChild child = getWidgets().getChildWidget(593, 7); if(child != null && child.isVisible()) child.interact(); } } return doAttack(); } private int doAttack(){ if (!getPlayers().myPlayer().isInCombat()) { NPC chicken = getNpcs().getClosest(new Filter<NPC>() { @Override public boolean match(NPC npc) { // Note the use of .equals at the end. You cannot do == like in many other bots. return npc != null && npc.getName().equals("Chicken") && npc.getActions().length > 0 && (!npc.isInCombat() || (npc.getInteractingCharacter() != null && npc.getInteractingCharacter().equals(getLocalPlayer()))); } }); if(chicken == null) return Calculations.random(300,600); try { if (chicken.interact("Attack")) { sleepUntil(new Condition() { @Override public boolean verify() { return getPlayers().myPlayer().isInCombat(); } },1000); } } catch (InterruptedException e) { e.printStackTrace(); } } return Calculations.random(300, 600); // Calculations.random to get random numbers } public void onPaint(Graphics g){ g.setColor(new Color(247, 148, 230)); g.drawString("DreamBot is awesome!", 100, 100); g.drawString("IsInCombat: " + getLocalPlayer().isInCombat(), 100, 120); } } Link to comment Share on other sites More sharing options...
Eliot 193 Share Posted November 22, 2014 Looks sweet, when do we get the beta bot release? Link to comment Share on other sites More sharing options...
Trustmybet 47 Share Posted November 22, 2014 Let me know if you need any testing bb Link to comment Share on other sites More sharing options...
Ericthecmh 184 Author Share Posted November 22, 2014 Looks sweet, when do we get the beta bot release? Neverrrrr later tonight? Tomorrow? In 2 OSBot days (aka never)? Link to comment Share on other sites More sharing options...
Jack 12 Share Posted November 22, 2014 In 2 OSBot days (aka never)? rofl Link to comment Share on other sites More sharing options...
Dogerina 330 Share Posted November 22, 2014 // Note the use of .equals at the end. You cannot do == like in many other bots. npc.getName().equals("Chicken") Link to comment Share on other sites More sharing options...
GoldenGates 72 Share Posted November 22, 2014 I like dis meme. Link to comment Share on other sites More sharing options...
Nebraska 136 Share Posted November 22, 2014 cannot wait for the beta matee Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.