Skip to content

Commit

Permalink
RANGE_* constants for creeps, structures and powercreeps
Browse files Browse the repository at this point in the history
clone and fixed merge conflicts of screeps/engine PR #6 by PostCrafter
added RANGE_* constants for PowerCreeps
  • Loading branch information
semperrabbit authored and RiftLurker committed Oct 27, 2020
1 parent b89971a commit 6431a58
Show file tree
Hide file tree
Showing 2 changed files with 424 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/game/creeps.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ function _getActiveBodyparts(body, type) {
}

function _hasActiveBodypart(body, type) {
if(!body) {
return true;
}
for(var i = body.length-1; i>=0; i--) {
if (body[i].hits <= 0)
break;
Expand Down Expand Up @@ -574,7 +577,7 @@ exports.make = function(_runtimeData, _intents, _register, _globals) {
if(this.room.controller && !this.room.controller.my && this.room.controller.safeMode) {
return C.ERR_NOT_OWNER;
}

if(resourceType == C.RESOURCE_ENERGY) {

if (register.structures[target.id] &&
Expand Down Expand Up @@ -713,6 +716,12 @@ exports.make = function(_runtimeData, _intents, _register, _globals) {
register.assertTargetObject(target);
return C.ERR_INVALID_TARGET;
}

var effect = _.find(target.effects, {power: C.PWR_FORTIFY});
if(effect && effect.ticksRemaining > 0) {
return C.ERR_INVALID_TARGET;
}

if(!target.pos.inRangeTo(this.pos, C.RANGE_ATTACK)) {
return C.ERR_NOT_IN_RANGE;
}
Expand Down
Loading

0 comments on commit 6431a58

Please sign in to comment.