-
Notifications
You must be signed in to change notification settings - Fork 0
/
role.soldat.js
39 lines (36 loc) · 1.32 KB
/
role.soldat.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
module.exports = {
run: function(creep) {
if (Game.flags['Attack']){
var invadeRoom = Game.flags['Attack'].pos.roomName;
var flag = Game.flags['Attack'].pos;}
var targ2 = creep.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
var targ = creep.pos.findClosestByRange(FIND_HOSTILE_STRUCTURES, {
filter: (s) => s.structureType != STRUCTURE_CONTROLLER});
if (targ2){
code=creep.attack(targ2)
console.log(code)
if (code == ERR_NOT_IN_RANGE) {
if(creep.moveTo(targ2) == ERR_NO_PATH)
creep.moveTo(targ2, {ignoreDestructibleStructures: true})
}
}
else if(targ){
code=creep.attack(targ)
console.log(code)
if (code == ERR_NOT_IN_RANGE) {
if(creep.moveTo(targ) == ERR_NO_PATH)
creep.moveTo(targ, { ignoreDestructibleStructures: true})
}
}
else if (invadeRoom != 'undefined') {
creep.moveTo(Game.flags.Attack, {reusePath:3}); //new
/*if(creep.pos.roomName != invadeRoom)
{
var exitDir = Game.map.findExit(creep.room.name, invadeRoom);
var Exit = creep.pos.findClosestByRange(exitDir);
creep.moveTo(Exit), [{reusePath: 3}];
}*/
}
//else creep.moveTo(flag);
}
};