1 Star 1 Fork 2

卜星星/CGAssistantJS

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
四转换花.js 15.34 KB
一键复制 编辑 原始数据 按行查看 历史
卜星星 提交于 2022-01-21 22:01 . 合并最新版cga:2022-01-21
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
var cga = require(process.env.CGA_DIR_PATH_UTF8+'/cgaapi')(function(){
console.log('重要提示:每一层白色方舟地图档都要下载,否则自动寻路会失败!')
var myname = cga.GetPlayerInfo().name;
var loop_count = 0;
var flowerTable = [
{
'红花' : 622051,
'黄花' : 622052,
'绿花' : 622053,
'蓝花' : 622054,
},
{
'红花' : 622055,
'黄花' : 622056,
'绿花' : 622057,
'蓝花' : 622058,
},
{
'红花' : 622059,
'黄花' : 622060,
'绿花' : 622061,
'蓝花' : 622062,
},
{
'红花' : 622059,
'黄花' : 622060,
'绿花' : 622061,
'蓝花' : 622062,
}
]
var waitFlower = (layerIndex, myItem, waitForItem, waitForPos, cb)=>{
cga.EnableFlags(cga.ENABLE_FLAG_TEAMCHAT, false);
cga.EnableFlags(cga.ENABLE_FLAG_TRADE, true);
cga.TurnTo(waitForPos[0], waitForPos[1]);
var isLeft = myItem > waitForItem;
var stuffs =
{
itemFilter : (item)=>{
if(item.itemid == flowerTable[layerIndex][myItem]){
return true;
}
return false;
}
}
var waitChat = ()=>{
cga.AsyncWaitChatMsg((err, r)=>{
if(r && r.unitid != -1)
{
var findpos = r.msg.indexOf(': CGA四转脚本等待换花');
if(findpos > 0)
{
var playername = r.msg.substr(0, findpos);
if(myname != playername)
{
var playerunit = cga.findPlayerUnit(playername);
if(playerunit != null && playerunit.xpos == waitForPos[0] && playerunit.ypos ==waitForPos[1])
{
cga.positiveTrade(playername, stuffs, undefined, result => {
if (result && result.success == true){
cb(true);
} else {
waitChat();
}
});
return;
}
}
}
}
waitChat();
}, 5000);
}
var waitTrade = ()=>{
cga.waitTrade(stuffs, null, (results)=>{
if(results && results.success == true)
{
cb(true);
}
else
{
cga.SayWords('CGA四转脚本等待换花,['+myItem+']交换'+'['+waitForItem+']', 0, 3, 1);
waitTrade();
}
}, 5000);
}
if(isLeft)
waitChat();
else
waitTrade();
}
var mineArray = [
{
type : 1,
name : '红组',
desired_flowers : [
'黄花',
'绿花',
'蓝花',
],
func_layer0 : (cb)=>{
cga.walkList([
[21, 96],
], ()=>{
cga.TurnTo(23, 96);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(4, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({x:28, y:96, delay:1000, timeout:5000}, cb);
});
});
});
});
},
func_layer0b : (cb)=>{
cga.walkList([
[58, 92],
], ()=>{
cga.TurnTo(58, 94);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({x:75, y:93, delay:1000, timeout:5000}, cb);
});
});
},
func_layer1 : (cb)=>{
cga.walkList([
[89, 75],
], ()=>{
waitFlower(0, '红花', '黄花', [89, 73], cb);
});
},
func_layer1b : (cb)=>{
cga.walkList([
[163, 77],
], ()=>{
cga.TurnTo(165, 77);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第二层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer2 : (cb)=>{
cga.walkList([
[126, 100],
], ()=>{
waitFlower(1, '黄花', '绿花', [126, 102], cb);
});
},
func_layer2b : (cb)=>{
cga.walkList([
[152, 88],
], ()=>{
cga.TurnTo(154, 88);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第三层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer3 : (cb)=>{
cga.walkList([
[122, 92],
], ()=>{
waitFlower(2, '绿花', '蓝花', [122, 90], cb);
});
},
func_layer3b : (cb)=>{
cga.walkList([
[88, 40],
], ()=>{
cga.TurnTo(90, 40);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第四层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer4 : (cb)=>{
cga.walkList([
[100, 94],
], ()=>{
cga.SayWords('已到达黑色方舟入口,请组队完成剩余部分!', 0, 3, 1);
cb(true);
});
}
},
{
type : 2,
name : '蓝组',
desired_flowers : [
'绿花',
'黄花',
'红花',
],
func_layer0 : (cb)=>{
cga.walkList([
[21, 108],
], ()=>{
cga.TurnTo(23, 108);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(4, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({x:28, y:108, delay:1000, timeout:5000}, cb);
});
});
});
});
},
func_layer0b : (cb)=>{
cga.walkList([
[60, 141],
], ()=>{
cga.TurnTo(60, 142);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({x:74, y:141, delay:1000, timeout:5000}, cb);
});
});
},
func_layer1 : (cb)=>{
cga.walkList([
[89, 131],
], ()=>{
waitFlower(0, '蓝花', '绿花', [89, 129], cb);
});
},
func_layer1b : (cb)=>{
cga.walkList([
[147, 138],
], ()=>{
cga.TurnTo(149, 136);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第二层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer2 : (cb)=>{
cga.walkList([
[126, 102],
], ()=>{
waitFlower(1, '绿花', '黄花', [126, 100], cb);
});
},
func_layer2b : (cb)=>{
cga.walkList([
[152, 108],
], ()=>{
cga.TurnTo(154, 108);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第三层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer3 : (cb)=>{
cga.walkList([
[54, 120],
], ()=>{
waitFlower(2, '黄花', '红花', [54, 118], cb);
});
},
func_layer3b : (cb)=>{
cga.walkList([
[37, 121],
], ()=>{
cga.TurnTo(37, 119);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第四层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer4 : (cb)=>{
cga.walkList([
[100, 94],
], ()=>{
cga.SayWords('已到达黑色方舟入口,请组队完成剩余部分!', 0, 3, 1);
cb(true);
});
}
},
{
type : 3,
name : '黄组',
desired_flowers : [
'红花',
'蓝花',
'绿花',
'黄花',
],
func_layer0 : (cb)=>{
cga.walkList([
[21, 92],
], ()=>{
cga.TurnTo(23, 92);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(4, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({x:28, y:92, delay:1000, timeout:5000}, cb);
});
});
});
});
},
func_layer0b : (cb)=>{
cga.walkList([
[59, 63],
], ()=>{
cga.TurnTo(61, 63);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({x:75, y:57, delay:1000, timeout:5000}, cb);
});
});
},
func_layer1 : (cb)=>{
cga.walkList([
[89, 73],
], ()=>{
waitFlower(0, '黄花', '红花', [89, 75], cb);
});
},
func_layer1b : (cb)=>{
cga.walkList([
[136, 48],
], ()=>{
cga.TurnTo(138, 48);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第二层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer2 : (cb)=>{
cga.walkList([
[70, 102],
], ()=>{
waitFlower(1, '红花', '蓝花', [70, 104], cb);
});
},
func_layer2b : (cb)=>{
cga.walkList([
[84, 88],
], ()=>{
cga.TurnTo(86, 88);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第三层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer3 : (cb)=>{
cga.walkList([
[122, 90],
], ()=>{
waitFlower(2, '蓝花', '绿花', [122, 92], cb);
});
},
func_layer3b : (cb)=>{
cga.walkList([
[101, 17],
], ()=>{
cga.TurnTo(101, 15);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第四层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer4 : (cb)=>{
cga.walkList([
[99, 83],
], ()=>{
waitFlower(3, '绿花', '黄花', [101, 83], ()=>{
cga.SayWords('已换完花,请自行完成剩余部分!', 0, 3, 1);
cb(true);
});
});
}
},
{
type : 4,
name : '绿组',
desired_flowers : [
'蓝花',
'红花',
'黄花',
'绿花',
],
func_layer0 : (cb)=>{
cga.walkList([
[21, 104],
], ()=>{
cga.TurnTo(23, 104);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(4, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({x:28, y:104, delay:1000, timeout:5000}, cb);
});
});
});
});
},
func_layer0b : (cb)=>{
cga.walkList([
[60, 121],
], ()=>{
cga.TurnTo(60, 123);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({x:75, y:121, delay:1000, timeout:5000}, cb);
});
});
},
func_layer1 : (cb)=>{
cga.walkList([
[89, 129],
], ()=>{
waitFlower(0, '绿花', '蓝花', [89, 131], cb);
});
},
func_layer1b : (cb)=>{
cga.walkList([
[164, 110],
], ()=>{
cga.TurnTo(164, 108);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第二层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer2 : (cb)=>{
cga.walkList([
[70, 104],
], ()=>{
waitFlower(1, '蓝花', '红花', [70, 102], cb);
});
},
func_layer2b : (cb)=>{
cga.walkList([
[84, 112],
], ()=>{
cga.TurnTo(86, 112);
cga.AsyncWaitNPCDialog((dlg)=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第三层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer3 : (cb)=>{
cga.walkList([
[54, 118],
], ()=>{
waitFlower(2, '红花', '黄花', [54, 120], cb);
});
},
func_layer3b : (cb)=>{
cga.walkList([
[68, 97],
], ()=>{
cga.TurnTo(70, 95);
cga.AsyncWaitNPCDialog((dlg)=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'白色方舟·第四层', delay:1000, timeout:5000}, cb);
});
});
},
func_layer4 : (cb)=>{
cga.walkList([
[101, 83],
], ()=>{
waitFlower(3, '黄花', '绿花', [99, 83], ()=>{
cga.SayWords('已换完花,请自行完成剩余部分!', 0, 3, 1);
cb(true);
});
});
}
},
]
var mineObject = null;
var task = cga.task.Task('誓言之花', [
{//0
intro: '1.前往光之路调查(165.81)处石碑,选“是”进入白色方舟第一层。',
workFunc: function(cb2){
var dropItem = cga.findItem('誓约之花');
if(dropItem != -1)
{
cga.DropItem(dropItem);
setTimeout(cb2, 1000, 'restart stage');
return;
}
if(cga.needSupplyInitial())
{
cga.travel.falan.toCastleHospital(()=>{
setTimeout(cb2, 3000, 'restart stage');
});
return;
}
cga.travel.newisland.toLiXiaIsland(()=>{
cga.walkList([
[90, 99, '国民会馆'],
[108, 39, '雪拉威森塔1层'],
[35, 96],
], ()=>{
cga.TurnTo(35, 94);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(4, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(32, 0);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(1, 0);
cga.AsyncWaitMovement({map:'辛梅尔', delay:1000, timeout:5000}, ()=>{
cga.walkList([
[207, 91, '光之路'],
[165, 82]
], ()=>{
cga.TurnTo(165, 80);
cga.AsyncWaitNPCDialog(()=>{
cga.ClickNPCDialog(4, 0);
cga.AsyncWaitMovement({map:'白色方舟·第一层', delay:1000, timeout:5000}, cb2);
});
});
});
});
});
});
});
});
});
}
},
{//1
intro: '2.根据职业与对应守卫对话,获得对应的【誓言之花】并进入白色方舟迷宫。',
workFunc: function(cb2){
mineObject.func_layer0(cb2);
}
},
{//2
intro: '3.地图切到换花部分',
workFunc: function(cb2){
mineObject.func_layer0b(cb2);
}
},
{//3
intro: '4.白色方舟·第一层换花。',
workFunc: function(cb2){
mineObject.func_layer1(cb2);
}
},
{//4
intro: '5.白色方舟·第一层换花完成,去第二层。',
workFunc: function(cb2){
mineObject.func_layer1b(cb2);
}
},
{//5
intro: '6.白色方舟·第二层换花',
workFunc: function(cb2){
mineObject.func_layer2(cb2);
}
},
{//6
intro: '7.白色方舟·第二层换花完成,去第三层。',
workFunc: function(cb2){
mineObject.func_layer2b(cb2);
}
},
{//7
intro: '8.白色方舟·第三层换花',
workFunc: function(cb2){
mineObject.func_layer3(cb2);
}
},
{//8
intro: '9.白色方舟·第三层换花完成,去第四层。',
workFunc: function(cb2){
mineObject.func_layer3b(cb2);
}
},
{//9
intro: '10.白色方舟·第四层,战斗系组队,生产系换花。',
workFunc: function(cb2){
mineObject.func_layer4(cb2);
}
},
],
[//任务阶段是否完成
function(){
return (cga.GetMapName() == '白色方舟·第一层' && cga.GetMapXY().x < 23) ? true : false;
},
function(){
return (cga.GetMapName() == '白色方舟·第一层' && cga.GetMapXY().x >= 23 && cga.GetMapXY().x <= 70) ? true : false;
},
function(){
return (cga.GetMapName() == '白色方舟·第一层' && cga.GetMapXY().x > 70 && cga.getItemCount(flowerTable[0][ mineObject.desired_flowers[0] ]) == 0) ? true : false;
},
function(){
return (cga.GetMapName() == '白色方舟·第一层' && cga.getItemCount(flowerTable[0][ mineObject.desired_flowers[0] ]) > 0) ? true : false;
},
function(){
return (cga.GetMapName() == '白色方舟·第二层' && cga.getItemCount(flowerTable[1][ mineObject.desired_flowers[1] ]) == 0) ? true : false;
},
function(){
return (cga.GetMapName() == '白色方舟·第二层' && cga.getItemCount(flowerTable[1][ mineObject.desired_flowers[1] ]) > 0) ? true : false;
},
function(){
return (cga.GetMapName() == '白色方舟·第三层' && cga.getItemCount(flowerTable[2][ mineObject.desired_flowers[2] ]) == 0) ? true : false;
},
function(){
return (cga.GetMapName() == '白色方舟·第三层' && cga.getItemCount(flowerTable[2][ mineObject.desired_flowers[2] ]) > 0) ? true : false;
},
function(){
if (cga.GetMapName() == '白色方舟·第四层'){
if(mineObject.desired_flowers[3] != undefined)
return cga.getItemCount(flowerTable[2][ mineObject.desired_flowers[3] ]) > 0;
}
return false;
},
]
);
cga.SayWords('欢迎使用CGA通用四转脚本换花,红组输入‘1’,蓝组输入‘2’,黄组输入‘3’,绿组输入‘4’。', 0, 3, 1);
cga.waitTeammateSay((player, msg)=>{
if(player.is_me == true){
for(var i in mineArray){
if(mineArray[i].type == parseInt(msg)){
mineObject = mineArray[i];
break;
}
}
if(mineObject != null){
cga.SayWords('您选择了'+mineObject.name+'', 0, 3, 1);
task.doTask(()=>{
});
return false;
}
}
return true;
});
});
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/bxxfighting/CGAssistantJS.git
git@gitee.com:bxxfighting/CGAssistantJS.git
bxxfighting
CGAssistantJS
CGAssistantJS
master

搜索帮助