刀_日服江户0816_测8
--出击次数
local SALLY_COUNT = 100;
--自动补充通行证
local AUTO_REFILL_PASSPORT = true;
--路线设定, 预设的路线是比较稳的左路8点, 想要自定义请查看节点ID和教程
--教程: http://oy0sznig4.bkt.clouddn.com/17-10-18/19474475.jpg
local PATTERN = {15,16,17,14,13,12,7,1,2,3,4,0};
--15, 12, 9, 8, 2, 3, 4, 0
--远征开关
local ENABLE_EXPEDITION = false;
--2/3/4队伍远征地图设置
local EXPEDITION_TEAM2 = nil;
local EXPEDITION_TEAM3 = {2, 4};
local EXPEDITION_TEAM4 = {5, 2};
--远征检查周期(分钟)
local EXPEDITION_CHECK_DURATION = {5, 10};
--以下为常量定义与程序逻辑, 无把握请勿修改
local e4Nodes = {
[0]={535,128}, --0(BOSS点)
{96,248}, --1
{207,201}, --2
{351,156}, --3
{466,175}, --4(BOSS点前)
{659,134}, --5
{724,182}, --6
{166,363}, --7
{258,274}, --8
{345,228}, --9
{596,211}, --10
{816,214}, --11
{352,316}, --12
{497,285}, --13
{626,286}, --14
{403,402}, --15
{551,370}, --16
{744,362}, --17
};
local currentIndex = 0;
local currentSally = 0;
function IsColorAll(array)
for i = 1, #array do
if not Base.IsColor(array[i][0],array[i][1],array[i][2]) then
return false;
end
end
return true;
end
function RedrawTKB()
--WM_SETREDRAW
Base.PostMessage(11, 1, 0);
--WM_PAINT
Base.PostMessage(15, 1, 0);
end
function IsHome() --判断是否在本丸
local buttonX, buttonY= Base.FindColor(3706112,3507456,3242753,992512,5404983,5668156,13424836,5668156,16777215,16777215,16777215,16777215,16777215,16711678,10269581,5668156,5668156,5668156,5668156,5668156);
local hash = Base.ImageHashContrast(Base.ImageHash(27,51,50,150),"007C7E1800187C75") < 10;
local colorX, colorY = Base.FindColor(3770880,3770880,3770880,4165127,5347359,6397747,6397747,6397747,6397747,6397747,6134576,4887573,3769601,3769601,3769601,3769601,5081883,6134576,6396980,6396980,6396980,5345312,4162569,3768321,4162569,5672743,6396212,6396212,6396212,6329652);
return ((buttonX ~= -1) and (buttonY ~= -1) and hash and (colorX ~= -1) and (colorY ~= -1));
end
function IsBannerScreen()
local x, y = Base.FindColor(1908756,1842963,1842963,1842963,1842963,1842963,1842963,2039828,2105621,2171414,2171414,2105621,2105621,2171414,2237207);
return ((x ~= -1) and (y ~= -1));
end
function IsTeamSelectScreen()
local x, y=Base.FindColor(7313825,1982796,7509408,11853030,13956863,14216436,9083809,4939878,7111817,10399928,11583176,4807784,8165283,15728639,5991798,2176318,2768971,13820911,14808063,6324620);
return ((x ~= -1) and (y ~= -1));
end
function IsTeamSelectScreenCN()
return Base.IsColor(520,151,14210936);
end
function IsMapOperable()
local flag1 = Base.ImageHashContrast(Base.ImageHash(806,498,100,25),"FFF888208008E0FF") < 10;
local x2, y2 = Base.FindColor(3773331,3773331,158872,158872,12246757,12246757,12246757,12246757,12246757,12246757,12246757,12246757,12246757,12246757,12246757);
local flag2 = ((x2 ~= -1) and (y2 ~= -1));
local flag3 = Base.ImageHashContrast(Base.ImageHash(40, 442, 100, 100),"00686C0031F7F737") < 10;
return flag1 or flag2 or flag3;
end
function IsE4Map()
local hash = Base.ImageHashContrast(Base.ImageHash(870,150,25,50),"00367E6E007E7E7E") < 10;
x, y = Base.FindColor(8490374,7632751,6184017,4341297,4671033,6120281,7174514,7438458,7307386,7044987,6847862,7570553,8424059,8027759,6515293,6253152,5798519,8428953,9810606,9153708,8824744,8163214,5856082,7760988,9274996,8355180,7631457,7894372,7893602,7433824);
--Base.Print(string.format("IsE4Map 1=%s 2=[%s %s]", hash, x, y));
return hash or ((x ~= -1) and (y ~= -1));
end
function IsExpeditionResultScreen()
local count = {};
table.insert(count,0,{[0]=7,572,2232581});
table.insert(count,0,{[0]=8,6,2561030});
table.insert(count,0,{[0]=47,26,2031390});
return IsColorAll(count);
end
function GetYesNoButton()
local yesAX, yesAY = Base.FindColor(4260561,4260561,4260561,4260561,11246823,16777215,16777215,13485552,4260561,4260561,8678622,16777215,6702039,4260561,10391012,16119036,16777215,16777215,16777215,16777215,11246823,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,12036842,16777215,16777215,14867958,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561,4260561);
local noAX, noAY = Base.FindColor(6718221,6718221,6718221,7638320,16777215,16777215,14541522,6718221,6718221,6718221,11385744,16777215,16777215,16777215,16777215,16777215,16777215,16777215,13949894,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,6718221,13818808,9676628,6718221,6718221,7374675,9283499,11126989,12508900,12969963,13035242,12902887,12640229,12378084,12115940,12115940,12247012,12968680,12903915,12378599,12312805,12575205,13232107,13560302,13429231,13298414,13101549,12378084,12247012,12378599,12772842,12574950,12772329,13232875);
local yesBX, yesBY = Base.FindColor(5973206,6105047,6302423,6302423,6368472,6368472,6500312,13484785,16777215,16777215,16777215,16777215,14143220,9927908,16777215,16777215,16777215,16777215,16777215,16777215,13682162,8016349,7225051,16777215,16777215,12562669,7225051,7225051,7225051,7225051,7225051,7225051,7225051,9466338,16777215,16777215,16250621,9993700,7027162,13089263,16777215,16777215,9927908,7686876,9862115,9202912,6697689,6500312,6500312,6368472,6368472,6302423,6302423,6105047,5973206,5907158,5709781,5709781,5577941,5446100,5380052,5182675,5182675,5050835,4918994,4589777,4589777,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096,4326096);
local noBX, noBY = Base.FindColor(6719505,6719505,6719505,11715464,16777215,11715464,9874780,14279107,16777215,16777215,14870994,13621940,16777215,16777215,15528161,6719505,6719505,6719505,6719505,14279107,16777215,14279107,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,9217613,16777215,16777215,6719505,6719505,6719505,6719505,6719505,6719505,6719505,10532203,16777215,13621940,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,7376672,16120048,16777215,16777215,14870994,8625726,6719505,6719505,6719505,6719505,6719505,13621940,16777215,16777215,9217613,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505,6719505);
if yesAX ~= -1 then
return { 1, { yesAX, yesAY }, { noAX, noAY } };
elseif yesBX ~= -1 then
return { 2, { yesBX, yesBY }, { noBX, noBY } };
else
return nil;
end
end
function IsMsgbox()
return GetYesNoButton() ~= nil;
end
function ProcessMsgbox(option, duration, interval)
local option = option or true;
local duration = duration or 60;
local interval = interval or 500;
--操作计数器
local time = 0;
--先获取一次
local pos = GetYesNoButton();
--没按钮直接跳
if pos == nil then
return false;
end
if pos[3][1] == -1 then
--按钮点亮规避
Base.Move(pos[2][1] + 180, pos[2][2]);
Base.Move(1, 1);
end
--再获取一次
local pos = GetYesNoButton();
--特殊通行证
local chkSpecialPassportX, chkSpecialPassportY = Base.FindColor(8540131,8540131,12362224,16777215,15657211,14009590,9067493,16777215,16777215,16249853,15657211,14602488,12955122,8540131,8540131,8540131,8540131,8540131,14602488,15657211,12955122,15657211,16777215,16777215,15129849,14602488,15129849,16777215,12362224,8540131,8540131,8540131,8540131,8540131,12362224,16777215,10187497,8540131,8540131,8540131,8540131,8540131,13482484,8540131,8540131,8540131,8540131,8540131,8540131,8540131);
if (chkSpecialPassportX ~= -1) and (chkSpecialPassportY ~= -1) then
Base.ClickRectEx(chkSpecialPassportX, chkSpecialPassportY, 10, 5);
end
--循环点击直到对话框消失
while IsMsgbox() and time < duration do
if (not option) and ((pos[3][1] ~= -1) and (pos[3][2] ~= -1)) then
Base.Click(pos[3][1], pos[3][2]);
else
Base.Click(pos[2][1], pos[2][2]);
end
Base.Sleep(interval);
time = time + (interval / 1000);
end
if time < duration then
return true;
else
return false;
end
end
--检测阵型选择界面
function IsFormationControl()
local x, y = Base.FindColor(1579977,2303438,1973693,985753,1248647,7893711,13881343,15790335,15659263,16252415,16055039,15857919,6448786,1184341,394586,591206,5456245,11971532,16776703,16252918);
return ((x ~= -1) and (y ~= -1));
end
function IsBattleFinished()
count = {};
table.insert(count,0,{[0]=5,5,591911})
table.insert(count,0,{[0]=4,573,328994})
table.insert(count,0,{[0]=492,198,16442880})
table.insert(count,0,{[0]=492,106,4773357})
return IsColorAll(count);
end
--选择阵型
function FormationChoice(default)
local default = default or 1;
--找红色的"有利"标志
positiveX, positiveY = Base.FindColor(131802,131802,131802,131802,131802,131802,131802,131802,131802,131802,131802,131802,131802,131802,131802);
--索敌失败
if positiveX == -1 and positiveY == -1 then
--直接按照传入的参数选择
if default == 1 then
Base.ClickRectEx(213,167,140,80)
elseif default == 2 then
Base.ClickRectEx(477,167,140,80)
elseif default == 3 then
Base.ClickRectEx(740,167,140,80)
elseif default == 4 then
Base.ClickRectEx(215,352,140,80)
elseif default == 5 then
Base.ClickRectEx(479,353,140,80)
elseif default == 6 then
Base.ClickRectEx(741,353,140,80)
end
Base.Print("索敌失败");
else
Base.Print("选择有利");
Base.ClickRect(positiveX + 95, positiveY + 52, 30);
end
end
--改过的处理战斗
function EventProcessBattle()
Base.Print("[战斗]进入战斗函数");
Base.Print("[战斗]等待选择阵型...");
while not IsFormationControl() do
Base.Sleep(500, true);
end
FormationChoice();
Base.Print("[战斗]阵型选择完成,等待战斗结束...");
while not IsBattleFinished() do
Base.Sleep(1000, true);
RedrawTKB();
if IsHome() then
return -1;
end
--[[
if IsMsgbox() then
ProcessMsgbox();
end
]]
end
Base.Print("[战斗]战斗结束");
Base.Sleep(1000, true);
Base.Print("[战斗]战斗后续处理...");
while true do
--[[
if IsMsgbox() then
Base.Print("[战斗]ProcessMsgbox");
ProcessMsgbox();
end
]]
if Base.IsColor(516,442,6718221) then
Base.Print("处理对话框-梅干");
Base.ClickRect(573,436);
Base.Sleep(1000, true);
end
if Base.IsColor(629,359,6718221) then
Base.Print("处理对话框-没步数了");
Base.ClickRect(629,359);
Base.Sleep(1000, true);
end
if IsHome() then
Base.Print("处理对话框-没步数了");
return -1;
end
if IsE4Map() then
Base.Print("isE4");
return 0;
end
Base.ClickRect(480, 290, 150);
Base.Sleep(800, true);
end
Base.Print("[战斗]战斗后续处理完毕");
end
--/***main***/
Base.SetConfig("Sleep+?", 1500);
Base.SetValue("AutoShouXing", AUTO_REFILL_PASSPORT and "1" or "0");
k2_conquest = EXPEDITION_TEAM2;
k3_conquest = EXPEDITION_TEAM3;
k4_conquest = EXPEDITION_TEAM4;
if ENABLE_EXPEDITION then
Base.Print("启动远征");
while not IsHome() do
Tou.GoHome();
Base.Sleep(800, true);
end
Tou.EasyConquestInit(60 * EXPEDITION_CHECK_DURATION[1], 60 * EXPEDITION_CHECK_DURATION[2]);
Tou.EasyConquestRun(false);
end
for currentSally = 1, SALLY_COUNT do
Base.Print("进行第" .. currentSally .. "次出击, 共计" .. SALLY_COUNT .. "次");
Tou.Sally(100, 4);
Base.Sleep(1500, false);
Base.Print("等待点击出阵...");
if Base.IsColor(584,517,4260561) then
Base.ClickRect(584,517, 10); --
Base.Sleep(1000, false);
end
Base.Print("等待点击确认消耗...");
Base.Sleep(1000, false);
if Base.IsColor(329,327,4260561) then
Base.ClickRect(426,319, 8); --点击确认消耗
Base.Sleep(1000, false);
end
currentIndex = 0;
while true do
if IsE4Map() and IsMapOperable() then
currentIndex = currentIndex + 1;
if currentIndex > #PATTERN then
error("设定的路线耗尽, 出阵未结束, 请检查设定的路线");
end
Base.Print("当前第" .. currentIndex .. "个点, 共" .. #PATTERN .. "个点");
Base.Print("进入点#" .. PATTERN[currentIndex]);
while IsE4Map() and IsMapOperable() do
if Base.IsColor(516,442,6718221) then
Base.Print("处理对话框-梅干");
Base.ClickRect(573,436);
Base.Sleep(1000, true);
end
if Base.IsColor(629,359,6718221) then
Base.Print("处理对话框-没步数了");
Base.ClickRect(629,359);
Base.Sleep(1000, true);
end
Base.ClickRect(e4Nodes[PATTERN[currentIndex]][1], e4Nodes[PATTERN[currentIndex]][2], 3);
Base.Sleep(250, false);
end
end
if IsBannerScreen() then
Base.Print("弹出提示, 估计是翻车了");
while IsBannerScreen() do
Base.ClickRect(480, 290, 200);
Base.Sleep(800, true);
end
end
if IsFormationControl() then
Base.Print("进行战斗");
local result = EventProcessBattle();
if result == -1 then
break;
end
end
--[[
if IsMsgbox() then
Base.Print("处理对话框");
ProcessMsgbox();
end
]]
if Base.IsColor(516,442,6718221) then
Base.Print("处理对话框-梅干");
Base.ClickRect(573,436);
Base.Sleep(1000, true);
end
if Base.IsColor(629,359,6718221) then
Base.Print("处理对话框-没步数了");
Base.ClickRect(629,359);
Base.Sleep(1000, true);
end
if IsExpeditionResultScreen() then
Base.ClickRect(480, 290, 100);
end
if IsHome() then
break;
end
Base.Sleep(500, true);
end
Base.Print("回到本丸");
Base.Print("操作间延迟...");
Base.SetConfig("Sleep+?", 180000);
Base.Sleep(2000, true);
Base.SetConfig("Sleep+?", 1500);
end
if ENABLE_EXPEDITION then
Base.Print("战斗次数已达到, 开始轮询远征状态");
Tou.EasyConquestEnterLoop();
else
Base.Print("战斗次数已达到, 脚本停止运行");
end
Last updated