1 Star 0 Fork 6

heart/CGAssistantJS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
转职保证书(卵4).js 17.08 KB
一键复制 编辑 原始数据 按行查看 历史
hzqst 提交于 2020-01-02 15:02 . 内容可能含有违规信息
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
var cga = require('./cgaapi')(function(){
var playerinfo = cga.GetPlayerInfo();
var teammates = [];
var teamplayers = cga.getTeamPlayers();
for(var i in teamplayers)
teammates[i] = teamplayers[i].name;
cga.isTeamLeader = (teammates[0] == playerinfo.name || teammates.length == 0) ? true : false
var callZLZZ = false;
var callWYW = false;
var doneBOSS = false;
cga.waitTeammateSay((player, msg)=>{
if(msg.indexOf('长老之证x7 GET') >= 0 ){
callZLZZ = true;
}
if(msg.indexOf('觉醒的文言抄本') >= 0 ){
callWYW = true;
}
return true;
});
var walkMazeForward = (cb)=>{
cga.walkRandomMaze(null, (err)=>{
console.log(err);
cb(err);
}, {
layerNameFilter : (layerIndex)=>{
return '海底墓场外苑第'+(layerIndex + 1)+'地带';
},
entryTileFilter : (e)=>{
return e.colraw == 0x462F;
}
});
}
var walkMazeBack = (cb)=>{
var map = cga.GetMapName();
if(map == '???'){
cb(null);
return;
}
cga.walkRandomMaze(null, (err)=>{
console.log(err);
cb(err);
}, {
layerNameFilter : (layerIndex)=>{
return layerIndex > 1 ? '海底墓场外苑第'+(layerIndex - 1)+'地带': '???';
},
entryTileFilter : (e)=>{
return e.colraw == 0x462E || e.colraw == 0;
}
});
}
var goodToGoZLZZ = (cb)=>{
var findObj = (cb3)=>{
var objs = cga.getMapObjects();
var pos = cga.GetMapXY();
if(objs.length){
for(var i in objs){
if(objs[i].mapx != pos.x || objs[i].mapy != pos.y){
cb3(objs[0]);
return;
}
}
}
setTimeout(findObj, 1000, cb3);
}
var battleAgain = ()=>{
if(cga.isInBattle()){
setTimeout(battleAgain, 5000);
return;
}
if(cga.getItemCount('长老之证') >= 7){
cga.SayWords('长老之证x7 GET', 0, 3, 1);
cb(true);
return;
}
if(callZLZZ){
cb(true);
return;
}
if(cga.isTeamLeader)
cga.ClickNPCDialog(1, 1);
setTimeout(battleAgain, 5000);
};
var retryNpc = (result)=>{
cga.TurnTo(result.xpos, result.ypos);
cga.AsyncWaitNPCDialog((err, dlg)=>{
if(dlg && dlg.message && (dlg.message.indexOf('已死的主人') >= 0 || dlg.message.indexOf('呼呼呼呼呼') >= 0 || dlg.message.indexOf('嘻嘻嘻嘻嘻嘻') >= 0)){
setTimeout(battleAgain, 1000);
}
else
{
setTimeout(retryNpc, 5000, result);
}
});
}
var search = ()=>{
var blackList = [];
cga.searchMap((units) => {
return units.find(u => u.unit_name == '守墓员' && u.type == 1 && u.model_id != 0) || cga.GetMapName() == '???'
}, (err, result) => {
if(cga.GetMapName() == '???'){
goodToGoZLZZ(cb);
return;
}
if(result && result.unit_name == '守墓员'){
retryNpc(result);
} else {
walkMazeForward(search);
}
});
}
if(cga.isTeamLeader){
findObj((obj)=>{
cga.walkList([
[obj.mapx, obj.mapy, '海底墓场外苑第1地带']
], search);
});
} else {
setTimeout(battleAgain, 5000);
}
}
var zhanglaozhizheng = (cb)=>{
if(cga.isTeamLeader){
cga.WalkTo(131, 62);
cga.waitTeammates(teammates, (r)=>{
if(r){
goodToGoZLZZ(cb);
return;
}
setTimeout(zhanglaozhizheng, 1000, cb);
});
} else {
cga.addTeammate(teammates[0], (r)=>{
if(r){
goodToGoZLZZ(cb);
return;
}
setTimeout(zhanglaozhizheng, 1000, cb);
});
}
}
var goodToGoZDZ = (cb)=>{
var findZDZ_D = ()=>{
cga.walkList([
[193, 184],
], ()=>{
if(cga.findNPCByPosition('障碍物', 192, 184)){
cga.turnTo(192, 184);
return;
}
cga.SayWords('错误:找不到任何活着的障碍物!', 0, 3, 1);
return;
});
}
var findZDZ_C = ()=>{
cga.walkList([
[234, 202],
], ()=>{
if(cga.findNPCByPosition('障碍物', 235, 202)){
cga.turnTo(235, 202);
return;
}
findZDZ_D();
return;
});
}
var findZDZ_B = ()=>{
cga.walkList([
[229, 177],
], ()=>{
if(cga.findNPCByPosition('障碍物', 230, 177)){
cga.turnTo(230, 177);
return;
}
findZDZ_C();
return;
});
}
var findZDZ_A = ()=>{
cga.walkList([
[213, 225],
], ()=>{
if(cga.findNPCByPosition('障碍物', 213, 226)){
cga.turnTo(213, 226);
return;
}
findZDZ_B();
return;
});
}
if(cga.isTeamLeader)
{
setTimeout(findZDZ_A, 1000);
}
var battleAgain = ()=>{
if(cga.isInBattle()){
setTimeout(battleAgain, 1500);
return;
}
var pos = cga.GetMapXY();
if(pos.x == 163 && pos.y == 100){
cb(true);
return;
}
setTimeout(battleAgain, 1500);
};
setTimeout(battleAgain, 1500);
}
var zudangzhe = (cb)=>{
var playerinfo = cga.GetPlayerInfo();
var teamplayers = cga.getTeamPlayers();
if(cga.isTeamLeader){
cga.waitTeammates(teammates, (r)=>{
if(r){
goodToGoZDZ(cb);
return;
}
setTimeout(zudangzhe, 1000, cb);
});
} else {
cga.addTeammate(teammates[0], (r)=>{
if(r){
goodToGoZDZ(cb);
return;
}
setTimeout(zudangzhe, 1000, cb);
});
}
}
var task = cga.task.Task('琥珀之卵4', [
{//0
intro: '◆在艾夏岛冒险者旅馆(102.115)内与时空之人(30.20)对话,输入“朵拉”选“是”,再选“确定”可重置本任务',
workFunc: function(cb2){
cga.travel.newisland.toPUB(()=>{
cga.walkList([
[31, 21],
], ()=>{
cga.TurnTo(30, 20);
cga.AsyncWaitNPCDialog(()=>{
cga.SayWords('朵拉', 0, 3, 1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(4, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
setTimeout(()=>{
cb2(true);
}, 1500);
});
});
});
});
});
}
},
{//1
intro: '1.黄昏或夜晚前往艾尔莎岛神殿·伽蓝(200.96)三楼神殿·里侧大厅,至(48.60)处进入约尔克神庙。调查(39.21)处,获得【琥珀之卵】。',
workFunc: function(cb2){
if(cga.getItemCount('琥珀之卵') > 0){
cb2(true);
return;
}
var retry = ()=>{
cga.cleanInventory(1, ()=>{
cga.turnTo(39, 21);
cga.AsyncWaitNPCDialog((err, dlg)=>{
if(!(dlg && dlg.message.indexOf('感觉脑海中有什么声响') >= 0)){
setTimeout(retry, 5000);
return;
}
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
setTimeout(cb2, 1000, true);
});
});
});
});
});
});
});
});
}
cga.travel.newisland.toStone('X', ()=>{
cga.walkList([
[201, 96, '神殿 伽蓝'],
[95, 104, '神殿 前廊'],
[44, 41, '神殿 里侧大厅'],
[34, 34, 59535],
[48, 60, '约尔克神庙'],
[39, 22],
], ()=>{
retry();
});
});
}
},
{//2
intro: '2.前往盖雷布伦森林路路耶博士的家(244.76),进入后再离开路路耶博士的家并传送至???。' + "\n" + '3.通过(142.69)或(122.69)处黄色传送石进入海底墓场外苑,寻找随机出现的守墓者并与之对话进入战斗。',
workFunc: function(cb2){
if(cga.needSupplyInitial({ })){
cga.travel.falan.toCastleHospital(()=>{
setTimeout(()=>{
cb2('restart stage');
}, 3000);
});
return;
}
cga.travel.newisland.toStone('X', ()=>{
cga.walkList([
[130, 50, '盖雷布伦森林'],
[246, 76, '路路耶博士的家'],
], ()=>{
cga.WalkTo(3, 10);
cga.AsyncWaitMovement({map:['???'], delay:1000, timeout:10000}, ()=>{
cga.walkList([
[131, 61],
], ()=>{
cga.TurnTo(131, 59);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog((err, dlg)=>{
if(dlg && dlg.message.indexOf('还不快点') == -1)
{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
zhanglaozhizheng(cb2);
});
} else {
cga.ClickNPCDialog(1, 0);
zhanglaozhizheng(cb2);
}
});
});
});
});
});
});
}
},
{//3
intro: '5.集齐7个【长老之证】后返回???,由持有7个【长老之证】的队员与荷特普(167.102)对话2次,选“是”交出【长老之证】并传送至盖雷布伦森林。',
workFunc: function(cb2){
var sayshit = ()=>{
if(cga.getItemCount('长老之证') >= 7){
console.log('sayshit1');
cga.TurnTo(131, 60);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(4, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.waitForLocation({map : '盖雷布伦森林'}, ()=>{
cb2(true);
});
});
});
});
} else {
console.log('sayshit2');
cga.waitForLocation({mapname : '盖雷布伦森林'}, ()=>{
cb2(true);
});
}
}
if(cga.isTeamLeader){
var walkShit = ()=>{
if(cga.GetMapName() == '???')
{
cga.walkList([
[131, 61],
[130, 61],
[131, 61],
[130, 61],
[131, 61],
], (r)=>{
sayshit();
});
return;
}
walkMazeBack(walkShit);
}
walkMazeBack(walkShit);
return;
}
else
{
cga.waitForLocation({mapname : '???', pos:[131, 60]}, sayshit);
return;
}
}
},
{//4
intro: '6.黄昏或夜晚时至神殿·伽蓝与荷特普(92.138)对话。',
workFunc: function(cb2){
cga.travel.newisland.toStone('X', ()=>{
cga.walkList([
[201, 96, '神殿 伽蓝'],
[91, 138],
], (r)=>{
cga.task.waitForNPC('荷特普', ()=>{
cga.turnTo(92, 138);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, -1);
setTimeout(()=>{
cb2(true);
}, 1000);
});
});
});
});
});
});
});
}
},
{//5
intro: '前往艾夏岛冒险者旅馆(102.115)与安洁可(55.32)对话,获得【逆十字】。',
workFunc: function(cb2){
if(cga.getItemCount('逆十字') > 0){
cb2(true);
return;
}
cga.travel.newisland.toPUB(()=>{
cga.walkList([
[56, 32],
], (r)=>{
cga.cleanInventory(1, ()=>{
cga.turnTo(56, 31);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, -1);
setTimeout(()=>{
cb2(true);
}, 1000);
});
});
});
});
});
}
},
{//6
intro: '7.前往梅布尔隘地,持有【琥珀之卵】、【逆十字】与祭坛守卫(211.116)对话进入???。',
workFunc: function(cb2){
if(cga.needSupplyInitial({ })){
cga.travel.falan.toCastleHospital(()=>{
setTimeout(()=>{
cb2('restart stage');
}, 3000);
});
return;
}
cga.travel.newisland.toStone('X', ()=>{
cga.walkList([
[165, 153],
], (r)=>{
cga.TurnTo(165, 154);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(8, -1);
cga.AsyncWaitMovement({map:['梅布尔隘地'], delay:1000, timeout:10000}, ()=>{
cga.walkList([
[211, 117],
], (r)=>{
cga.TurnTo(212, 116);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, -1);
cga.AsyncWaitMovement({map:['???'], delay:1000, timeout:10000}, ()=>{
cb2(r);
});
});
});
});
});
});
});
});
});
}
},
{//7
intro: '8.击倒(136.197)一带的阻挡者后,进入(156.197)的传送石。9.击倒(213.226)、(235.202)等位置的任意一个阻挡者,随机被传送。',
workFunc: function(cb2){
cga.walkList([
[135, 197],
], (r)=>{
var step = 7;
var go = ()=>{
cga.ForceMove(0, true);
if(step > 0){
step --;
setTimeout(go, 500);
}else{
cga.walkList((cga.isTeamLeader == true) ?
[
[156, 197, '???', 213, 164],
[213, 165],
] : [
[156, 197, '???', 213, 164],
], ()=>{
zudangzhe(cb2);
});
}
}
setTimeout(go, 1000);
});
}
},
{//8
intro: '10.击倒(161.108)一带的阻挡者,经由(241.118)的传送石进入???。',
workFunc: function(cb2){
var waitBOSS = ()=>{
if(cga.isInBattle())
{
doneBOSS = true;
if(cga.getItemCount('觉醒的文言抄本') > 0){
//cga.LogBack();
setTimeout(cb2, 1000, true);
return;
}
setTimeout(waitBOSS, 1000);
return;
}
if(doneBOSS && !callWYW && (cga.getItemCount('觉醒的文言抄本') > 0)){
cga.SayWords('觉醒的文言抄本 GET', 0, 3, 1);
callWYW = true;
}
if(doneBOSS && callWYW){
//cga.LogBack();
setTimeout(cb2, 1000, true);
return;
}
setTimeout(waitBOSS, 1500);
}
if(!cga.isTeamLeader){
setTimeout(waitBOSS, 1500);
return;
}
cga.walkList([
[163, 107],
], (r)=>{
var step = 4;
var go = ()=>{
cga.ForceMove(2, true);
if(step > 0){
step --;
setTimeout(go, 500);
}else{
cga.walkList([
[218, 117],
[242, 117, 59716],
[221, 187],
], ()=>{
cga.turnTo(222, 188);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(8, -1);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, -1);
setTimeout(waitBOSS, 1500);
});
});
});
});
});
});
});
});
});
}
}
setTimeout(go, 1000);
});
}
},
{//9
intro: '13.返回盖雷布伦森林,持有【觉醒的文言抄本】与纳塞(245.73)对话,获得【转职保证书】。',
workFunc: function(cb2){
cga.travel.newisland.toStone('X', ()=>{
cga.walkList([
[130, 50, '盖雷布伦森林'],
[244, 74],
], ()=>{
cga.TurnTo(245, 73);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
setTimeout(()=>{
if(cga.getItemCount('转职保证书') > 0){
cb2(true);
return;
}
}, 1000, true);
});
});
});
});
});
});
}
},
],
[//任务阶段是否完成
function(){//消除任务
return false;
},
function(){//琥珀之卵
return (cga.getItemCount('琥珀之卵') >= 1) ? true : false;
},
function(){//长老之证
return (cga.getItemCount('长老之证') >= 7 || callZLZZ) ? true : false;
},
function(){
return false;
},
function(){
return false;
},
function(){//逆十字
return (cga.getItemCount('逆十字') > 0) ? true : false;
},
function(){
return false;
},
function(){
return false;
},
function(){
return false;
},
function(){
return cga.getItemCount('转职保证书') > 0 ? true : false;
},
]
);
task.anyStepDone = false;
cga.SayWords('欢迎使用琥珀之卵4(转职保证书)脚本,输入‘0’从头(朵拉)开始任务,输入‘1’从打长老证之前开始任务,输入‘3’从荷普特开始任务,输入‘4’从祭坛守卫开始任务,输入‘5’从打完BOSS换保证书开始任务(必须有文言抄本)。', 0, 3, 1);
cga.waitForChatInput((msg, index)=>{
if(index !== null)
{
console.log(index);
if(index == 0)
task.jumpToStep = 0;
else if(index == 1)
task.jumpToStep = 2;
//else if(index == 2)
// task.jumpToStep = 3;
else if(index == 3)
task.jumpToStep = 4;
else if(index == 4)
task.jumpToStep = 6;
else if(index == 5)
task.jumpToStep = 9;
if(typeof task.jumpToStep != 'undefined'){
task.doTask(()=>{
console.log('ok');
});
return false;
}
}
return true;
});
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/heart_melody/CGAssistantJS.git
git@gitee.com:heart_melody/CGAssistantJS.git
heart_melody
CGAssistantJS
CGAssistantJS
master

搜索帮助