import java.awt.Rectangle; import impsoft.nexus.bots.color.constants.Areas; import impsoft.nexus.bots.color.methods.ColorRandom; import impsoft.nexus.bots.color.scriptobjects.RGB; import impsoft.nexus.bots.color.scriptobjects.RGBXY; import impsoft.nexus.bots.color.scriptobjects.XY; public class findTradeSRL extends ColorRandom { private static String[] noPhrases = { "nvm", "naw", "forget about it", "no thnx", "no", "nope", "no thanks", "noooooooooooooooo", "never mind" }; private static String[] thnxPhrases = { "thanks", "thank you", "gracias", "merci", "thnx m8", "go ma wo", "why thank you dear", "I shall thank thou for thee wonderful piece 'f arte", "xie..xie..ni?", "7hnXX :D", "*hug*", "I appreciate your goods", "I liked that!", "That helped me out a lot.", "That hard work was very great of you.", "You just did a million-dollar job for me", "heres some candy :)", "*me invites you to dinner*", "your the best", "I don't think I could be here w/o what you just did :)", "you rock", "i love you!", "thnx!", "u's hawt!" }; @Override public void random() throws InterruptedException { String Trader = getChat(4).split(" wishes to trade with you.")[0] .trim().toLowerCase(); log("TRADING WITH" + Trader + "\n"); Rectangle searchZone = Areas.GAME; searchZone.width = 20; RGBXY x = findRGBXY(getColorArray2d(), new RGB(8388736, RGB.COLOR_TYPE_SCAR), searchZone); if (x != null) { mouseClickLeft(x); long mark = System.currentTimeMillis(); do { sleep(random(500, 1000)); if (timeFromMark(mark) > 10000) { log("TRADE FAILED " + Trader); sleep(50 + Random(50)); return; } } while (!getColor(264, 194).equals( new RGB(49152, RGB.COLOR_TYPE_SCAR))); do { sleep(500 + Random(500)); if (timeFromMark(mark) > 20000 || getColor(264, 194) != new RGB(49152, RGB.COLOR_TYPE_SCAR)) { log("TRADE FAILED " + Trader); clickMSColor(192); sleep(50 + Random(50)); return; } } while (getColor(221, 316).equals( new RGB(16777215, RGB.COLOR_TYPE_SCAR))); clickMSColor(49152); // CLICK FIRST ACCEPT do { sleep(500 + Random(500)); if (timeFromMark(mark) > 10000) { log("TRADE FAILED " + Trader); sleep(50 + Random(50)); return; } } while (!getColor(228, 310).equals( new RGB(49152, RGB.COLOR_TYPE_SCAR))); do { sleep(500 + Random(500)); boolean b = !getColor(228, 310).equals( new RGB(49152, RGB.COLOR_TYPE_SCAR)); if (timeFromMark(mark) > 20000 || b) { log("TRADE FAILED " + Trader); clickMSColor(192); return; } } while (!getColor(228, 45).equals( new RGB(16776960, RGB.COLOR_TYPE_SCAR))); clickMSColor(49152); // CLICK SECOND ACCEPT sleep(2000); if (getColor(206, 312).equals(new RGB(49152, RGB.COLOR_TYPE_SCAR)) && getColor(279, 312).equals( new RGB(192, RGB.COLOR_TYPE_SCAR))) { clickMSColor(192); sendMyText(noPhrases[Random(noPhrases.length)] + " " + Trader); log("TRADE FAILED " + Trader); sleep(50 + Random(50)); } else { log("TRADE COMPLETE " + Trader); sleep(50 + Random(50)); sendMyText(thnxPhrases[Random(thnxPhrases.length)]); } } } public long timeFromMark(long mark) { return System.currentTimeMillis() - mark; } public void clickMSColor(int color) throws InterruptedException { XY z = FindColor(color, 3, 3, 515, 338); if (z != null) mouseClickLeft(z); } public void sendMyText(String Text) throws InterruptedException { // converted // from // spky's // awesome // method boolean mistakeMade = false; String mistakeWord = returnRandomWord(Text); int Posi = Text.indexOf(mistakeWord); String Buff = Text.substring(1, Posi); String Buffa = Text.substring(Posi + mistakeWord.length(), Text .length()); SendText(Buff); if (sendText2(mistakeWord)) mistakeMade = true; if (mistakeMade) { int MistakeType = 1 + Random(10); if (MistakeType == 1 || MistakeType == 2 || MistakeType == 3 || MistakeType == 4 || MistakeType == 5) { SendText(Buffa + "\n"); sleep(1000 + Random(1000)); SendText(mistakeWord + "*\n"); } if (MistakeType == 6 || MistakeType == 7 || MistakeType == 8 || MistakeType == 9) { int i = 0; do { i++; SendKey(8); sleep(50 + Random(150)); } while (i != mistakeWord.length()); sleep(Random(500)); SendText(Text.substring(Text.indexOf(mistakeWord), Text .length()) + "\n"); } if (MistakeType == 10) SendText(Buffa + "\n"); } else SendText(Buffa + "\n"); sleep(500 + Random(500)); } public String returnRandomWord(String s) { int Int = wordPosition(Random(s.split(" ").length), s); int i = Int; do { if (s.charAt(i + 1) != ' ') Int++; if (Int + 1 > s.length()) return ""; } while (s.charAt(Int + 1) != ' '); Int = Int - i; return s.substring(i, i + Int + 1).trim(); } private int wordPosition(int wordNumber, String s) { for (int i = 1; i < s.length(); i++) { if (s.substring(1, i).split(" ").length == wordNumber) return s.substring(1, i).length(); } return -1; } private boolean sendText2(String Text) throws InterruptedException { boolean result = false; int w = 0; for (int i = 1; i < Text.length() - 1; i++) { String s = String.valueOf(Text.charAt(i)); if (Random(5) + 1 == 1 && w < 3) { w++; result = true; int j = (int) (s.charAt(1)); if (j != 13) s = String.valueOf((char) (j + (Random(5) + 1))); if (s.equals(String.valueOf((char) 13))) s = "l"; } SendText(s); sleep(50 + Random(100)); } return result; } @Override public boolean startUp() throws InterruptedException { if (FindColor(8388736, 21, 416, 29, 425) != null) return true; return false; } }