guard, and change some numbers
This commit is contained in:
parent
b8ada37da4
commit
be4b33d728
@ -1,11 +1,11 @@
|
||||
// usernames are all lowercase, we compare with to lower
|
||||
var USERNAME_WHITELIST = ['chrisinajar', 'ho0ber', 'fractaloop', 'n7-anthony', 'overra', 'tyrel', 'fervens'];
|
||||
|
||||
|
||||
module.exports = {
|
||||
findEnemy: findEnemy,
|
||||
run: run
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
var target = findEnemy(creep);
|
||||
*/
|
||||
@ -20,7 +20,7 @@ function findEnemy (creep) {
|
||||
}
|
||||
return creep.pos.findClosestByPath(targets);
|
||||
}
|
||||
|
||||
|
||||
function run (creep) {
|
||||
var target = findEnemy(creep);
|
||||
if (!target) {
|
||||
@ -38,7 +38,7 @@ function run (creep) {
|
||||
creep.attack(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function findWall (creep) {
|
||||
var targets = creep.room.find(FIND_STRUCTURES, {
|
||||
filter: function(object) {
|
||||
|
21
main.js
21
main.js
@ -1,24 +1,30 @@
|
||||
var roleHarvester = require('role.harvester');
|
||||
var roleUpgrader = require('role.upgrader');
|
||||
var roleBuilder = require('role.builder');
|
||||
var roleGuard = require('role.guard');
|
||||
var helpers = require('helpers');
|
||||
|
||||
var creepRolePriority = ['harvester', 'builder', 'upgrader'];
|
||||
var creepRolePriority = ['harvester', 'builder', 'upgrader', 'guard'];
|
||||
var creepsConfig = {
|
||||
harvester: {
|
||||
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
||||
minimumCreeps: 6,
|
||||
bodyParts: [WORK, CARRY, MOVE, MOVE, MOVE],
|
||||
minimumCreeps: 2,
|
||||
role: roleHarvester
|
||||
},
|
||||
builder: {
|
||||
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
||||
minimumCreeps: 1,
|
||||
minimumCreeps: 0,
|
||||
role: roleBuilder
|
||||
},
|
||||
upgrader: {
|
||||
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
||||
minimumCreeps: 1,
|
||||
bodyParts: [WORK, CARRY, MOVE, MOVE, MOVE],
|
||||
minimumCreeps: 3,
|
||||
role: roleUpgrader
|
||||
},
|
||||
guard: {
|
||||
bodyParts: [TOUGH, MOVE, ATTACK, MOVE, ATTACK],
|
||||
minimumCreeps: 2,
|
||||
role: roleGuard
|
||||
}
|
||||
};
|
||||
|
||||
@ -56,7 +62,8 @@ module.exports.loop = function(){
|
||||
var roleCounts = {
|
||||
builder: 0,
|
||||
harvester: 0,
|
||||
upgrader: 0
|
||||
upgrader: 0,
|
||||
guard: 0
|
||||
}
|
||||
for (var name in Game.creeps){
|
||||
var creep = Game.creeps[name];
|
||||
|
17
role.guard.js
Normal file
17
role.guard.js
Normal file
@ -0,0 +1,17 @@
|
||||
var battle = require("battle")
|
||||
|
||||
var roleGuard = {
|
||||
run: function(creep){
|
||||
console.log(creep, "running Guard")
|
||||
var target = battle.findEnemy(creep);
|
||||
console.log("\t", creep, "tageting:",target)
|
||||
if(target && creep.hits > creep.hitsMax - 500 /* no more attack */) {
|
||||
creep.moveTo(target);
|
||||
creep.attack(target);
|
||||
} else {
|
||||
creep.moveTo(Game.spawns.Spawn1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
module.exports = roleGuard;
|
Loading…
Reference in New Issue
Block a user