-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrole.unit.js
35 lines (33 loc) · 1 KB
/
role.unit.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
Creep.prototype.roleUnit = function() {
let myFlag;
let myGroup;
if (this.memory.currentFlag == undefined) {
// Creep has no current flag --> get one!
myGroup = this.findMyFlag("unitGroup");
myFlag = Game.flags[myGroup];
}
else {
// Creep has current flag --> check!
if (Game.flags[this.memory.currentFlag] != undefined) {
//myFlag = this.memory.currentFlag;
return;
}
else {
myGroup = this.findMyFlag("unitGroup");
myFlag = Game.flags[myGroup];
}
}
if (myFlag == undefined) {
//No flag found for creep --> go home
if (this.goToHomeRoom() == true) {
let range = this.pos.getRangeTo(this.room.controller);
if (range > 1) {
this.moveTo(this.room.controller, {reusePath: moveReusePath()});
}
}
this.memory.currentFlag = undefined;
}
else {
this.memory.currentFlag = myFlag.name;
}
};