Guest User

Untitled

a guest
Jun 21st, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.98 KB | None | 0 0
  1. /**
  2. * Created by Mortenrb for KBot.info
  3. */
  4. package com.scripts;
  5.  
  6. import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
  7. import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
  8. import com.kbot2.scriptable.Script;
  9. import com.kbot2.scriptable.methods.data.Skills;
  10. import com.kbot2.scriptable.methods.input.Mouse;
  11. import com.kbot2.scriptable.methods.wrappers.GroundItem;
  12. import com.kbot2.scriptable.methods.wrappers.NPC;
  13. import com.kbot2.scriptable.methods.wrappers.Tile;
  14. import com.kbot2.scriptable.methods.data.Walking;
  15. import java.awt.*;
  16.  
  17. public class ChickenKiller extends Script implements PaintListener, ServerMessageListener {
  18.  
  19. private chickenframe FRAME;
  20.  
  21. NPC C;
  22. GroundItem P;
  23.  
  24. int[] chickens = new int[]{2313, 2314, 2315, 1017, 41};
  25. Tile[] RND = new Tile[] {new Tile(2673, 3420)};
  26. int PICKUP[];
  27. int DONE[];
  28. int SKILL = 2;
  29.  
  30.  
  31. private boolean _active = true;
  32. private boolean runnable = false;
  33.  
  34.  
  35. @Override
  36. public boolean active() {
  37. return _active;
  38. }
  39.  
  40. @Override
  41. public boolean onStart() {
  42. log("Welcome to Mortenrb's Chicken Killer");
  43. FRAME = new chickenframe();
  44. FRAME.setVisible(true);
  45. return true;
  46. }
  47.  
  48. public String getName() {
  49. return "Chicken Killer";
  50. }
  51.  
  52. public String getVer() {
  53. return "v1,0";
  54. }
  55.  
  56. public String getAuthor() {
  57. return "Mortenrb";
  58. }
  59.  
  60. public String getDescription() {
  61. return "It kills chickens!\n\nYou have to start in a chicken farm or some\nplace close to chickens to make the script work.";
  62. }
  63.  
  64. public void onServerMessage(String e) {
  65. if (e.contains("Someone else is")) {
  66. walking.randomizePath(RND, 3, 3);
  67. }
  68. if (e.contains("I'm already under")) {
  69. log("Fixing this soon, I think.");
  70. }
  71. }
  72.  
  73. public int loop() {
  74. if(runnable) {
  75. if(skills.getLevel(SKILL) >= DONE[0]) {
  76. log("Level archeived.");
  77. _active = false;
  78. }
  79. if(!getMyPlayer().isInCombat() && !getMyPlayer().isMoving() && getMyPlayer().getAnimation() == -1) {
  80. P = groundItems.getClosestItem(10, PICKUP);
  81. if(P != null) {
  82. log("Picking up items.");
  83. P.doAction("Take");
  84. return random (300, 1200);
  85. }
  86. C = npcs.getClosest(10, chickens);
  87. if (C != null) {
  88. C.doAction("Attack");
  89. return random (300, 1200);
  90. }
  91. }
  92. return random (300, 1200);
  93. }
  94. return random (300, 1200);
  95. }
  96.  
  97. public void onRepaint(Graphics g) {
  98. g.drawString("Script: " + getName() + " " + getVer(), 250, 370);
  99. g.drawString("Creator: " + getAuthor(), 250, 385);
  100. g.drawString("Current Level In Training Skill: " + skills.getLevel(SKILL), 250, 400);
  101. }
  102. public int[] extractIntegers(String text) { // Thanks to
  103. int[] ints = null;
  104. try {
  105. text = text.replaceAll(" ", "");
  106. String[] strInts = text.split(",");
  107. ints = new int[strInts.length];
  108. for (int a = 0; a < strInts.length; a++) {
  109. ints[a] = Integer.parseInt(strInts[a]);
  110. }
  111. } catch (Exception e) {
  112. System.out.print("extractIntegers(String) error: " + e);
  113. }
  114. return ints;
  115. }
  116.  
  117. public class chickenframe extends javax.swing.JFrame {
  118.  
  119. /** Creates new form chickenframe */
  120. public chickenframe() {
  121. initComponents();
  122. }
  123.  
  124. /** This method is called from within the constructor to
  125. * initialize the form.
  126. * WARNING: Do NOT modify this code. The content of this method is
  127. * always regenerated by the Form Editor.
  128. */
  129. @SuppressWarnings("unchecked")
  130. // <editor-fold defaultstate="collapsed" desc="Generated Code">
  131. private void initComponents() {
  132.  
  133. buttonGroup1 = new javax.swing.ButtonGroup();
  134. jTextField1 = new javax.swing.JTextField();
  135. jLabel1 = new javax.swing.JLabel();
  136. jLabel2 = new javax.swing.JLabel();
  137. jLabel3 = new javax.swing.JLabel();
  138. jTextField2 = new javax.swing.JTextField();
  139. jLabel4 = new javax.swing.JLabel();
  140. jLabel5 = new javax.swing.JLabel();
  141. jRadioButton1 = new javax.swing.JRadioButton();
  142. jRadioButton2 = new javax.swing.JRadioButton();
  143. jRadioButton3 = new javax.swing.JRadioButton();
  144. jButton1 = new javax.swing.JButton();
  145.  
  146. setTitle("Mortenrb's Chicken Killer");
  147. setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
  148. setMinimumSize(new java.awt.Dimension(295, 230));
  149. setResizable(false);
  150.  
  151. jTextField1.setText("99");
  152.  
  153. jLabel1.setText("Stop Training At Level:");
  154.  
  155. jLabel2.setText("Train:");
  156.  
  157. jLabel3.setText("Pick up item ids:");
  158.  
  159. jTextField2.setText("0");
  160.  
  161. jLabel4.setForeground(new java.awt.Color(204, 0, 0));
  162. jLabel4.setText("Made By Mortenrb");
  163.  
  164. jLabel5.setForeground(new java.awt.Color(0, 0, 204));
  165. jLabel5.setText("Kosaki and KBot is hot");
  166.  
  167. buttonGroup1.add(jRadioButton1);
  168. jRadioButton1.setSelected(true);
  169. jRadioButton1.setText("Strength");
  170.  
  171. buttonGroup1.add(jRadioButton2);
  172. jRadioButton2.setText("Attack");
  173.  
  174. buttonGroup1.add(jRadioButton3);
  175. jRadioButton3.setText("Defence");
  176.  
  177. jButton1.setText("Start");
  178. jButton1.addActionListener(new java.awt.event.ActionListener() {
  179. public void actionPerformed(java.awt.event.ActionEvent evt) {
  180. jButton1ActionPerformed(evt);
  181. }
  182. });
  183.  
  184. javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
  185. getContentPane().setLayout(layout);
  186. layout.setHorizontalGroup(
  187. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  188. .addGroup(layout.createSequentialGroup()
  189. .addContainerGap()
  190. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  191. .addGroup(layout.createSequentialGroup()
  192. .addComponent(jLabel2)
  193. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
  194. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  195. .addComponent(jRadioButton1)
  196. .addComponent(jRadioButton2)
  197. .addComponent(jRadioButton3))
  198. .addContainerGap())
  199. .addGroup(layout.createSequentialGroup()
  200. .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
  201. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  202. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
  203. .addGap(132, 132, 132))
  204. .addGroup(layout.createSequentialGroup()
  205. .addGap(10, 10, 10)
  206. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
  207. .addContainerGap())
  208. .addGroup(layout.createSequentialGroup()
  209. .addComponent(jLabel3)
  210. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  211. .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)
  212. .addGap(123, 123, 123))
  213. .addGroup(layout.createSequentialGroup()
  214. .addComponent(jLabel4)
  215. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  216. .addComponent(jLabel5)
  217. .addContainerGap(11, Short.MAX_VALUE))))
  218. );
  219. layout.setVerticalGroup(
  220. layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  221. .addGroup(layout.createSequentialGroup()
  222. .addContainerGap()
  223. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
  224. .addComponent(jLabel2)
  225. .addComponent(jRadioButton1))
  226. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  227. .addComponent(jRadioButton2)
  228. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  229. .addComponent(jRadioButton3)
  230. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  231. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  232. .addComponent(jLabel1)
  233. .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  234. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  235. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  236. .addComponent(jLabel3)
  237. .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
  238. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  239. .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 20, Short.MAX_VALUE)
  240. .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
  241. .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
  242. .addComponent(jLabel4)
  243. .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)))
  244. );
  245.  
  246. java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
  247. setBounds((screenSize.width-236)/2, (screenSize.height-210)/2, 236, 210);
  248. }// </editor-fold>
  249.  
  250. // Variables declaration - do not modify
  251. private javax.swing.ButtonGroup buttonGroup1;
  252. private javax.swing.JButton jButton1;
  253. private javax.swing.JLabel jLabel1;
  254. private javax.swing.JLabel jLabel2;
  255. private javax.swing.JLabel jLabel3;
  256. private javax.swing.JLabel jLabel4;
  257. private javax.swing.JLabel jLabel5;
  258. private javax.swing.JRadioButton jRadioButton1;
  259. private javax.swing.JRadioButton jRadioButton2;
  260. private javax.swing.JRadioButton jRadioButton3;
  261. private javax.swing.JTextField jTextField1;
  262. private javax.swing.JTextField jTextField2;
  263. // End of variables declaration
  264.  
  265. }
  266.  
  267. public void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
  268. runnable = true;
  269. DONE = extractIntegers(FRAME.jTextField1.getText());
  270. PICKUP = extractIntegers(FRAME.jTextField2.getText());
  271. if (FRAME.jRadioButton1.isSelected()) {
  272. SKILL = 2;
  273. mouse.moveMouse(542, 182, 10, 5);
  274. mouse.clickMouse(true);
  275. sleep(300, 600);
  276. mouse.moveMouse(678, 273, 10, 5);
  277. mouse.clickMouse(true);
  278. sleep(300, 600);
  279. mouse.moveMouse(640, 189, 10, 5);
  280. mouse.clickMouse(true);
  281. }
  282. if (FRAME.jRadioButton2.isSelected()) {
  283. SKILL = 0;
  284. mouse.moveMouse(542, 182, 10, 5);
  285. mouse.clickMouse(true);
  286. sleep(300, 600);
  287. mouse.moveMouse(611, 274, 10, 5);
  288. mouse.clickMouse(true);
  289. sleep(300, 600);
  290. mouse.moveMouse(640, 189, 10, 5);
  291. mouse.clickMouse(true);
  292. }
  293. if (FRAME.jRadioButton3.isSelected()) {
  294. SKILL = 1;
  295. mouse.moveMouse(542, 182, 10, 5);
  296. mouse.clickMouse(true);
  297. sleep(300, 600);
  298. mouse.moveMouse(686, 330, 10, 5);
  299. mouse.clickMouse(true);
  300. sleep(300, 600);
  301. mouse.moveMouse(640, 189, 10, 5);
  302. mouse.clickMouse(true);
  303. }
  304. }
  305.  
  306. }
Add Comment
Please, Sign In to add comment