Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ ArkLights(速通)是一个开源的,几乎没有任何限制的开源项
## 须知

- 请尊重项目代码风格,即使你并不喜欢他,大面积的reformat对代码审阅是一种灾难!
- 请尽量避免改动已经存在的代码,除非这个是一个经过测试且确信的该进,请在commit中进行标注。
- 请尽量避免改动已经存在的代码,除非这个是一个经过测试且确信的改进,请在commit中进行标注。
- 请不要重载已经存在的函数,本项目的底层含有大量耦合的代码,请不要重载他们。
- 任何pr前请先确保本地测试通过。

Expand Down
223 changes: 131 additions & 92 deletions main.lua
Original file line number Diff line number Diff line change
@@ -1,111 +1,150 @@
-- predebug = true
-- always_enable_log = true
-- test_fight = true
-- fake_fight = true
-- prefer_bapp = true
-- zl_disable_log = true
-- enable_drug_24hour = true
-- prefer_speed = true
-- disable_dorm_shift=true
-- disable_manu_shift=true
-- disable_overview_shift=true
-- disable_hotupdate = true
-- disable_root_mode = true
-- no_background_after_run = true
-- fake_recruit = true
-- debug_tag = true
-- during_crisis_contract =true
-- disable_communication_check=true
-- speedrun=true
-- debug = true
-- disable_log = true
-- unsafe_tap = true
-- zl_disable_fight_drop = true
zl_enable_tap_before_drag = true
zero_wait_click = true
check_after_tap = true
crontab_enable = true
-- enable_simultaneous_tap = true
-- auto_clean_fight=true
-- enable_dorm_check = true
-- fake_transfer= true
-- verbose_fca = true
-- no_dorm = true
-- test_some = true
-- ok_time = 1000
-- ignore_jmfight_enough_check=true
-- use_zhuzhu_game = true
-- no_config_cache = true
-- prefer_bapp_on_android7 = true
-- debug0721 = true
-- longest_tag = true
-- very_slow_state_check = true
default_findcolor_confidence = 95 / 100
default_auto_timeout_second = 300
-- default_max_drug_times = 9999
-- default_max_stone_times = 0
-- disable_game_up_check = true
-- skip_snapshot_service_check = true
-- need_show_console = true
-- 设成10以下时,单核机作战导航失败率高,真机基建缩放也会有问题
-- 设成1000//30时,真机同时开着B服与官服时会出现点着点着脚本就停(从基建开始做邮件)
frame_milesecond = 1000 // 30
milesecond_after_click = frame_milesecond
release_date = "08.01 20:32"
ui_submit_color = "#ff0d47a1"
ui_cancel_color = "#ff1976d2"
ui_warn_color = "#ff33ccff"
ui_page_width = -2
ui_submit_width = -2
ui_small_submit_width = -2
ui_small_submit_height = -2
network_timeout = 300
matrixOcr = ocr

-- update_source = 'https://arklights.pages.dev'
update_source = 'https://gitee.com/bilabila/arknights/raw/master'
update_source_fallback = update_source

require('util')
require("point")
require("path")
require("tag")
require('skill')
require("fight")
require("cloud")
require("ex")

