Last active
March 13, 2020 20:39
-
-
Save 0xdeki/792a31c216cd4c88b6fab4a163fa8d82 to your computer and use it in GitHub Desktop.
Source code for Deki Stun Alch on the rspeer SDN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.deki.stunalch; | |
import org.rspeer.runetek.adapter.component.Item; | |
import org.rspeer.runetek.adapter.scene.Npc; | |
import org.rspeer.runetek.api.commons.Time; | |
import org.rspeer.runetek.api.component.tab.*; | |
import org.rspeer.runetek.api.scene.Npcs; | |
import org.rspeer.runetek.api.scene.Players; | |
import org.rspeer.runetek.event.listeners.ChatMessageListener; | |
import org.rspeer.runetek.event.types.ChatMessageEvent; | |
import org.rspeer.script.Script; | |
import org.rspeer.script.ScriptMeta; | |
import javax.swing.*; | |
import java.util.ArrayList; | |
import java.util.List; | |
@ScriptMeta(desc = "Does whatever + alchs", developer = "Deki", name = "Deki Stun Alch") | |
public class StunAlch extends Script implements ChatMessageListener { | |
private Spell[] spells = new Spell[]{Spell.Modern.CURSE, Spell.Modern.STUN}; | |
private Spell firstSpell; | |
private String npc; | |
private final Spell alch = Spell.Modern.HIGH_LEVEL_ALCHEMY; | |
private String item; | |
private boolean shouldAlch = false; | |
@Override | |
public void onStart() { | |
List<String> npcs = new ArrayList<>(); | |
for (Npc i : Npcs.getLoaded()) { | |
if (!npcs.contains(i.getName())) { | |
npcs.add(i.getName()); | |
} | |
} | |
List<String> items = new ArrayList<>(); | |
for (Item i : Inventory.getItems()) { | |
items.add(i.getName()); | |
} | |
npc = (String)JOptionPane.showInputDialog( | |
null, "Select NPC to cast on:\n", "Deki Stun Alch", | |
JOptionPane.PLAIN_MESSAGE, null, npcs.toArray(), null); | |
item = (String)JOptionPane.showInputDialog( | |
null, "Item to alch:\n", "Deki Stun Alch", | |
JOptionPane.PLAIN_MESSAGE, null, items.toArray(), null); | |
firstSpell = (Spell)JOptionPane.showInputDialog( | |
null, "Spell to cast:\n", "Deki Stun Alch", | |
JOptionPane.PLAIN_MESSAGE, null, spells, null); | |
} | |
@Override | |
public int loop() { | |
if (!Inventory.contains(item)) { | |
setStopping(true); | |
return 0; | |
} | |
if (shouldAlch) { | |
Tabs.open(Tab.MAGIC); | |
Magic.cast(alch); | |
Time.sleep(200); | |
Inventory.getFirst(item).interact("Cast"); | |
shouldAlch = false; | |
return 1400; | |
} | |
if (Players.getLocal().getTarget() != null) { | |
Tabs.open(Tab.MAGIC); | |
Time.sleep(100); | |
firstSpell.getAddress().resolve().interact("Cast"); | |
Time.sleep(300); | |
if (Players.getLocal().getTarget() != null) { | |
Players.getLocal().getTarget().interact("Cast"); | |
shouldAlch = true; | |
} | |
return 900; | |
} | |
Npc npc = Npcs.getNearest(this.npc); | |
if (npc != null) { | |
Tabs.open(Tab.MAGIC); | |
Time.sleep(100); | |
firstSpell.getAddress().resolve().interact("Cast"); | |
Time.sleep(300); | |
npc.interact("Cast"); | |
shouldAlch = true; | |
return 900; | |
} | |
return 1000; | |
} | |
@Override | |
public void notify(ChatMessageEvent chatMessageEvent) { | |
if (chatMessageEvent.getMessage().contains("You do not have enough ") && chatMessageEvent.getMessage().contains(" to cast this spell")) { | |
System.out.println("Not enough runes!"); | |
setStopping(true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment