-
Notifications
You must be signed in to change notification settings - Fork 0
/
role.soldier.js
37 lines (28 loc) · 992 Bytes
/
role.soldier.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
var roleSoldier = {
/** @param {Creep} creep **/
run: function (creep) {
if (creep.changeRoomsIfNeeded())
return;
let closest_hostile = creep.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
if (closest_hostile) {
if (creep.attack(closest_hostile) == ERR_NOT_IN_RANGE) {
creep.moveTo(closest_hostile);
}
}
/*
if (creep.room.name != creep.memory.target) {
//find exit to the target room
let exit = creep.room.findExitTo(creep.memory.target);
creep.moveTo(creep.pos.findClosestByRange(exit));
} else {
let closest_hostile = creep.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
if (closest_hostile) {
if (creep.attack(closest_hostile) == ERR_NOT_IN_RANGE) {
creep.moveTo(closest_hostile);
}
}
}
*/
}
};
module.exports = roleSoldier;