`
rainshow
  • 浏览: 31434 次
  • 性别: Icon_minigender_1
  • 来自: 厦门
文章分类
社区版块
存档分类
最新评论

昆仑ONLINE外挂脚本--基于Seraph

阅读更多
下面是我开发的基于seraph的昆仑外挂:

外挂功能:
1)自动移动找怪
2)移动卡住时随机移动
3)自动复位
4)验证码避开
5)自动战斗(反应时间<1秒)
6)自动根据怪物的数量选择战斗技能
7)自动抓宝宝
8)自动给人物和宝宝补红、补蓝
9)自动丢弃垃圾物品

下面是脚本内容:
=========================================================================
# 在此定义全局变量
dim startTime //挂机的开始时间
dim bbImage //宝宝图片
dim aimImage //怪物图片
dim blueImage //蓝
dim redImage //红
dim purpleImage //紫
dim blue1Image //中蓝
dim red1Image //中红
dim purple1Image //中紫
dim fuckImage //验证码
dim enterImage //进入游戏
dim testImage //测试用图片
dim redbarImage //
dim ooImage //地图原点位置(未使用)
dim skillImage //技能
dim p00Image //相对原点
dim digitImages[10] //数字图片0-9
dim slashImage //斜线图片(分隔 当前血/总血量)
dim dropImages[13] //需要抛弃的物品
dim origx //原点x坐标
dim origy //原点y坐标
dim px //相对原点x坐标
dim py //相对原点y坐标
dim logfile="kunlun.log"

function main
//SetInputMode(2)
dim targetWinID //目标窗口
Print("重置随机数")
Randomize() //随机数,用于移动卡住时做随机移动
Print("开始初始化")
initialize() //初始化
//FindWindow("昆仑 S5-纵横四海(电信) - 谷歌浏览器", targetWinID)
Print("查找目标窗口")
startTime=GetTime() //获取当前时间
WriteLog(logfile,"进入游戏的时间:"&startTime)
FindWindow(GetConfigString("winName"), targetWinID)
if IsNull(targetWinID) then //找不到目标窗口
  Print("窗口["&GetConfigString("winName")&"]不存在")
else
  GetWindowXY(targetWinID, winLeft, winTop)
  Print("发现目标窗口,窗口位置["&winLeft&","&winTop&"]")
  getPos() //获取原点坐标
  saveLocation1() //记录原点坐标
  //drop() //丢弃垃圾
  //checkBlueAndRed1()
  WHILE true
   //WriteLog(logfile,"检查红蓝")
   checkBlueAndRed1(false) //检查红蓝
   //WriteLog(logfile,"开始移动")
   move() //移动
   //WriteLog(logfile,"结束移动")
  WEND
end if
end function

//本方法获取游戏中画面中的相对原点
function getPos()
if FindImageEx(p00Image,Color(20,20,20),0,0,512,768,true,px,py) then
  WriteLog(logfile,"参照物坐标["&px&","&py&"]")
end if
//Print(px)
//Print(py)
end function

//初始化图片
function initialize()
LoadImage("bb.sel",bbImage)
LoadImage("aim1.sel",aimImage)
LoadImage("blue.sel",blueImage)
LoadImage("red.sel",redImage)
LoadImage("purple.sel",purpleImage)
LoadImage("blue1.sel",blue1Image)
LoadImage("red1.sel",red1Image)
LoadImage("purple1.sel",purple1Image)
LoadImage("fuck.sel",fuckImage)
LoadImage("enter.sel",enterImage)
LoadImage("test.sel",testImage)
LoadImage("red_bar.sel",redbarImage)
LoadImage("oo.sel",ooImage)
LoadImage("skill.sel",skillImage)
LoadImage("00.sel",p00Image)

LoadImage("d1.sel",digitImages[1]) //1
LoadImage("d2.sel",digitImages[2]) //2
LoadImage("d3.sel",digitImages[3])
LoadImage("d4.sel",digitImages[4])
LoadImage("d5.sel",digitImages[5])
LoadImage("d6.sel",digitImages[6])
LoadImage("d7.sel",digitImages[7])
LoadImage("d8.sel",digitImages[8])
LoadImage("d9.sel",digitImages[9]) //9
LoadImage("d0.sel",digitImages[10]) //0

LoadImage("drop_01.sel",dropImages[1])
LoadImage("drop_02.sel",dropImages[2])
LoadImage("drop_03.sel",dropImages[3])
LoadImage("drop_04.sel",dropImages[4])
LoadImage("drop_05.sel",dropImages[5])
LoadImage("drop_06.sel",dropImages[6])
LoadImage("drop_07.sel",dropImages[7])
LoadImage("drop_08.sel",dropImages[8])
LoadImage("drop_09.sel",dropImages[9])
LoadImage("drop_10.sel",dropImages[10])
LoadImage("drop_11.sel",dropImages[11])
LoadImage("drop_12.sel",dropImages[12])
LoadImage("drop_13.sel",dropImages[13])

LoadImage("slash.sel",slashImage)
end function

function checkBlueAndRed()
if CheckColor(px-8,py-468,Color(255,223,178),0) then
  //bb red
  if CheckColor(px+106,py-386,Color(243,77,77),10) then
   //red of bb is enougth
  else
   if not packageOpened() then
    KeyPress("B")
    wait(100)
   end if
   addBBRed()
  end if
  
  //character blue
  //if CheckColor(px+87, py-421, Color(0, 80, 182), 10) then //判断坐标(100, 100)上的颜色是否接近黑色,容差20
   //mana is enougth
  //else
  // if not packageOpened() then
  //  KeyPress("B")
  //  wait(100)
  // end if
  // addBlue()
  //end if
  //character red
  i=0
  while i<50
   if CheckColor(px+53+i, py-422, Color(111, 102, 105), 5) then
    if not packageOpened() then
     KeyPress("B")
     wait(100)
    end if
    addBlue()
    i=999
   end if
   i=i+1
  wend
  
  
  //bb blue
  if CheckColor(px+103,py-374,Color(0,102,233),10) then
   //mana of bb is enougth
  else
   if not packageOpened() then
    KeyPress("B")
    wait(100)
   end if
   addBBBlue()
  end if
  
  //character red
  i=0
  while i<60
   if CheckColor(px+53+i, py-436, Color(107, 103, 102), 5) then
    if not packageOpened() then
     KeyPress("B")
     wait(100)
    end if
    addRed()
    i=999
   end if
   i=i+1
  wend

  if packageOpened() then
   KeyPress("B")
  end if
end if
end function

function checkBlueAndRed1(waitFor)
if not waitFor and not CheckColor(px-8,py-468,Color(255,223,178),0) then
  //do nothing
else
  CopyScreen()
  loopFlag=true
  found=true
  while loopFlag and not (FindImage(slashImage, px+50,py-441,px+120,py-430, false, slx, sly) or FindImage(slashImage, px+50,py-428,px+120,py-417, false, slx1, sly1))
   if not waitFor then
    loopFlag=false
    found=false
   else
    Wait(50)
    CopyScreen()
   end if
  wend
  
  if found then
   //bb red
   redp=GetConfigNumber("pet-red-percent")
   keydot=Int(55*(redp/100)) //55 是血条的长度
   if CheckColor(px+72+keydot,py-386,Color(243,77,77),10) then
    //red of bb is enougth
   else
    if not packageOpened() then
     KeyPress("B")
     wait(50)
    end if
    addBBRed()
   end if
  
   //bb blue
   bluep=GetConfigNumber("pet-blue-percent")
   keydot=Int(55*(bluep/100)) //55 是血条的长度
   if CheckColor(px+72+keydot,py-374,Color(0,102,233),10) then
    //mana of bb is enougth
   else
    if not packageOpened() then
     KeyPress("B")
     wait(50)
    end if
    addBBBlue()
   end if
  
   cred=0
   tred=0
   if ReadNumberEx(digitImages,Color(20,20,20),px+50,py-441,slx,py-430,true,red1) then
    cred=CNum(red1)
   end if
   if ReadNumberEx(digitImages,Color(20,20,20),slx,py-441,px+120,py-430,true,red2) then
    tred=CNum(red2)
   end if
   if tred-cred>GetConfigNumber("red-fill") then
    WriteLog(logfile,"人物红:"&cred&"/"&tred)
    if not packageOpened() then
     KeyPress("B")
     wait(50)
    end if
    addRed()
   end if
  
   cblue=0
   tblue=0
   if ReadNumberEx(digitImages,Color(20,20,20),px+50,py-428,slx1,py-417,true,blue1) then
    cblue=CNum(blue1)
   end if
   if ReadNumberEx(digitImages,Color(20,20,20),slx1,py-428,px+120,py-417,true,blue2) then
    tblue=CNum(blue2)
   end if
   if tblue-cblue>GetConfigNumber("blue-fill") then
    WriteLog(logfile,"人物蓝:"&cblue&"/"&tblue)
    if not packageOpened() then
     KeyPress("B")
     wait(50)
    end if
    addBlue()
   end if    
  
   if packageOpened() then
    KeyPress("B")
   end if
  end if
end if
end function

function packageOpened()
if CheckColor(px+658, py-342, Color(252, 232, 24), 5) and CheckColor(px+658, py-242, Color(252, 232, 24), 5) and CheckColor(px+658, py-142, Color(252, 232, 24), 5) then
  packageOpened=true
else
  packageOpened=false
end if
end function

function addBlue()
WriteLog(logfile,"人物蓝少")
getBluePos(bpx,bpy)
if not IsNull(bpx) then
  MouseLeftClick(px+483,py-191,100)
  wait(100)
  MouseLeftDBClick(bpx+3,bpy+3,100)
  WriteLog(logfile,"补蓝成功!")
else
  WriteLog(logfile,"补蓝失败!")
end if
end function

function addBBBlue()
WriteLog(logfile,"宝宝蓝少")
getBluePos(bpx,bpy)
if not IsNull(bpx) then
  MouseLeftClick(px+562,py-191,100)
  wait(100)
  MouseLeftDBClick(bpx+3,bpy+3,100)
  WriteLog(logfile,"补蓝成功!")
else
  WriteLog(logfile,"补蓝失败!")
end if
end function

function addRed()
WriteLog(logfile,"人物红少")
getRedPos(rpx,rpy)
if not IsNull(rpx) then
  MouseLeftClick(px+483,py-191,100)
  wait(100)
  MouseLeftDBClick(rpx+3,rpy+3,100)
  WriteLog(logfile,"补红成功!")
else
  WriteLog(logfile,"补红失败!")
end if
end function

function addBBRed()
WriteLog(logfile,"宝宝红少")
getRedPos(rpx,rpy)
if not IsNull(rpx) then
  MouseLeftClick(px+562,py-191,100)
  wait(100)
  MouseLeftDBClick(rpx+3,rpy+3,100)
  WriteLog(logfile,"补红成功!")
else
  WriteLog(logfile,"补红失败!")
end if
end function

function getRedPos(byref rpx,byref rpy)
if not FindImage(redImage,px+374,py-166,px+551,py-24,true,rpx,rpy)  then
  if not FindImage(red1Image,px+374,py-166,px+551,py-24,true,rpx,rpy)  then
   if not FindImage(purpleImage,px+374,py-166,px+551,py-24,true,rpx,rpy)  then
    if not FindImage(purple1Image,px+374,py-166,px+551,py-24,true,rpx,rpy)  then
     WriteLog(logfile,"警告:红紫没有发现")
    end if
   end if
  end if
end if
end function

function getBluePos(byref bpx,byref bpy)
if not FindImage(blueImage,px+374,py-166,px+551,py-24,true,bpx,bpy)  then
  if not FindImage(blue1Image,px+374,py-166,px+551,py-24,true,bpx,bpy)  then
   if not FindImage(purpleImage,px+374,py-166,px+551,py-24,true,bpx,bpy)  then
    if not FindImage(purple1Image,px+374,py-166,px+551,py-24,true,bpx,bpy)  then
     WriteLog(logfile,"警告:蓝紫没有发现")
    end if
   end if
  end if
end if
end function

function getRndStep(unit)
rnum1=Rnd()
rnum1=rnum1-0.5
if rnum1<0 then
  //Print(Round(unit*(-0.3+0.4*rnum1)))
  getRndStep=Round(unit*(-0.3+0.4*rnum1))
else
  //Print(Round(unit*(0.3+0.4*rnum1)))
  getRndStep=Round(unit*(0.3+0.4*rnum1))
end if
end function

function getOffsetX(xx,byref offsetx,byref offsety)
offsetx=(xx-origx)*40
offsety=(xx-origx)*20
end function

function getOffsetY(yy,byref offsetx,byref offsety)
offsetx=(origy-yy)*40
offsety=(yy-origy)*20
end function

//center 355 322
dim lastx=0
dim lasty=0
dim same=0

function move()
if ReadNumber(digitImages,px+567,py-434,px+620,py-422,true,n3) and ReadNumber(digitImages,px+626,py-434,px+679,py-422,true,n4) then
  num3=CNum(n3)
  num4=CNum(n4)
  Print("读取人物的昆仑坐标["&num3&","&num4&"]")
  if num3=lastx and num4=lasty then
   same=same+1
   if same=20 then
    Print("Random move")
    MouseLeftClick(px+339-getRndStep(200), py-232-getRndStep(100))
    same=0
   else
    MouseLeftClick(px+339-160, py-232+80)
    searchAim(8)
    MouseLeftClick(px+339+160, py-232-80)
    searchAim(8)
   end if
   searchAim(2)
   wait(100)
  else
   same=0
   if Abs(num3-origx)>2 or Abs(num4-origy)>2 then
    Print("Original pos["&origx&","&origy&"]")
    Print("Current  pos["&num3&","&num4&"]")
    Dim x1,y1,x2,y2
    getOffsetX(num3,x1,y1)
    getOffsetY(num4,x2,y2)
    //print(x1)
    Print("横向移动"&(x1+x2)&",纵向移动"&(y1+y2))
    //Print("Move to ["& (px+339-40*(num3-origx)) & "," & (py-232-20*(num4-origy)) &"]")
    if x1+x2<-185 and y1+y2>150 then
     MouseLeftClick(px+339+185, py-232-150)
    else
     MouseLeftClick(px+339-(x1+x2), py-232-(y1+y2))
    end if
    searchAim(6)
   else
    MouseLeftClick(px+339-160, py-232+80)
    searchAim(8)
    MouseLeftClick(px+339+160, py-232-80)
    searchAim(8)
   end if
  end if
  lastx=num3
  lasty=num4
else
  Print("人物的昆仑坐标没有发现,等待")
  Wait(100)
  searchAim(2)
end if
end function

function searchAim(scount)
FOR i=1 TO scount
  if lookFor() then
   Exit For
  end if
NEXT
end function

function lookFor()
fuckOff()
if CheckColor(px+570, py-89, Color(0, 255, 255), 20) then
  catched=catchBB()
  //catched=catchTest()
  idle(catched)
  lookFor=true
else
  Wait(50)
  lookFor=false
  //Print("searching...")
end if
end function

function idle(catched)
while not CheckColor(px-8, py-468, Color(255, 223, 178), 10)
  if catched=false then
   if FindImageEx(skillImage,Color(20,20,20),px+170,py-20,px+501,py+28,true,skx,sky) then
    lastFoundX=-1
    lastFoundY=0
    CopyScreen(px-18,0,px+494,768)
    aims=0
    while FindImageEx(aimImage,Color(5,5,5),px-10,py-478,px+362,py-142,lastFoundX,lastFoundY,false,foundX,foundY)
     aims=aims+1
     lastFoundX=foundX
     lastFoundY=foundY+16
    wend
    
    Print(aims&" aims was(were) found")
    
    if aims>1 then
     KeyPress("1",100)
     wait(10)
     MouseLeftClick(lastFoundX+25,lastFoundY+50,50) //attack
     //MouseLeftClick(lastFoundX+5,lastFoundY+50,50)
     //MouseLeftDBClick()
     wait(260)
     KeyPress("2",100)
     Wait(50)
     MouseLeftClick(lastFoundX+25,lastFoundY+50,50) //bb attack
     //MouseLeftClick(lastFoundX+5,lastFoundY+50,50) //bb attack
    else
     MouseLeftDBClick(lastFoundX+25,lastFoundY+50,50) //attack
     //MouseLeftDBClick(lastFoundX+5,lastFoundY+50,50) //attack
     //MouseLeftDBClick()
     Wait(260)
     KeyPress("1",100)
     wait(50)
     MouseLeftClick(lastFoundX+25,lastFoundY+50,50) //bb attack
     //MouseLeftClick(lastFoundX+5,lastFoundY+50,50) //bb attack
    end if
   end if
  else
   wait(100)
   MouseLeftDBClick()
   catched=false
  end if
  wait(50)
wend
//wait(500)
checkBlueAndRed1(true)

if GetTime()-startTime>GetConfigNumber("timeout") then
  Wait(5000)
  MouseLeftClick(px+663,py+19)
  Wait(200)
  MouseLeftClick(px+336,py-139)
  Wait(200)
  MouseLeftClick(px+309,py-198)
  //Wait(3000)
  
  while not FindImage(enterImage,px+406,py-322,px+698,py-123,true,enterx,entery)
   wait(500)
  wend
  MouseLeftClick(enterx+40,entery+12)
  Wait(5000)
  startTime=GetTime()
  WriteLog(logfile,"开始丢弃")
  drop()
end if
end function

function catchBB()
if FindImageEx(bbImage,Color(5,5,5),px-18,py-478,px+362,py-142,true,bbx,bby)  then
  WriteLog(logfile,"发现宝宝!!!!!!"&"bb posx=" & bbx & "posy=" & bby)
  MouseLeftClick(px+585,py-15)
  MouseLeftClick(bbx-6,bby+50)
  //Beep(800, 500)
  catchBB=true
else
  catchBB=false
end if
end function

function catchTest()
if FindImageEx(testImage,Color(5,5,5),px-18,py-478,px+362,py-142,true,testx,testy)  then
  WriteLog(logfile,"test posx=" & testx & "posy=" & testy)
  MouseLeftClick(px+585,py-15)
  MouseLeftClick(testx+24,testy+50)
  //Beep(800, 1000)
  catchTest=true
else
  catchTest=false
end if
end function

function saveLocation1()
if ReadNumber(digitImages,px+567,py-434,px+620,py-422,true,n1) then
  origx=CNum(n1)
  //print(num1)
end if
if ReadNumber(digitImages,px+626,py-434,px+679,py-422,true,n2) then
  origy=CNum(n2)
  //print(num2)
end if
end function

function saveLocation()
KeyPress("M")
Wait(300)
FindImage(ooImage,px+68,py-313,px+652,py-20,true,origx,origy)
WriteLog(logfile,"原点地址["&origx&","&origy&"]")
KeyPress("M")
end function

function reset()
KeyPress("M")
Wait(300)
MouseLeftDBClick(origx+2,origy+3)
WriteLog(logfile,"开始复位["&origx&","&origy&"]")
KeyPress("M")
Wait(1000)
end function

function fuckOff()
if FindImage(fuckImage,px+184,py-355,px+496,py-85,true,FoundX,FoundY) then
  //Beep(800, 1000)  
  //KeyPress("F5")
  //MouseLeftClick(px+61,py-497) //google
  Wait(3000)
  MouseLeftClick(px+82,py-497) // ff
  waitAndEnter()
end if
end function

function waitAndEnter()
//while not FindImage(enterImage,px+406,py-322,px+698,py-123,true,enterx,entery)
// wait(500)
//wend
Wait(5000)
//循环播放声音文件"d:\mp3\最爱你的时候.mp3"
PlaySound("E:\game\kunlun\最爱你的时候.mp3")
Wait(999999999)
//MouseLeftClick(enterx+40,entery+12)
end function

function drop()
Wait(200)
if not packageOpened() then
  KeyPress("B",100)
  Wait(200)
end if
MouseLeftClick(px+571,py-159,100)
Wait(200)
FOR i=1 TO ArrayLen(dropImages,1)
  if FindImage(dropImages,px+374,py-166,px+551,py-24,true,tmpx,tmpy)  then
   WriteLog(logfile,"Drop item["& i &"]")
   MouseLeftClick(tmpx,tmpy,200)
   Wait(200)
   MouseLeftClick(px+597,py-110,100) // drop
   Wait(200)
   MouseLeftClick(px+323,py-202,150) //confirm
   Wait(200)
  end if
NEXT
Wait(200)
MouseLeftClick(px+625,py-159,100)
Wait(200)
FOR i=1 TO ArrayLen(dropImages,1)
  if FindImage(dropImages,px+374,py-166,px+551,py-24,true,tmpx,tmpy)  then
   WriteLog(logfile,"Drop item["& i &"]")
   MouseLeftClick(tmpx,tmpy,100)
   Wait(200)
   MouseLeftClick(px+597,py-110,100) // drop
   Wait(200)
   MouseLeftClick(px+323,py-202,150) //confirm
   Wait(200)
  end if
NEXT
Wait(200)
MouseLeftClick(px+571,py-159,100)
Wait(200)
if packageOpened() then
  KeyPress("B",100)
  Wait(200)
end if
end function
=========================================================================

下面是外挂的配置文件:
=========================================================================
[NAME]
winName
[DESC]
游戏窗口的名称
[VALUE]
昆仑 S5-纵横四海(电信) - Microsoft Internet Explorer
[NAME]
timeout
[DESC]
重新登陆系统的时间(单位:秒)
[VALUE]
1500000
[NAME]
red-fill
[DESC]
当人物血减少了超过当前参数设置时,开始给人物补红
[VALUE]
600
[NAME]
blue-fill
[DESC]
当人物的蓝减少量超过当前参数设置时,开始给人物补蓝
[VALUE]
500
[NAME]
pet-red-percent
[DESC]
宠物的血量<当前参数值时,开始给宠物补血
[VALUE]
80
[NAME]
pet-blue-percent
[DESC]
宠物蓝<当前参数值时,开始给宠物补蓝
[VALUE]
50
[EOF]
=========================================================================
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics