-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrole.healer.js
More file actions
39 lines (33 loc) · 1.16 KB
/
Copy pathrole.healer.js
File metadata and controls
39 lines (33 loc) · 1.16 KB
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
34
35
36
37
38
39
var roleHealer = {
/** @param {Creep} creep **/
run: function(creep) {
var healFlag = Game.flags['HealFlag'];
var healTarget = creep.pos.findClosestByRange(FIND_MY_CREEPS, {
filter: (creep) => {
return (creep.hits < creep.hitsMax);
}
});
var spawn = creep.pos.findClosestByRange(FIND_MY_SPAWNS);
if(creep.ticksToLive < 100){
if(spawn.renewCreep(creep) == ERR_NOT_IN_RANGE){
creep.moveTo(spawn, {visualizePathStyle: {stroke: '#ff0000'}});
}
}
if(healTarget) {
if(creep.heal(healTarget) == ERR_NOT_IN_RANGE) {
creep.moveTo(healTarget, {visualizePathStyle: {stroke: '#00ff00'}});
}
}
else{
if(creep.ticksToLive > 600){
creep.moveTo(healFlag, {visualizePathStyle: {stroke: '#ff0000'}});
}
else{
if(spawn.renewCreep(creep) == ERR_NOT_IN_RANGE){
creep.moveTo(spawn, {visualizePathStyle: {stroke: '#ff0000'}});
}
}
}
}
};
module.exports = roleHealer;