-
-
Save ChuckMayo/0aff99f631d45364b354 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var avoid = []; | |
if (sourceKeepersInRoom.length) | |
{ | |
for (var sk = 0; sk < sourceKeepersInRoom.length; sk++) | |
{ | |
var center = sourceKeepersInRoom[sk].pos; | |
var top = center.y - 4; | |
var bottom = center.y + 4; | |
var left = center.x - 4; | |
var right = center.x + 4; | |
// generate room positions for each row and column | |
for (var rowIndex = top; rowIndex < bottom + 1; rowIndex++) | |
{ | |
for (var columnIndex = left; columnIndex < right + 1; columnIndex++) | |
{ | |
var avoidPosition = creep.room.getPositionAt(columnIndex, rowIndex); | |
if (avoidPosition != null) | |
avoid.push(avoidPosition); | |
if (sk == 0) | |
{ | |
var flagName = rowIndex + ' ' + columnIndex; | |
} | |
} | |
} | |
} | |
} | |
var moveResult = creep.moveTo(target, { avoid: avoid, reusePath: 30 }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment