加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
role.outHarvester.js 2.34 KB
一键复制 编辑 原始数据 按行查看 历史
Lev 提交于 2020-02-17 12:50 . first commit
module.exports = {
run: function(creep){
if(creep.memory.arrive == 0 && creep.pos.isEqualTo(Game.flags['OutBuild']))
creep.memory.arrive = 1;
if(creep.memory.arrive == 0){
creep.moveTo(Game.flags['OutBuild']);
return;
}
if(creep.store[RESOURCE_ENERGY] < creep.store.getCapacity()) {
var tar = creep.pos.findClosestByPath(FIND_SOURCES);
if(!tar){ creep.say('Where the fuck Source is??'); return -1; }
if(creep.pos.isEqualTo(Game.flags['Source1R2']) == 0 && Game.flags['Source1R2'].pos.lookFor(LOOK_CREEPS).length == 0){
creep.moveTo(Game.flags['Source1R2'],{visualizePathStyle: {stroke: '#ffaa00'}});
return ;
}else if(0 && creep.pos.isEqualTo(Game.flags['Source2R2']) == 0 && Game.flags['Source2R2'].pos.lookFor(LOOK_CREEPS).length == 0){
creep.moveTo(Game.flags['Source2R2'],{visualizePathStyle: {stroke: '#ffaa00'}});
return ;
}
var target = creep.pos.findClosestByRange(FIND_SOURCES);
if(creep.pos.isEqualTo(Game.flags['Source2R2'])) target = Game.getObjectById('5bbcab1c9099fc012e632d94');
creep.harvest(target);
creep.drop(RESOURCE_ENERGY);
}else{
var targets = creep.pos.findClosestByPath(FIND_STRUCTURES, {
filter: (structure) => {
return (
structure.structureType == STRUCTURE_EXTENSION ||
structure.structureType == STRUCTURE_SPAWN ||
structure.structureType == STRUCTURE_TOWER) && structure.store[RESOURCE_ENERGY] < structure.energyCapacity;
}
});
if(creep.room.energyAvailable >= 1000) targets = creep.pos.findClosestByPath(FIND_STRUCTURES, {
filter: (structure) => {
return (structure.structureType == STRUCTURE_TOWER) && structure.store[RESOURCE_ENERGY] < structure.energyCapacity;
}
});
if(targets) {
if(creep.transfer(targets, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(targets, {visualizePathStyle: {stroke: '#ffffff'}});
}
}else console.log("CRY!");
}
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化