guard, and change some numbers

This commit is contained in:
Tyrel Souza 2016-06-29 13:21:09 -04:00
parent b8ada37da4
commit be4b33d728
No known key found for this signature in database
GPG Key ID: 2EECB5087209E6A5
7 changed files with 252 additions and 228 deletions

View File

@ -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
View File

@ -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
View 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;