@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,77 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo, Position } from '../../sdk/types.js';
|
|
2
|
-
import { dist } from '../game-utils.js';
|
|
3
|
-
|
|
4
|
-
export interface AnchorLingerOptions {
|
|
5
|
-
/** 游走环最小半径(px)。 */
|
|
6
|
-
min?: number;
|
|
7
|
-
/** 游走环最大半径(px)。 */
|
|
8
|
-
max?: number;
|
|
9
|
-
/** 走到离游走点这么近就算到达、换下一个点。 */
|
|
10
|
-
reached?: number;
|
|
11
|
-
/** 单个游走点最多停留这么久就强制换点,防止点落在墙里不可达时卡死。 */
|
|
12
|
-
dwellMs?: number;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* 围绕一个锚点 min-max px 的「粘性游走」:游走点一旦选定就粘住,直到走到 / 超时 / 换了锚点,
|
|
17
|
-
* 不每 tick 重随机——否则主循环对「同一移动目标」的去重永不触发,会每轮打断上一次移动、在原地抖
|
|
18
|
-
* 而走不出一条游走腿。有 avoid 目标时偏向锚点相对最近目标的对侧。贴尸游走(LingerCorpseGoal)
|
|
19
|
-
* 与跟随同伴在其任务点假装做任务(FollowCompanionGoal)复用同一套游走机制。
|
|
20
|
-
*/
|
|
21
|
-
export class AnchorLinger {
|
|
22
|
-
private target: Position | null = null;
|
|
23
|
-
private until = 0;
|
|
24
|
-
private key = '';
|
|
25
|
-
private readonly min: number;
|
|
26
|
-
private readonly max: number;
|
|
27
|
-
private readonly reached: number;
|
|
28
|
-
private readonly dwellMs: number;
|
|
29
|
-
|
|
30
|
-
constructor(options: AnchorLingerOptions = {}) {
|
|
31
|
-
this.min = options.min ?? 40;
|
|
32
|
-
this.max = options.max ?? 100;
|
|
33
|
-
this.reached = options.reached ?? 24;
|
|
34
|
-
this.dwellMs = options.dwellMs ?? 4000;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/** 丢弃当前游走点:离开锚点(尸体出视野、同伴起身走动)时调用,下次重新挑点。 */
|
|
38
|
-
reset(): void {
|
|
39
|
-
this.target = null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/** 围绕 anchor 取下一个游走点;key 变了(换了锚点)会立即重挑。 */
|
|
43
|
-
step(state: GameState, key: string, anchor: Position, avoid: PlayerInfo[] = []): Position {
|
|
44
|
-
const now = Date.now();
|
|
45
|
-
const reached = this.target != null
|
|
46
|
-
&& dist(state.you.x, state.you.y, this.target.x, this.target.y) <= this.reached;
|
|
47
|
-
if (this.target == null || this.key !== key || reached || now >= this.until) {
|
|
48
|
-
this.key = key;
|
|
49
|
-
this.target = this.pickOffset(state, anchor, avoid);
|
|
50
|
-
this.until = now + this.dwellMs;
|
|
51
|
-
}
|
|
52
|
-
return this.target;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
private pickOffset(state: GameState, anchor: Position, avoid: PlayerInfo[]): Position {
|
|
56
|
-
return avoid.length > 0 ? this.farSideOffset(state, anchor, avoid) : this.randomOffset(anchor);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
private farSideOffset(state: GameState, anchor: Position, avoid: PlayerInfo[]): Position {
|
|
60
|
-
const nearest = avoid.reduce((best, p) => {
|
|
61
|
-
const d = p.distance ?? dist(state.you.x, state.you.y, p.x, p.y);
|
|
62
|
-
const bestD = best.distance ?? dist(state.you.x, state.you.y, best.x, best.y);
|
|
63
|
-
return d < bestD ? p : best;
|
|
64
|
-
});
|
|
65
|
-
const vx = anchor.x - nearest.x;
|
|
66
|
-
const vy = anchor.y - nearest.y;
|
|
67
|
-
const len = Math.hypot(vx, vy);
|
|
68
|
-
if (len === 0) return this.randomOffset(anchor);
|
|
69
|
-
return { x: anchor.x + (vx / len) * this.max, y: anchor.y + (vy / len) * this.max };
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
private randomOffset(anchor: Position): Position {
|
|
73
|
-
const angle = Math.random() * 2 * Math.PI;
|
|
74
|
-
const radius = this.min + Math.random() * (this.max - this.min);
|
|
75
|
-
return { x: anchor.x + Math.cos(angle) * radius, y: anchor.y + Math.sin(angle) * radius };
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import {
|
|
3
|
-
dist,
|
|
4
|
-
hasReachedRoomTarget,
|
|
5
|
-
PatrolState,
|
|
6
|
-
PROGRESS_INTERVAL_MS,
|
|
7
|
-
pursueVisibleTarget,
|
|
8
|
-
setStrategyIntent,
|
|
9
|
-
strategyPlayerLabel,
|
|
10
|
-
} from '../game-utils.js';
|
|
11
|
-
import type { BehaviorDecision, RoomTarget, StrategyContext } from '../types.js';
|
|
12
|
-
import { Goal } from './goal.js';
|
|
13
|
-
import { KeepAwayGoal, type ThreatResolver } from './keep-away-goal.js';
|
|
14
|
-
import { MoveRoomGoal, type RoomArrival } from './move-room-goal.js';
|
|
15
|
-
|
|
16
|
-
const PATROL_PRIORITY = 0.2;
|
|
17
|
-
const MOVE_PRIORITY = 0.5;
|
|
18
|
-
const EMPTY_GRACE_MS = 8_000;
|
|
19
|
-
// 次近玩家落在这个范围内就原地待着;超出才迈步靠近。须 < 视野半径,留边缘余量。
|
|
20
|
-
const GATHER_FOLLOW_DISTANCE = 200;
|
|
21
|
-
|
|
22
|
-
type MoveMode = 'patrol' | 'flee' | 'gather';
|
|
23
|
-
|
|
24
|
-
export class AvoidLoneTop extends Goal {
|
|
25
|
-
private readonly patrol = new PatrolState();
|
|
26
|
-
private emptySince: number | null = null;
|
|
27
|
-
private moveMode: MoveMode | null = null;
|
|
28
|
-
private lastNoticeKey = '';
|
|
29
|
-
|
|
30
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
31
|
-
const now = Date.now();
|
|
32
|
-
const visible = state.players;
|
|
33
|
-
|
|
34
|
-
if (visible.length === 0) {
|
|
35
|
-
if (this.emptySince == null) this.emptySince = now;
|
|
36
|
-
// 有「上一条移动」要守护时就尊重 8 秒空视野宽限:flee 靠子目标续命(KeepAwayGoal),
|
|
37
|
-
// gather 是内联返回的跟随 move(无子目标),靠 moveMode==='gather' 标记守护——
|
|
38
|
-
// 否则人短暂出视野会被立刻改判巡逻、覆盖掉刚发出的跟随移动。
|
|
39
|
-
const hasMoveToHold = this.subGoal != null || this.moveMode === 'gather';
|
|
40
|
-
if (!hasMoveToHold || now - this.emptySince >= EMPTY_GRACE_MS) {
|
|
41
|
-
this.setPatrolGoal(state, ctx);
|
|
42
|
-
this.emitProgress(state, ctx, 'patrol', null, visible);
|
|
43
|
-
} else {
|
|
44
|
-
this.emitProgress(state, ctx, this.moveMode, null, visible); // 宽限期内维持原目标
|
|
45
|
-
}
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
this.emptySince = null;
|
|
50
|
-
|
|
51
|
-
if (visible.length === 1) {
|
|
52
|
-
const lone = visible[0].name;
|
|
53
|
-
this.setKeepAway(`single:${lone}`,
|
|
54
|
-
currentState => currentState.players.filter(player => player.name === lone));
|
|
55
|
-
if (!this.emitNotice(ctx, `flee:${lone}`,
|
|
56
|
-
`视野内只有${lone},正在寻路避免落单。`))
|
|
57
|
-
this.emitProgress(state, ctx, 'flee', null, visible);
|
|
58
|
-
return [];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// 2+ 人:跟住「次近」的人。最近的人本就贴着、最不会掉出视野;真正卡在
|
|
62
|
-
// 「≥2 人 / 跌回 1 人独处」临界点上的是第二近的人,盯住他、保持在视野舒适范围内即可维持人数。
|
|
63
|
-
this.clearGoal();
|
|
64
|
-
this.moveMode = 'gather';
|
|
65
|
-
const anchor = [...visible].sort((a, b) => this.distOf(state, a) - this.distOf(state, b))[1]; // length>=2 必存在
|
|
66
|
-
const decision = pursueVisibleTarget(state, anchor, { kill: false, followDistance: GATHER_FOLLOW_DISTANCE });
|
|
67
|
-
if (decision) {
|
|
68
|
-
if (!this.emitNotice(ctx, `gather:follow:${anchor.name}`,
|
|
69
|
-
`视野内${visible.length}人,正在靠近${anchor.name}维持人数。`))
|
|
70
|
-
this.emitProgress(state, ctx, 'gather', null, visible);
|
|
71
|
-
return [{
|
|
72
|
-
action: decision.action.withThinking(
|
|
73
|
-
`跟住次近的${anchor.name},维持视野内至少两人,避免落单。`,
|
|
74
|
-
),
|
|
75
|
-
intent: {
|
|
76
|
-
activity: 'moving',
|
|
77
|
-
summary: `正在${anchor.room || state.you.room || '当前位置'}跟随${strategyPlayerLabel(anchor)},保持在人群中。`,
|
|
78
|
-
...(anchor.room ? { room: anchor.room } : {}),
|
|
79
|
-
targetPlayer: anchor.name,
|
|
80
|
-
},
|
|
81
|
-
}];
|
|
82
|
-
}
|
|
83
|
-
setStrategyIntent(ctx, {
|
|
84
|
-
activity: 'waiting',
|
|
85
|
-
summary: `正在${state.you.room || '当前位置'}和${strategyPlayerLabel(anchor)}保持在人群中。`,
|
|
86
|
-
...(state.you.room ? { room: state.you.room } : {}),
|
|
87
|
-
targetPlayer: anchor.name,
|
|
88
|
-
});
|
|
89
|
-
if (!this.emitNotice(ctx, `gather:hold:${visible.length}`,
|
|
90
|
-
`视野内${visible.length}人,已和大家在一起保持安全。`))
|
|
91
|
-
this.emitProgress(state, ctx, 'gather', null, visible);
|
|
92
|
-
return [];
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
private distOf(state: GameState, p: PlayerInfo): number {
|
|
96
|
-
return p.distance ?? dist(state.you.x, state.you.y, p.x, p.y);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
private setPatrolGoal(state: GameState, ctx: StrategyContext): void {
|
|
100
|
-
let room = this.patrol.nextRoom(ctx);
|
|
101
|
-
if (!room) {
|
|
102
|
-
this.clearGoal();
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (hasReachedRoomTarget(state, room)) {
|
|
107
|
-
this.patrol.advance(ctx);
|
|
108
|
-
room = this.patrol.nextRoom(ctx);
|
|
109
|
-
if (!room) {
|
|
110
|
-
this.clearGoal();
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
this.setMoveGoal(room, 'patrol', true, PATROL_PRIORITY);
|
|
116
|
-
this.lastNoticeKey = '';
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* 寻路躲避:用 KeepAwayGoal 推演逃点远离这个唯一可见的人(不限距离,避免落单)。
|
|
121
|
-
* finishWhenClear:false——人短暂丢失视野时子目标不自我结束,交由父层 8 秒空视野宽限
|
|
122
|
-
* 决定何时转巡逻,否则一丢视野就同轮被清、下一 tick 立刻 patrol,宽限只剩一帧会来回摇摆。
|
|
123
|
-
*/
|
|
124
|
-
private setKeepAway(key: string, resolveThreats: ThreatResolver): void {
|
|
125
|
-
const worker = this.subGoal;
|
|
126
|
-
if (worker instanceof KeepAwayGoal && worker.key === key) {
|
|
127
|
-
this.moveMode = 'flee';
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
if (this.subGoal) this.removeSubGoal();
|
|
131
|
-
this.setSubGoal(new KeepAwayGoal(key, resolveThreats, {
|
|
132
|
-
threatRadius: Infinity,
|
|
133
|
-
finishWhenClear: false,
|
|
134
|
-
noun: '',
|
|
135
|
-
}), MOVE_PRIORITY);
|
|
136
|
-
this.moveMode = 'flee';
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
private setMoveGoal(
|
|
140
|
-
room: RoomTarget,
|
|
141
|
-
mode: MoveMode,
|
|
142
|
-
stopOnPlayer: boolean,
|
|
143
|
-
priority = MOVE_PRIORITY,
|
|
144
|
-
hasArrived: RoomArrival = hasReachedRoomTarget,
|
|
145
|
-
): void {
|
|
146
|
-
const worker = this.subGoal;
|
|
147
|
-
if (worker instanceof MoveRoomGoal && worker.room === room.name && this.moveMode === mode) return;
|
|
148
|
-
if (this.subGoal) this.removeSubGoal();
|
|
149
|
-
this.setSubGoal(new MoveRoomGoal(room.name, hasArrived, {
|
|
150
|
-
emitProgress: false,
|
|
151
|
-
stopOnPlayer,
|
|
152
|
-
purpose: mode === 'patrol' ? '巡逻寻找人群' : '靠近人群',
|
|
153
|
-
}), priority);
|
|
154
|
-
this.moveMode = mode;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
private clearGoal(): void {
|
|
158
|
-
if (this.subGoal) this.removeSubGoal();
|
|
159
|
-
this.moveMode = null;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
private emitNotice(ctx: StrategyContext, key: string, message: string): boolean {
|
|
163
|
-
if (key === this.lastNoticeKey) return false;
|
|
164
|
-
this.lastNoticeKey = key;
|
|
165
|
-
ctx.notifications.push(message);
|
|
166
|
-
return true;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
private emitProgress(
|
|
170
|
-
state: GameState,
|
|
171
|
-
ctx: StrategyContext,
|
|
172
|
-
mode: MoveMode | null,
|
|
173
|
-
target: RoomTarget | null,
|
|
174
|
-
visible: PlayerInfo[],
|
|
175
|
-
): void {
|
|
176
|
-
const now = Date.now();
|
|
177
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
178
|
-
ctx.lastProgressNotifyAt = now;
|
|
179
|
-
|
|
180
|
-
const room = state.you.room ?? '未知';
|
|
181
|
-
let msg = `[进度] 当前在${room},视野内${visible.length}人`;
|
|
182
|
-
if (mode === 'gather') msg += ',正在跟随人群';
|
|
183
|
-
else if (mode === 'flee') msg += ',正在避免落单风险';
|
|
184
|
-
else msg += ',正在巡逻寻找人群';
|
|
185
|
-
if (target) msg += `,前往${target.name}`;
|
|
186
|
-
msg += '。';
|
|
187
|
-
ctx.notifications.push(msg);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import { hasReachedRoomTarget, isTargetAlive, matchesAnyTarget, PatrolState, PROGRESS_INTERVAL_MS } from '../game-utils.js';
|
|
3
|
-
import type { BehaviorDecision, RoomTarget, StrategyContext } from '../types.js';
|
|
4
|
-
import { Goal } from './goal.js';
|
|
5
|
-
import { KeepAwayGoal, type KeepAwayGoalOptions, type ThreatResolver } from './keep-away-goal.js';
|
|
6
|
-
import { MoveRoomGoal } from './move-room-goal.js';
|
|
7
|
-
|
|
8
|
-
const PATROL_PRIORITY = 0.2;
|
|
9
|
-
const FLEE_PRIORITY = 0.5;
|
|
10
|
-
|
|
11
|
-
export class AvoidPlayersTop extends Goal {
|
|
12
|
-
private readonly patrol = new PatrolState();
|
|
13
|
-
private moveMode: 'patrol' | 'flee' | null = null;
|
|
14
|
-
private lastAvoidNoticeKey = '';
|
|
15
|
-
|
|
16
|
-
constructor(private readonly targets: number[]) {
|
|
17
|
-
super();
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
21
|
-
const threats = this.threats(state, ctx);
|
|
22
|
-
|
|
23
|
-
if (threats.length > 0) {
|
|
24
|
-
this.setKeepAway();
|
|
25
|
-
if (!this.emitAvoidNotice(ctx, threats)) this.emitAvoidProgress(state, ctx, threats);
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
this.lastAvoidNoticeKey = '';
|
|
30
|
-
let room = this.patrol.nextRoom(ctx);
|
|
31
|
-
if (!room) {
|
|
32
|
-
this.emitPatrolProgress(state, ctx, null);
|
|
33
|
-
return [];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (hasReachedRoomTarget(state, room)) {
|
|
37
|
-
this.patrol.advance(ctx);
|
|
38
|
-
room = this.patrol.nextRoom(ctx);
|
|
39
|
-
if (!room) {
|
|
40
|
-
this.emitPatrolProgress(state, ctx, null);
|
|
41
|
-
return [];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
this.setMoveGoal(room, PATROL_PRIORITY, 'patrol', false);
|
|
46
|
-
this.emitPatrolProgress(state, ctx, room);
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/** 寻路躲避:用 KeepAwayGoal 推演逃点远离回避目标(不限距离,名单上的人始终要躲)。 */
|
|
51
|
-
private setKeepAway(): void {
|
|
52
|
-
const key = this.targets.join('|');
|
|
53
|
-
const resolve: ThreatResolver = (state, ctx) => this.threats(state, ctx);
|
|
54
|
-
const options: KeepAwayGoalOptions = { threatRadius: Infinity, noun: '回避目标' };
|
|
55
|
-
const worker = this.subGoal;
|
|
56
|
-
if (worker instanceof KeepAwayGoal && worker.key === key) {
|
|
57
|
-
this.moveMode = 'flee';
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (this.subGoal) this.removeSubGoal();
|
|
61
|
-
this.setSubGoal(new KeepAwayGoal(key, resolve, options), FLEE_PRIORITY);
|
|
62
|
-
this.moveMode = 'flee';
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/** targets 中仍存活的玩家;空名单表示只巡逻。 */
|
|
66
|
-
private threats(state: GameState, ctx: StrategyContext): PlayerInfo[] {
|
|
67
|
-
const validTargets = this.targets.filter(target => isTargetAlive(state, target, ctx));
|
|
68
|
-
return state.players.filter(p => matchesAnyTarget(p, validTargets, ctx));
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
private setMoveGoal(room: RoomTarget, priority: number, mode: 'patrol' | 'flee', stopOnPlayer: boolean): void {
|
|
72
|
-
const worker = this.subGoal;
|
|
73
|
-
if (worker instanceof MoveRoomGoal && worker.room === room.name && this.moveMode === mode) return;
|
|
74
|
-
if (this.subGoal) this.removeSubGoal();
|
|
75
|
-
this.setSubGoal(new MoveRoomGoal(room.name, hasReachedRoomTarget, {
|
|
76
|
-
emitProgress: false,
|
|
77
|
-
stopOnPlayer,
|
|
78
|
-
purpose: '巡逻并避开指定玩家',
|
|
79
|
-
}), priority);
|
|
80
|
-
this.moveMode = mode;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
private emitAvoidNotice(ctx: StrategyContext, threats: PlayerInfo[]): boolean {
|
|
84
|
-
const names = threats.map(p => p.name).join('、');
|
|
85
|
-
const key = threats.map(p => p.name).sort().join('|');
|
|
86
|
-
if (key === this.lastAvoidNoticeKey) return false;
|
|
87
|
-
this.lastAvoidNoticeKey = key;
|
|
88
|
-
|
|
89
|
-
ctx.notifications.push(`发现回避目标${names},正在寻路躲避。`);
|
|
90
|
-
return true;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
private emitPatrolProgress(state: GameState, ctx: StrategyContext, target: RoomTarget | null): void {
|
|
94
|
-
const now = Date.now();
|
|
95
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
96
|
-
ctx.lastProgressNotifyAt = now;
|
|
97
|
-
|
|
98
|
-
const room = state.you.room ?? '未知';
|
|
99
|
-
const targetNames = this.targets.length > 0 ? this.targets.join(', ') : '(未配置)';
|
|
100
|
-
|
|
101
|
-
let msg = `[进度] 当前在${room},巡逻中,回避名单: ${targetNames}`;
|
|
102
|
-
if (target) {
|
|
103
|
-
msg += `,正在前往${target.name}`;
|
|
104
|
-
}
|
|
105
|
-
msg += '。';
|
|
106
|
-
ctx.notifications.push(msg);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
private emitAvoidProgress(
|
|
110
|
-
state: GameState,
|
|
111
|
-
ctx: StrategyContext,
|
|
112
|
-
threats: PlayerInfo[],
|
|
113
|
-
): void {
|
|
114
|
-
const now = Date.now();
|
|
115
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
116
|
-
ctx.lastProgressNotifyAt = now;
|
|
117
|
-
|
|
118
|
-
const here = state.you.room ?? '未知';
|
|
119
|
-
const names = threats.map(p => p.name).join('、');
|
|
120
|
-
ctx.notifications.push(`[进度] 当前在${here},发现${names},正在寻路躲避。`);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
3
|
-
import { Goal } from './goal.js';
|
|
4
|
-
import { GoalManager } from './goal-manager.js';
|
|
5
|
-
import { URGENT_GOAL_PRIORITY } from './leaf-goal.js';
|
|
6
|
-
import type { SpeechModule } from '../speech-module.js';
|
|
7
|
-
|
|
8
|
-
export class ConversationGoal extends Goal {
|
|
9
|
-
private readonly innerMgr = new GoalManager();
|
|
10
|
-
|
|
11
|
-
constructor(
|
|
12
|
-
private readonly makeInner: () => Goal,
|
|
13
|
-
private readonly speech: SpeechModule,
|
|
14
|
-
) {
|
|
15
|
-
super();
|
|
16
|
-
this.innerMgr.setTop(makeInner());
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
20
|
-
if (this.innerMgr.getTop() === null) this.innerMgr.setTop(this.makeInner());
|
|
21
|
-
const innerDecisions = this.innerMgr.tick(state, ctx);
|
|
22
|
-
|
|
23
|
-
const interruptible = this.innerLeafPriority() < URGENT_GOAL_PRIORITY;
|
|
24
|
-
const primaryIsMove = innerDecisions[0]?.action.type === 'move';
|
|
25
|
-
const result = this.speech.evaluate(state, ctx, {
|
|
26
|
-
allowAutoGreet: interruptible && primaryIsMove,
|
|
27
|
-
});
|
|
28
|
-
for (const msg of result.notifications) ctx.speechNotifications.push(msg);
|
|
29
|
-
|
|
30
|
-
return innerDecisions;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
onMeetingResume(): void {
|
|
34
|
-
this.speech.resetMeetingState();
|
|
35
|
-
this.innerMgr.getTop()?.onMeetingResume();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
updateConfig(role: string): void {
|
|
39
|
-
this.speech.updateConfig(role);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
private innerLeafPriority(): number {
|
|
43
|
-
let node: Goal | null = this.innerMgr.getTop();
|
|
44
|
-
let priority = 0;
|
|
45
|
-
while (node) {
|
|
46
|
-
priority = node.priority;
|
|
47
|
-
node = node.subGoal;
|
|
48
|
-
}
|
|
49
|
-
return priority;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import type { GameState } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
corpseAtScene,
|
|
5
|
-
emergencyRushDecision,
|
|
6
|
-
nearestKnownCorpseNav,
|
|
7
|
-
patrolStep,
|
|
8
|
-
PatrolState,
|
|
9
|
-
PROGRESS_INTERVAL_MS,
|
|
10
|
-
} from '../game-utils.js';
|
|
11
|
-
import type { BehaviorDecision, CorpseTarget, StrategyContext } from '../types.js';
|
|
12
|
-
import { Goal } from './goal.js';
|
|
13
|
-
import { LingerCorpseGoal } from './linger-corpse-goal.js';
|
|
14
|
-
|
|
15
|
-
const GREETING_COOLDOWN_MS = 120_000;
|
|
16
|
-
|
|
17
|
-
export class CorpsePatrolTop extends Goal {
|
|
18
|
-
private readonly patrol = new PatrolState();
|
|
19
|
-
private readonly linger = new LingerCorpseGoal();
|
|
20
|
-
private lastCorpseNotified = false;
|
|
21
|
-
private lastGreetingAt: number | null = null;
|
|
22
|
-
|
|
23
|
-
constructor(private readonly greetingPhrases: string[]) {
|
|
24
|
-
super();
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
28
|
-
// 残局抢修紧急任务(已知存活≤6):天堂鱼最高优先级,先于贴尸/巡逻/打招呼——
|
|
29
|
-
// 紧急任务超时则蟹直接获胜;天堂鱼要拖到第二轮及以后被投出,故残局抢着把维修做掉、掐断蟹的破坏取胜线。
|
|
30
|
-
const emergency = emergencyRushDecision(state, ctx);
|
|
31
|
-
if (emergency) {
|
|
32
|
-
this.emitProgress(state, ctx, null, true);
|
|
33
|
-
return [emergency];
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const decisions: BehaviorDecision[] = [];
|
|
37
|
-
|
|
38
|
-
const greetingDecision = this.tryGreeting(state);
|
|
39
|
-
if (greetingDecision) decisions.push(greetingDecision);
|
|
40
|
-
|
|
41
|
-
const corpse = nearestKnownCorpseNav(state, ctx);
|
|
42
|
-
const canMove = !state.you.doing_task;
|
|
43
|
-
|
|
44
|
-
if (corpse) {
|
|
45
|
-
if (!this.lastCorpseNotified) {
|
|
46
|
-
this.lastCorpseNotified = true;
|
|
47
|
-
const label = corpse.name ? `${corpse.name}的尸体` : '尸体';
|
|
48
|
-
// corpseAtScene=已站在尸体旁(≤150px);仅凭记忆/房间锚点导航过去时人还没到,别谎报「在附近徘徊」。
|
|
49
|
-
ctx.notifications.push(
|
|
50
|
-
corpseAtScene(state) ? `发现${label}!在附近徘徊观察。` : `发现${label}!正前往查看。`,
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
if (canMove) decisions.push(...this.linger.tick(state, ctx));
|
|
54
|
-
} else {
|
|
55
|
-
this.lastCorpseNotified = false;
|
|
56
|
-
if (canMove) decisions.push(...patrolStep(state, ctx, this.patrol, false, '巡逻寻找尸体'));
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
this.emitProgress(state, ctx, corpse);
|
|
60
|
-
return decisions;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private tryGreeting(state: GameState): BehaviorDecision | null {
|
|
64
|
-
if (this.greetingPhrases.length === 0) return null;
|
|
65
|
-
if (state.players.length === 0) return null;
|
|
66
|
-
|
|
67
|
-
const now = Date.now();
|
|
68
|
-
if (this.lastGreetingAt !== null && now - this.lastGreetingAt < GREETING_COOLDOWN_MS) return null;
|
|
69
|
-
|
|
70
|
-
const text = this.greetingPhrases[Math.floor(Math.random() * this.greetingPhrases.length)];
|
|
71
|
-
this.lastGreetingAt = now;
|
|
72
|
-
return {
|
|
73
|
-
action: Action.speech(text),
|
|
74
|
-
intent: {
|
|
75
|
-
activity: 'acting',
|
|
76
|
-
summary: `正在${state.you.room || '当前位置'}向附近玩家打招呼。`,
|
|
77
|
-
...(state.you.room ? { room: state.you.room } : {}),
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
private emitProgress(
|
|
83
|
-
state: GameState,
|
|
84
|
-
ctx: StrategyContext,
|
|
85
|
-
corpse: CorpseTarget | null,
|
|
86
|
-
emergencyRush = false,
|
|
87
|
-
): void {
|
|
88
|
-
const now = Date.now();
|
|
89
|
-
if (now - ctx.lastProgressNotifyAt < PROGRESS_INTERVAL_MS) return;
|
|
90
|
-
ctx.lastProgressNotifyAt = now;
|
|
91
|
-
|
|
92
|
-
const room = state.you.room ?? '未知';
|
|
93
|
-
|
|
94
|
-
if (emergencyRush) {
|
|
95
|
-
const name = ctx.emergency?.task_name ?? '紧急维修';
|
|
96
|
-
ctx.notifications.push(
|
|
97
|
-
`[进度] 当前在${room},残局仅剩${state.alive_count}人,抢着去做紧急任务「${name}」,阻止蟹靠破坏倒计时取胜。`,
|
|
98
|
-
);
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
let msg = `[进度] 当前在${room}`;
|
|
103
|
-
if (corpse) {
|
|
104
|
-
const label = corpse.name ?? '未知';
|
|
105
|
-
msg += corpseAtScene(state)
|
|
106
|
-
? `,在${label}的尸体附近徘徊。`
|
|
107
|
-
: `,正前往${label}的尸体所在位置。`;
|
|
108
|
-
} else {
|
|
109
|
-
const target = this.patrol.nextRoom(ctx);
|
|
110
|
-
if (target) {
|
|
111
|
-
msg += `,巡逻中,正在前往${target.name}。`;
|
|
112
|
-
} else {
|
|
113
|
-
msg += `,巡逻中。`;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
msg += ` 共${ctx.rooms.length}个房间。`;
|
|
117
|
-
|
|
118
|
-
ctx.notifications.push(msg);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
|
-
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import {
|
|
4
|
-
canUseKill,
|
|
5
|
-
corpseAtScene,
|
|
6
|
-
dist,
|
|
7
|
-
killCommitRange,
|
|
8
|
-
nearestReportableCorpse,
|
|
9
|
-
nonTeammatesVisible,
|
|
10
|
-
reportCorpseDecision,
|
|
11
|
-
playerStrategyIntent,
|
|
12
|
-
strategyDecision,
|
|
13
|
-
} from '../game-utils.js';
|
|
14
|
-
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* 蟹(坏人)/ 章鱼(中立带刀)默认策略共享的「反射动作」——由 CrabSabotageTop 与 LoneKillTaskTop
|
|
18
|
-
* 在各自 tick() 的**最前面**调用,抢在破坏/任务/落单猎杀编排之前先处理两类即时机会:
|
|
19
|
-
*
|
|
20
|
-
* - immediateLoneKillDecision:唯一一个落单非队友就贴在脸上(出刀范围内)且刀好 → 立刻出刀。它无视
|
|
21
|
-
* LoneKillCore 的「暂停窗口」,也不管自己是否正在做破坏任务——只要能原地一刀就先杀。
|
|
22
|
-
* - corpseReportWithNonTeammate:地上有尸体且附近有非队友 → 报警(够不着先靠近)。不管尸体是谁
|
|
23
|
-
* 造成的(含队友的杀),靠主动报警伪装好人 / 把嫌疑栽到在场者身上。
|
|
24
|
-
*
|
|
25
|
-
* 调用方按「能贴脸杀就杀,否则报警」的次序:先 immediateLoneKillDecision 再 corpseReportWithNonTeammate。
|
|
26
|
-
* 两者都不读取玩家分类参数,与默认蟹/章鱼对任意落单非队友照杀的设定一致;蟹/章鱼目前
|
|
27
|
-
* 没有记忆版策略,故没有「点名/保护」入口。
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
/** 有尸体且附近有非队友 → 报警/靠近报警;否则 null。respectBlock 防止 5s 内重复报。 */
|
|
31
|
-
export function corpseReportWithNonTeammate(state: GameState, ctx: StrategyContext): BehaviorDecision[] | null {
|
|
32
|
-
// 报尸自证/嫁祸是「此刻就在尸体旁、有人撞见」的现场反射,必须用当帧视野的尸体;用持久记忆会让
|
|
33
|
-
// 蟹/章鱼在地图别处随便撞见一个人就生成错误的栽赃简报。
|
|
34
|
-
if (!corpseAtScene(state)) return null;
|
|
35
|
-
const witnesses = nonTeammatesVisible(state, ctx);
|
|
36
|
-
if (witnesses.length === 0) return null;
|
|
37
|
-
|
|
38
|
-
const report = reportCorpseDecision(state, ctx, { respectBlock: true });
|
|
39
|
-
if (!report) return null;
|
|
40
|
-
|
|
41
|
-
const witnessNames = witnesses.map(p => p.name).join('、');
|
|
42
|
-
if (report.action.type === 'report') {
|
|
43
|
-
// 实时给 Agent 一条「为什么是我报的尸」简报:报尸=召集会议,是高风险自证动作。
|
|
44
|
-
// 若尸体很可能是自己刚才下的那一刀,必须显式提醒,免得 Agent 之后发言露馅。
|
|
45
|
-
const corpse = nearestReportableCorpse(state);
|
|
46
|
-
const corpseName = corpse?.name ?? '';
|
|
47
|
-
ctx.agentAlerts.push(
|
|
48
|
-
isRecentOwnKill(ctx, corpse)
|
|
49
|
-
? `我刚下手的目标${corpseName ? `(${corpseName})` : ''}尸体被${witnessNames}撞见,我抢先报尸召集会议、把自己装成发现者并把嫌疑引向在场者。接下来发言/投票要顺着「我是主动报告的人」走,绝不能承认是自己动的手。`
|
|
50
|
-
: `尸体旁有${witnessNames}在场,我抢先报尸召集会议、伪装成主动报告的好人。发言时按「主动报告的发现者」立场走。`,
|
|
51
|
-
);
|
|
52
|
-
ctx.notifications.push(`尸体旁有${witnessNames}在场,立刻报告自证。`);
|
|
53
|
-
const base = report.action.thinkingContent ?? '发现尸体,报告召开会议';
|
|
54
|
-
return [{
|
|
55
|
-
action: report.action.withThinking(`${base};尸体旁有${witnessNames}在场,立刻报告自证。`),
|
|
56
|
-
intent: report.intent,
|
|
57
|
-
}];
|
|
58
|
-
}
|
|
59
|
-
ctx.notifications.push(`尸体旁有${witnessNames}在场,靠近尸体准备报告自证。`);
|
|
60
|
-
return [{
|
|
61
|
-
action: report.action.withThinking(`尸体旁有${witnessNames}在场,靠近尸体准备报告自证。`),
|
|
62
|
-
intent: report.intent,
|
|
63
|
-
}];
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* 唯一一个落单非队友贴脸(出刀范围内)且刀好 → 立刻出刀;否则 null。无视暂停窗口、不管在做什么任务。
|
|
68
|
-
* 可选 skipTarget:返回 true 的目标本帧不出刀(章鱼残局抢修期用它放过紧挨紧急维修点的目标)。
|
|
69
|
-
*/
|
|
70
|
-
export function immediateLoneKillDecision(
|
|
71
|
-
state: GameState,
|
|
72
|
-
ctx: StrategyContext,
|
|
73
|
-
skipTarget?: (target: PlayerInfo) => boolean,
|
|
74
|
-
): BehaviorDecision[] | null {
|
|
75
|
-
if (!canUseKill(state)) return null;
|
|
76
|
-
|
|
77
|
-
const targets = nonTeammatesVisible(state, ctx);
|
|
78
|
-
if (targets.length !== 1) return null;
|
|
79
|
-
|
|
80
|
-
const target = targets[0];
|
|
81
|
-
const distance = target.distance ?? dist(state.you.x, state.you.y, target.x, target.y);
|
|
82
|
-
if (distance > killCommitRange(state.you.role)) return null;
|
|
83
|
-
if (skipTarget?.(target)) return null;
|
|
84
|
-
|
|
85
|
-
ctx.notifications.push(`发现落单目标${target.name}就在身边,立刻出刀!`);
|
|
86
|
-
if (target.seat == null || target.seat <= 0) return null;
|
|
87
|
-
return [strategyDecision(Action.kill(target.seat), playerStrategyIntent(target, '追杀', 'acting'))];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* 这具尸体是不是「自己刚才下的那一刀」。先按尸体座位号精确匹配 recentlyKilledTargets(刚杀过且未过期),
|
|
92
|
-
* 座位对不上但近期确实杀过人时,冒出的尸体大概率也是自己造成的,按 true 处理(宁可多提醒一次)。
|
|
93
|
-
*/
|
|
94
|
-
function isRecentOwnKill(
|
|
95
|
-
ctx: StrategyContext,
|
|
96
|
-
corpse: { seat?: number } | null,
|
|
97
|
-
): boolean {
|
|
98
|
-
const map = ctx.recentlyKilledTargets;
|
|
99
|
-
if (!map || map.size === 0) return false;
|
|
100
|
-
const now = Date.now();
|
|
101
|
-
if (corpse?.seat != null) {
|
|
102
|
-
const until = map.get(String(corpse.seat));
|
|
103
|
-
if (until != null && until > now) return true;
|
|
104
|
-
}
|
|
105
|
-
for (const until of map.values()) {
|
|
106
|
-
if (until > now) return true;
|
|
107
|
-
}
|
|
108
|
-
return false;
|
|
109
|
-
}
|