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
|
// usernames are all lowercase, we compare with to lower
|
||||||
var USERNAME_WHITELIST = ['chrisinajar', 'ho0ber', 'fractaloop', 'n7-anthony', 'overra', 'tyrel', 'fervens'];
|
var USERNAME_WHITELIST = ['chrisinajar', 'ho0ber', 'fractaloop', 'n7-anthony', 'overra', 'tyrel', 'fervens'];
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findEnemy: findEnemy,
|
findEnemy: findEnemy,
|
||||||
run: run
|
run: run
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
var target = findEnemy(creep);
|
var target = findEnemy(creep);
|
||||||
*/
|
*/
|
||||||
@ -20,7 +20,7 @@ function findEnemy (creep) {
|
|||||||
}
|
}
|
||||||
return creep.pos.findClosestByPath(targets);
|
return creep.pos.findClosestByPath(targets);
|
||||||
}
|
}
|
||||||
|
|
||||||
function run (creep) {
|
function run (creep) {
|
||||||
var target = findEnemy(creep);
|
var target = findEnemy(creep);
|
||||||
if (!target) {
|
if (!target) {
|
||||||
@ -38,7 +38,7 @@ function run (creep) {
|
|||||||
creep.attack(target);
|
creep.attack(target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function findWall (creep) {
|
function findWall (creep) {
|
||||||
var targets = creep.room.find(FIND_STRUCTURES, {
|
var targets = creep.room.find(FIND_STRUCTURES, {
|
||||||
filter: function(object) {
|
filter: function(object) {
|
||||||
|
21
main.js
21
main.js
@ -1,24 +1,30 @@
|
|||||||
var roleHarvester = require('role.harvester');
|
var roleHarvester = require('role.harvester');
|
||||||
var roleUpgrader = require('role.upgrader');
|
var roleUpgrader = require('role.upgrader');
|
||||||
var roleBuilder = require('role.builder');
|
var roleBuilder = require('role.builder');
|
||||||
|
var roleGuard = require('role.guard');
|
||||||
var helpers = require('helpers');
|
var helpers = require('helpers');
|
||||||
|
|
||||||
var creepRolePriority = ['harvester', 'builder', 'upgrader'];
|
var creepRolePriority = ['harvester', 'builder', 'upgrader', 'guard'];
|
||||||
var creepsConfig = {
|
var creepsConfig = {
|
||||||
harvester: {
|
harvester: {
|
||||||
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
bodyParts: [WORK, CARRY, MOVE, MOVE, MOVE],
|
||||||
minimumCreeps: 6,
|
minimumCreeps: 2,
|
||||||
role: roleHarvester
|
role: roleHarvester
|
||||||
},
|
},
|
||||||
builder: {
|
builder: {
|
||||||
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
||||||
minimumCreeps: 1,
|
minimumCreeps: 0,
|
||||||
role: roleBuilder
|
role: roleBuilder
|
||||||
},
|
},
|
||||||
upgrader: {
|
upgrader: {
|
||||||
bodyParts: [WORK, CARRY, MOVE, MOVE],
|
bodyParts: [WORK, CARRY, MOVE, MOVE, MOVE],
|
||||||
minimumCreeps: 1,
|
minimumCreeps: 3,
|
||||||
role: roleUpgrader
|
role: roleUpgrader
|
||||||
|
},
|
||||||
|
guard: {
|
||||||
|
bodyParts: [TOUGH, MOVE, ATTACK, MOVE, ATTACK],
|
||||||
|
minimumCreeps: 2,
|
||||||
|
role: roleGuard
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -56,7 +62,8 @@ module.exports.loop = function(){
|
|||||||
var roleCounts = {
|
var roleCounts = {
|
||||||
builder: 0,
|
builder: 0,
|
||||||
harvester: 0,
|
harvester: 0,
|
||||||
upgrader: 0
|
upgrader: 0,
|
||||||
|
guard: 0
|
||||||
}
|
}
|
||||||
for (var name in Game.creeps){
|
for (var name in Game.creeps){
|
||||||
var creep = Game.creeps[name];
|
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