forked from shryme/Screeps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsourceDestroyer.js
More file actions
31 lines (26 loc) · 865 Bytes
/
sourceDestroyer.js
File metadata and controls
31 lines (26 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
module.exports = function (creep) {
//Destroy the source keeper and tell everyone it's done once it is
var sourceDistance = creep.pos.getRangeTo(Game.spawns.Spawn1.memory.sourceKeeperPos);
var isMoving = sourceDistance >= 0 ? true : false;
var targets = creep.pos.findInRange(Game.HOSTILE_CREEPS, 3);
if (targets.length > 0) {
if (targets[0].hits > 100) {
creep.rangedAttack(targets[0]);
// Game.spawns.Spawn1.memory.keeper_neutralized = false;
}
else {
// Game.spawns.Spawn1.memory.keeper_neutralized = true;
}
}
else {
//Move towards the source keeper
if (isMoving) {
//TODO detect when destroyer is in the way for harvesting
creep.moveTo(Game.spawns.Spawn1.memory.sourceKeeperPos);
// Game.spawns.Spawn1.memory.keeper_neutralized = false;
}
else {
// Game.spawns.Spawn1.memory.keeper_neutralized = true;
}
}
}