刀_日服简易加速锻刀

--[[

简易加速锻刀
用于大批量锻刀

★★使用说明★★
停留在锻刀界面运行脚本
如禁止自动设置配方,则请先进行一次锻刀,目的是为了将锻刀的各种资源值固定


注:本脚本只在日服测试通过,未作任何错误处理,请确保资源与加速足够
]]



--[[---------------------------------设置区域-----------------------------------]]

--[[ 锻刀次数,默认无限 ]]
runCount = math.huge

--[[ 设置配方 0=不设置(自行手动锻一次) 1=首次设置 2=每次设置 ]]
setRecipe = 0

--[[ 要设置的配方 ]]
recipe = { 400, 400, 400, 400 }

--[[ 要优先使用的绘马 0=不使用 1=使用梅 2=使用梅和竹 3=使用梅竹和松 4=使用梅竹松和富士 ]]
useOfuda = 0

--[[---------------------------------------------------------------------------]]

Tou.SetToukenH5(true)

-- Fuck WordPress
GT = function(lhs, rhs) return (math.max(lhs, rhs) == lhs) and (lhs ~= rhs); end
LT = function(lhs, rhs) return (math.max(lhs, rhs) == rhs) and (lhs ~= rhs); end

--[[使用加速]]
function UseSpeed()
    while not Base.IsColor(613,537,1974015) do
	    Base.ClickRect(616, 483)
		Base.Sleep(100, true)
	end
end

--[[取得可用的锻造位 1 - 4 ]]
function GetPositionIndex()
	for i = 1, 4 do
		if Base.IsColor(308, 163 + (i - 1) * 111,16777215) then
			return i
		end
	end
	return 0
end

function UseOfuda()
    local name = { [0] = "梅", "竹", "松", "富士" }
    Base.Print("设置绘马")
	Base.ClickRect(310, 485)
	Base.Sleep(750, true)
	for i = useOfuda - 1, 0, -1 do
	    if Base.IsColorEx(585, 84 + (96 * i), 10444083, 5) then
		    Base.Print("使用 " .. name[i] .. " 绘马")
		    Base.ClickRect(585, 97 + (96 * i), 10)
			return
		end
	end
	Base.Print("设置不使用/无可用的绘马")
	Base.ClickRect(508, 469, 20)
end

--[[输入配方]]
function SetRecipe()
    local xPos = { [0] = 472, 759 }
	local yPos = { [0] = 204, 376 }
	local xDistance = 72
	local r = 114
	
	for i = 0, 3 do
	    local x = xPos[i % 2]
		local y = yPos[math.floor(i / 2)]
		if GT(recipe[i + 1], 999) or LT(recipe[i + 1], 50) then
		    error("配方有误")
		end
		local digits = { [0] = math.floor(recipe[i + 1] / 100 % 10), math.floor(recipe[i + 1] / 10 % 10), math.floor(recipe[i + 1] % 10) }
	    for j = 0, 2 do
		    local degree = digits[j] * 36
		    local deltaX = r * math.cos(math.rad(degree - 90))
		    local deltaY = r * math.sin(math.rad(degree - 90))
		    Base.ClickRect(x + (xDistance * j), y)
			Base.Sleep(200, true)
			Base.ClickRect(x + (xDistance * j) + deltaX, y + deltaY)
			Base.Sleep(200, true)
		end
		Base.Sleep(500, true)
	end
end

--[[进入循环]]
for i = 1, runCount do

	Base.Print("开始第" .. i .. "次")

    Base.Move(0, 0)
	index = GetPositionIndex()

	if index == 0 then
		--输出无空位了
		Base.Print("系统错误:锻刀炉全部忙碌,或不在锻刀界面")
		break
	end
	
	
	Base.Print("使用" .. index .. "号位置")

	--点击空位
	Base.ClickRect(500, 160 + (index - 1) * 111, 100)
	Base.Sleep(1000, true)
	
	if setRecipe == 2 or (setRecipe == 1 and i == 1) then
	    Base.Print("设置配方")
		SetRecipe()
	end
	
    if useOfuda ~= 0 then
	    Base.Print("使用绘马")
	    UseOfuda()
	    Base.Sleep(1000, true)
    end

	Base.Print("使用加速")
	UseSpeed()
	Base.Sleep(750, true)

	Base.Print("点击锻造")
	--点击锻造
	Base.ClickRect(778, 526, 30)
	Base.Sleep(750, true)

	--回到锻刀
	Base.Print("等待回到锻刀")
	while GT(Base.ImageHashContrast(Base.ImageHash(472,90,80,15),"D372545050480367"), 10) do
	    Base.ClickRect(964, 529, 300)
	    Base.Sleep(1000, true)
	end
	
	Base.Print("稍作延迟")
	Base.Sleep(2000, true)
end

Last updated