Gabriel Genois 9 months ago
parent
commit
51e3b2442a
  1. 12
      cUtility.js
  2. 4
      creepBasic.js
  3. 1
      creepBuilder.js
  4. 4
      main.js

12
cUtility.js

@ -32,7 +32,7 @@ var cUtility = {
let iRs = null;
let iSs = null;
if (c.memory.savedSpot = undefined || c.memory.savedSpot == null) {
if (c.memory.savedSpot == undefined || c.memory.savedSpot == null) {
for (iR in r.rSources) {
let oSource = Game.getObjectById(r.rSources[iR].id);
@ -41,11 +41,14 @@ var cUtility = {
for (iS in r.rSources[iR].rSpot) {
if (r.rSources[iR].rSpot[iS].takenBy != null) {
let creep = Game.getObjectById(r.rSources[iR].rSpot[iS].takenBy);
iAllReadyReserved = iAllReadyReserved + creep.store.getFreeCapacity();
if (creep != null) {
iAllReadyReserved = iAllReadyReserved + creep.store.getFreeCapacity();
}
}
}
if ((oSource.energy - iAllReadyReserved) >= c.store.getFreeCapacity()) {
if ((oSource.energy - iAllReadyReserved) >= c.store.getFreeCapacity()) {
for (iS in r.rSources[iR].rSpot) {
if (r.rSources[iR].rSpot[iS].takenBy == null) {
let DestPos = new RoomPosition(
@ -96,8 +99,7 @@ var cUtility = {
findEnergy(Engine, c) {
if (cUtility.isAvailableSpot && (c.memory.savedSpot == null || c.memory.savedSpot == undefined)) {
if (cUtility.isAvailableSpot(Engine, c) && (c.memory.savedSpot == null || c.memory.savedSpot == undefined)) {
cUtility.getMeASpot(Engine, c);
} else {
// No spot available or already

4
creepBasic.js

@ -44,12 +44,12 @@ var creepBasic = {
filter: (structure) => {
return (
structure.structureType == STRUCTURE_TOWER &&
structure.store.getFreeCapacity(RESOURCE_ENERGY) > c.store.getCapacity()
structure.store.getFreeCapacity(RESOURCE_ENERGY) > c.store.getCapacity(RESOURCE_ENERGY)
);
}
});
if (oTarget) {
oAction = c.transfer(oTarget, RESOURCE_ENERGY);
if (oAction == ERR_NOT_IN_RANGE) {
c.moveTo(oTarget);

1
creepBuilder.js

@ -36,6 +36,7 @@ var creepBuilder = {
switch (c.memory.mode) {
case 0:
Engine.m['cUtility'].findEnergy(Engine, c);
break ;
case 1:

4
main.js

@ -14,7 +14,7 @@ var Engine = {
try {
fnc(Engine, creep);
} catch (e) {
console.log("chook| " + m + " | " + e);
console.log("chook| " + m + " | " + e + " " + e.lineNumber);
}
}
}
@ -30,7 +30,7 @@ var Engine = {
let fnc = Engine.m[m].rHook;
fnc(Engine, Memory.engine.rooms[r]);
} catch (e) {
console.log("rHook| " + m + " | " + e);
console.log("rHook| " + m + " | " + e + " " + e.lineNumber);
}
}
}

Loading…
Cancel
Save