【发布时间】:2017-02-07 17:38:43
【问题描述】:
很难找到最接近小兵的小兵,因为它必须有一组特定的角色并且必须没有指定的伙伴。
这是为了设置专用矿工和专用能源载体(它们必须找到最近的矿工或收割机并携带它们的能量)。
我试过了(其中cree变量是运行脚本的cree):
var nearestMinerCreep = creep.pos.findNearest(Game.MY_CREEPS, {
filter: function(creep) {
return (creep.memory.role == "miner"
|| creep.memory.role == "harvester")
&& !creep.memory.partner;
}
});
但 findNearest() 似乎已被贬低。用 findClosestByPath() 和 findClosestByRange() 的变体替换它也不起作用。我能做的最好的就是用这个来获得一个cree的位置:
var nearestPos = (creep.pos.findfindClosestByPath(FIND_MY_CREEPS)).pos;
但是由于需要转移能量,这是未经过滤的,并且不够具体。提前感谢您的帮助!
【问题讨论】:
标签: screeps