diff --git a/src/game/creeps.js b/src/game/creeps.js index 07fb0147..cae78aed 100644 --- a/src/game/creeps.js +++ b/src/game/creeps.js @@ -352,7 +352,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { if(!target.energy) { return C.ERR_NOT_ENOUGH_RESOURCES; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_HARVEST_SOURCE)) { return C.ERR_NOT_IN_RANGE; } if(this.room.controller && ( @@ -367,7 +367,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { if(!target.mineralAmount) { return C.ERR_NOT_ENOUGH_RESOURCES; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_HARVEST_MINERAL)) { return C.ERR_NOT_IN_RANGE; } var extractor = _.find(target.pos.lookFor('structure'), {structureType: C.STRUCTURE_EXTRACTOR}); @@ -385,7 +385,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { } } else if(register.deposits[target.id] && (target instanceof globals.Deposit)) { - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_HARVEST_DEPOSIT)) { return C.ERR_NOT_IN_RANGE; } if(target.cooldown) { @@ -460,7 +460,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { return C.ERR_INVALID_TARGET; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_TRANSFER)) { return C.ERR_NOT_IN_RANGE; } if(!data(this.id).store || !data(this.id).store[resourceType]) { @@ -537,7 +537,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { return C.ERR_INVALID_TARGET; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_WITHDRAW)) { return C.ERR_NOT_IN_RANGE; } @@ -578,7 +578,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { if(utils.calcResources(data(this.id)) >= data(this.id).storeCapacity) { return C.ERR_FULL; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_PICKUP)) { return C.ERR_NOT_IN_RANGE; } @@ -615,7 +615,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { return C.ERR_INVALID_TARGET; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_ATTACK)) { return C.ERR_NOT_IN_RANGE; } @@ -642,7 +642,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { register.assertTargetObject(target); return C.ERR_INVALID_TARGET; } - if(!this.pos.inRangeTo(target, 3)) { + if(!this.pos.inRangeTo(target, C.RANGE_RANGED_ATTACK)) { return C.ERR_NOT_IN_RANGE; } @@ -691,7 +691,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { register.assertTargetObject(target); return C.ERR_INVALID_TARGET; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_HEAL)) { return C.ERR_NOT_IN_RANGE; } if(this.room.controller && !this.room.controller.my && this.room.controller.safeMode) { @@ -722,7 +722,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { if(this.room.controller && !this.room.controller.my && this.room.controller.safeMode) { return C.ERR_NO_BODYPART; } - if(!this.pos.inRangeTo(target, 3)) { + if(!this.pos.inRangeTo(target, C.RANGE_RANGED_HEAL)) { return C.ERR_NOT_IN_RANGE; } @@ -750,7 +750,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { register.assertTargetObject(target); return C.ERR_INVALID_TARGET; } - if(!this.pos.inRangeTo(target, 3)) { + if(!this.pos.inRangeTo(target, C.RANGE_REPAIR)) { return C.ERR_NOT_IN_RANGE; } @@ -777,7 +777,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { register.assertTargetObject(target); return C.ERR_INVALID_TARGET; } - if(!this.pos.inRangeTo(target, 3)) { + if(!this.pos.inRangeTo(target, C.RANGE_BUILD)) { return C.ERR_NOT_IN_RANGE; } @@ -860,7 +860,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { if(!_hasActiveBodypart(this.body, C.CLAIM)) { return C.ERR_NO_BODYPART; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_CLAIM_CONTROLLER)) { return C.ERR_NOT_IN_RANGE; } if(target.structureType != 'controller') { @@ -896,7 +896,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { if(!_getActiveBodyparts(this.body, C.CLAIM)) { return C.ERR_NO_BODYPART; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_ATTACK_CONTROLLER)) { return C.ERR_NOT_IN_RANGE; } if(!target.owner && !target.reservation) { @@ -937,7 +937,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { if(target.upgradeBlocked && target.upgradeBlocked > 0) { return C.ERR_INVALID_TARGET; } - if(!target.pos.inRangeTo(this.pos, 3)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_UPGRADE_CONTROLLER)) { return C.ERR_NOT_IN_RANGE; } if(!target.my) { @@ -964,7 +964,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { register.assertTargetObject(target); return C.ERR_INVALID_TARGET; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_RESERVE_CONTROLLER)) { return C.ERR_NOT_IN_RANGE; } if(target.structureType != 'controller') { @@ -1030,7 +1030,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { register.assertTargetObject(target); return C.ERR_INVALID_TARGET; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_DISMANTLE)) { return C.ERR_NOT_IN_RANGE; } if(this.room.controller && !this.room.controller.my && this.room.controller.safeMode) { @@ -1061,7 +1061,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { register.assertTargetObject(target); return C.ERR_INVALID_TARGET; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_GENERATE_SAFEMODE)) { return C.ERR_NOT_IN_RANGE; } @@ -1079,7 +1079,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { register.assertTargetObject(target); return C.ERR_INVALID_TARGET; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_SIGN_CONTROLLER)) { return C.ERR_NOT_IN_RANGE; } if(target.structureType != 'controller') { diff --git a/src/game/power-creeps.js b/src/game/power-creeps.js index 7bb9c1cf..3b6e2cb7 100644 --- a/src/game/power-creeps.js +++ b/src/game/power-creeps.js @@ -305,7 +305,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { register.assertTargetObject(target); return C.ERR_INVALID_TARGET; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_ENABLE_POWER)) { return C.ERR_NOT_IN_RANGE; } if(target.structureType != 'controller' || target.safeMode && !target.my) { @@ -332,7 +332,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { if((target instanceof globals.StructurePowerSpawn) && !utils.checkStructureAgainstController(data(target.id), register.objectsByRoom[data(target.id).room], data(target.room.controller.id))) { return C.ERR_RCL_NOT_ENOUGH; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_RENEW_POWERCREEP)) { return C.ERR_NOT_IN_RANGE; } intents.set(this.id, 'renew', {id: target.id}); diff --git a/src/game/structures.js b/src/game/structures.js index 1025d352..ad055256 100644 --- a/src/game/structures.js +++ b/src/game/structures.js @@ -334,7 +334,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { register.assertTargetObject(lab2); return C.ERR_INVALID_TARGET; } - if(this.pos.getRangeTo(lab1) > 2 || this.pos.getRangeTo(lab2) > 2) { + if(this.pos.getRangeTo(lab1) > C.RANGE_RUN_REACTION || this.pos.getRangeTo(lab2) > C.RANGE_RUN_REACTION) { return C.ERR_NOT_IN_RANGE; } var reactionAmount = C.LAB_REACTION_AMOUNT; @@ -420,7 +420,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { register.assertTargetObject(target); return C.ERR_INVALID_TARGET; } - if(!this.pos.isNearTo(target)) { + if(!this.pos.inRangeTo(target, C.RANGE_BOOST_CREEP)) { return C.ERR_NOT_IN_RANGE; } if(data(this.id).store.energy < C.LAB_BOOST_ENERGY) { @@ -457,7 +457,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { if(!_.some(target.body, p => !!p.boost)) { return C.ERR_NOT_FOUND; } - if(!this.pos.isNearTo(target)) { + if(!this.pos.inRange(target, C.RANGE_UNBOOST_CREEP)) { return C.ERR_NOT_IN_RANGE; } @@ -1239,7 +1239,10 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { if(runtimeData.roomObjects[this.id].off) { return C.ERR_RCL_NOT_ENOUGH; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.my) { + return C.ERR_NOT_OWNER; + } + if(!target.pos.inRangeTo(this.pos, C.RANGE_RENEW_CREEP)) { return C.ERR_NOT_IN_RANGE; } if(this.room.energyAvailable < Math.ceil(C.SPAWN_RENEW_RATIO * utils.calcCreepCost(target.body) / C.CREEP_SPAWN_TIME / target.body.length)) { @@ -1271,7 +1274,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) { if(!target.my) { return C.ERR_NOT_OWNER; } - if(!target.pos.isNearTo(this.pos)) { + if(!target.pos.inRangeTo(this.pos, C.RANGE_RECYCLE_CREEP)) { return C.ERR_NOT_IN_RANGE; } diff --git a/src/processor/intents/creeps/attack.js b/src/processor/intents/creeps/attack.js index bfc1012b..9c5dcc38 100644 --- a/src/processor/intents/creeps/attack.js +++ b/src/processor/intents/creeps/attack.js @@ -18,7 +18,7 @@ module.exports = function(object, intent, scope) { if(!target || target == object) { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_ATTACK || Math.abs(target.y - object.y) > C.RANGE_ATTACK) { return; } if(target.type == 'creep' && target.spawning) { diff --git a/src/processor/intents/creeps/attackController.js b/src/processor/intents/creeps/attackController.js index 5fe01e89..438383ee 100644 --- a/src/processor/intents/creeps/attackController.js +++ b/src/processor/intents/creeps/attackController.js @@ -16,7 +16,7 @@ module.exports = function(object, intent, {roomObjects, bulk, roomController, ga if(!target || target.type != 'controller') { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_ATTACK_CONTROLLER || Math.abs(target.y - object.y) > C.RANGE_ATTACK_CONTROLLER) { return; } if(!target.user && !target.reservation) { diff --git a/src/processor/intents/creeps/build.js b/src/processor/intents/creeps/build.js index cee234f0..06a1db8b 100644 --- a/src/processor/intents/creeps/build.js +++ b/src/processor/intents/creeps/build.js @@ -20,7 +20,7 @@ module.exports = function(object, intent, {roomObjects, roomTerrain, bulk, roomC !C.CONSTRUCTION_COST[target.structureType]) { return; } - if(Math.abs(target.x - object.x) > 3 || Math.abs(target.y - object.y) > 3) { + if(Math.abs(target.x - object.x) > C.RANGE_BUILD || Math.abs(target.y - object.y) > C.RANGE_BUILD) { return; } diff --git a/src/processor/intents/creeps/claimController.js b/src/processor/intents/creeps/claimController.js index 59120a70..40bf5595 100644 --- a/src/processor/intents/creeps/claimController.js +++ b/src/processor/intents/creeps/claimController.js @@ -16,7 +16,7 @@ module.exports = function(object, intent, {roomObjects, bulk, bulkUsers, users}) if(!target || target.type != 'controller') { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_CLAIM_CONTROLLER || Math.abs(target.y - object.y) > C.RANGE_CLAIM_CONTROLLER) { return; } if(target.bindUser && object.user != target.bindUser) { diff --git a/src/processor/intents/creeps/dismantle.js b/src/processor/intents/creeps/dismantle.js index 46cae318..77518369 100644 --- a/src/processor/intents/creeps/dismantle.js +++ b/src/processor/intents/creeps/dismantle.js @@ -18,7 +18,7 @@ module.exports = function(object, intent, scope) { if(!target || !C.CONSTRUCTION_COST[target.type]) { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_DISMANTLE || Math.abs(target.y - object.y) > C.RANGE_DISMANTLE) { return; } if(roomController && roomController.user != object.user && roomController.safeMode > gameTime) { diff --git a/src/processor/intents/creeps/generateSafeMode.js b/src/processor/intents/creeps/generateSafeMode.js index 50d2aac9..9dbff4b7 100644 --- a/src/processor/intents/creeps/generateSafeMode.js +++ b/src/processor/intents/creeps/generateSafeMode.js @@ -13,7 +13,7 @@ module.exports = function(object, intent, {roomObjects, bulk}) { if(!target || target.type != 'controller') { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_GENERATE_SAFEMODE || Math.abs(target.y - object.y) > C.RANGE_GENERATE_SAFEMODE) { return; } if(!object.store || !(object.store[C.RESOURCE_GHODIUM] >= C.SAFE_MODE_COST)) { diff --git a/src/processor/intents/creeps/harvest.js b/src/processor/intents/creeps/harvest.js index e755df3c..3ed7b843 100644 --- a/src/processor/intents/creeps/harvest.js +++ b/src/processor/intents/creeps/harvest.js @@ -3,6 +3,12 @@ var _ = require('lodash'), driver = utils.getDriver(), C = driver.constants; +const RANGES = { + 'source': C.RANGE_HARVEST_SOURCE, + 'mineral': C.RANGE_HARVEST_MINERAL, + 'deposit': C.RANGE_HARVEST_DEPOSIT, +}; + module.exports = function(object, intent, scope) { const {roomObjects, roomTerrain, bulk, roomController, stats, eventLog, gameTime} = scope; @@ -18,7 +24,8 @@ module.exports = function(object, intent, scope) { if(!target) { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + + if(Math.abs(target.x - object.x) > RANGES[target.type] || Math.abs(target.y - object.y) > RANGES[target.type]) { return; } diff --git a/src/processor/intents/creeps/heal.js b/src/processor/intents/creeps/heal.js index 5ef10211..aaa031a6 100644 --- a/src/processor/intents/creeps/heal.js +++ b/src/processor/intents/creeps/heal.js @@ -16,7 +16,7 @@ module.exports = function(object, intent, {roomObjects, roomController, gameTime if(!target || (target.type != 'creep' && target.type != 'powerCreep') || target.spawning) { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_HEAL || Math.abs(target.y - object.y) > C.RANGE_HEAL) { return; } if(roomController && roomController.user != object.user && roomController.safeMode > gameTime) { diff --git a/src/processor/intents/creeps/pickup.js b/src/processor/intents/creeps/pickup.js index 259ec173..09a8bb33 100644 --- a/src/processor/intents/creeps/pickup.js +++ b/src/processor/intents/creeps/pickup.js @@ -16,7 +16,7 @@ module.exports = function(object, intent, {roomObjects, bulk}) { if(!target || target.type != 'energy') { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_PICKUP || Math.abs(target.y - object.y) > C.RANGE_PICKUP) { return; } diff --git a/src/processor/intents/creeps/rangedAttack.js b/src/processor/intents/creeps/rangedAttack.js index 08f165eb..e27fe918 100644 --- a/src/processor/intents/creeps/rangedAttack.js +++ b/src/processor/intents/creeps/rangedAttack.js @@ -18,7 +18,7 @@ module.exports = function(object, intent, scope) { if(!target || target == object) { return; } - if(Math.abs(target.x - object.x) > 3 || Math.abs(target.y - object.y) > 3) { + if(Math.abs(target.x - object.x) > C.RANGE_RANGED_ATTACK || Math.abs(target.y - object.y) > C.RANGE_RANGED_ATTACK) { return; } if(target.type == 'creep' && target.spawning) { diff --git a/src/processor/intents/creeps/rangedHeal.js b/src/processor/intents/creeps/rangedHeal.js index 9cd0e365..13f1c7bb 100644 --- a/src/processor/intents/creeps/rangedHeal.js +++ b/src/processor/intents/creeps/rangedHeal.js @@ -16,7 +16,7 @@ module.exports = function(object, intent, {roomObjects, roomController, gameTime if(!target || (target.type != 'creep' && target.type != 'powerCreep') || target.spawning) { return; } - if(Math.abs(target.x - object.x) > 3 || Math.abs(target.y - object.y) > 3) { + if(Math.abs(target.x - object.x) > C.RANGE_RANGED_HEAL || Math.abs(target.y - object.y) > C.RANGE_RANGED_HEAL) { return; } if(roomController && roomController.user != object.user && roomController.safeMode > gameTime) { diff --git a/src/processor/intents/creeps/rangedMassAttack.js b/src/processor/intents/creeps/rangedMassAttack.js index ab386b5e..3a71e97a 100644 --- a/src/processor/intents/creeps/rangedMassAttack.js +++ b/src/processor/intents/creeps/rangedMassAttack.js @@ -25,8 +25,8 @@ module.exports = function(object, intent, scope) { var targets = _.filter(roomObjects, (i) => { return (!_.isUndefined(i.user) || i.type == 'powerBank') && i.user != object.user && - i.x >= object.x - 3 && i.x <= object.x + 3 && - i.y >= object.y - 3 && i.y <= object.y + 3; + i.x >= object.x - C.RANGE_RANGED_MASS_ATTACK && i.x <= object.x + C.RANGE_RANGED_MASS_ATTACK && + i.y >= object.y - C.RANGE_RANGED_MASS_ATTACK && i.y <= object.y + C.RANGE_RANGED_MASS_ATTACK; }); var distanceRate = {0: 1, 1: 1, 2: 0.4, 3: 0.1}; diff --git a/src/processor/intents/creeps/repair.js b/src/processor/intents/creeps/repair.js index 56b7219b..a6ce2ffd 100644 --- a/src/processor/intents/creeps/repair.js +++ b/src/processor/intents/creeps/repair.js @@ -16,7 +16,7 @@ module.exports = function(object, intent, {roomObjects, bulk, stats, eventLog}) if(!target || !target.hitsMax || !C.CONSTRUCTION_COST[target.type] || target.hits >= target.hitsMax) { return; } - if(Math.abs(target.x - object.x) > 3 || Math.abs(target.y - object.y) > 3) { + if(Math.abs(target.x - object.x) > C.RANGE_REPAIR || Math.abs(target.y - object.y) > C.RANGE_REPAIR) { return; } diff --git a/src/processor/intents/creeps/reserveController.js b/src/processor/intents/creeps/reserveController.js index 6fed9ebb..90718ccf 100644 --- a/src/processor/intents/creeps/reserveController.js +++ b/src/processor/intents/creeps/reserveController.js @@ -16,7 +16,7 @@ module.exports = function(object, intent, {roomObjects, bulk, gameTime, eventLog if(!target || target.type != 'controller') { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_RESERVE_CONTROLLER || Math.abs(target.y - object.y) > C.RANGE_RESERVE_CONTROLLER) { return; } if(target.user || target.reservation && target.reservation.user != object.user) { diff --git a/src/processor/intents/creeps/signController.js b/src/processor/intents/creeps/signController.js index 32c620a2..ed08b934 100644 --- a/src/processor/intents/creeps/signController.js +++ b/src/processor/intents/creeps/signController.js @@ -16,7 +16,7 @@ module.exports = function(object, intent, {roomObjects, bulk, gameTime}) { if(!target || target.type != 'controller') { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_SIGN_CONTROLLER || Math.abs(target.y - object.y) > C.RANGE_SIGN_CONTROLLER) { return; } diff --git a/src/processor/intents/creeps/transfer.js b/src/processor/intents/creeps/transfer.js index 2eaeae19..67bd0edb 100644 --- a/src/processor/intents/creeps/transfer.js +++ b/src/processor/intents/creeps/transfer.js @@ -17,7 +17,7 @@ module.exports = function(object, intent, {roomObjects, bulk, eventLog}) { if(!target || target.type == 'creep' && target.spawning) { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_TRANSFER || Math.abs(target.y - object.y) > C.RANGE_TRANSFER) { return; } diff --git a/src/processor/intents/creeps/upgradeController.js b/src/processor/intents/creeps/upgradeController.js index 30fde070..d4963590 100644 --- a/src/processor/intents/creeps/upgradeController.js +++ b/src/processor/intents/creeps/upgradeController.js @@ -14,7 +14,7 @@ module.exports = function(object, intent, {roomObjects, bulk, bulkUsers, stats, if(!target || target.type != 'controller') { return; } - if(Math.abs(target.x - object.x) > 3 || Math.abs(target.y - object.y) > 3) { + if(Math.abs(target.x - object.x) > C.RANGE_UPGRADE_CONTROLLER || Math.abs(target.y - object.y) > C.RANGE_UPGRADE_CONTROLLER) { return; } if(target.level == 0 || target.user != object.user) { diff --git a/src/processor/intents/creeps/withdraw.js b/src/processor/intents/creeps/withdraw.js index 8ad97373..f8a6e81d 100644 --- a/src/processor/intents/creeps/withdraw.js +++ b/src/processor/intents/creeps/withdraw.js @@ -25,7 +25,7 @@ module.exports = function(object, intent, {roomObjects, bulk, roomController, ga if(object.user != target.user && _.any(roomObjects, i => i.type == C.STRUCTURE_RAMPART && i.user != object.user && !i.isPublic && i.x == target.x && i.y == target.y)) { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_WITHDRAW || Math.abs(target.y - object.y) > C.RANGE_WITHDRAW) { return; } diff --git a/src/processor/intents/labs/boost-creep.js b/src/processor/intents/labs/boost-creep.js index c24bbe8b..0a8de5f3 100644 --- a/src/processor/intents/labs/boost-creep.js +++ b/src/processor/intents/labs/boost-creep.js @@ -20,7 +20,7 @@ module.exports = function(object, intent, {roomObjects, bulk}) { if(!target || target.type != 'creep' || target.spawning) { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_BOOST_CREEP || Math.abs(target.y - object.y) > C.RANGE_BOOST_CREEP) { return; } diff --git a/src/processor/intents/labs/run-reaction.js b/src/processor/intents/labs/run-reaction.js index e6722532..68cdca21 100644 --- a/src/processor/intents/labs/run-reaction.js +++ b/src/processor/intents/labs/run-reaction.js @@ -23,7 +23,7 @@ module.exports = function(object, intent, {roomObjects, bulk, gameTime}) { if(!lab1MineralType || lab1.store[lab1MineralType] < reactionAmount) { return; } - if(Math.abs(lab1.x - object.x) > 2 || Math.abs(lab1.y - object.y) > 2) { + if(Math.abs(lab1.x - object.x) > C.RANGE_RUN_REACTION || Math.abs(lab1.y - object.y) > C.RANGE_RUN_REACTION) { return; } @@ -35,7 +35,7 @@ module.exports = function(object, intent, {roomObjects, bulk, gameTime}) { if(!lab2MineralType || lab2.store[lab2MineralType] < reactionAmount) { return; } - if(Math.abs(lab2.x - object.x) > 2 || Math.abs(lab2.y - object.y) > 2) { + if(Math.abs(lab2.x - object.x) > C.RANGE_RUN_REACTION || Math.abs(lab2.y - object.y) > C.RANGE_RUN_REACTION) { return; } diff --git a/src/processor/intents/labs/unboost-creep.js b/src/processor/intents/labs/unboost-creep.js index 19806fe5..4f54b76b 100644 --- a/src/processor/intents/labs/unboost-creep.js +++ b/src/processor/intents/labs/unboost-creep.js @@ -17,7 +17,7 @@ module.exports = function(object, intent, scope) { if(!utils.checkStructureAgainstController(object, roomObjects, roomController)) { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > ะก.RANGE_UNBOOST_CREEP || Math.abs(target.y - object.y) > C.RANGE_UNBOOST_CREEP) { return; } const boostedParts = _.mapValues(_.groupBy(_.filter(target.body,p=>!!p.boost), 'boost'), v=>v.length); diff --git a/src/processor/intents/power-creeps/renew.js b/src/processor/intents/power-creeps/renew.js index 474331ca..0ee3b6ae 100644 --- a/src/processor/intents/power-creeps/renew.js +++ b/src/processor/intents/power-creeps/renew.js @@ -9,7 +9,7 @@ module.exports = function(object, intent, {roomObjects, roomController, bulk, ga if(!target || target.type != 'powerBank' && target.type != 'powerSpawn') { return; } - if(utils.dist(object, target) > 1) { + if(utils.dist(object, target) > C.RANGE_RENEW_POWERCREEP) { return; } diff --git a/src/processor/intents/spawns/recycle-creep.js b/src/processor/intents/spawns/recycle-creep.js index 7ed1da53..61411a5c 100644 --- a/src/processor/intents/spawns/recycle-creep.js +++ b/src/processor/intents/spawns/recycle-creep.js @@ -15,7 +15,7 @@ module.exports = function(object, intent, scope) { if(!target || target.type != 'creep' || target.user != object.user || target.spawning) { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_RECYCLE_CREEP || Math.abs(target.y - object.y) > C.RANGE_RECYCLE_CREEP) { return; } diff --git a/src/processor/intents/spawns/renew-creep.js b/src/processor/intents/spawns/renew-creep.js index 6818f76a..04c3de4c 100644 --- a/src/processor/intents/spawns/renew-creep.js +++ b/src/processor/intents/spawns/renew-creep.js @@ -18,7 +18,7 @@ module.exports = function(object, intent, scope) { if(!target || target.type != 'creep' || target.user != object.user || target.spawning) { return; } - if(Math.abs(target.x - object.x) > 1 || Math.abs(target.y - object.y) > 1) { + if(Math.abs(target.x - object.x) > C.RANGE_RENEW_CREEP || Math.abs(target.y - object.y) > C.RANGE_RENEW_CREEP) { return; } if(_.filter(target.body, (i) => i.type == C.CLAIM).length > 0) {