加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
stru.Spawn.js 5.27 KB
一键复制 编辑 原始数据 按行查看 历史
Lev 提交于 2020-02-17 12:50 . first commit
module.exports = {
run: function(Spawn){
var spawn = Game.spawns[Spawn];
if(spawn.spawning) return;
const room = spawn.room.name;
var creep_list = spawn.room.find(FIND_MY_CREEPS);
var srcminer_count = 0;
var picker_count = 0;
var upgrader_count = 0;
var upgpicker_count = 0;
var maintainer_count = 0;
var builder_count = 0;
var cs_list = spawn.room.find(FIND_CONSTRUCTION_SITES);
for(var creep of creep_list){
if(creep.memory.role == 'srcminer') srcminer_count++;
if(creep.memory.role == 'picker') picker_count++;
if(creep.memory.role == 'upgrader') upgrader_count++;
if(creep.memory.role == 'upgpicker') upgpicker_count++;
if(creep.memory.role == 'maintainer') maintainer_count++;
if(creep.memory.role == 'builder') builder_count++;
}
if(srcminer_count < Memory.rooms[room].spawnlist.srcminer.count){
const body = Memory.rooms[room].spawnlist.srcminer.body;
const name = 'srcminer '+Game.time%010503;
spawn.spawnCreep(body,name,{memory:{role:'srcminer'}});
}
if(picker_count < Memory.rooms[room].spawnlist.picker.count){
const body = Memory.rooms[room].spawnlist.picker.body;
const name = 'picker '+Game.time%010503;
spawn.spawnCreep(body,name,{memory:{role:'picker'}});
}
if(upgrader_count < Memory.rooms[room].spawnlist.upgrader.count){
const body = Memory.rooms[room].spawnlist.upgrader.body;
const name = 'upgrader '+Game.time%010503;
spawn.spawnCreep(body,name,{memory:{role:'upgrader'}});
}
if(upgpicker_count < Memory.rooms[room].spawnlist.upgpicker.count){
const body = Memory.rooms[room].spawnlist.upgpicker.body;
const name = 'upgpicker '+Game.time%010503;
spawn.spawnCreep(body,name,{memory:{role:'upgpicker'}});
}
if(maintainer_count < Memory.rooms[room].spawnlist.maintainer.count){
const body = Memory.rooms[room].spawnlist.maintainer.body;
const name = 'maintainer '+Game.time%010503;
spawn.spawnCreep(body,name,{memory:{role:'maintainer'}});
}
if(cs_list.length > 0 && builder_count < 2){
const body = Memory.rooms[room].spawnlist.builder.body;
const name = 'builder '+Game.time%010503;
spawn.spawnCreep(body,name,{memory:{role:'builder'}});
}
if(spawn.room.name == 'W48N31' && false){
if(picker_count >= Memory.rooms[room].spawnlist.picker.count && srcminer_count == Memory.rooms[room].spawnlist.srcminer.count){
if(!Game.creeps['S']){
Game.spawns['R4S1'].spawnCreep([WORK,WORK,CARRY,MOVE,MOVE, MOVE,WORK,WORK,CARRY,MOVE,
MOVE,MOVE,WORK,WORK,CARRY, MOVE,MOVE,MOVE,WORK,WORK,
CARRY,MOVE,MOVE,MOVE],'S',{memory:{role:'digger'}});
}
if(!Game.creeps['T']){
Game.spawns['R4S1'].spawnCreep([WORK,WORK,CARRY,MOVE,MOVE, MOVE,WORK,WORK,CARRY,MOVE,
MOVE,MOVE,WORK,WORK,CARRY, MOVE,MOVE,MOVE,WORK,WORK,
CARRY,MOVE,MOVE,MOVE],'T',{memory:{role:'digger'}});
}
if(!Game.creeps['V']){
Game.spawns['R4S1'].spawnCreep([WORK,WORK,CARRY,MOVE,MOVE,MOVE, WORK,WORK,CARRY,MOVE,MOVE,MOVE,
WORK,WORK,CARRY,MOVE,MOVE,MOVE, WORK,WORK,CARRY,MOVE,MOVE,MOVE],'V',{memory:{role:'digger'}});
}
if(!Game.creeps['U']){
Game.spawns['R4S1'].spawnCreep([WORK,WORK,CARRY,MOVE,MOVE,MOVE, WORK,WORK,CARRY,MOVE,MOVE,MOVE,
WORK,WORK,CARRY,MOVE,MOVE,MOVE, WORK,WORK,CARRY,MOVE,MOVE,MOVE],'U',{memory:{role:'digger'}});
}
if(!Game.creeps['W']){
Game.spawns['R4S1'].spawnCreep([WORK,WORK,CARRY,MOVE,MOVE, MOVE,WORK,WORK,CARRY,MOVE,
MOVE,MOVE,WORK,WORK,CARRY, MOVE,MOVE,MOVE,WORK,WORK,CARRY,MOVE,MOVE,MOVE],'W',{memory:{role:'digger'}});
}
if(!Game.creeps['X']){
Game.spawns['R4S1'].spawnCreep([WORK,WORK,CARRY,MOVE,MOVE, MOVE,WORK,WORK,CARRY,MOVE,
MOVE,MOVE,WORK,WORK,CARRY, MOVE,MOVE,MOVE,WORK,WORK,
CARRY,MOVE,MOVE,MOVE],'X',{memory:{role:'digger'}});
}
if(!Game.creeps['Z']){
Game.spawns['R4S1'].spawnCreep([WORK,WORK,CARRY,MOVE,MOVE, MOVE,WORK,WORK,CARRY,MOVE,
MOVE,MOVE,WORK,WORK,CARRY, MOVE,MOVE,MOVE,WORK,WORK,
CARRY,MOVE,MOVE,MOVE],'Z',{memory:{role:'digger'}});
}
}
}
if(spawn.room.name == 'W49N35' && false){
if(picker_count >= Memory.rooms[room].spawnlist.picker.count && srcminer_count == Memory.rooms[room].spawnlist.srcminer.count){
if(!Game.creeps['Y']){
Game.spawns['R5S'].spawnCreep([WORK,WORK,CARRY,MOVE,MOVE,MOVE,WORK,WORK,CARRY,MOVE,MOVE,MOVE,WORK,WORK,CARRY,MOVE,MOVE,MOVE],'Y',{memory:{role:'digger'}});
}
}
}
}
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化