加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
act.role.ESH.js 1.76 KB
一键复制 编辑 原始数据 按行查看 历史
Lev 提交于 2020-02-17 12:50 . first commit
var CB = require('behaviors');
module.exports = {
run: function(creep){
var CS = creep.pos.lookFor(LOOK_CONSTRUCTION_SITES);
if(true){
var src = Game.getObjectById(creep.memory.src);
var posi;
if(creep.name == 'ESH A') posi = Game.flags['ESP A'];
if(creep.name == 'ESH B') posi = Game.flags['ESP B'];
if((creep.pos.isEqualTo(posi))) creep.harvest(src);
else creep.moveTo(posi,{reuse:200});
if(CS.length) creep.build(CS[0]);
CB.HolyTread(creep);
creep.drop(RESOURCE_ENERGY);
return;
}
if(creep.memory.mining == undefined) creep.memory.mining = 0;
if(creep.store.getUsedCapacity() == 0) creep.memory.mining = 1;
if(creep.store.getFreeCapacity() == 0 || creep.ticksToLive < 250) creep.memory.mining = 0;
var target = creep.pos.findClosestByPath(FIND_CONSTRUCTION_SITES);
if(!creep.memory.mining && creep.store.getUsedCapacity() > 0 && target != null){
if(creep.pos.inRangeTo(target,3)) creep.build(target);
else creep.moveTo(target);
return;
}
if(creep.memory.mining){
var src = Game.getObjectById(creep.memory.src);
if(creep.pos.isNearTo(Game.flags[creep.name])) creep.harvest(src);
else creep.moveTo(Game.flags[creep.name],{reuse:200});
}else{
var storage;
if(creep.name == 'ESH A') storage = Game.rooms['W35N28'].storage;
if(creep.name == 'ESH B') storage = Game.rooms['W34N28'].storage;
if(creep.pos.isNearTo(storage)) creep.transfer(storage,RESOURCE_ENERGY);
else creep.moveTo(storage,{reuse:200});
}
CB.HolyTread(creep);
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化