?? fight.ser
字號:
#[HOTKEY][EXT]MULTIPLY
#SetArgsOnCompile
#完美國際2自動打怪腳本
#游戲設置為800×600窗口模式
#另需要以下設置:
#關閉雷達地圖鎖定模式
#界面設置中,打開“顯示周圍怪物”,關閉“顯示地面物品名字”
#游戲設置中,打開“A,D轉向切換”
#按鍵設置:F1,F2技能,F3揀物,F7打坐
dim WinX,WinY
dim raidCX,raidCY
dim sitBlood,sitMP
dim pi
dim turnRate,forwardRate
#初始化全局變量
function Init
Init=false
pi = 4 * Atn(1)
GetActiveWindowXY(WinX, WinY)
raidCX=737
raidCY=58
GetActiveWindowSize(width, height)
if width<>800 or height<>600 then
Print("錯誤:只支持800*600的窗口模式運行游戲")
exit function
end if
sitBlood=GetConfigNumber("打坐血百分比")
sitMP=GetConfigNumber("打坐MP百分比")
turnRate=GetConfigNumber("轉向速率")
forwardRate=GetConfigNumber("前進速率")
Init=true
end function
#判斷一個顏色是否為怪的名字顏色
function IsMonsterNameColor(pixel)
r=GetR(pixel)
g=GetG(pixel)
b=GetB(pixel)
if r=g and g=b and r>252 then
IsMonsterNameColor = true
else
IsMonsterNameColor = false
end if
end function
#根據移動的XY差值計算當前的方向角度(按順利針從0到2pi)
function GetAngle(fromX, fromY, toX, toY)
dim angle
if toX-fromX=0 then
if toY-fromY>0 then
GetAngle=0
else
GetAngle=pi
end if
exit function
else
angle=Atn(-(toY-fromY)/(toX-fromX))
end if
if toX-fromX <0 then
angle=angle+pi
end if
GetAngle=angle+0.5*pi
end function
#判斷已有怪被選中
function IsMonsterSelected
GetPixel(WinX+338, WinY+24, true, pixel)
if pixel=Color(0,0,0) then
IsMonsterSelected=true
else
IsMonsterSelected=false
end if
end function
#判斷一個顏色點所在的名字邊界。返回0則不是一個字
function CalcNameRect(x, y, byref x0, byref y0, byref x1, byref y1)
x0=x
x1=x
y0=y
y1=y
pixelCount=0
#向右搜
missCount=0
curX=x
do
found=false
for j=-10 to 10
GetPixel(curX,y+j,false,pixel)
if IsMonsterNameColor(pixel) then
pixelCount=pixelCount+1
if curX>x1 then
x1=curX
end if
if y+j<y0 then
y0=y+j
end if
if y+j>y1 then
y1=y+j
end if
found=true
end if
next
if found then
missCount=0
else
missCount=missCount+1
end if
curX=curX+1
loop while missCount<3
#向左搜
missCount=0
curX=x
do
found=false
for j=-10 to 10
GetPixel(curX,y+j,false,pixel)
if IsMonsterNameColor(pixel) then
pixelCount=pixelCount+1
if curX<x0 then
x0=curX
end if
if y+j<y0 then
y0=y+j
end if
if y+j>y1 then
y1=y+j
end if
found=true
end if
next
if found then
missCount=0
else
missCount=missCount+1
end if
curX=curX-1
loop while missCount<3
#至少超過20個點
if pixelCount>20 then
CalcNameRect=true
else
CalcNameRect=false
end if
end function
#在屏幕上找怪
function FindMonster(byref x, byref y)
FindMonster=false
CopyScreen()
for y=WinY+320 to WinY+110 step -3
for x=WinX+80 to WinX+720 step 3
GetPixel(x,y,false,pixel)
if IsMonsterNameColor(pixel) then
#判斷此顏色周圍的相同顏色,以確認名字邊界
if CalcNameRect(x,y,x0,y0,x1,y1) then
x=(x0+x1)\2
y=y1
FindMonster=true
exit function
end if
end if
next
next
end function
#在雷達上找最近的怪
function FindNearestMonsterInRaid(byref mx, byref my)
FindNearestMonsterInRaid=false
CopyScreen()
minDist=9999
mx=-1
my=-1
for y=raidCY-50 to raidCY+50
for x=raidCX-50 to raidCX+50
GetPixel(WinX+x, WinY+y, false, pixel1)
GetPixel(WinX+x+1, WinY+y+1, false, pixel2)
if pixel1=Color(207,207,207) and pixel2=Color(207,207,207) then
angle=GetAngle(raidCX, raidCY, x, y)
absAngle=angle
if absAngle>pi then
absAngle=pi*2-absAngle
end if
dist1=sqr((x-raidCX)*(x-raidCX)+(y-raidCY)*(y-raidCY))
dist=dist1+absAngle/(pi/7.2)
if dist<minDist and dist1>2 then
mx=x
my=y
minDist=dist
FindNearestMonsterInRaid=true
end if
end if
next
next
end function
#轉向一個角度
function TurnToAngle(angle)
piTime=3000/turnRate
absAngle=angle
if absAngle>pi then
absAngle=pi*2-absAngle
end if
if angle<pi then
dir="D"
else
dir="A"
end if
KeyDown(dir)
Wait(absAngle/pi*piTime)
KeyUp(dir)
end function
#攻打選中的怪
function fight
do
KeyPress("F2")
Wait(1500)
if not IsMonsterSelected() then
exit do
end if
KeyPress("F1")
Wait(800)
loop while IsMonsterSelected()
#按3揀東西
KeyPress("F3")
Wait(1000)
KeyPress("F3")
Wait(1000)
KeyPress("F3")
end function
function NearColor(pixel1, pixel2, err)
NearColor=(ABS(GetR(pixel1)-GetR(pixel2))<=err and ABS(GetG(pixel1)-GetG(pixel2))<=err and ABS(GetB(pixel1)-GetB(pixel2))<=err)
end function
#判斷一個顏色是血條的顏色
function IsBloodColor(pixel)
IsBloodColor=false
r=GetR(pixel)
g=GetG(pixel)
b=GetB(pixel)
if r<150 and (r<g*2 or r<b*2) then
exit function
end if
if abs(g-b)>10 then
exit function
end if
IsBloodColor=true
end function
#判斷一個顏色是藍條的顏色
function IsMPColor(pixel)
IsMPColor=NearColor(pixel, Color(0, 69, 139), 10)
end function
#取得當前的血的百分比
function GetBloodPercent()
minX=WinX+129
maxX=WinX+268
y=WinY+29
CopyScreen()
for x=minX to maxX
GetPixel(x, y, false, pixel)
if not IsBloodColor(pixel) then
exit for
end if
next
GetBloodPercent=(x-minX)/(maxX-minX+1)*100
end function
#取得當前的MP的百分比
function GetMPPercent()
minX=WinX+129
maxX=WinX+268
y=WinY+37
CopyScreen()
for x=minX to maxX
GetPixel(x, y, false, pixel)
if not IsMPColor(pixel) then
exit for
end if
next
GetMPPercent=(x-minX)/(maxX-minX+1)*100
end function
#檢查血和MP,不足打坐
function CheckBloodMP
BloodPercent = GetBloodPercent()
MPPercent = GetMPPercent()
if BloodPercent<sitBlood or MPPercent<sitMP then
#打坐
KeyPress("F7")
st=GetTime()
do
wait(200)
BloodPercent = GetBloodPercent()
MPPercent = GetMPPercent()
loop while BloodPercent<99 and MPPercent<99 and GetTime()-st<30000 //30秒超時
end if
end function
function main
if not Init() then
exit function
end if
do
#檢查血,不足則打坐
CheckBloodMP()
do while not IsMonsterSelected()
#沒有點中怪,取消走路
KeyPress("ESC")
#屏幕上找怪
if not FindMonster(x,y) then
#當前屏幕上沒有怪,在雷達上找怪
if FindNearestMonsterInRaid(mx,my) then
pixelTime=400/forwardRate
angle=GetAngle(raidCX, raidCY, mx, my)
dist=sqr((mx-raidCX)*(mx-raidCX)+(my-raidCY)*(my-raidCY))
# Print("Dist:"&dist)
# Print("Angle:"&angle)
#轉向怪物
TurnToAngle(angle)
#走到適當距離
KeyDown("W")
dist=dist-4
if dist<0 then
dist=0
end if
wait(dist*pixelTime)
KeyUp("W")
end if
else
#屏幕上找到怪的名字了
MouseLeftClick(x, y+40)
Wait(500)
end if
loop
#選中怪了,開打
Fight()
#檢查血,不足則打坐
CheckBloodMP()
loop while true
end function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -