-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathactionRepaireler.js
91 lines (82 loc) · 3.91 KB
/
actionRepaireler.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
module.exports = {
run:function(creep){
let startCpu = Game.cpu.getUsed();
let elapsed;
if(creep.room.name !== creep.memory.roomID){
let actRes = creep.moveTo(new RoomPosition(25,25,creep.memory.roomID));
if (actRes === OK) {
creep.memory.action= 'traveling back ';
}
if( Memory.noticeSettings !== undefined && Memory.noticeSettings['noticeCPU'] === true && Memory.noticeSettings['noticeCPULevel']) {
elapsed = Game.cpu.getUsed() - startCpu;
if (elapsed > Memory.noticeSettings['noticeCPULevel']) {
creep.say(Math.round(elapsed,2)+'%');
}
}
return;
}
if(creep.carry.energy === creep.carryCapacity){
creep.memory.working = true;
}
if(creep.carry.energy === 0 || !creep.memory.working){
delete creep.memory.wallID;
let container = creep.pos.findClosestByPath(FIND_STRUCTURES, {
filter: s => ((s.structureType === STRUCTURE_CONTAINER || s.structureType === STRUCTURE_STORAGE ) && s.store[RESOURCE_ENERGY] > 0) || (s.structureType === STRUCTURE_LINK && s.energy > 0)
});
if (container !== undefined) {
let actRes = creep.withdraw(container, RESOURCE_ENERGY);
if ( actRes === ERR_NOT_IN_RANGE) {
creep.moveTo(container);
}
else if(actRes === ERR_NOT_ENOUGH_RESOURCES || actRes === ERR_INVALID_TARGET){
creep.memory.working = creep.mineEnergy();
}
}
else{
creep.memory.working = creep.mineEnergy();
}
}
else{
if(!creep.doRepair()){
if(!creep.doWallsRampartsRepair()){
if(!creep.doBuild()){
creep.memory.working = creep.doUpgrade();
if( Memory.noticeSettings !== undefined && Memory.noticeSettings['noticeCPU'] === true && Memory.noticeSettings['noticeCPULevel']) {
elapsed = Game.cpu.getUsed() - startCpu;
if (elapsed > Memory.noticeSettings['noticeCPULevel']) {
creep.say(Math.round(elapsed,2)+'%');
}
}
}
else{
creep.memory.working = true;
if( Memory.noticeSettings !== undefined && Memory.noticeSettings['noticeCPU'] === true && Memory.noticeSettings['noticeCPULevel']) {
elapsed = Game.cpu.getUsed() - startCpu;
if (elapsed > Memory.noticeSettings['noticeCPULevel']) {
creep.say(Math.round(elapsed,2)+'%');
}
}
}
}
else{
creep.memory.working = true;
if( Memory.noticeSettings !== undefined && Memory.noticeSettings['noticeCPU'] === true && Memory.noticeSettings['noticeCPULevel']) {
elapsed = Game.cpu.getUsed() - startCpu;
if (elapsed > Memory.noticeSettings['noticeCPULevel']) {
creep.say(Math.round(elapsed,2)+'%');
}
}
}
}
else{
if( Memory.noticeSettings !== undefined && Memory.noticeSettings['noticeCPU'] === true && Memory.noticeSettings['noticeCPULevel']) {
elapsed = Game.cpu.getUsed() - startCpu;
if (elapsed > Memory.noticeSettings['noticeCPULevel']) {
creep.say(Math.round(elapsed,2)+'%');
}
}
creep.memory.working = true;
}
}
}
};