forked from VladThePaler/screeps.behaviour-action-pattern
-
Notifications
You must be signed in to change notification settings - Fork 0
/
creep.action.guarding.js
27 lines (26 loc) · 930 Bytes
/
creep.action.guarding.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
let action = new Creep.Action('guarding');
module.exports = action;
action.isAddableAction = function(){ return true; };
action.isAddableTarget = function(){ return true; };
action.newTarget = function(creep){
var flag;
if( creep.data.destiny ) flag = Game.flags[creep.data.destiny.flagName];
if ( !flag ) {
flag = FlagDir.find(FLAG_COLOR.defense, creep.pos, false, FlagDir.rangeMod, {
rangeModPerCrowd: 400
//rangeModByType: creep.data.creepType
});
}
if( creep.action && creep.action.name == 'guarding' && creep.flag )
return creep.flag;
if( flag ) Population.registerCreepFlag(creep, flag);
return flag;
};
action.work = function(creep){
if( creep.data.flagName )
return OK;
else return ERR_INVALID_ARGS;
};
action.onAssignment = function(creep, target) {
if( SAY_ASSIGNMENT ) creep.say(String.fromCharCode(9929), SAY_PUBLIC);
};