TJ

Auto.js 自动通天塔脚本V2

TJUGERKFER 2020年01月19日 编程开发 117 0

支持2232*1080分辨率

S00119-11241651.png

使用了定时器的写法 效率比之前那玩意高得多

(魅族16T真香

function stupidOperation(img,x,y,color,ran,id,spt){  //操作核心函数V2
	if (images.detectsColor(img, color, x, y)){ //判断指定坐标颜色是否与目标颜色相符
		clickx=x + random(-ran,ran) //点击的位置等于拾色位置加随机值
		clicky=y + random(-ran,ran) //点击的位置等于拾色位置加随机值
		toast(id);	//发现按钮的提示
        click(clickx,clicky); //点击目标按钮
        sleep(spt);//先躺会儿
	}
}

function randomSwipe(x1,y1,x2,y2,ran,duration){ //随机滑动函数
	clickx1=random(-ran,ran) + x1
    clickx2=random(-ran,ran) + x2
    clicky1=random(-ran,ran) + y1
    clicky2=random(-ran,ran) + y2
	swipe(clickx1, clicky1, clickx2, clicky2, duration)
}

function loopcheck(){
    nowimg=captureScreen() //减少频繁截图带来的资源开销
    if (images.detectsColor(nowimg, "#3D4F3D", 826, 185)){
        boss=true
        stupidOperation(nowimg,1127,605,"#4774C8",200,"star",100)
    } else {
        boss=false
        stupidOperation(nowimg,1610,847,"#805f34",40,"play",300)
        stupidOperation(nowimg,1901,997,"#8e6d3b",40,"again",300)
        stupidOperation(nowimg,2112,45,"#153657",20,"skip",300)
        stupidOperation(nowimg,1704,943,"#aa7344",50,"speedup",20)
		stupidOperation(nowimg,1127,605,"#4774C8",200,"star",100)
    }
}

function boss_battle(){
    if (boss){
        stupidOperation(nowimg,2023, 26,"#074055",10,"auto",100)
    } 
}

function move(){
	if (images.detectsColor(nowimg, "#1468AB", 2155, 275)){ //正在游戏中且不打墨子
		if (!boss){
			randomSwipe(347,807,195,601,6,1800)
		}
	}
}

//程序入口
requestScreenCapture(true) //得到截图权限
boss=false
nowimg=captureScreen() //减少频繁截图带来的资源开销
setScreenMetrics(1080, 2232) //锁定屏幕分辨率
setInterval(loopcheck,500)
setInterval(boss_battle,500)
setInterval(move,200)

2020.5.16 更新悬浮窗 效率显示

function stupidOperation(img,x,y,color,ran,id,spt){  //操作核心函数V1.4
	if (images.detectsColor(img, color, x, y)){ //判断指定坐标颜色是否与目标颜色相符
		clickx=x + random(-ran,ran) //点击的位置等于拾色位置加随机值
		clicky=y + random(-ran,ran) //点击的位置等于拾色位置加随机值
        toast(id);	//发现按钮的提示
        if(id=="again"){
            if(!issettle){
                issettle=true
                round++
                spendtime=(new Date().getTime()-starttime)/1000
                gotmoney=round*29
                efficiency=Math.round(gotmoney/spendtime*60)
                toast("第"+round+"局 "+"已赚"+gotmoney+"金币 "+ "用时" +spendtime+"秒 " +"效率"+efficiency+"金币每分钟 ")
            }
        }
        if(id=="play"){
            issettle=false
        }  
        click(clickx,clicky); //点击目标按钮
        sleep(spt);//先躺会儿
	}
}

function randomSwipe(x1,y1,x2,y2,ran,duration){ //随机滑动函数
	clickx1=random(-ran,ran) + x1
    clickx2=random(-ran,ran) + x2
    clicky1=random(-ran,ran) + y1
    clicky2=random(-ran,ran) + y2
	swipe(clickx1, clicky1, clickx2, clicky2, duration)
}

function loopcheck(){
    nowimg=captureScreen() //减少频繁截图带来的资源开销
    if (images.detectsColor(nowimg, "#3D4F3D", 826, 185)){
        if (!boss) {
        boss=true
        }
        stupidOperation(nowimg,1127,605,"#4774C8",200,"star",100)
    } else {
        boss=false
        stupidOperation(nowimg,1610,847,"#805f34",40,"play",300)
        stupidOperation(nowimg,1901,997,"#8e6d3b",40,"again",300)
        stupidOperation(nowimg,2112,45,"#153657",20,"skip",300)
        stupidOperation(nowimg,1596,956,"#fcf9c2",50,"speedup",20)
		stupidOperation(nowimg,1127,605,"#4774C8",200,"star",100)
    }
}

function boss_battle(){
    if (boss){
        stupidOperation(nowimg,2023, 26,"#074055",10,"auto",100)
    } 
}

function move(){
	if (images.detectsColor(nowimg, "#1468AB", 2155, 275)){ //正在游戏中且不打墨子
		if (!boss){
			randomSwipe(447,807,269,491,6,2000)
		}
	}
}

setInterval(()=>{
    ui.run(function(){
        window.text.setText("第"+round+"局 "+"已赚"+gotmoney+"金币 "+ "用时" +spendtime+"秒 " +"效率"+efficiency+"金币每分钟 ");
    });
}, 5000);
//程序入口
window = floaty.rawWindow(
    <frame gravity="center">
        <text id="text" textSize="16sp" textColor="#ffffff" bg="#66000000"/>
    </frame>
);
starttime=new Date().getTime()
requestScreenCapture(true) //得到截图权限
boss=false
round=0
issettle=0
gotmoney=0
spendtime=0
efficiency=0
nowimg=captureScreen() //减少频繁截图带来的资源开销
setScreenMetrics(1080, 2232) //锁定屏幕分辨率
setInterval(loopcheck,500)
setInterval(boss_battle,500)
setInterval(move,100)


发布评论

分享到:

[恶搞工具]SuperVOOOOCPromChargePlusMax++充电工具
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。