Skip to content

Commit

Permalink
tweaks to safemode, invasionDefense triggers
Browse files Browse the repository at this point in the history
  • Loading branch information
bencbartlett committed Feb 1, 2019
1 parent da466af commit 75fc1b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/Overseer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,17 @@ export class Overseer implements IOverseer {
private handleColonyInvasions(colony: Colony) {
// Defend against invasions in owned rooms
if (colony.room && colony.level >= DirectiveInvasionDefense.requiredRCL) {

// See if invasion is big enough to warrant creep defenses
let effectiveInvaderCount = _.sum(_.map(colony.room.hostiles,
invader => invader.boosts.length > 0 ? 2 : 1));
if (effectiveInvaderCount >= 3 || colony.room.dangerousPlayerHostiles.length > 0) {
let needsDefending = effectiveInvaderCount >= 3 || colony.room.dangerousPlayerHostiles.length > 0;

// Place defensive directive after hostiles have been present for a long enough time
let safetyData = colony.room.memory.safety;
let invasionIsPersistent = safetyData && safetyData.unsafeFor > 20;

if (needsDefending && invasionIsPersistent) {
DirectiveInvasionDefense.createIfNotPresent(colony.controller.pos, 'room');
}
}
Expand Down
13 changes: 12 additions & 1 deletion src/roomPlanner/BarrierPlanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,22 @@ export class BarrierPlanner {
private buildMissingRamparts(): void {
// Max buildings that can be placed each tick
let count = RoomPlanner.settings.maxSitesPerColony - this.colony.constructionSites.length;

// Build missing ramparts
let barrierPositions = [];
let barrierPositions: RoomPosition[] = [];
for (let coord of _.keys(this.memory.barrierLookup)) {
barrierPositions.push(derefCoords(coord, this.colony.name));
}

// Add critical structures to barrier lookup
let criticalStructures: Structure[] = _.compact([...this.colony.towers,
...this.colony.spawns,
this.colony.storage!,
this.colony.terminal!]);
for (let structure of criticalStructures) {
barrierPositions.push(structure.pos);
}

for (let pos of barrierPositions) {
if (count > 0 && RoomPlanner.canBuild(STRUCTURE_RAMPART, pos) && this.barrierShouldBeHere(pos)) {
let ret = pos.createConstructionSite(STRUCTURE_RAMPART);
Expand Down

0 comments on commit 75fc1b9

Please sign in to comment.