costCallBack in creep.moveTo doesn't appear to do anything.
-
I am trying to get some creeps to avoid going through Ramparts but when I add a costCallBack function to moveTo nothing changes. Am I using this wrong? Any help would be much appreciated.
creep.moveTo(target, {visualizePathStyle: {stroke: '#00ff00'}, costCallBack: function(roomName, cm)
{
var ramparts = Game.rooms[roomName].find(FIND_STRUCTURES, {filter: i => i.structureType == STRUCTURE_RAMPART});
ramparts.forEach(i => cm.set(i.pos.x, i.pos.y, 255));
}});
-
You don't need PathFinder.use(true); it is enabled by default
-
This post is deleted!
-
You have the capitalisation of the option wrong.
It should be costCallback and not costCallBack
otherwise your code looks functional. Although creating cost matrices very tick is very expensive in CPU.
-
@stevetrov lol Well that's embarrassing! Works great now. Thank you.