mirror of
https://github.com/babalae/bettergi-scripts-list.git
synced 2026-03-15 03:23:22 +08:00
JS脚本更新:1、新增博士周本。2、养成一条龙适配新UI (#2958)
This commit is contained in:
@@ -63,6 +63,9 @@ switch (settings.monsterName) {
|
||||
break;
|
||||
case "门扉前的弈局":
|
||||
await utils.weeklyBoss12();
|
||||
break;
|
||||
case "博士":
|
||||
await utils.weeklyBoss13();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "周本一条龙",
|
||||
"version": "3.1.3",
|
||||
"version": "3.2",
|
||||
"description": "https://www.bilibili.com/video/BV1F2uvz3E4K/?vd_source=9dfaf88af48ecc0ff95a41f1145af7a2",
|
||||
"authors": [
|
||||
{
|
||||
|
||||
@@ -15,9 +15,22 @@
|
||||
"吞星之鲸",
|
||||
"仆人",
|
||||
"源焰之主",
|
||||
"门扉前的弈局"
|
||||
"门扉前的弈局",
|
||||
"博士"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "difficulty",
|
||||
"type": "select",
|
||||
"label": "难度等级(默认最高的四级)",
|
||||
"options": [
|
||||
"1",
|
||||
"2",
|
||||
"3",
|
||||
"4"
|
||||
],
|
||||
"default": "4"
|
||||
},
|
||||
{
|
||||
"name": "challengeTime",
|
||||
"type": "input-text",
|
||||
@@ -61,4 +74,4 @@
|
||||
"label": "签署霸王条款开启使用,出了事跟作者无关",
|
||||
"default": false
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
async function keyMaintain(key, duration) {
|
||||
keyDown(key);
|
||||
await sleep(duration);
|
||||
keyUp(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动导航直到检测到指定文字
|
||||
* @param {Object} options 配置选项
|
||||
@@ -728,7 +734,9 @@ await sleep(500);
|
||||
keyPress("F");
|
||||
await sleep(2000);
|
||||
await repeatOperationUntilTextFound({x: 1650,y: 1000,width: 160,height: 45,targetText: "单人挑战",stepDuration: 0,waitTime: 100});//等待点击单人挑战
|
||||
await sleep(500);
|
||||
await sleep(1500);
|
||||
if(settings.monsterName!="风魔龙")click(300,settings.difficulty*110+90);
|
||||
|
||||
if(!settings.fightMode){
|
||||
let capture = captureGameRegion();
|
||||
const region = RecognitionObject.ocr(1320, 10, 290, 80);//领奖次数区域
|
||||
@@ -1426,7 +1434,53 @@ await checkDate(main);
|
||||
}
|
||||
|
||||
async function weeklyBoss13() {
|
||||
async function extraFightAction(fight = 0) {
|
||||
switch (fight) {
|
||||
case 1://单次调用战斗任务后
|
||||
|
||||
break;
|
||||
case 2: //未出现boss名称但有队伍名称
|
||||
|
||||
break;
|
||||
case 3://全无,可能是过程动画
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
await goToChallenge();
|
||||
//副本内前往BOSS处
|
||||
await eatFood();//嗑药
|
||||
//前进触发战斗,然后前往柱子处躲避
|
||||
keyPress("1");await sleep(500);//切换钟离
|
||||
await keyMaintain("w", 2000);
|
||||
await keyMaintain("s", 3500);
|
||||
await keyMaintain("d", 4300);
|
||||
await keyMaintain("e", 1000);
|
||||
await sleep(5000);
|
||||
keyDown("w");
|
||||
await sleep(700);
|
||||
keyDown("SHIFT");
|
||||
await sleep(400);
|
||||
keyUp("SHIFT");
|
||||
await sleep(700);
|
||||
keyUp("w");
|
||||
keyDown("d");
|
||||
await sleep(200);
|
||||
keyDown("w");
|
||||
await sleep(700);
|
||||
keyUp("w");
|
||||
keyUp("d");
|
||||
await autoFightAsync();
|
||||
await autoFightAndEndDetection(extraFightAction);//一直战斗直到检测到结束
|
||||
await autoNavigateToReward();
|
||||
await claimAndExit();
|
||||
}
|
||||
await checkDate(main);
|
||||
}
|
||||
|
||||
this.utils = {
|
||||
@@ -1441,5 +1495,6 @@ this.utils = {
|
||||
weeklyBoss9,
|
||||
weeklyBoss10,
|
||||
weeklyBoss11,
|
||||
weeklyBoss12
|
||||
weeklyBoss12,
|
||||
weeklyBoss13,
|
||||
};
|
||||
|
||||
@@ -68,7 +68,124 @@ async function isTaskCompleted(materialType, materialName, currentRequireCounts)
|
||||
return previousRequireCounts === currentRequireCounts;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 在指定区域内查找并点击指定文字
|
||||
* @param {string} targetText - 要点击的目标文字
|
||||
* @param {number} x - 识别区域的左上角X坐标
|
||||
* @param {number} y - 识别区域的左上角Y坐标
|
||||
* @param {number} width - 识别区域的宽度
|
||||
* @param {number} height - 识别区域的高度
|
||||
* @param {object} options - 可选参数
|
||||
* @param {boolean} options.trimText - 是否对OCR结果进行trim处理,默认true
|
||||
* @param {boolean} options.clickCenter - 是否点击文字区域中心,默认true
|
||||
* @param {number} options.retryCount - 重试次数,默认3
|
||||
* @param {number} options.retryInterval - 重试间隔(毫秒),默认500
|
||||
* @returns {Promise<boolean>} 是否找到并点击了文字
|
||||
*/
|
||||
async function clickTextInRegion(targetText, x=0, y=0, width=1920, height=1080, options = {}) {
|
||||
const {
|
||||
trimText = true,
|
||||
clickCenter = true,
|
||||
retryCount = 3,
|
||||
retryInterval = 400
|
||||
} = options;
|
||||
|
||||
for (let attempt = 0; attempt <= retryCount; attempt++) {
|
||||
let captureRegion = null;
|
||||
let ocrRo = null;
|
||||
let results = null;
|
||||
|
||||
try {
|
||||
// 获取游戏区域截图
|
||||
captureRegion = captureGameRegion();
|
||||
|
||||
// 创建OCR识别对象,限定识别区域
|
||||
ocrRo = RecognitionObject.ocr(x, y, width, height);
|
||||
|
||||
// 在限定区域内进行OCR识别
|
||||
results = captureRegion.findMulti(ocrRo);
|
||||
|
||||
// 遍历OCR结果
|
||||
for (let i = 0; i < results.count; i++) {
|
||||
const res = results[i];
|
||||
let detectedText = res.text;
|
||||
|
||||
// 可选:去除前后空白字符
|
||||
if (trimText) {
|
||||
detectedText = detectedText.trim();
|
||||
}
|
||||
|
||||
// 检查是否匹配目标文字
|
||||
if (detectedText === targetText) {
|
||||
//log.info(`找到目标文字: "${targetText}",位置: (${res.x}, ${res.y}, ${res.width}, ${res.height})`);
|
||||
|
||||
if (clickCenter) {
|
||||
// 点击文字区域中心
|
||||
await sleep(200);
|
||||
keyDown("VK_LMENU");
|
||||
await sleep(600);
|
||||
res.click();
|
||||
await sleep(200);
|
||||
keyUp("VK_LMENU");
|
||||
log.info(`已点击文字中心: "${targetText}"`);
|
||||
|
||||
} else {
|
||||
// 点击文字区域的左上角
|
||||
res.clickTo(0, 0);
|
||||
log.info(`已点击文字偏移位置: "${targetText}"`);
|
||||
}
|
||||
|
||||
// 释放资源
|
||||
if (captureRegion) {
|
||||
captureRegion.Dispose();
|
||||
}
|
||||
if (res) {
|
||||
res.Dispose();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// 释放当前遍历的结果对象
|
||||
if (res) {
|
||||
res.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// 如果当前尝试未找到,且还有重试机会,则等待后重试
|
||||
if (attempt < retryCount) {
|
||||
|
||||
await sleep(retryInterval);
|
||||
}
|
||||
} catch (error) {
|
||||
log.error(`点击文字"${targetText}"时发生错误: ${error.message}`);
|
||||
if (attempt < retryCount) {
|
||||
await sleep(retryInterval);
|
||||
}
|
||||
} finally {
|
||||
// 确保每次尝试都释放资源
|
||||
if (captureRegion) {
|
||||
captureRegion.Dispose();
|
||||
}
|
||||
if (results) {
|
||||
// 如果还有未释放的结果对象
|
||||
for (let i = 0; i < results.count; i++) {
|
||||
const res = results[i];
|
||||
if (res && typeof res.Dispose === 'function') {
|
||||
try {
|
||||
res.Dispose();
|
||||
} catch (e) {
|
||||
// 忽略释放错误
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.info(`未找到文字: "${targetText}",已尝试${retryCount + 1}次`);
|
||||
return false;
|
||||
}
|
||||
//获取BOSS材料数量
|
||||
async function getBossMaterialCount(bossName) {
|
||||
await genshin.returnMainUi();
|
||||
@@ -708,8 +825,8 @@ async function getMaterialCount(bookName) {
|
||||
await genshin.returnMainUi();
|
||||
await sleep(500);
|
||||
keyPress("F1");
|
||||
await repeatOperationUntilTextFound({x: 250,y: 420,width: 100,height: 60,targetText: "秘境",stepDuration: 0,waitTime: 100,ifClick: true});//用来等待点击文字,10s等待
|
||||
await repeatOperationUntilTextFound({x: 415,y: 390,width: 300,height: 80,targetText: "天赋",stepDuration: 0,waitTime: 100,ifClick: true});//用来等待点击文字,10s等待
|
||||
await clickTextInRegion("秘境",0,0,700,1000);
|
||||
await clickTextInRegion("天赋突破素材",510,0,960,1000);
|
||||
// 1. 进入对应国家的副本
|
||||
log.info(`正在点击${country}副本...`);
|
||||
try {
|
||||
@@ -792,8 +909,8 @@ async function getWeaponMaterialCount(materialName) {
|
||||
await genshin.returnMainUi();
|
||||
await sleep(500);
|
||||
keyPress("F1");
|
||||
await repeatOperationUntilTextFound({x: 250,y: 420,width: 100,height: 60,targetText: "秘境",stepDuration: 0,waitTime: 100,ifClick: true});//用来等待点击文字,10s等待
|
||||
await repeatOperationUntilTextFound({x: 415,y: 300,width: 300,height: 80,targetText: "武器",stepDuration: 0,waitTime: 100,ifClick: true});//用来等待点击文字,10s等待
|
||||
await clickTextInRegion("秘境",0,0,700,1000);
|
||||
await clickTextInRegion("武器突破素材",510,0,960,1000);
|
||||
// 1. 进入对应国家的副本
|
||||
log.info(`正在点击${country}副本...`);
|
||||
try {
|
||||
@@ -1008,7 +1125,7 @@ if(afterStamina< 20) skipCheckStamina = 0;
|
||||
await pathingScript.runFile(`assets/goToBoss/${bossName}前往.json`);
|
||||
if(bossName=="超重型陆巡舰·机动战垒"){
|
||||
keyDown("w");
|
||||
await sleep(13000);
|
||||
await sleep(15000);
|
||||
keyUp("w");
|
||||
}
|
||||
else if(bossName=="深黯魇语之主"){
|
||||
@@ -1154,3 +1271,4 @@ sendBufferedNotifications();//发送累积的完成信息
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 1,
|
||||
"name": "角色养成一条龙",
|
||||
"version": "1.7.0",
|
||||
"version": "1.8.0",
|
||||
"description": "详见readme.md",
|
||||
"authors": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user