自愈蠕变

时间:2014-12-04 23:34:21

标签: javascript screeps

我想做一个自我修复的蠕变,但下面的代码似乎不起作用。有什么建议吗?

module.exports = function(creep) {
    var targets = creep.room.find(Game.HOSTILE_CREEPS);
        if(targets.length) {
            creep.rangedAttack(targets[0]);
        }
        if(creep.hits < creep.hitsMax) {
                creep.heal(creep);
                console.log("healing")
        }}

1 个答案:

答案 0 :(得分:1)

假设https://gist.github.com/avdg/7835babe74904a8a123b处的代码准确无误,小兵无法自愈。 第4657行有一组检查,导致治疗功能什么也不做,没有错误。 其中一项检查是k == b,其中k似乎是目标,而b似乎是进行治疗的蠕动。所以,如果它们是相同的,它就什么都不做。

相关问题