//6.1更新增加随机数、识别战斗状态,测试无错误
//在我接触按键一月以来感谢【爱? 老婆'炜儿】一直以来的指导、帮助,一个很低调很热心的朋友,大哥哥,发自内心的感谢你...(此处省去1W字,O(∩_∩)O哈哈~)希望我们的友谊天长地久---------感恩版
//此脚本功能简单,由于还在学习大漠所以当时没有用上插件,这是半月前写出来的,早想编译出来了,可是学车耽误半月。。。
//测试地图:江南野外、大唐国境
//备注:附赠源码,只为交流学习,如有喜欢交流的朋友论坛找我吧
//论坛名字:豪燕
//QQ:839552004
UserVar Var1=DropList{"物理攻击":"A"|"法术攻击":"Q"}=0 "人物攻击"
UserVar Var2=DropList{"物理攻击":"A"|"法术攻击":"Q"}=0 "宠物攻击"
Hwnd = Plugin.Window.Foreground()
sRect = Plugin.Window.GetClientRect(Hwnd)
Dim MyArray
MyArray=Split(sRect,"|")
Ux=CLng(MyArray(0))
Uy=CLng(MyArray(1))
Call Plugin.Window.Move(Hwnd, 0, 0)
Hwndck = Plugin.Window.Find(0, "梦幻西游 聊天窗口")
Call Plugin.Window.Hide(Hwndck)
Rem 开始
KeyPress "Tab", 1
Delay 200
i = 0
While i=0
    FindPic 0,0,1024,768,"Attachment:\地图.bmp",0.2,dituX,dituY
    If dituX > 0 And dituY > 0 Then 
        Delay 200
        Call 随机数()
        i = 1
        Call 战斗()
    Else 
        KeyPress "Tab", 1
        SayString "没找到图"
    End If
Wend
KeyPress "Tab", 1
Call 战斗()
Delay 8000
Goto 开始
Sub 战斗()
    FindColorEx 286+Ux,34+Uy,368+Ux,81+Uy,"F8FCF8",0,0.9,intX,intY
    If intX > Ux And intY > Uy Then
        SayString "调用战斗"
        Rem 战斗
        FindPic Ux,Uy,Ux+640,Uy+480,"Attachment:\法术.bmp",0.9,intX,intY
        If intX > 0 And intY > 0 Then 
            SayString "战斗开始"
            MoveTo Ux, Uy
            LeftClick 1
            KeyDown 18, 1
            If Var1 = "A" Then 
                KeyPress "A", 1
            ElseIf Var1 = "Q" Then
                KeyPress "Q", 1
            End If
            KeyUp 18, 1
            Delay 500
            KeyDown 18, 1
            If Var2 = "A" Then 
                KeyPress "A", 1
            ElseIf Var2 = "Q" Then
                KeyPress "Q", 1
            End If
            KeyUp 18, 1
        End If
        Delay 8000
        FindColorEx 286+Ux,34+Uy,368+Ux,81+Uy,"F8FCF8",0,0.9,intX,intY
        If intX > Ux And intY > Uy Then 
                Goto 战斗
        Else
            Goto 战斗结束
        End If
    End If
    Rem 战斗结束
    Delay 1000
    MoveTo Ux, Uy
End Sub
Sub 随机数()
    Randomize
    //获得0-3的随机数
    n = Int(rnd * 4)
    If n = 0 Then 
        MoveTo 151 + dituX, 87 + dituY
        Delay 50
        LeftClick 1
    End If
    If n = 1 Then 
        MoveTo 355+dituX, 61+dituY
        Delay 50
        LeftClick 1
    End If
    If n = 2 Then 
        MoveTo 126+dituX, 224+dituY
        Delay 50
        LeftClick 1
    End If
    If n = 3 Then 
        MoveTo 370+dituX, 226+dituY
        Delay 50
        LeftClick 1
    End If