Implemented basic Creep spawning and display option for messages.
This commit is contained in:
parent
63c68a3cf4
commit
7681a47568
@ -1,12 +1,18 @@
|
|||||||
var creepBuilds = {
|
var creepBuilds = {
|
||||||
|
|
||||||
getHarvesterSmall: function() {
|
getBuildsDict: function() {
|
||||||
return [WORK, WORK, CARRY, MOVE];
|
let harvester = [WORK, WORK, CARRY, MOVE]
|
||||||
},
|
let upgrader = [WORK, CARRY, MOVE];
|
||||||
|
let builder = [WORK, CARRY, MOVE];
|
||||||
|
|
||||||
getUpgraderSmall: function() {
|
let buildsDict = {
|
||||||
return [WORK, CARRY, MOVE];
|
harvester: harvester,
|
||||||
}
|
upgrader: upgrader,
|
||||||
|
builder: builder,
|
||||||
|
}
|
||||||
|
|
||||||
|
return buildsDict;
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = creepBuilds;
|
module.exports = creepBuilds;
|
||||||
|
@ -10,5 +10,6 @@ var creepManager = require("./manage_creeps");
|
|||||||
|
|
||||||
module.exports.loop = function () {
|
module.exports.loop = function () {
|
||||||
misc.clearMemory();
|
misc.clearMemory();
|
||||||
|
misc.displayMessage(Game.spawns.Spawn1, "test")
|
||||||
creepManager.run();
|
creepManager.run();
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ var creepManager = {
|
|||||||
|
|
||||||
run: function() {
|
run: function() {
|
||||||
if (spawnCreeps) {
|
if (spawnCreeps) {
|
||||||
for (role in creepGoalAmount) {
|
for (let role in creepGoalAmount) {
|
||||||
roleCreepsAmount = _.filter(Game.creeps, (creep) => creep.memory.role == role);
|
let roleCreepsAmount = (_.filter(Game.creeps, (creep) => creep.memory.role == role)).length;
|
||||||
if (roleCreepsAmount < creepGoalAmount[role]) {
|
if (roleCreepsAmount < creepGoalAmount[role]) {
|
||||||
spawnCreep(role, roleCreepsAmount);
|
spawnCreep(role, roleCreepsAmount);
|
||||||
}
|
}
|
||||||
@ -27,17 +27,15 @@ var creepManager = {
|
|||||||
module.exports = creepManager;
|
module.exports = creepManager;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function spawnCreep(role, existing) {
|
function spawnCreep(role, existing) {
|
||||||
let name = role + "_Spheal_" + existing;
|
let newCreepName = role + "_Spheal_" + existing;
|
||||||
|
let newCreepBuild = creepBuilds.getBuildsDict()[role];
|
||||||
|
|
||||||
|
Game.spawns.Spawn1.spawnCreep(newCreepBuild, newCreepName, { memory: { role: role } });
|
||||||
|
|
||||||
if (!Game.spawns.Spawn1.spawning) {
|
if (!Game.spawns.Spawn1.spawning) {
|
||||||
misc.displayMessage("Spawn", Game.spawns.Spawn1, "Spawning next: " + name);
|
misc.displayMessage(Game.spawns.Spawn1, "Spawning next: " + newCreepName);
|
||||||
}
|
} else {
|
||||||
else {
|
misc.displayMessage(Game.spawns.Spawn1, "Spawning Creep");
|
||||||
misc.displayMessage("Spawn", Game.spawns.Spawn1, "Spawning Creep");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
Game.spawns.Spawn1.spawnCreep(creepBuilds[buildType], newCreepName, { memory: { role: buildType } });
|
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,30 @@ var settings = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
displayMessage: function(object, msgString) {
|
||||||
|
if (object instanceof Spawn) {
|
||||||
|
object.room.visual.text(
|
||||||
|
msgString,
|
||||||
|
object.pos.x,
|
||||||
|
object.pos.y+1,
|
||||||
|
{
|
||||||
|
align: 'center',
|
||||||
|
opacity: 0.9,
|
||||||
|
backgroundPadding: 0.2,
|
||||||
|
backgroundColor: "#222222",
|
||||||
|
color: "#eeeeee"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (object instanceof Creep) {
|
||||||
|
object.say(msgString);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("ERROR: displayMessage(" + object + ", " + msgString + ") failed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = settings;
|
module.exports = settings;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
var settings = {
|
var settings = {
|
||||||
|
|
||||||
getCreepGoalAmount: function() {
|
getCreepGoalAmount: function() {
|
||||||
var getCreepAmountGoalDict = {
|
var getCreepGoalAmountDict = {
|
||||||
harvester: 1,
|
harvester: 1,
|
||||||
upgrader: 1,
|
upgrader: 0,
|
||||||
builder: 1
|
builder: 0
|
||||||
}
|
}
|
||||||
return getCreepAmountGoalDict;
|
return getCreepGoalAmountDict;
|
||||||
},
|
},
|
||||||
|
|
||||||
getSpawnCreeps: function() {
|
getSpawnCreeps: function() {
|
||||||
|
Loading…
Reference in New Issue
Block a user