--predebug = true
--always_enable_log = true
-- test_fight = true
-- fake_fight = true
-- prefer_bapp = true
-- zl_disable_log = true
-- enable_drug_24hour = true
-- prefer_speed = true
-- disable_dorm_shift=true
-- disable_manu_shift=true
-- disable_overview_shift=true
-- disable_hotupdate = true
-- disable_root_mode = true
-- no_background_after_run = true
-- fake_recruit = true
-- debug_tag = true
-- during_crisis_contract =true
-- disable_communication_check=true
-- speedrun=true
-- debug = true
-- disable_log = true
-- unsafe_tap = true
-- zl_disable_fight_drop = true
zl_enable_tap_before_drag = true
zero_wait_click = true
check_after_tap = true
crontab_enable = true
-- enable_simultaneous_tap = true
-- auto_clean_fight=true
-- enable_dorm_check = true
-- fake_transfer= true
-- verbose_fca = true
-- no_dorm = true
-- test_some = true
-- ok_time = 1000
-- ignore_jmfight_enough_check=true
-- use_zhuzhu_game = true
-- no_config_cache = true
-- prefer_bapp_on_android7 = true
-- debug0721 = true
-- longest_tag = true
-- very_slow_state_check = true
default_findcolor_confidence = 95 / 100
default_auto_timeout_second = 300
-- default_max_drug_times = 9999
-- default_max_stone_times = 0
-- disable_game_up_check = true
-- skip_snapshot_service_check = true
-- need_show_console = true
-- 设成10以下时,单核机作战导航失败率高,真机基建缩放也会有问题
-- 设成1000//30时,真机同时开着B服与官服时会出现点着点着脚本就停(从基建开始做邮件)
frame_milesecond = 1000 // 30
milesecond_after_click = frame_milesecond
release_date = "08.01 20:32"
ui_submit_color = "#ff0d47a1"
ui_cancel_color = "#ff1976d2"
ui_warn_color = "#ff33ccff"
ui_page_width = -2
ui_submit_width = -2
ui_small_submit_width = -2
ui_small_submit_height = -2
network_timeout = 300
matrixOcr = ocr
-- update_source = 'https://arklights.pages.dev'
update_source = 'https://gitee.com/bilabila/arknights/raw/master'
update_source_fallback = update_source
require('util')
require("point")
require("path")
require("tag")
require('skill')
require("fight")
require("cloud")
require("ex")
load(after_require_hook or '')()

consoleInit()
showControlBar(true)
setEventCallback()
consoleInit()--调用控制台
showControlBar(true)--显示悬浮窗
setEventCallback()--设置脚本关闭和悬浮窗触控事件
hotUpdate()
fetchSkillIcon()
check_root_mode()
enable_accessibility_service()
enable_snapshot_service()
enable_accessibility_service()--无障碍权限
enable_snapshot_service()--开启无障碍截图
remove_old_log()
detectServer()
detectServer()--查找游戏服务器对应的app
predebug_hook()
showUI()
loadUIConfig()
loadUIConfig()--读取ui配置
restart_mode_hook()
update_state_from_debugui()
check_crontab_on_start()
cloud.startHeartBeat()
cloud.startHeartBeat()--云控



-- debug_mode=true
log("抄作业:",copy_homework)
if copy_homework then
ip = pc_ipv4--本机ip
local adbPath = adb_adress--adb位置
local host = simulator_host--模拟器地址
local headers ="Content-Type: application/json"--post请求头
simulator_id=""--maa返回的模拟器编号
--get maa版本号
local ret,time = httpGet("http://" .. ip .. ":8848/API/V1/getVersion")
log(ret)
if not ret then
log("未获取到maa版本号")
exit()
end
ssleep (1)
local t= {
adbPath=adbPath,
host=host,
detailJson="",
}
ssleep (3)
--请求maa连接模拟器并返回id,这之后ide会和模拟器断开,但是模拟器里面的脚本在继续,后面请用log,不要用print调试
--asynHttpGet(callback,"http://" .. ip .. ":8848/API/V1/connect?adbPath="..adbPath .."&host="..host)

local res ,code = httpPost("http://" .. ip .. ":8848/API/V1/connect",JsonEncode(t),30,headers)
--延时到端口返回json
--[===[while not resp ==true do
ssleep (1)
log (resp)
end
ssleep (10)
log (resp)]===]

if res then simulator_id= JsonDecode(res)["data"]["id"] end
log("模拟器id",simulator_id)
if not simulator_id or #simulator_id ==0 then exit() end
end

--debug_mode=true
if debug_mode then
log("debug_mode")
-- log(findOne("活动公告返回"))
-- log(findOne("framelayout_only"))
-- log(findOne("login"))
-- ssleep(1)
-- tap("login")
-- exit()



