-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprototype.tower.js
36 lines (34 loc) · 1.2 KB
/
prototype.tower.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
//New functions for StructureTower
StructureTower.prototype.attackNearEnemys =
function () {
// find closes hostile creep
var target = this.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
if (target) {//If we found it, kill it
return this.attack(target) == 0;
}
return false;
};
StructureTower.prototype.supportNearAllys =
function () {
//Heal near creeps
var target = this.pos.findClosestByRange(FIND_MY_CREEPS, {
filter: (thisCreep) => (thisCreep.hits < thisCreep.hitsMax)
});
if(target){
return this.heal(target) == 0;
}
return false;
};
StructureTower.prototype.repairNearStructures =
function () {
//Repair near structures
if (this.energy > 600){
var target = this.pos.findClosestByRange(FIND_STRUCTURES, {
filter: (structure) => (((structure.hits < structure.hitsMax/2) && structure.structureType != STRUCTURE_WALL && structure.structureType != STRUCTURE_RAMPART) || (structure.hits < 10000 && (structure.hits + 1000) < structure.hitsMax))
});
if(target){
return this.repair(target) == 0;
}
}
return false;
};