diff --git a/src/modules/room/spawn/CreepRelease.ts b/src/modules/room/spawn/CreepRelease.ts index 40dcd954..26d001a8 100644 --- a/src/modules/room/spawn/CreepRelease.ts +++ b/src/modules/room/spawn/CreepRelease.ts @@ -421,9 +421,10 @@ export default class RoomCreepReleaseController { * * @param targetFlagName 进攻旗帜名称 * @param num 要孵化的数量 + * @param keepSpawn 是否持续生成 * @param wayPoint 路径点 */ - public attacker(targetFlagName = "", num = 1, wayPoint?: WayPoint): string { + public attacker(targetFlagName = "", num = 1, keepSpawn = false, wayPoint?: WayPoint): string { if (num <= 0 || num > 10) num = 1; for (let i = 0; i < num; i++) { @@ -432,7 +433,7 @@ export default class RoomCreepReleaseController { role: "attacker", data: { targetFlagName: targetFlagName || DEFAULT_FLAG_NAME.ATTACK, - keepSpawn: false, + keepSpawn, wayPoint } }); diff --git a/src/modules/room/spawn/nameGetter.ts b/src/modules/room/spawn/nameGetter.ts index 9114cf0b..b31af0d6 100644 --- a/src/modules/room/spawn/nameGetter.ts +++ b/src/modules/room/spawn/nameGetter.ts @@ -28,5 +28,5 @@ export class GetName { public static boostDismantler = (roomName: string): string => `${roomName} dismantler ${Game.time}`; public static boostRangedAttacker = (roomName: string): string => `${roomName} boostRangedAttacker ${Game.time}`; public static defender = (roomName: string): string => `${roomName} defender`; - public static scout = (roomName: string, index: number): string => `${roomName} scout ${Game.time}-${index}`; + public static scout = (roomName: string, index: number): string => `${roomName} scout ${index}`; } diff --git a/src/mount/CreepExtension/CreepExtension.ts b/src/mount/CreepExtension/CreepExtension.ts index d40189f3..13c6a3b6 100644 --- a/src/mount/CreepExtension/CreepExtension.ts +++ b/src/mount/CreepExtension/CreepExtension.ts @@ -186,15 +186,14 @@ export class CreepExtension extends Creep { private getBuildTarget(target?: ConstructionSite): ConstructionSite { // 指定了目标,直接用,并且把 id 备份一下 if (target) { - this.memory.constructionSiteId = target.id; - this.memory.constructionSitePos = [target.pos.x, target.pos.y]; - this.memory.constructionSiteType = target.structureType; return target; } // 没有指定目标,或者指定的目标消失了,从本地内存查找 else { const selfKeepTarget = Game.getObjectById(this.memory.constructionSiteId); - if (selfKeepTarget) return selfKeepTarget; + if (selfKeepTarget) { + return selfKeepTarget; + } // 本地内存里保存的 id 找不到工地了,检查下是不是造好了 else if (this.memory.constructionSitePos) { // 获取曾经工地的位置 @@ -217,7 +216,6 @@ export class CreepExtension extends Creep { // 同时发布刷墙任务 this.room.work.updateTask({ type: "fillWall", priority: 0 }); } - delete this.memory.constructionSiteId; } } @@ -255,6 +253,9 @@ export class CreepExtension extends Creep { const target = this.getBuildTarget(targetConstruction); if (!target) return ERR_NOT_FOUND; + this.memory.constructionSiteId = target.id; + this.memory.constructionSitePos = [target.pos.x, target.pos.y]; + this.memory.constructionSiteType = target.structureType; // 上面发现有墙要刷了,这个 tick 就不再造建造了 // 防止出现造好一个 rampart,然后直接造下一个 rampart,造好后又扭头去刷第一个 rampart 的小问题出现 if (this.memory.fillWallId) return ERR_BUSY;