end



load(before_account_hook or '')()

no_extra_job = {}
Expand Down
34 changes: 24 additions & 10 deletions path.lua
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ path.base = {
fight_start_time = fight_start_time or time()
local elapsed = time() - fight_start_time
local fight_type = get_fight_type(cur_fight)

log("接管作战")
-- 一般10分钟,剿灭40分钟
local fight_timeout = (table.includes({"剿灭"}, fight_type) and elapsed >
40 * 60 * 1000) or
(not table.includes({"剿灭"}, fight_type) and
elapsed > 10 * 60 * 1000)

log(fight_timeout)
-- 超时跳过当前关
if fight_timeout then
local info = table.join(qqmessage, ' ') .. " [" .. cur_fight ..
Expand All @@ -154,6 +154,7 @@ path.base = {
if not wait(function()
if not findOne("接管作战") then return true end
-- log(126)
--if findOne("跳过剧情") then path.跳过剧情() end
if findOne("暂停中") and not disappear("暂停中", 5) then
tap("开包skip")
disappear("暂停中")
Expand Down Expand Up @@ -183,7 +184,7 @@ path.base = {
-- 实测560秒,给两倍
if time() - first_time_see_zero_star > 1200 then zero_star = true end
end

if findOne("开始行动") and findOne("代理指挥开") then
log(59)
normal = true
Expand Down Expand Up @@ -3120,11 +3121,13 @@ extrajianpin2name = {
当前委托 = "当期委托",
}



path.开始游戏 = function(x, disable_ptrs_check)

-- 记录石头数量
save_run_state()

local need_copy_homework =nil
log("开始游戏", fight_tick, x)
if not findOne("开始行动") then return end
if x == "1-11" then return path["1-11"] end
Expand All @@ -3137,14 +3140,20 @@ path.开始游戏 = function(x, disable_ptrs_check)
-- log(findOne("报酬合成玉已满"))
-- log(findOne("开始行动"))
-- safeexit()

print(copy_homework)

if not appear("代理指挥开", .5) then
tap("代理指挥开1")
if not appear("代理指挥开", .5) then
-- clean_fight(x)
fight_failed_times[cur_fight] = max_fight_failed_times
if not appear("主页") then back() end
return path.跳转("首页")
if copy_homework then
need_copy_homework = true
ssleep (6)--等待右上角提示消失
else
-- clean_fight(x)
fight_failed_times[cur_fight] = max_fight_failed_times
if not appear("主页") then back() end
return path.跳转("首页")
end
end
-- if not wait(function()
-- if findOne("代理指挥开") and not disappear("代理指挥开", .5) then
Expand Down Expand Up @@ -3172,7 +3181,7 @@ path.开始游戏 = function(x, disable_ptrs_check)
state = findAny({
"开始行动红", "源石恢复理智取消", "药剂恢复理智取消",
"单选确认框", "源石恢复理智不足", "当期委托侧边栏",
"行动结束",
"行动结束"
})
-- 剿灭后一直按开始行动导致开始行动界面消失,可能出现下面的界面
if state == "当前委托侧边栏" then
Expand Down Expand Up @@ -3206,6 +3215,10 @@ path.开始游戏 = function(x, disable_ptrs_check)
return path.base.接管作战()
elseif state == "开始行动红" then
no_success_one_loop = 0
if need_copy_homework then
maa_copliot(x)
else

if fake_fight then
log("debug0415", x)
if not wait(function()
Expand Down Expand Up @@ -3235,6 +3248,7 @@ path.开始游戏 = function(x, disable_ptrs_check)
-- return
-- end
if findOne("单选确认框") then return end
end
return path.base.接管作战()
elseif stone_times < max_stone_times and state == "源石恢复理智取消" or
drug_times < max_drug_times and state == "药剂恢复理智取消" then
Expand Down
Loading