1 Star 0 Fork 0

Leviaton/Screeps

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
role.outBuilder.js 1.73 KB
一键复制 编辑 原始数据 按行查看 历史
Lev 提交于 2020-02-17 12:50 . first commit
module.exports = {
run: function(creep){
console.log('ddd?' + creep.memory.arrive);
if(creep.memory.arrive != 1 && creep.pos.isEqualTo(Game.flags['OutBuild']))
creep.memory.arrive = 1;
if(creep.memory.arrive != 1){
creep.moveTo(Game.flags['OutBuild']);
return;
}
if(creep.memory.building && creep.store[RESOURCE_ENERGY] == 0) {
creep.memory.building = false;
creep.say('资源资源!');
}
if(!creep.memory.building && creep.store[RESOURCE_ENERGY] >= 50) {
creep.memory.building = true;
creep.say('Move!');
}
if(creep.memory.building) {
var targets = creep.pos.findClosestByPath(FIND_CONSTRUCTION_SITES);
if(targets == null)
creep.say('累了');
else if(creep.build(targets) == ERR_NOT_IN_RANGE)
creep.moveTo(targets, {visualizePathStyle: {stroke: '#ffffff'}});
}else{
if(creep.room.name == 'W35N28'){
if(creep.pos.isEqualTo(41,25)){
creep.pickup(creep.pos.findClosestByPath(FIND_DROPPED_RESOURCES));
}else creep.moveTo(41,25);
}else{
if(creep.pos.isEqualTo(17,33)){
creep.pickup(creep.pos.findClosestByPath(FIND_DROPPED_RESOURCES));
}else creep.moveTo(17,33);
}return;
var tar = creep.pos.findClosestByPath(FIND_SOURCES);
if(!tar){
creep.say('Where to Harvest?');
return -1;
}
if(creep.harvest(tar) == ERR_NOT_IN_RANGE)
creep.moveTo(tar, {visualizePathStyle: {stroke: '#ffaa00'}});
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/Chorolop/Screeps.git
git@gitee.com:Chorolop/Screeps.git
Chorolop
Screeps
Screeps
master

搜索帮助