Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/modules/room/spawn/CreepRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand All @@ -432,7 +433,7 @@ export default class RoomCreepReleaseController {
role: "attacker",
data: {
targetFlagName: targetFlagName || DEFAULT_FLAG_NAME.ATTACK,
keepSpawn: false,
keepSpawn,
wayPoint
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/modules/room/spawn/nameGetter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
}
11 changes: 6 additions & 5 deletions src/mount/CreepExtension/CreepExtension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
// 获取曾经工地的位置
Expand All @@ -217,7 +216,6 @@ export class CreepExtension extends Creep {
// 同时发布刷墙任务
this.room.work.updateTask({ type: "fillWall", priority: 0 });
}

delete this.memory.constructionSiteId;
}
}
Expand Down Expand Up @@ -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;
Expand Down