-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrole.drainer.js
41 lines (38 loc) · 1.34 KB
/
role.drainer.js
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
40
41
"use strict";
module.exports = {
run: function(creep){
var heal_parts = creep.getActiveBodyparts(HEAL);
if(creep.hits < creep.hitsMax) {
if (heal_parts > 0) {
creep.heal(creep);
if (!creep.room.controller) {
creep.moveToDestination();
} else if (!creep.isAtDestinationRoom()) {
creep.avoidEdges();
}
return 0;
}
}
if (creep.isAtDestinationRoom()) {
if (creep.updateDestination()) {
return;
}
creep.redRally();
if (heal_parts > 0) {
var hurtfriendly = creep.pos.findClosestByPath(_.filter(creep.room.find(FIND_MY_CREEPS), function(creep){ return (creep.hits < creep.hitsMax) }));
if (hurtfriendly) {
var frange = creep.pos.getRangeTo(hurtfriendly);
if (frange == 1) {
//creep.say('h melee');
creep.heal(hurtfriendly);
} else if (frange < 4) {
//creep.say('h range');
creep.rangedHeal(hurtfriendly);
}
}
}
} else {
creep.moveToDestination();
}
}
}