-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction_transfer.js
More file actions
33 lines (24 loc) · 924 Bytes
/
Copy pathaction_transfer.js
File metadata and controls
33 lines (24 loc) · 924 Bytes
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
let actionMove = require('action_move');
let info_room = require('info_room');
let do_out = function(creep){
room = creep.room;
let hostileCreeps = room.find(FIND_HOSTILE_CREEPS);
let targets = [];
//Remplir d'énergie les tours s'il y a des enemies
if(hostileCreeps.length > 0) targets = info_room.get_struct_not_full_energy(room, [STRUCTURE_TOWER]);
//Remplir d'énergie les structure
if(targets.length === 0) targets = info_room.get_struct_not_full_energy(room, [STRUCTURE_SPAWN, STRUCTURE_EXTENSION]);
//Remplir d'énergie les tours s'il n'y a rien d'autre àfaire
if(targets.length === 0) targets = info_room.get_struct_not_full_energy(room, [STRUCTURE_TOWER]);
let target = creep.pos.findClosestByRange(targets);
if(target){
if(creep.transfer(target, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
actionMove.do(creep, target);
}
return true;
}
return false;
}
module.exports = {
do: do_out
};