@myclaw163/clawclaw-cli 0.8.5 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/docs/configuration.md +2 -1
- package/docs/custom-modules/behavior.md +7 -18
- package/docs/custom-modules/trigger.md +3 -4
- package/docs/runtime/short-commands-and-capabilities.md +1 -1
- package/package.json +9 -3
- package/scripts/find-hide-spots.py +2 -2
- package/skills/clawclaw/SKILL.md +17 -13
- package/skills/clawclaw/references/BEHAVIORS.md +13 -9
- package/skills/clawclaw/references/COMMANDS.md +17 -29
- package/skills/clawclaw/references/TACTICS.md +1 -1
- package/src/commands/load.ts +245 -14
- package/src/commands/trigger.ts +22 -13
- package/src/lib/capability-load-diagnostics.ts +182 -0
- package/src/lib/gameplay-config.ts +10 -0
- package/src/lib/hub-reminder.ts +3 -5
- package/src/lib/trigger-config.ts +2 -10
- package/src/runtime/clawclaw/behavior-read-api.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/astar-path.ts +1 -1
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/escape-planner.ts +1 -1
- package/src/{strategies → runtime/clawclaw/navigation}/hide-spots.ts +2 -2
- package/src/{strategies → runtime/clawclaw/navigation}/off-route-points.ts +6 -3
- package/src/{strategies/pathfind → runtime/clawclaw/navigation}/walkable-grid.ts +1 -1
- package/src/runtime/clawclaw/owner.ts +4 -6
- package/src/runtime/clawclaw/plugins/game-query/game-query-plugin.ts +1 -1
- package/src/runtime/framework/modules/runtime-module-loader.ts +0 -54
- package/src/sdk/behavior-toolkit/escape.ts +2 -2
- package/scripts/build-official-hub-behaviors.mjs +0 -136
- package/scripts/build-official-hub-behaviors.test.mjs +0 -178
- package/scripts/compare-perception-replays.test.ts +0 -188
- package/scripts/enable_ccl_permissions.test.mjs +0 -167
- package/scripts/enable_monitor.test.mjs +0 -201
- package/scripts/sync-bundled-skill.test.mjs +0 -87
- package/scripts/watch-perception-events.test.ts +0 -43
- package/src/behaviors/official-finite/do-task.ts +0 -211
- package/src/behaviors/official-finite/evade.ts +0 -78
- package/src/behaviors/official-finite/find-player.ts +0 -50
- package/src/behaviors/official-finite/follow-player.ts +0 -70
- package/src/behaviors/official-finite/go-to.ts +0 -69
- package/src/behaviors/official-finite/hide-temporarily.ts +0 -77
- package/src/behaviors/official-finite/hold-position.ts +0 -48
- package/src/behaviors/official-finite/hunt-player.ts +0 -47
- package/src/behaviors/official-finite/index.ts +0 -44
- package/src/behaviors/official-finite/inspect-corpse.ts +0 -64
- package/src/behaviors/official-finite/patrol-area.ts +0 -80
- package/src/behaviors/official-finite/report-corpse.ts +0 -73
- package/src/behaviors/official-finite/seek-kill-opportunity.ts +0 -152
- package/src/behaviors/official-finite/shared.ts +0 -27
- package/src/hub-official-behaviors/kill-lone.ts +0 -138
- package/src/hub-official-behaviors/patrol.ts +0 -30
- package/src/hub-official-behaviors/shared.ts +0 -125
- package/src/hub-official-behaviors/task-only.ts +0 -158
- package/src/runtime/clawclaw/plugins/behavior/official-goal-behavior.ts +0 -757
- package/src/strategies/avoid-lone.ts +0 -32
- package/src/strategies/avoid-players.ts +0 -43
- package/src/strategies/corpse-patrol.ts +0 -50
- package/src/strategies/crab-sabotage.ts +0 -48
- package/src/strategies/find-player.ts +0 -49
- package/src/strategies/game-utils.ts +0 -927
- package/src/strategies/goals/anchor-linger.ts +0 -77
- package/src/strategies/goals/avoid-lone-top.ts +0 -189
- package/src/strategies/goals/avoid-players-top.ts +0 -122
- package/src/strategies/goals/conversation-goal.ts +0 -51
- package/src/strategies/goals/corpse-patrol-top.ts +0 -120
- package/src/strategies/goals/crab-octopus-reflexes.ts +0 -109
- package/src/strategies/goals/crab-sabotage-top.ts +0 -139
- package/src/strategies/goals/emergency-hunt-goal.ts +0 -40
- package/src/strategies/goals/find-player-top.ts +0 -136
- package/src/strategies/goals/flee-players-goal.ts +0 -55
- package/src/strategies/goals/follow-companion-goal.ts +0 -130
- package/src/strategies/goals/goal-manager.ts +0 -41
- package/src/strategies/goals/goal-root-strategy.ts +0 -49
- package/src/strategies/goals/goal.ts +0 -28
- package/src/strategies/goals/hide-top.ts +0 -240
- package/src/strategies/goals/keep-away-goal.ts +0 -243
- package/src/strategies/goals/kill-frenzy-top.ts +0 -90
- package/src/strategies/goals/kill-lone-top.ts +0 -166
- package/src/strategies/goals/kill-target-goal.ts +0 -69
- package/src/strategies/goals/kill-target-top.ts +0 -121
- package/src/strategies/goals/leaf-goal.ts +0 -27
- package/src/strategies/goals/linger-corpse-goal.ts +0 -43
- package/src/strategies/goals/lone-kill-core.ts +0 -86
- package/src/strategies/goals/lone-kill-goal.ts +0 -24
- package/src/strategies/goals/lone-kill-task-top.ts +0 -133
- package/src/strategies/goals/move-room-goal.ts +0 -102
- package/src/strategies/goals/normal-shrimp-top.ts +0 -248
- package/src/strategies/goals/paradise-fish-top.ts +0 -234
- package/src/strategies/goals/patrol-top.ts +0 -68
- package/src/strategies/goals/report-patrol-top.ts +0 -97
- package/src/strategies/goals/safe-task-goal.ts +0 -130
- package/src/strategies/goals/social-task-top.ts +0 -192
- package/src/strategies/goals/task-kill-report-top.ts +0 -187
- package/src/strategies/goals/task-only-top.ts +0 -64
- package/src/strategies/goals/task-or-patrol-goal.ts +0 -59
- package/src/strategies/goals/task-report-top.ts +0 -57
- package/src/strategies/goals/wander-task-goal.ts +0 -33
- package/src/strategies/goals/warrior-shrimp-top.ts +0 -293
- package/src/strategies/greeting.ts +0 -60
- package/src/strategies/hide.ts +0 -51
- package/src/strategies/kill-frenzy.ts +0 -32
- package/src/strategies/kill-lone.ts +0 -52
- package/src/strategies/kill-target.ts +0 -48
- package/src/strategies/lone-kill-task.ts +0 -48
- package/src/strategies/meeting-gate.ts +0 -28
- package/src/strategies/move-room.ts +0 -46
- package/src/strategies/paradise-fish.ts +0 -70
- package/src/strategies/patrol.ts +0 -32
- package/src/strategies/player-targets.ts +0 -18
- package/src/strategies/report-patrol.ts +0 -32
- package/src/strategies/shrimp-memory.ts +0 -87
- package/src/strategies/social-task.ts +0 -67
- package/src/strategies/speech-module.ts +0 -123
- package/src/strategies/task-kill-report.ts +0 -49
- package/src/strategies/task-only.ts +0 -34
- package/src/strategies/task-report.ts +0 -50
- package/src/strategies/types.ts +0 -116
- package/src/strategies/warrior-memory.ts +0 -54
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/clawclaw-walkable.bin +0 -0
- /package/src/{strategies/pathfind → runtime/clawclaw/navigation}/distance-field.ts +0 -0
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
isInRoom,
|
|
5
|
-
patrolStrategyIntent,
|
|
6
|
-
PROGRESS_INTERVAL_MS,
|
|
7
|
-
resolveRoom,
|
|
8
|
-
setStrategyIntent,
|
|
9
|
-
strategyDecision,
|
|
10
|
-
} from '../game-utils.js';
|
|
11
|
-
import type { BehaviorDecision, RoomTarget, StrategyContext } from '../types.js';
|
|
12
|
-
import { Goal } from './goal.js';
|
|
13
|
-
|
|
14
|
-
export type RoomArrival = (state: GameState, target: RoomTarget) => boolean;
|
|
15
|
-
|
|
16
|
-
const arrivedByRoomName: RoomArrival = (state, target) => isInRoom(target.name, state);
|
|
17
|
-
|
|
18
|
-
export interface MoveRoomGoalOptions {
|
|
19
|
-
emitProgress?: boolean;
|
|
20
|
-
stopOnPlayer?: boolean;
|
|
21
|
-
/** Human-readable purpose such as "巡逻" or "巡逻寻找人群". */
|
|
22
|
-
purpose?: string;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class MoveRoomGoal extends Goal {
|
|
26
|
-
constructor(
|
|
27
|
-
public readonly room: string,
|
|
28
|
-
private readonly hasArrived: RoomArrival = arrivedByRoomName,
|
|
29
|
-
private readonly options: MoveRoomGoalOptions = {},
|
|
30
|
-
) {
|
|
31
|
-
super();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
35
|
-
const target = resolveRoom(this.room, ctx);
|
|
36
|
-
this.emitProgress(state, ctx, target);
|
|
37
|
-
if (!target) {
|
|
38
|
-
setStrategyIntent(ctx, {
|
|
39
|
-
activity: 'waiting',
|
|
40
|
-
summary: `暂时找不到目标房间“${this.room}”,正在${state.you.room || '当前位置'}等待地图信息。`,
|
|
41
|
-
...(state.you.room ? { room: state.you.room } : {}),
|
|
42
|
-
});
|
|
43
|
-
return [];
|
|
44
|
-
}
|
|
45
|
-
if (this.hasArrived(state, target)) {
|
|
46
|
-
setStrategyIntent(ctx, {
|
|
47
|
-
activity: 'idle',
|
|
48
|
-
summary: `已到达${target.name},等待下一步指令。`,
|
|
49
|
-
room: target.name,
|
|
50
|
-
});
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
const intent = this.options.purpose
|
|
54
|
-
? patrolStrategyIntent(target, this.options.purpose)
|
|
55
|
-
: {
|
|
56
|
-
activity: 'moving' as const,
|
|
57
|
-
summary: `正在前往${target.name}。`,
|
|
58
|
-
room: target.name,
|
|
59
|
-
};
|
|
60
|
-
setStrategyIntent(ctx, intent);
|
|
61
|
-
return [strategyDecision(
|
|
62
|
-
Action.move({ x: target.x, y: target.y }, this.options.stopOnPlayer ?? false),
|
|
63
|
-
intent,
|
|
64
|
-
)];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
isFinish(state: GameState, ctx: StrategyContext): boolean {
|
|
68
|
-
const target = resolveRoom(this.room, ctx);
|
|
69
|
-
if (target == null) return false;
|
|
70
|
-
const finished = this.hasArrived(state, target);
|
|
71
|
-
if (finished) {
|
|
72
|
-
this.emitProgress(state, ctx, target);
|
|
73
|
-
setStrategyIntent(ctx, {
|
|
74
|
-
activity: 'idle',
|
|
75
|
-
summary: `已到达${target.name},等待下一步指令。`,
|
|
76
|
-
room: target.name,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return finished;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private emitProgress(state: GameState, ctx: StrategyContext, target: RoomTarget | null): void {
|
|
83
|
-
if (this.options.emitProgress === false) return;
|
|
84
|
-
|
|
85
|
-
const now = Date.now();
|
|
86
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
87
|
-
ctx.lastProgressNotifyAt = now;
|
|
88
|
-
|
|
89
|
-
const room = state.you.room ?? '未知房间';
|
|
90
|
-
if (!target) {
|
|
91
|
-
const available = ctx.rooms.map(room => room.name).join(', ') || '地图尚未加载';
|
|
92
|
-
ctx.notifications.push(`[进度] 当前在${room},找不到目标房间「${this.room}」。可用房间: ${available}。`);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (state.you.room === target.name) {
|
|
97
|
-
ctx.notifications.push(`[进度] 已到达目标房间「${target.name}」,当前位置${room}。`);
|
|
98
|
-
} else {
|
|
99
|
-
ctx.notifications.push(`[进度] 当前在${room},正在前往目标房间「${target.name}」。`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import {
|
|
3
|
-
corpseAtScene,
|
|
4
|
-
dist,
|
|
5
|
-
firstAvailableTask,
|
|
6
|
-
hasKnownCorpse,
|
|
7
|
-
matchesAnyTarget,
|
|
8
|
-
nonTeammatesVisible,
|
|
9
|
-
PROGRESS_INTERVAL_MS,
|
|
10
|
-
reportCorpseDecision,
|
|
11
|
-
SHRIMP_VISION_RANGE,
|
|
12
|
-
SHRIMP_VISION_RELEASE_RANGE,
|
|
13
|
-
taskMoveDecision,
|
|
14
|
-
} from '../game-utils.js';
|
|
15
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
16
|
-
import { GreetingTracker } from '../greeting.js';
|
|
17
|
-
import { Goal } from './goal.js';
|
|
18
|
-
import { KeepAwayGoal, type KeepAwayGoalOptions, type ThreatResolver } from './keep-away-goal.js';
|
|
19
|
-
import { SafeTaskOrPatrolGoal } from './safe-task-goal.js';
|
|
20
|
-
|
|
21
|
-
const SUB_PRIORITY = 0.5;
|
|
22
|
-
/** 陌生人贴近到这个距离才触发拉开(B 档入口)。 */
|
|
23
|
-
const STRANGER_TRIGGER_RADIUS = SHRIMP_VISION_RANGE;
|
|
24
|
-
/** B 档 KeepAwayGoal 的交战兼结束半径:270 进 / 300 出,天然滞回。 */
|
|
25
|
-
const STRANGER_RELEASE_RADIUS = SHRIMP_VISION_RELEASE_RANGE;
|
|
26
|
-
/** 目击者记忆 TTL;0 表示只按当前轮可见玩家判断。 */
|
|
27
|
-
const WITNESS_MEMORY_MS = 0;
|
|
28
|
-
/** 近期见过这么多个陌生人即豁免 B 档——蟹不敢当众动手,独处单个陌生人才危险。 */
|
|
29
|
-
const WITNESS_EXEMPT_COUNT = 2;
|
|
30
|
-
const TASK_RETURN_INERTIA_MS = 2_000;
|
|
31
|
-
const FLEE_BAD_KEY = 'shrimp-flee-bad';
|
|
32
|
-
const STRANGER_KEY = 'shrimp-stranger-distance';
|
|
33
|
-
|
|
34
|
-
type Tier = 'flee-bad' | 'keep-distance' | 'task';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* 普通虾·记忆进阶版(好人、不带刀)的核心 Goal,按行为表逐条判断,命中即执行:
|
|
38
|
-
*
|
|
39
|
-
* - P0 发现尸体:一律报警(reportCorpseDecision),并按参数名单描述尸体旁玩家。
|
|
40
|
-
* - P1 规避危险:
|
|
41
|
-
* · A 视野里有 hostileTargets 指定的危险玩家 → 寻路躲避(KeepAwayGoal,不限距离)。
|
|
42
|
-
* · B 无 trustedTargets 同伴且其他玩家贴近(≤270px)→ 先拉开距离(KeepAwayGoal,拉开到 300px 即回任务)。
|
|
43
|
-
* 目击者豁免:当前见到 ≥2 个陌生人时不触发后撤(蟹不敢当众动手,独处才危险);
|
|
44
|
-
* 进行中的后撤也会重新判定,只有仍是单陌生人危险时才拉满到 300px。豁免期间陌生人也不算任务威胁点。
|
|
45
|
-
* - P2 紧急任务:无危险时优先处理。
|
|
46
|
-
* - P3 否则做任务 / 巡逻(SafeTaskOrPatrolGoal:测地最近、威胁旁/途经威胁的任务硬排除、带粘性)。
|
|
47
|
-
*
|
|
48
|
-
* 「认定坏人」「可信同伴」「天堂鱼」全部来自策略参数名单。
|
|
49
|
-
* 队友由游戏事实判定(nonTeammatesVisible)。有可信同伴在场时不对陌生人触发 B 档。
|
|
50
|
-
*/
|
|
51
|
-
export class NormalShrimpTop extends Goal {
|
|
52
|
-
private readonly taskGoal = new SafeTaskOrPatrolGoal(
|
|
53
|
-
// 豁免期间陌生人不算威胁点(与 B 档不触发保持视野半径对齐),认定坏人始终算。
|
|
54
|
-
(s, c) => nonTeammatesVisible(s, c)
|
|
55
|
-
.filter(p => !this.isTrusted(p, c))
|
|
56
|
-
.filter(p => this.isHostile(p, c) || !this.witnessExempt)
|
|
57
|
-
.map(p => ({ x: p.x, y: p.y })),
|
|
58
|
-
);
|
|
59
|
-
private readonly strangerSeenAt = new Map<string, number>();
|
|
60
|
-
private witnessExempt = false;
|
|
61
|
-
private readonly corpseWitnessNotified = new Set<string>();
|
|
62
|
-
private readonly greeting: GreetingTracker;
|
|
63
|
-
|
|
64
|
-
constructor(
|
|
65
|
-
greetingPhrases: string[] = [],
|
|
66
|
-
private readonly hostileTargets: number[] = [],
|
|
67
|
-
private readonly trustedTargets: number[] = [],
|
|
68
|
-
private readonly paradiseFishTargets: number[] = [],
|
|
69
|
-
) {
|
|
70
|
-
super();
|
|
71
|
-
this.greeting = new GreetingTracker(greetingPhrases);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
75
|
-
const visible = nonTeammatesVisible(state, ctx);
|
|
76
|
-
this.updateWitnessMemory(visible, ctx);
|
|
77
|
-
const decisions: BehaviorDecision[] = [];
|
|
78
|
-
const greeting = this.greeting.tryGreeting(state);
|
|
79
|
-
if (greeting) decisions.push(greeting);
|
|
80
|
-
|
|
81
|
-
// ── P0 发现尸体 → 报警 ──
|
|
82
|
-
// 章鱼时间服务端禁用报尸,reportCorpseDecision 本就会返回 null;此处把整块 P0 一并跳过,否则
|
|
83
|
-
// notifyCorpseWitnesses 仍会推「尸体旁发现…,直接报警」这类提示,误导 Agent 以为仍应报尸召集会议。
|
|
84
|
-
// 跳过后落到后续 P1 躲避 / P3 任务巡逻的生存分支,同时清掉之前“靠近尸体准备报告”的残留状态。
|
|
85
|
-
if (ctx.octopusTimeActive) {
|
|
86
|
-
ctx.reportCorpseTarget = null;
|
|
87
|
-
this.corpseWitnessNotified.clear();
|
|
88
|
-
} else if (hasKnownCorpse(ctx)) {
|
|
89
|
-
// 「尸体旁目击者」只在此刻确实站在命案现场(当帧视野有尸体)时才标注——否则会把后来路上
|
|
90
|
-
// 遇见的人误报成目击者。报尸本身可以追着记忆里已离开视野的尸体走回去。
|
|
91
|
-
if (corpseAtScene(state)) this.notifyCorpseWitnesses(visible, ctx);
|
|
92
|
-
else this.corpseWitnessNotified.clear();
|
|
93
|
-
const report = reportCorpseDecision(state, ctx, { respectBlock: true });
|
|
94
|
-
if (report) {
|
|
95
|
-
this.clearSub();
|
|
96
|
-
return [report, ...decisions];
|
|
97
|
-
}
|
|
98
|
-
// 报告短暂受阻时继续执行后续分支,避免在尸体旁空站。
|
|
99
|
-
} else {
|
|
100
|
-
this.corpseWitnessNotified.clear();
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// ── P1-A 视野里有认定坏人 → 寻路躲避 ──
|
|
104
|
-
const threats = visible.filter(p => this.isHostile(p, ctx));
|
|
105
|
-
if (threats.length > 0) {
|
|
106
|
-
this.taskGoal.planTask(state, ctx, { holdUnsafeCurrentForMs: TASK_RETURN_INERTIA_MS });
|
|
107
|
-
this.setKeepAway(FLEE_BAD_KEY, (s, c) => nonTeammatesVisible(s, c).filter(p => this.isHostile(p, c)), {
|
|
108
|
-
threatRadius: Infinity,
|
|
109
|
-
noun: '认定坏人',
|
|
110
|
-
});
|
|
111
|
-
this.emitProgress(state, ctx, visible, 'flee-bad');
|
|
112
|
-
return decisions;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// ── P1-B 无可信同伴且陌生人贴近 → 拉开距离再做任务 ──
|
|
116
|
-
const trustedVisible = visible.some(p => this.isTrusted(p, ctx));
|
|
117
|
-
if (!trustedVisible) {
|
|
118
|
-
const you = state.you;
|
|
119
|
-
const strangerClose = visible.some(p =>
|
|
120
|
-
!this.isTrusted(p, ctx) && (p.distance ?? dist(p.x, p.y, you.x, you.y)) <= STRANGER_TRIGGER_RADIUS);
|
|
121
|
-
const worker = this.subGoal;
|
|
122
|
-
const stillBackingOff = worker instanceof KeepAwayGoal && worker.key === STRANGER_KEY && !worker.isFinish(state, ctx);
|
|
123
|
-
// 第二个陌生人加入时重新判定,豁免生效后不继续旧的后撤。
|
|
124
|
-
if (!this.witnessExempt && (strangerClose || stillBackingOff)) {
|
|
125
|
-
this.taskGoal.planTask(state, ctx, { holdUnsafeCurrentForMs: TASK_RETURN_INERTIA_MS });
|
|
126
|
-
this.setKeepAway(STRANGER_KEY, (s, c) => nonTeammatesVisible(s, c).filter(p => !this.isTrusted(p, c)), {
|
|
127
|
-
threatRadius: STRANGER_RELEASE_RADIUS,
|
|
128
|
-
noun: '陌生人',
|
|
129
|
-
planOpts: { steps: 4 },
|
|
130
|
-
});
|
|
131
|
-
this.emitProgress(state, ctx, visible, 'keep-distance');
|
|
132
|
-
return decisions;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// ── P2 紧急任务 ──
|
|
137
|
-
const emergency = firstAvailableTask([], t => t.faction !== 'crab', ctx.emergency, ctx.blockedMoveTarget);
|
|
138
|
-
if (emergency) {
|
|
139
|
-
this.clearSub();
|
|
140
|
-
return [taskMoveDecision(state, ctx, emergency), ...decisions];
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// ── P3 兜底 → 做任务 / 巡逻 ──
|
|
144
|
-
this.clearSub();
|
|
145
|
-
const work = this.taskGoal.tick(state, ctx);
|
|
146
|
-
this.emitProgress(state, ctx, visible, 'task');
|
|
147
|
-
return [...work, ...decisions];
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* 目击者豁免:用 TTL 记忆平滑陌生人计数;当前设为 0,只看本轮可见玩家。
|
|
152
|
-
*/
|
|
153
|
-
private updateWitnessMemory(visible: PlayerInfo[], ctx: StrategyContext): void {
|
|
154
|
-
const now = Date.now();
|
|
155
|
-
for (const p of visible) {
|
|
156
|
-
if (this.isTrusted(p, ctx)) continue;
|
|
157
|
-
const key = p.name || String(p.seat ?? '');
|
|
158
|
-
if (key) this.strangerSeenAt.set(key, now);
|
|
159
|
-
}
|
|
160
|
-
for (const [key, at] of this.strangerSeenAt) {
|
|
161
|
-
if (now - at > WITNESS_MEMORY_MS) this.strangerSeenAt.delete(key);
|
|
162
|
-
}
|
|
163
|
-
this.witnessExempt = this.strangerSeenAt.size >= WITNESS_EXEMPT_COUNT;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/** hostileTargets 中且不在 trustedTargets 中的玩家。 */
|
|
167
|
-
private isHostile(p: PlayerInfo, ctx: StrategyContext): boolean {
|
|
168
|
-
return !this.isTrusted(p, ctx) && matchesAnyTarget(p, this.hostileTargets, ctx);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/** trustedTargets 中的可信同伴;与 hostileTargets 重叠时优先。 */
|
|
172
|
-
private isTrusted(p: PlayerInfo, ctx: StrategyContext): boolean {
|
|
173
|
-
return matchesAnyTarget(p, this.trustedTargets, ctx);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
private setKeepAway(key: string, resolve: ThreatResolver, options: KeepAwayGoalOptions): void {
|
|
177
|
-
const worker = this.subGoal;
|
|
178
|
-
if (worker instanceof KeepAwayGoal && worker.key === key) return;
|
|
179
|
-
if (this.subGoal) this.removeSubGoal();
|
|
180
|
-
this.setSubGoal(new KeepAwayGoal(key, resolve, options), SUB_PRIORITY);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
private clearSub(): void {
|
|
184
|
-
if (this.subGoal) this.removeSubGoal();
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
private notifyCorpseWitnesses(visible: PlayerInfo[], ctx: StrategyContext): void {
|
|
188
|
-
const bad: string[] = [];
|
|
189
|
-
const paradise: string[] = [];
|
|
190
|
-
const unknown: string[] = [];
|
|
191
|
-
const trusted: string[] = [];
|
|
192
|
-
|
|
193
|
-
for (const player of visible) {
|
|
194
|
-
const key = player.name || String(player.seat ?? '');
|
|
195
|
-
if (!key || this.corpseWitnessNotified.has(key)) continue;
|
|
196
|
-
this.corpseWitnessNotified.add(key);
|
|
197
|
-
|
|
198
|
-
if (this.isHostile(player, ctx)) bad.push(player.name);
|
|
199
|
-
else if (this.isKnownParadiseFish(player, ctx)) paradise.push(player.name);
|
|
200
|
-
else if (this.isTrusted(player, ctx)) trusted.push(player.name);
|
|
201
|
-
else unknown.push(player.name);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
if (bad.length > 0) ctx.notifications.push(`尸体旁发现认定坏人${bad.join('、')},直接报警。`);
|
|
205
|
-
if (paradise.length > 0) ctx.notifications.push(`尸体旁发现天堂鱼${paradise.join('、')},直接报警。`);
|
|
206
|
-
if (unknown.length > 0) ctx.notifications.push(`尸体旁发现身份不明者${unknown.join('、')},直接报警;可按判断更新 hostileTargets。`);
|
|
207
|
-
if (trusted.length > 0) ctx.notifications.push(`尸体旁发现可信同伴${trusted.join('、')},仍直接报警;建议复核 trustedTargets。`);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
private isKnownParadiseFish(p: PlayerInfo, ctx: StrategyContext): boolean {
|
|
211
|
-
return matchesAnyTarget(p, this.paradiseFishTargets, ctx);
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
private emitProgress(state: GameState, ctx: StrategyContext, visible: PlayerInfo[], tier: Tier): void {
|
|
215
|
-
const now = Date.now();
|
|
216
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
217
|
-
ctx.lastProgressNotifyAt = now;
|
|
218
|
-
|
|
219
|
-
const room = state.you.room ?? '未知';
|
|
220
|
-
const completed = ctx.taskData.filter(t => t.status === 'completed').length;
|
|
221
|
-
const total = ctx.taskData.filter(t => t.faction !== 'crab').length;
|
|
222
|
-
const current = this.taskGoal.currentTask;
|
|
223
|
-
|
|
224
|
-
let msg = `[进度] 当前在${room}`;
|
|
225
|
-
if (tier === 'flee-bad') {
|
|
226
|
-
const names = visible.filter(p => this.isHostile(p, ctx)).map(p => p.name).join('、');
|
|
227
|
-
msg += `,发现认定坏人${names},正在远离。`;
|
|
228
|
-
} else if (tier === 'keep-distance') {
|
|
229
|
-
msg += `,陌生人靠得太近,先拉开距离再做任务。`;
|
|
230
|
-
} else if (visible.length === 0) {
|
|
231
|
-
msg += ',附近无人,做任务/巡逻。';
|
|
232
|
-
} else if (visible.some(p => this.isTrusted(p, ctx))) {
|
|
233
|
-
msg += `,附近有可信同伴,结伴做任务。`;
|
|
234
|
-
} else if (this.witnessExempt && visible.length >= 2) {
|
|
235
|
-
msg += `,附近${visible.length}个陌生人互为目击者,照常做任务。`;
|
|
236
|
-
} else {
|
|
237
|
-
msg += `,附近有${visible.length}人,继续做任务/巡逻。`;
|
|
238
|
-
}
|
|
239
|
-
if (current) {
|
|
240
|
-
msg += ` 当前任务目标:${current.room}「${current.task_name}」。`;
|
|
241
|
-
}
|
|
242
|
-
msg += ` 已完成 ${completed}/${total} 个任务。`;
|
|
243
|
-
if (state.emergency) {
|
|
244
|
-
msg += ` 紧急任务进行中!`;
|
|
245
|
-
}
|
|
246
|
-
ctx.notifications.push(msg);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo, Position } from '../../sdk/types.js';
|
|
2
|
-
import {
|
|
3
|
-
corpseAtScene,
|
|
4
|
-
emergencyRushDecision,
|
|
5
|
-
hasKnownCorpse,
|
|
6
|
-
matchesAnyTarget,
|
|
7
|
-
nonTeammatesVisible,
|
|
8
|
-
PatrolState,
|
|
9
|
-
PROGRESS_INTERVAL_MS,
|
|
10
|
-
safePatrolStep,
|
|
11
|
-
} from '../game-utils.js';
|
|
12
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
13
|
-
import { GreetingTracker } from '../greeting.js';
|
|
14
|
-
import { FollowCompanionGoal } from './follow-companion-goal.js';
|
|
15
|
-
import { Goal } from './goal.js';
|
|
16
|
-
import { KeepAwayGoal, type KeepAwayGoalOptions, type ThreatResolver } from './keep-away-goal.js';
|
|
17
|
-
import { LingerCorpseGoal } from './linger-corpse-goal.js';
|
|
18
|
-
|
|
19
|
-
const SUB_PRIORITY = 0.5;
|
|
20
|
-
const AVOID_ROUTE_MEMORY_MS = 10_000;
|
|
21
|
-
const WITNESS_EXEMPT_COUNT = 2;
|
|
22
|
-
|
|
23
|
-
type Tier = 'emergency' | 'corpse' | 'flee-bad' | 'keep-distance' | 'huddle' | 'wander';
|
|
24
|
-
|
|
25
|
-
export class ParadiseFishTop extends Goal {
|
|
26
|
-
private readonly linger = new LingerCorpseGoal((state, ctx) => this.visibleAvoidTargets(state, ctx));
|
|
27
|
-
private readonly follow = new FollowCompanionGoal(
|
|
28
|
-
(state, ctx) => nonTeammatesVisible(state, ctx).filter(p => this.isTrusted(p, ctx)),
|
|
29
|
-
(state, ctx) => this.visibleAvoidTargets(state, ctx),
|
|
30
|
-
);
|
|
31
|
-
private readonly patrol = new PatrolState();
|
|
32
|
-
private readonly greeting: GreetingTracker;
|
|
33
|
-
private readonly recentAvoidPoints = new Map<string, { point: Position; until: number; threat: boolean }>();
|
|
34
|
-
|
|
35
|
-
constructor(
|
|
36
|
-
greetingPhrases: string[] = [],
|
|
37
|
-
private readonly hostileTargets: number[] = [],
|
|
38
|
-
private readonly trustedTargets: number[] = [],
|
|
39
|
-
) {
|
|
40
|
-
super();
|
|
41
|
-
this.greeting = new GreetingTracker(greetingPhrases);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
45
|
-
const visible = nonTeammatesVisible(state, ctx);
|
|
46
|
-
const threatTargets = visible.filter(p => this.isHostile(p, ctx));
|
|
47
|
-
const trustedTargets = visible.filter(p => this.isTrusted(p, ctx));
|
|
48
|
-
const strangerAvoidTargets = this.strangerAvoidTargets(visible, ctx);
|
|
49
|
-
this.rememberAvoidPoints(visible, ctx, strangerAvoidTargets.length > 0);
|
|
50
|
-
|
|
51
|
-
if (threatTargets.length > 0) {
|
|
52
|
-
const decisions: BehaviorDecision[] = [];
|
|
53
|
-
const greeting = this.greeting.tryGreeting(state);
|
|
54
|
-
if (greeting) decisions.push(greeting);
|
|
55
|
-
this.setKeepAway('pf-flee-bad', (s, c) => nonTeammatesVisible(s, c).filter(p => this.isHostile(p, c)), {
|
|
56
|
-
threatRadius: Infinity,
|
|
57
|
-
noun: '认定带刀坏人',
|
|
58
|
-
});
|
|
59
|
-
this.emitProgress(state, ctx, visible, 'flee-bad');
|
|
60
|
-
return decisions;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// 服务端已确认进入任务执行态后静默等待完成:不要每 tick 重提同一紧急任务,也不要让陌生人回避、
|
|
64
|
-
// 贴尸、抱团或巡逻等普通移动打断任务。明确标记的 hostile 仍由上面的最高优先级分支触发逃离。
|
|
65
|
-
if (state.you.doing_task) {
|
|
66
|
-
this.clearSub();
|
|
67
|
-
return [];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// 残局抢修紧急任务(已知存活≤6):仅次于躲避带刀坏人,先于保持距离/贴尸/抱团。
|
|
71
|
-
const emergency = emergencyRushDecision(state, ctx);
|
|
72
|
-
if (emergency) {
|
|
73
|
-
this.clearSub();
|
|
74
|
-
this.emitProgress(state, ctx, visible, 'emergency');
|
|
75
|
-
return [emergency];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const decisions: BehaviorDecision[] = [];
|
|
79
|
-
const greeting = this.greeting.tryGreeting(state);
|
|
80
|
-
if (greeting) decisions.push(greeting);
|
|
81
|
-
|
|
82
|
-
if (strangerAvoidTargets.length > 0) {
|
|
83
|
-
this.setKeepAway('pf-keep-distance', (s, c) => this.strangerAvoidTargets(nonTeammatesVisible(s, c), c), {
|
|
84
|
-
threatRadius: Infinity,
|
|
85
|
-
noun: '陌生人',
|
|
86
|
-
planOpts: { steps: 4 },
|
|
87
|
-
});
|
|
88
|
-
this.emitProgress(state, ctx, visible, 'keep-distance');
|
|
89
|
-
return decisions;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// 贴尸游走制造嫌疑是「往尸体处移动」的导航行为(不灭口/不报警/不栽赃),与 corpse-patrol 一致用记忆
|
|
93
|
-
// 驱动:记得某处有尸体就走回去徘徊,尸体离开视野也不丢,直到开会清场(LingerCorpseGoal 内部按
|
|
94
|
-
// nearestKnownCorpseNav 导航——有坐标就贴尸 40-100 游走,只记得房间没坐标时先走向房间锚点,
|
|
95
|
-
// 人进视野后坐标自然补全,再切到贴尸游走)。
|
|
96
|
-
if (hasKnownCorpse(ctx)) {
|
|
97
|
-
this.clearSub();
|
|
98
|
-
const linger = this.linger.tick(state, ctx);
|
|
99
|
-
if (linger.length > 0) {
|
|
100
|
-
this.emitProgress(state, ctx, visible, 'corpse');
|
|
101
|
-
return [...linger, ...decisions];
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (trustedTargets.length > 0) {
|
|
106
|
-
this.clearSub();
|
|
107
|
-
const follow = this.follow.tick(state, ctx);
|
|
108
|
-
this.emitProgress(state, ctx, visible, 'huddle');
|
|
109
|
-
return [...follow, ...decisions];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
this.clearSub();
|
|
113
|
-
this.emitProgress(state, ctx, visible, 'wander');
|
|
114
|
-
return [...this.wander(state, ctx), ...decisions];
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/** hostileTargets 中且不在 trustedTargets 中的危险玩家。 */
|
|
118
|
-
private isHostile(p: PlayerInfo, ctx: StrategyContext): boolean {
|
|
119
|
-
return !this.isTrusted(p, ctx) && matchesAnyTarget(p, this.hostileTargets, ctx);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private isTrusted(p: PlayerInfo, ctx: StrategyContext): boolean {
|
|
123
|
-
return matchesAnyTarget(p, this.trustedTargets, ctx);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
private strangerAvoidTargets(visible: PlayerInfo[], ctx: StrategyContext): PlayerInfo[] {
|
|
127
|
-
if (visible.some(p => this.isTrusted(p, ctx))) return [];
|
|
128
|
-
const nonBad = visible.filter(p => !this.isHostile(p, ctx));
|
|
129
|
-
if (nonBad.length >= WITNESS_EXEMPT_COUNT) return [];
|
|
130
|
-
return visible.filter(p => !this.isTrusted(p, ctx) && !this.isHostile(p, ctx));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
private visibleAvoidTargets(state: GameState, ctx: StrategyContext): PlayerInfo[] {
|
|
134
|
-
const visible = nonTeammatesVisible(state, ctx);
|
|
135
|
-
const threats = visible.filter(p => this.isHostile(p, ctx));
|
|
136
|
-
return threats.length > 0 ? threats : this.strangerAvoidTargets(visible, ctx);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
private wander(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
140
|
-
return safePatrolStep(state, ctx, this.patrol, false, {
|
|
141
|
-
threatPoints: this.activeAvoidPoints(),
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
private rememberAvoidPoints(visible: PlayerInfo[], ctx: StrategyContext, avoidNonThreat: boolean): void {
|
|
146
|
-
const now = Date.now();
|
|
147
|
-
if (visible.length > 0 && !avoidNonThreat) {
|
|
148
|
-
for (const [key, item] of this.recentAvoidPoints) {
|
|
149
|
-
if (!item.threat) this.recentAvoidPoints.delete(key);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
for (const p of visible) {
|
|
153
|
-
const key = this.playerKey(p);
|
|
154
|
-
if (!key) continue;
|
|
155
|
-
if (this.isTrusted(p, ctx)) {
|
|
156
|
-
this.recentAvoidPoints.delete(key);
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
const threat = this.isHostile(p, ctx);
|
|
160
|
-
if (!threat && !avoidNonThreat) {
|
|
161
|
-
this.recentAvoidPoints.delete(key);
|
|
162
|
-
continue;
|
|
163
|
-
}
|
|
164
|
-
this.recentAvoidPoints.set(key, {
|
|
165
|
-
point: { x: p.x, y: p.y },
|
|
166
|
-
until: now + AVOID_ROUTE_MEMORY_MS,
|
|
167
|
-
threat,
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
for (const [key, item] of this.recentAvoidPoints) {
|
|
171
|
-
if (item.until <= now) this.recentAvoidPoints.delete(key);
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
private activeAvoidPoints(): Position[] {
|
|
176
|
-
const now = Date.now();
|
|
177
|
-
const points: Position[] = [];
|
|
178
|
-
for (const [key, item] of this.recentAvoidPoints) {
|
|
179
|
-
if (item.until <= now) {
|
|
180
|
-
this.recentAvoidPoints.delete(key);
|
|
181
|
-
} else {
|
|
182
|
-
points.push(item.point);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return points;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
private playerKey(p: PlayerInfo): string {
|
|
189
|
-
return p.name || (p.seat != null ? String(p.seat) : `${Math.round(p.x)},${Math.round(p.y)}`);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
private setKeepAway(key: string, resolve: ThreatResolver, options: KeepAwayGoalOptions): void {
|
|
193
|
-
const worker = this.subGoal;
|
|
194
|
-
if (worker instanceof KeepAwayGoal && worker.key === key) return;
|
|
195
|
-
if (this.subGoal) this.removeSubGoal();
|
|
196
|
-
this.setSubGoal(new KeepAwayGoal(key, resolve, options), SUB_PRIORITY);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
private clearSub(): void {
|
|
200
|
-
if (this.subGoal) this.removeSubGoal();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
private emitProgress(state: GameState, ctx: StrategyContext, visible: PlayerInfo[], tier: Tier): void {
|
|
204
|
-
const now = Date.now();
|
|
205
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
206
|
-
ctx.lastProgressNotifyAt = now;
|
|
207
|
-
|
|
208
|
-
const room = state.you.room ?? '未知';
|
|
209
|
-
let msg = `[进度] 当前在${room}`;
|
|
210
|
-
if (tier === 'emergency') {
|
|
211
|
-
const name = ctx.emergency?.task_name ?? '紧急维修';
|
|
212
|
-
msg += `,残局仅剩${state.alive_count}人,抢着去做紧急任务「${name}」,阻止蟹靠破坏倒计时取胜。`;
|
|
213
|
-
} else if (tier === 'corpse') {
|
|
214
|
-
// corpseAtScene=已贴近尸体(≤150px);仅凭记忆走向尸体房间、人还没到时别谎报「在尸体附近游走」。
|
|
215
|
-
if (!corpseAtScene(state)) {
|
|
216
|
-
msg += ',记得有尸体,正前往尸体处(不报警)。';
|
|
217
|
-
} else {
|
|
218
|
-
msg += visible.length > 0
|
|
219
|
-
? ',发现尸体,远离旁人但仍在尸体附近游走(不报警)。'
|
|
220
|
-
: ',发现尸体,附近无人,贴着尸体游走制造嫌疑(不报警)。';
|
|
221
|
-
}
|
|
222
|
-
} else if (tier === 'flee-bad') {
|
|
223
|
-
const names = visible.filter(p => this.isHostile(p, ctx)).map(p => p.name).join('、');
|
|
224
|
-
msg += `,发现认定带刀坏人${names},正在远离。`;
|
|
225
|
-
} else if (tier === 'keep-distance') {
|
|
226
|
-
msg += `,附近有${visible.length}人但无可信同伴,保持距离中。`;
|
|
227
|
-
} else if (tier === 'huddle') {
|
|
228
|
-
msg += ',附近有可信同伴,抱团假装做任务。';
|
|
229
|
-
} else {
|
|
230
|
-
msg += ',附近无人,四处游荡。';
|
|
231
|
-
}
|
|
232
|
-
ctx.notifications.push(msg);
|
|
233
|
-
}
|
|
234
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import { hasReachedRoomTarget, PatrolState, PROGRESS_INTERVAL_MS, setStrategyIntent } from '../game-utils.js';
|
|
3
|
-
import type { BehaviorDecision, RoomTarget, StrategyContext } from '../types.js';
|
|
4
|
-
import { Goal } from './goal.js';
|
|
5
|
-
import { MoveRoomGoal } from './move-room-goal.js';
|
|
6
|
-
|
|
7
|
-
const PATROL_PRIORITY = 0.2;
|
|
8
|
-
|
|
9
|
-
export class PatrolTop extends Goal {
|
|
10
|
-
private readonly patrol = new PatrolState();
|
|
11
|
-
|
|
12
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
13
|
-
let room = this.patrol.nextRoom(ctx);
|
|
14
|
-
if (!room) {
|
|
15
|
-
setStrategyIntent(ctx, {
|
|
16
|
-
activity: 'waiting',
|
|
17
|
-
summary: `暂时没有可巡逻的房间,正在${state.you.room || '当前位置'}等待。`,
|
|
18
|
-
...(state.you.room ? { room: state.you.room } : {}),
|
|
19
|
-
});
|
|
20
|
-
this.emitProgress(state, ctx, null);
|
|
21
|
-
return [];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (hasReachedRoomTarget(state, room)) {
|
|
25
|
-
this.patrol.advance(ctx);
|
|
26
|
-
room = this.patrol.nextRoom(ctx);
|
|
27
|
-
if (!room) {
|
|
28
|
-
this.emitProgress(state, ctx, null);
|
|
29
|
-
return [];
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const worker = this.subGoal;
|
|
34
|
-
if (worker instanceof MoveRoomGoal) {
|
|
35
|
-
if (worker.room !== room.name) {
|
|
36
|
-
this.removeSubGoal();
|
|
37
|
-
this.setSubGoal(new MoveRoomGoal(room.name, hasReachedRoomTarget, {
|
|
38
|
-
emitProgress: false,
|
|
39
|
-
purpose: '巡逻',
|
|
40
|
-
}), PATROL_PRIORITY);
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
this.setSubGoal(new MoveRoomGoal(room.name, hasReachedRoomTarget, {
|
|
44
|
-
emitProgress: false,
|
|
45
|
-
purpose: '巡逻',
|
|
46
|
-
}), PATROL_PRIORITY);
|
|
47
|
-
}
|
|
48
|
-
this.emitProgress(state, ctx, room);
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
private emitProgress(state: GameState, ctx: StrategyContext, target: RoomTarget | null): void {
|
|
53
|
-
const now = Date.now();
|
|
54
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
55
|
-
ctx.lastProgressNotifyAt = now;
|
|
56
|
-
|
|
57
|
-
const room = state.you.room ?? '未知';
|
|
58
|
-
const totalRooms = ctx.rooms.length;
|
|
59
|
-
|
|
60
|
-
let msg = `[进度] 当前在${room}`;
|
|
61
|
-
if (target) {
|
|
62
|
-
msg += `,正在巡逻前往${target.name}`;
|
|
63
|
-
}
|
|
64
|
-
msg += `。共${totalRooms}个房间。`;
|
|
65
|
-
|
|
66
|
-
ctx.notifications.push(msg);
|
|
67
|
-
}
|
|
68
|
-
}
|