Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/game/rooms.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ function makePathfindingGrid(id, opts, endNodesKey) {
for(var y=0; y<50; y++) {
rows[y] = new Array(50);
for(var x=0; x<50; x++) {
rows[y][x] = x == 0 || y == 0 || x == 49 || y == 49 ? 11 : 2;
rows[y][x] = x == 0 || y == 0 || x == 49 || y == 49 ? 11 : C.MOVE_FATIGUE_PLAINS;
//var terrainCode = register.terrainByRoom.spatial[id][y][x];
var terrainCode = runtimeData.staticTerrainData[id][y*50+x];
if(terrainCode & C.TERRAIN_MASK_WALL) {
rows[y][x] = 0;
}
if ((terrainCode & C.TERRAIN_MASK_SWAMP) && rows[y][x] == 2) {
rows[y][x] = 10;
if ((terrainCode & C.TERRAIN_MASK_SWAMP) && rows[y][x] == C.MOVE_FATIGUE_PLAINS) {
rows[y][x] = C.MOVE_FATIGUE_SWAMP;
}
}
}
Expand Down Expand Up @@ -183,11 +183,11 @@ function makePathfindingGrid2(id, opts) {
}

if (object.type == 'swamp' && costs.get(object.x, object.y) == 0) {
costs.set(object.x, object.y, opts.ignoreRoads ? 5 : 10);
costs.set(object.x, object.y, opts.ignoreRoads ? ~~(C.MOVE_FATIGUE_SWAMP / C.MOVE_FATIGUE_PLAINS) : C.MOVE_FATIGUE_SWAMP);
}

if (!opts.ignoreRoads && object.type == 'road' && costs.get(object.x, object.y) < 0xFF) {
costs.set(object.x, object.y, 1);
costs.set(object.x, object.y, C.MOVE_FATIGUE_ROAD);
}
});
}
Expand Down Expand Up @@ -255,8 +255,8 @@ function _findPath2(id, fromPos, toPos, opts) {
maxRooms: opts.maxRooms
};
if(!opts.ignoreRoads) {
searchOpts.plainCost = 2;
searchOpts.swampCost = 10;
searchOpts.plainCost = C.MOVE_FATIGUE_PLAINS;
searchOpts.swampCost = C.MOVE_FATIGUE_SWAMP;
}
if(opts.plainCost) {
searchOpts.plainCost = opts.plainCost;
Expand Down Expand Up @@ -352,8 +352,8 @@ function _findClosestByPath2(fromPos, objects, opts) {
maxRooms: 1
};
if(!opts.ignoreRoads) {
searchOpts.plainCost = 2;
searchOpts.swampCost = 10;
searchOpts.plainCost = C.MOVE_FATIGUE_PLAINS;
searchOpts.swampCost = C.MOVE_FATIGUE_SWAMP;
}
var ret = globals.PathFinder.search(fromPos, goals, searchOpts);

Expand Down
6 changes: 3 additions & 3 deletions src/processor/common/fake-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ const defaultCostMatrix = function defaultCostMatrix(roomId, opts, creep, roomOb
}

if (object.type == 'swamp' && costs.get(object.x, object.y) == 0) {
costs.set(object.x, object.y, opts.ignoreRoads ? 5 : 10);
costs.set(object.x, object.y, opts.ignoreRoads ? ~~(C.MOVE_FATIGUE_SWAMP / C.MOVE_FATIGUE_PLAINS) : C.MOVE_FATIGUE_SWAMP);
}

if (!opts.ignoreRoads && object.type == 'road' && costs.get(object.x, object.y) < Infinity) {
Expand Down Expand Up @@ -160,8 +160,8 @@ const findPath = function findPath(source, target, opts, scope) {
searchOpts.maxRooms = 1;
searchOpts.roomCallback = roomCallback;
if(!searchOpts.ignoreRoads) {
searchOpts.plainCost = 2;
searchOpts.swampCost = 10;
searchOpts.plainCost = C.MOVE_FATIGUE_PLAINS;
searchOpts.swampCost = C.MOVE_FATIGUE_SWAMP;
}

const fromPos = new RoomPosition(source.x, source.y, source.room);
Expand Down
6 changes: 3 additions & 3 deletions src/processor/intents/movement.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,17 +201,17 @@ exports.execute = function(object, scope) {

var cellObjects = _.filter(roomObjects, (i) => i.x == move.x && i.y == move.y);

var fatigueRate = 2;
var fatigueRate = C.MOVE_FATIGUE_PLAINS;

if(_.any(cellObjects, {type: 'swamp'}) ||
utils.checkTerrain(roomTerrain, move.x, move.y, C.TERRAIN_MASK_SWAMP)) {
fatigueRate = 10;
fatigueRate = C.MOVE_FATIGUE_SWAMP;
}

var road = _.find(cellObjects, {type: 'road'});

if(road) {
fatigueRate = 1;
fatigueRate = C.MOVE_FATIGUE_ROAD;
if(object.type == 'powerCreep') {
road.nextDecayTime -= C.ROAD_WEAROUT_POWER_CREEP;
}
Expand Down