-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbehaviours.js
More file actions
33 lines (28 loc) · 804 Bytes
/
behaviours.js
File metadata and controls
33 lines (28 loc) · 804 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
31
32
33
module.exports = (function() {
var data = {
guard: guard,
harvester: harvester
}
return data;
function guard(creep){
return function() {
var targets = creep.room.find(Game.HOSTILE_CREEPS);
if (targets.length) {
creep.moveTo(targets[0]);
creep.attack(targets[0]);
}
}
}
function harvester(creep){
return function() {
if (creep.energy < creep.energyCapacity) {
var sources = creep.room.find(Game.SOURCES);
creep.moveTo(sources[0]);
creep.harvest(sources[0]);
} else {
creep.moveTo(Game.spawns.Spawn1);
creep.transferEnergy(Game.spawns.Spawn1)
}
}
}
})();