以下是我在大三时,武林外传游戏还在公测时写的一个外挂,辅助玩游戏。以前在大学时用着很好用,和大家共享出来。希望有朋友能够进行重构,发布一些更好用的JAVA实现的外挂程序。
由于这是本人的处女做,所以代码结构有些乱,但由于程序本身并不是很复杂,有心人是一定会看懂的,此外还有一些简单的注释。
由于当时不会使用IDE,仅用记事本写的,所以写得比较辛苦,也花费了较长时间。希望对大家能够有所帮助。
package game; import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; import java.lang.*; import java.io.*; //主类 public class Action { static int TimeNumber=0; public static void main(String[] args) { ViewFlow vf=new ViewFlow(); vf.addActionlistener(); } }
package game; import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; import java.lang.*; import java.io.*; class MyActionListener2 implements ActionListener//核心类(实现主要功能) { static int ip=0; public void actionPerformed(ActionEvent e2) { try { Robot robot=new Robot(); int x=73,y=23, x2=ViewFlow.slider1.getValue(), y2=23, x3=228,y3=26, x4=0,y4=0; /* int i=ViewFlow.slider1.getValue(),j=23,k=0; { try { Robot rb=new Robot(); while(k<1) { rb.mouseMove(i,j); rb.getPixelColor(i,j); System.out.print((k++)+": "+rb.getPixelColor(i,j)+": "); System.out.println("(i="+(i++)+",j="+j+");"); } } catch(AWTException e3){} } */ if(robot.getPixelColor(x,y).equals(new Color(255,75,53))&&MyActionListener2.ip==1)//自动打怪 { robot.keyPress(KeyEvent.VK_5);//捡东西 if( robot.getPixelColor(x3,y3).equals(new Color(255,107,87)) ||robot.getPixelColor(x3,y3).equals(new Color(255,107,86))) { robot.keyPress(KeyEvent.VK_1);//技能1 //robot.keyPress(KeyEvent.VK_2);//技能2 //robot.keyPress(KeyEvent.VK_3);//技能3 //robot.keyPress(KeyEvent.VK_4);//打怪1 } else { robot.keyPress(KeyEvent.VK_TAB); robot.keyRelease(KeyEvent.VK_TAB); } } //System.out.println(MyActionListener.myTimer.getDelay());//改变加血速度测试 if(!robot.getPixelColor(x,y).equals(new Color(255,75,53))) { ViewFlow.setText1("提示:请启动游戏"); //System.out.println(ViewFlow.slider1.getValue());//测试1 //System.out.println(ViewFlow.slider2.getValue());//测试2 } else if( robot.getPixelColor(x2,y2).equals(new Color(255,75,53)) //加血位置与血的颜色相等 ||robot.getPixelColor(x,y).equals(robot.getPixelColor(x2,y2)) //加血位置与指定的理想的血的位置的颜色相等 /* ||robot.getPixelColor(x2,y2).equals(new Color(255,159,147)) //加血位置与指血的颜色1比较 ||robot.getPixelColor(x2,y2).equals(new Color(247,193,186)) //加血位置与指血的颜色2比较 ||robot.getPixelColor(x2,y2).equals(new Color(228,103,88)) //加血位置与指血的颜色3比较 ||robot.getPixelColor(x2,y2).equals(new Color(245,72,51)) //加血位置与指血的颜色4比较 ||robot.getPixelColor(x2,y2).equals(new Color(255,183,174)) //加血位置与指血的颜色5比较 ||robot.getPixelColor(x2,y2).equals(new Color(228,91,75)) //加血位置与指血的颜色6比较 ||robot.getPixelColor(x2,y2).equals(new Color(248,73,52)) //加血位置与指血的颜色7比较 ||robot.getPixelColor(x2,y2).equals(new Color(225,195,188)) //加血位置与指血的颜色8比较 ||robot.getPixelColor(x2,y2).equals(new Color(235,141,130)) //加血位置与指血的颜色9比较 ||robot.getPixelColor(x2,y2).equals(new Color(235,69,49)) //加血位置与指血的颜色10比较 ||robot.getPixelColor(x2,y2).equals(new Color(239,154,144)) //加血位置与指血的颜色11比较 */ ) { ViewFlow.setText1("不需加血"); } else if( robot.getPixelColor(x,y).equals(new Color(255,75,53))//加血 &&!robot.getPixelColor(x,y).equals(robot.getPixelColor(x2,y2)) ) { robot.keyPress(KeyEvent.VK_F8);//加血的键位 //ViewFlow.setText1("自动加血开始"); } } catch(AWTException eException1){} } }
package game; import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; import java.lang.*; import java.io.*; class MyActionListener3 implements ActionListener { public void actionPerformed(ActionEvent e3) { MyActionListener.myTimer.stop(); ViewFlow.setText1(" 外挂程序已停止"); } }
package game; import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; import java.lang.*; import java.io.*; class MyActionListener4 implements ActionListener { public void actionPerformed(ActionEvent e7) { if(e7.getSource()==ViewFlow.helpMenuItem1)//打开使用帮助网页 { try { Runtime.getRuntime().exec("\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"http://blog.csdn.net/sunnyjavamoon/archive/2006/10/27/1352772.aspx"); } catch(IOException eIO){} } else if(e7.getSource()==ViewFlow.helpMenuItem2)//打开在线更新网页 { try { Runtime.getRuntime().exec("\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"http://blog.csdn.net/sunnyjavamoon/archive/2006/11/04/1366552.aspx"); } catch(IOException eIO){} } else if(e7.getSource()==ViewFlow.helpMenuItem3)//打开作者主页网页 { try { Runtime.getRuntime().exec("\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"http://blog.csdn.net/SunnyJavaMoon/"); } catch(IOException eIO){} } else if(e7.getSource()==ViewFlow.helpMenuItem4)//打开关于网页 { try { Runtime.getRuntime().exec("\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"http://blog.csdn.net/sunnyjavamoon/archive/2006/10/27/1352772.aspx"); } catch(IOException eIO){} } else if(e7.getSource()==ViewFlow.exchangeItem1)//论坛交流 { try { Runtime.getRuntime().exec("\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"http://vip3.getbbs.com/Board/TList.aspx?BID=5177"); } catch(IOException eIO){} } else if(e7.getSource()==ViewFlow.exchangeItem2)//论坛主页 { try { Runtime.getRuntime().exec("\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"http://ljf365.getbbs.com"); } catch(IOException eIO){} } else if(e7.getSource()==ViewFlow.jbt3)//论坛主页 { try { Runtime.getRuntime().exec("\"C:\\Program Files\\Internet Explorer\\iexplore.exe\"http://blog.csdn.net/sunnyjavamoon/archive/2006/11/04/1366552.aspx"); } catch(IOException eIO){} } } }
package game; import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; import java.lang.*; import java.io.*; class MyActionListener implements ActionListener { static Timer myTimer=new Timer(1500,new MyActionListener2());//速度控制 public void actionPerformed(ActionEvent e) { ViewFlow.setText1(" 外挂程序启动中......"); MyActionListener.myTimer.start(); } }
package game; import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; import java.lang.*; import java.io.*; class MyChangeListener1 implements ChangeListener { public void stateChanged(ChangeEvent e4) { ViewFlow.setText2("加血位置:"+ViewFlow.slider1.getValue()+"/170"); } }
package game; import javax.swing.*; import java.awt.*; import java.awt.event.*; import javax.swing.event.*; import java.lang.*; import java.io.*; class MyChangeListener2 implements ChangeListener { public void stateChanged(ChangeEvent e5) { ViewFlow.setText3("加血速度:"+ViewFlow.slider2.getValue()+" 毫秒/次"); MyActionListener.myTimer.setDelay(ViewFlow.slider2.getValue()); } }