@myclaw163/clawclaw-cli 0.6.67 → 0.6.69
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/bin/clawclaw-cli.mjs +3 -3
- package/package.json +1 -1
- package/scripts/sync-bundled-skill.mjs +1 -1
- package/skills/clawclaw/references/COMMANDS.md +4 -4
- package/skills/clawclaw/references/KNOWLEDGE.md +14 -12
- package/src/commands/config.ts +30 -30
- package/src/commands/game.ts +15 -0
- package/src/commands/knowledge.test.ts +4 -10
- package/src/commands/knowledge.ts +10 -39
- package/src/commands/setup/hermes.test.ts +96 -96
- package/src/commands/setup/hermes.ts +76 -76
- package/src/commands/setup/index.ts +13 -13
- package/src/commands/setup/openclaw.test.ts +114 -114
- package/src/commands/setup/openclaw.ts +147 -147
- package/src/commands/watch.test.ts +11 -0
- package/src/commands/watch.ts +2 -3
- package/src/lib/auth.test.ts +15 -0
- package/src/lib/host-config-patcher.test.ts +130 -130
- package/src/lib/host-config-patcher.ts +151 -151
- package/src/lib/hub-reminder.ts +19 -19
- package/src/lib/knowledge-store.test.ts +28 -38
- package/src/lib/knowledge-store.ts +52 -57
- package/src/pipeline/event-format.test.ts +82 -2
- package/src/pipeline/event-format.ts +114 -5
- package/src/pipeline/event-hints.ts +20 -3
- package/src/runtime/event-daemon.test.ts +34 -0
- package/src/runtime/event-daemon.ts +51 -3
- package/src/sdk/index.ts +2 -3
- package/src/sdk/types.ts +2 -0
- package/src/strategies/avoid-players.knowledge.md +7 -8
- package/src/strategies/avoid-players.ts +1 -1
- package/src/strategies/corpse-patrol.ts +1 -1
- package/src/strategies/game-utils.test.ts +53 -1
- package/src/strategies/game-utils.ts +92 -28
- package/src/strategies/goals/avoid-players-top.ts +3 -3
- package/src/strategies/goals/corpse-patrol-top.ts +23 -1
- package/src/strategies/goals/crab-octopus-reflexes.ts +11 -3
- package/src/strategies/goals/keep-away-goal.ts +9 -5
- package/src/strategies/goals/leaf-goal.ts +2 -0
- package/src/strategies/goals/lone-kill-task-top.ts +58 -11
- package/src/strategies/goals/normal-shrimp-top.ts +11 -11
- package/src/strategies/goals/paradise-fish-top.ts +32 -15
- package/src/strategies/goals/warrior-shrimp-top.test.ts +4 -3
- package/src/strategies/goals/warrior-shrimp-top.ts +62 -295
- package/src/strategies/hide-spots.ts +11 -75
- package/src/strategies/kill-lone.knowledge.md +6 -9
- package/src/strategies/lone-kill-task.ts +1 -1
- package/src/strategies/off-route-points.ts +105 -0
- package/src/strategies/paradise-fish.knowledge.md +7 -8
- package/src/strategies/paradise-fish.ts +1 -1
- package/src/strategies/shrimp-memory.knowledge.md +7 -8
- package/src/strategies/shrimp-memory.ts +1 -1
- package/src/strategies/warrior-memory.knowledge.md +9 -10
- package/src/strategies/warrior-memory.ts +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { GameState, PlayerInfo, Position } from '../../sdk/types.js';
|
|
2
2
|
import {
|
|
3
3
|
corpseAtScene,
|
|
4
|
+
emergencyRushDecision,
|
|
4
5
|
hasKnownCorpse,
|
|
5
|
-
|
|
6
|
+
isKnowledgeHostile,
|
|
6
7
|
isKnowledgeTrusted,
|
|
7
8
|
nonTeammatesVisible,
|
|
8
9
|
PatrolState,
|
|
@@ -20,7 +21,7 @@ const SUB_PRIORITY = 0.5;
|
|
|
20
21
|
const AVOID_ROUTE_MEMORY_MS = 10_000;
|
|
21
22
|
const WITNESS_EXEMPT_COUNT = 2;
|
|
22
23
|
|
|
23
|
-
type Tier = 'corpse' | 'flee-bad' | 'keep-distance' | 'huddle' | 'wander';
|
|
24
|
+
type Tier = 'emergency' | 'corpse' | 'flee-bad' | 'keep-distance' | 'huddle' | 'wander';
|
|
24
25
|
|
|
25
26
|
export class ParadiseFishTop extends Goal {
|
|
26
27
|
private readonly linger = new LingerCorpseGoal((state, ctx) => this.visibleAvoidTargets(state, ctx));
|
|
@@ -39,16 +40,16 @@ export class ParadiseFishTop extends Goal {
|
|
|
39
40
|
|
|
40
41
|
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
41
42
|
const visible = nonTeammatesVisible(state, ctx);
|
|
42
|
-
const threatTargets = visible.filter(p => this.
|
|
43
|
+
const threatTargets = visible.filter(p => this.isHostile(p, ctx));
|
|
43
44
|
const trustedTargets = visible.filter(p => this.isTrusted(p, ctx));
|
|
44
45
|
const strangerAvoidTargets = this.strangerAvoidTargets(visible, ctx);
|
|
45
46
|
this.rememberAvoidPoints(visible, ctx, strangerAvoidTargets.length > 0);
|
|
46
|
-
const decisions: BehaviorDecision[] = [];
|
|
47
|
-
const greeting = this.greeting.tryGreeting(state);
|
|
48
|
-
if (greeting) decisions.push(greeting);
|
|
49
47
|
|
|
50
48
|
if (threatTargets.length > 0) {
|
|
51
|
-
|
|
49
|
+
const decisions: BehaviorDecision[] = [];
|
|
50
|
+
const greeting = this.greeting.tryGreeting(state);
|
|
51
|
+
if (greeting) decisions.push(greeting);
|
|
52
|
+
this.setKeepAway('pf-flee-bad', (s, c) => nonTeammatesVisible(s, c).filter(p => this.isHostile(p, c)), {
|
|
52
53
|
threatRadius: Infinity,
|
|
53
54
|
noun: '认定带刀坏人',
|
|
54
55
|
});
|
|
@@ -56,6 +57,18 @@ export class ParadiseFishTop extends Goal {
|
|
|
56
57
|
return decisions;
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
// 残局抢修紧急任务(已知存活≤6):仅次于躲避带刀坏人,先于保持距离/贴尸/抱团。
|
|
61
|
+
const emergency = emergencyRushDecision(state, ctx);
|
|
62
|
+
if (emergency) {
|
|
63
|
+
this.clearSub();
|
|
64
|
+
this.emitProgress(state, ctx, visible, 'emergency');
|
|
65
|
+
return [emergency];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const decisions: BehaviorDecision[] = [];
|
|
69
|
+
const greeting = this.greeting.tryGreeting(state);
|
|
70
|
+
if (greeting) decisions.push(greeting);
|
|
71
|
+
|
|
59
72
|
if (strangerAvoidTargets.length > 0) {
|
|
60
73
|
this.setKeepAway('pf-keep-distance', (s, c) => this.strangerAvoidTargets(nonTeammatesVisible(s, c), c), {
|
|
61
74
|
threatRadius: Infinity,
|
|
@@ -91,8 +104,9 @@ export class ParadiseFishTop extends Goal {
|
|
|
91
104
|
return [...this.wander(state, ctx), ...decisions];
|
|
92
105
|
}
|
|
93
106
|
|
|
94
|
-
|
|
95
|
-
|
|
107
|
+
/** 坏人:知识库 hostile(明确敌对带刀者)。被怀疑者(未标记)走下面的保持距离档。 */
|
|
108
|
+
private isHostile(p: PlayerInfo, ctx: StrategyContext): boolean {
|
|
109
|
+
return isKnowledgeHostile(p, ctx);
|
|
96
110
|
}
|
|
97
111
|
|
|
98
112
|
private isTrusted(p: PlayerInfo, ctx: StrategyContext): boolean {
|
|
@@ -101,14 +115,14 @@ export class ParadiseFishTop extends Goal {
|
|
|
101
115
|
|
|
102
116
|
private strangerAvoidTargets(visible: PlayerInfo[], ctx: StrategyContext): PlayerInfo[] {
|
|
103
117
|
if (visible.some(p => this.isTrusted(p, ctx))) return [];
|
|
104
|
-
const nonBad = visible.filter(p => !this.
|
|
118
|
+
const nonBad = visible.filter(p => !this.isHostile(p, ctx));
|
|
105
119
|
if (nonBad.length >= WITNESS_EXEMPT_COUNT) return [];
|
|
106
|
-
return visible.filter(p => !this.isTrusted(p, ctx) && !this.
|
|
120
|
+
return visible.filter(p => !this.isTrusted(p, ctx) && !this.isHostile(p, ctx));
|
|
107
121
|
}
|
|
108
122
|
|
|
109
123
|
private visibleAvoidTargets(state: GameState, ctx: StrategyContext): PlayerInfo[] {
|
|
110
124
|
const visible = nonTeammatesVisible(state, ctx);
|
|
111
|
-
const threats = visible.filter(p => this.
|
|
125
|
+
const threats = visible.filter(p => this.isHostile(p, ctx));
|
|
112
126
|
return threats.length > 0 ? threats : this.strangerAvoidTargets(visible, ctx);
|
|
113
127
|
}
|
|
114
128
|
|
|
@@ -132,7 +146,7 @@ export class ParadiseFishTop extends Goal {
|
|
|
132
146
|
this.recentAvoidPoints.delete(key);
|
|
133
147
|
continue;
|
|
134
148
|
}
|
|
135
|
-
const threat = this.
|
|
149
|
+
const threat = this.isHostile(p, ctx);
|
|
136
150
|
if (!threat && !avoidNonThreat) {
|
|
137
151
|
this.recentAvoidPoints.delete(key);
|
|
138
152
|
continue;
|
|
@@ -183,7 +197,10 @@ export class ParadiseFishTop extends Goal {
|
|
|
183
197
|
|
|
184
198
|
const room = state.you.room ?? '未知';
|
|
185
199
|
let msg = `[进度] 当前在${room}`;
|
|
186
|
-
if (tier === '
|
|
200
|
+
if (tier === 'emergency') {
|
|
201
|
+
const name = ctx.emergency?.task_name ?? '紧急维修';
|
|
202
|
+
msg += `,残局仅剩${state.alive_count}人,抢着去做紧急任务「${name}」,阻止蟹靠破坏倒计时取胜。`;
|
|
203
|
+
} else if (tier === 'corpse') {
|
|
187
204
|
// corpseAtScene=已贴近尸体(≤150px);仅凭记忆走向尸体房间、人还没到时别谎报「在尸体附近游走」。
|
|
188
205
|
if (!corpseAtScene(state)) {
|
|
189
206
|
msg += ',记得有尸体,正前往尸体处(不报警)。';
|
|
@@ -193,7 +210,7 @@ export class ParadiseFishTop extends Goal {
|
|
|
193
210
|
: ',发现尸体,附近无人,贴着尸体游走制造嫌疑(不报警)。';
|
|
194
211
|
}
|
|
195
212
|
} else if (tier === 'flee-bad') {
|
|
196
|
-
const names = visible.filter(p => this.
|
|
213
|
+
const names = visible.filter(p => this.isHostile(p, ctx)).map(p => p.name).join('、');
|
|
197
214
|
msg += `,发现认定带刀坏人${names},正在远离。`;
|
|
198
215
|
} else if (tier === 'keep-distance') {
|
|
199
216
|
msg += `,附近有${visible.length}人但无可信同伴,保持距离中。`;
|
|
@@ -29,7 +29,7 @@ function state(): GameState {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
function knowledge(mark: '
|
|
32
|
+
function knowledge(mark: 'hostile' | 'trusted') {
|
|
33
33
|
const ts = Date.now();
|
|
34
34
|
const file: KnowledgeFile = {
|
|
35
35
|
version: 1,
|
|
@@ -68,10 +68,11 @@ function context(overrides: Partial<StrategyContext> = {}): StrategyContext {
|
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
describe('WarriorShrimpTop knowledge tiers', () => {
|
|
71
|
-
it('
|
|
71
|
+
it('keeps distance from an unmarked (suspected-by-default) player even when the weapon is ready', () => {
|
|
72
72
|
const top = new WarriorShrimpTop();
|
|
73
73
|
|
|
74
|
-
|
|
74
|
+
// 不打任何标记:未标记 = 默认被怀疑 → 只保持距离,刀好也不主动出刀。
|
|
75
|
+
top.tick(state(), context());
|
|
75
76
|
|
|
76
77
|
expect(top.subGoal).toBeInstanceOf(KeepAwayGoal);
|
|
77
78
|
});
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import type { GameState, PlayerInfo
|
|
1
|
+
import type { GameState, PlayerInfo } from '../../sdk/types.js';
|
|
2
2
|
import { Action } from '../../sdk/action.js';
|
|
3
|
-
import { planEscape } from '../pathfind/escape-planner.js';
|
|
4
|
-
import { loadWalkableGrid, type WalkableGrid } from '../pathfind/walkable-grid.js';
|
|
5
3
|
import {
|
|
6
4
|
canUseKill,
|
|
7
5
|
corpseAtScene,
|
|
@@ -9,11 +7,9 @@ import {
|
|
|
9
7
|
firstAvailableTask,
|
|
10
8
|
hasKnownCorpse,
|
|
11
9
|
isKnowledgeHostile,
|
|
12
|
-
isKnowledgeThreat,
|
|
13
10
|
isKnowledgeTrusted,
|
|
14
11
|
killCooldownSecs,
|
|
15
12
|
killCommitRange,
|
|
16
|
-
killRangeFor,
|
|
17
13
|
matchesAnyTarget,
|
|
18
14
|
nonTeammatesVisible,
|
|
19
15
|
PROGRESS_INTERVAL_MS,
|
|
@@ -24,7 +20,7 @@ import {
|
|
|
24
20
|
} from '../game-utils.js';
|
|
25
21
|
import type { BehaviorDecision, StrategyContext } from '../types.js';
|
|
26
22
|
import { Goal } from './goal.js';
|
|
27
|
-
import {
|
|
23
|
+
import { KeepAwayGoal, type KeepAwayGoalOptions } from './keep-away-goal.js';
|
|
28
24
|
import { KillVisibleTargetGoal } from './kill-target-goal.js';
|
|
29
25
|
import { SafeTaskOrPatrolGoal } from './safe-task-goal.js';
|
|
30
26
|
|
|
@@ -36,105 +32,57 @@ const WITNESS_EXEMPT_COUNT = 2;
|
|
|
36
32
|
const TASK_RETURN_INERTIA_MS = 2_000;
|
|
37
33
|
const FLEE_KEY = 'warrior-flee';
|
|
38
34
|
const STRANGER_KEY = 'warrior-stranger-distance';
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
// 贴身掠过污染(对方只是顺着走廊转、并非在追我,却累积出大转角)。流程:
|
|
43
|
-
// ① 同一 suspect 连续 JUKE_STREAK 帧「朝我贴身追击」(aimedPursuit:相对上帧位移 ≥ MOVE_EPS 且方向与「指向我」
|
|
44
|
-
// 夹角余弦 ≥ TOWARD_COS;cone 半角≈31.8°)且 planEscape 判定甩不掉 → 被咬住又逃不掉,开始试探;
|
|
45
|
-
// ② 主动横向变一次向(jukeTarget),变向幅度足够大,使「不跟随者」必然掉出 cone;
|
|
46
|
-
// ③ 变向后 JUKE_WINDOW 帧内,若它重新指向我的【新】位置(cone re-entry)= 跟随一次。只认变向【之后】的重新瞄准,
|
|
47
|
-
// 走廊弯曲转过的角度一概不算——直奔固定任务点 / 顺着走廊走的虾不会跟我的横向变向,永远掉出 cone、攒不到跟随。
|
|
48
|
-
// 变向后第 1 帧对方因反应延迟可能短暂掉出 cone,故用 WINDOW 容忍这一帧;窗口内始终不重新瞄准 = 没跟 → 重置。
|
|
49
|
-
// ④ 攒够 JUKE_FOLLOWS 次跟随、且已进 killRangeFor 射程、视线无墙,才出刀(趁 160 射程在合拢阶段先手,蟹只有 80)。
|
|
50
|
-
const SELF_DEFENSE_JUKE_STREAK = 2;
|
|
51
|
-
const SELF_DEFENSE_JUKE_WINDOW = 3;
|
|
52
|
-
const SELF_DEFENSE_JUKE_FOLLOWS = 2;
|
|
53
|
-
const SELF_DEFENSE_MOVE_EPS = 40;
|
|
54
|
-
const SELF_DEFENSE_TOWARD_COS = 0.85;
|
|
55
|
-
// 主动变向试探:横向位移目标距离;方向以横向为主、略带「背离对方」分量以免试探时丢距离;落点至少这么远才算有效变向。
|
|
56
|
-
const SELF_DEFENSE_JUKE_DIST = 170;
|
|
57
|
-
const SELF_DEFENSE_JUKE_LATERAL = 0.85;
|
|
58
|
-
const SELF_DEFENSE_JUKE_AWAY = 0.45;
|
|
59
|
-
const SELF_DEFENSE_JUKE_MIN_MOVE = 60;
|
|
35
|
+
// 尸体现场灭口开关:false=站在尸体旁也绝不因「身边有未报警的身份不明者」先手灭口,只报警(hostile/启动目标仍按 P1 追杀);
|
|
36
|
+
// true=刀可用时先击杀尸体旁最近的非 trusted 非队友。关掉是为根治「把尸体边未报警的无辜虾当凶手灭口」的误杀。
|
|
37
|
+
const CORPSE_SCENE_KILL_ENABLED: boolean = false;
|
|
60
38
|
|
|
61
39
|
type ProgressTier = 'flee-bad' | 'keep-distance' | 'task';
|
|
62
40
|
|
|
63
|
-
/** 单位向量;长度过小(重合)返回 null。 */
|
|
64
|
-
function unitVec(x: number, y: number): { x: number; y: number } | null {
|
|
65
|
-
const m = Math.hypot(x, y);
|
|
66
|
-
if (m < 1e-6) return null;
|
|
67
|
-
return { x: x / m, y: y / m };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** 两点世界坐标连线是否整段可走(无墙)。沿线段每半格采样一次,任一采样点落在墙上即判被挡。 */
|
|
71
|
-
function segmentWalkable(grid: WalkableGrid, ax: number, ay: number, bx: number, by: number): boolean {
|
|
72
|
-
const span = Math.hypot(bx - ax, by - ay);
|
|
73
|
-
const steps = Math.max(1, Math.ceil(span / (grid.tileSize * 0.5)));
|
|
74
|
-
for (let i = 0; i <= steps; i++) {
|
|
75
|
-
const t = i / steps;
|
|
76
|
-
const x = ax + (bx - ax) * t;
|
|
77
|
-
const y = ay + (by - ay) * t;
|
|
78
|
-
if (!grid.isWalkable(Math.floor(x / grid.tileSize), Math.floor(y / grid.tileSize))) return false;
|
|
79
|
-
}
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
41
|
/**
|
|
84
42
|
* 带刀虾·记忆进阶版(武士虾/枪虾,带刀好人)。好人阵营但能出刀,按行为表的优先级逐条判断:
|
|
85
43
|
*
|
|
86
|
-
* - P0
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
44
|
+
* - P0 发现尸体:旁边是 hostile/启动猎杀目标且刀可用 → 现场先手击杀;未报警的身份不明者默认不灭口
|
|
45
|
+
* (CORPSE_SCENE_KILL_ENABLED,根治误杀);否则报警(靠近至可报距离)。
|
|
46
|
+
* - P1 处理危险:**只对【已确认 hostile】(启动参数 / 知识库 hostile)出刀**——刀好就追杀,刀冷就硬躲所有非好人。
|
|
47
|
+
* 其余非 trusted 一律按「被怀疑」处理(未标记 = 默认被怀疑):**只回避、绝不出刀**——无可信同伴且单个被怀疑者
|
|
48
|
+
* 贴近 → 按普通虾 B 档先拉开距离(多人互为目击者则照常做任务)。
|
|
49
|
+
* (历史上的「贴身追击判定 + 诱饵试探 + 绝境自卫反杀」整套已删除:几何上无法把「贴身跟我观察的好人」和「贴身追我的
|
|
50
|
+
* 凶手」区分开,自卫出刀迟早误杀同阵营好人、触发 warrior_shrimp_self_destruct 直接崩盘,代价远大于收益。)
|
|
90
51
|
* - P2 紧急任务:无危险时优先处理。
|
|
91
52
|
* - P3 兜底:做任务 / 巡逻
|
|
92
53
|
* (SafeTaskOrPatrolGoal:测地最近、威胁旁/途经威胁的任务硬排除、带粘性)。
|
|
93
54
|
*
|
|
94
|
-
*
|
|
55
|
+
* 谁算「坏人」「可信同伴」来自 ctx.knowledge(见 warrior-memory.knowledge.md),其余默认被怀疑;
|
|
95
56
|
* 队友由游戏事实判定(nonTeammatesVisible),知识库只提供推断。
|
|
96
57
|
*/
|
|
97
58
|
export class WarriorShrimpTop extends Goal {
|
|
98
59
|
private readonly taskGoal = new SafeTaskOrPatrolGoal(
|
|
99
|
-
// 威胁点 =
|
|
60
|
+
// 威胁点 = 坏人(始终算),或未被目击者豁免的被怀疑者;可信同伴不算。
|
|
100
61
|
(s, c) => nonTeammatesVisible(s, c)
|
|
101
62
|
.filter(p => !this.isTrusted(p, c))
|
|
102
|
-
.filter(p => this.
|
|
63
|
+
.filter(p => this.isHuntTarget(p, c) || !this.witnessExempt)
|
|
103
64
|
.map(p => ({ x: p.x, y: p.y })),
|
|
104
65
|
);
|
|
105
66
|
private readonly strangerSeenAt = new Map<string, number>();
|
|
106
67
|
private witnessExempt = false;
|
|
107
|
-
/** 自卫:当前被判定在追我的 suspect key、它上一帧坐标、连续「朝我贴身追击」帧数(决定何时开始试探)、
|
|
108
|
-
* 变向后等待对方跟随的剩余帧数(0=未在等)、发起变向那刻我的坐标(验证跟随用)、已验证的跟随次数、
|
|
109
|
-
* 本轮是否已推过自卫简报。 */
|
|
110
|
-
private selfDefenseTargetKey: string | null = null;
|
|
111
|
-
private selfDefenseSuspectPrev: { x: number; y: number } | null = null;
|
|
112
|
-
private selfDefenseStreak = 0;
|
|
113
|
-
private selfDefenseJukeWatch = 0;
|
|
114
|
-
private selfDefenseJukeFromPos: { x: number; y: number } | null = null;
|
|
115
|
-
private selfDefenseJukeFollows = 0;
|
|
116
|
-
private selfDefenseAlerted = false;
|
|
117
68
|
|
|
118
69
|
constructor(private readonly huntTargets: string[] = []) {
|
|
119
70
|
super();
|
|
120
71
|
}
|
|
121
72
|
|
|
122
|
-
/** warrior-memory 开会后不重建 Top(resetOnMeetingResume:false);自卫追击计数按「连续游荡」语义,
|
|
123
|
-
* 开会是天然中断点,恢复后从零重算,避免拿会议前的追击 streak 一恢复就秒杀。 */
|
|
124
|
-
onMeetingResume(): void {
|
|
125
|
-
this.resetSelfDefense();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
73
|
tick(state: GameState, ctx: StrategyContext): BehaviorDecision[] {
|
|
129
74
|
const visible = nonTeammatesVisible(state, ctx);
|
|
130
75
|
this.updateWitnessMemory(visible, ctx);
|
|
131
76
|
const killReady = canUseKill(state);
|
|
132
77
|
|
|
133
78
|
// ── P0 发现尸体 ──
|
|
134
|
-
//
|
|
135
|
-
// 否则会变成随便撞见一个人就灭口。
|
|
79
|
+
// 只在「此刻就在命案现场」(当帧视野有尸体)时考虑现场出刀——记忆里某处有尸体不算现场。
|
|
136
80
|
if (corpseAtScene(state) && killReady) {
|
|
137
|
-
|
|
81
|
+
// 尸体旁的【已确认敌对 / 启动猎杀目标】始终先手击杀,不受灭口开关影响、且排在报尸之前——凶手就在身边时照杀。
|
|
82
|
+
// 仅「未报警的身份不明者」(非 trusted、非 hostile)才受 CORPSE_SCENE_KILL_ENABLED 控制:默认关,
|
|
83
|
+
// 根治「把尸体边未报警的无辜虾当凶手灭口」的误杀。
|
|
84
|
+
const victim = this.nearestKillable(state, ctx, visible, true)
|
|
85
|
+
?? (CORPSE_SCENE_KILL_ENABLED ? this.nearestKillable(state, ctx, visible, false) : null);
|
|
138
86
|
if (victim) {
|
|
139
87
|
this.clearSub();
|
|
140
88
|
return [{ action: Action.kill(victim.name) }];
|
|
@@ -149,36 +97,32 @@ export class WarriorShrimpTop extends Goal {
|
|
|
149
97
|
}
|
|
150
98
|
}
|
|
151
99
|
|
|
152
|
-
// ── P1
|
|
153
|
-
const threats = visible.filter(p => this.
|
|
100
|
+
// ── P1 处理危险:非 trusted 即潜在威胁(坏人 + 被怀疑) ──
|
|
101
|
+
const threats = visible.filter(p => !this.isTrusted(p, ctx));
|
|
154
102
|
if (threats.length > 0) {
|
|
155
103
|
const huntTargets = threats.filter(p => this.isHuntTarget(p, ctx));
|
|
104
|
+
// P1-A 坏人/启动目标且刀好 → 主动追杀。
|
|
156
105
|
if (killReady && huntTargets.length > 0) {
|
|
157
|
-
this.resetSelfDefense();
|
|
158
106
|
this.setHunt(this.nearestByDistance(state, huntTargets).name);
|
|
159
107
|
return [];
|
|
160
108
|
}
|
|
161
|
-
// 只剩 suspect、本应只回避;但若连续多帧确认同一个在朝我贴身追击且避让算法判定避不开,就主动横向变向试探,
|
|
162
|
-
// 只有它每次都跟着我的变向重新咬住(攒够跟随次数)、且已进 160 射程、视线无墙,才自卫先下手(趁 reach 优势在合拢阶段先手)+ Agent 自卫简报。
|
|
163
|
-
const selfDefense = this.selfDefenseKill(state, ctx, threats, killReady);
|
|
164
|
-
if (selfDefense) return selfDefense;
|
|
165
109
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
110
|
+
// P1-B 有坏人/启动目标但刀冷(杀不了)→ 硬躲所有非好人。
|
|
111
|
+
if (huntTargets.length > 0) {
|
|
112
|
+
this.taskGoal.planTask(state, ctx, { holdUnsafeCurrentForMs: TASK_RETURN_INERTIA_MS });
|
|
113
|
+
this.setFlee();
|
|
114
|
+
this.emitProgress(state, ctx, visible, 'flee-bad');
|
|
115
|
+
return [];
|
|
116
|
+
}
|
|
172
117
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
118
|
+
// P1-C 只剩被怀疑者(无已确认坏人):无可信同伴且单个贴近、且未被目击者豁免 → 按普通虾 B 档拉开距离(只回避,绝不出刀);
|
|
119
|
+
// 多个被怀疑者互为目击者(witnessExempt)则不后撤,落到下面照常做任务。
|
|
120
|
+
const trustedVisible = visible.some(p => this.isTrusted(p, ctx));
|
|
176
121
|
const worker = this.subGoal;
|
|
177
|
-
const
|
|
178
|
-
|
|
179
|
-
&& (p.distance ?? dist(p.x, p.y, state.you.x, state.you.y)) <= STRANGER_TRIGGER_RADIUS);
|
|
122
|
+
const suspectedClose = threats.some(p =>
|
|
123
|
+
(p.distance ?? dist(p.x, p.y, state.you.x, state.you.y)) <= STRANGER_TRIGGER_RADIUS);
|
|
180
124
|
const stillBackingOff = worker instanceof KeepAwayGoal && worker.key === STRANGER_KEY && !worker.isFinish(state, ctx);
|
|
181
|
-
if (!this.witnessExempt && (
|
|
125
|
+
if (!trustedVisible && !this.witnessExempt && (suspectedClose || stillBackingOff)) {
|
|
182
126
|
this.taskGoal.planTask(state, ctx, { holdUnsafeCurrentForMs: TASK_RETURN_INERTIA_MS });
|
|
183
127
|
this.setStrangerKeepAway();
|
|
184
128
|
this.emitProgress(state, ctx, visible, 'keep-distance');
|
|
@@ -199,11 +143,11 @@ export class WarriorShrimpTop extends Goal {
|
|
|
199
143
|
return this.taskGoal.tick(state, ctx);
|
|
200
144
|
}
|
|
201
145
|
|
|
202
|
-
/** 目击者豁免:当前只按本轮可见玩家判断,见到 2
|
|
146
|
+
/** 目击者豁免:当前只按本轮可见玩家判断,见到 2 个以上被怀疑者时不对其后撤(多人互为目击者,蟹不敢当众动手)。 */
|
|
203
147
|
private updateWitnessMemory(visible: PlayerInfo[], ctx: StrategyContext): void {
|
|
204
148
|
const now = Date.now();
|
|
205
149
|
for (const p of visible) {
|
|
206
|
-
if (!this.
|
|
150
|
+
if (!this.isSuspected(p, ctx)) continue;
|
|
207
151
|
const key = p.name || String(p.seat ?? '');
|
|
208
152
|
if (key) this.strangerSeenAt.set(key, now);
|
|
209
153
|
}
|
|
@@ -213,8 +157,9 @@ export class WarriorShrimpTop extends Goal {
|
|
|
213
157
|
this.witnessExempt = this.strangerSeenAt.size >= WITNESS_EXEMPT_COUNT;
|
|
214
158
|
}
|
|
215
159
|
|
|
216
|
-
|
|
217
|
-
|
|
160
|
+
/** 被怀疑者:非 trusted(好人)且非坏人/启动目标——未标记的默认就落这档,对应 B 档保持距离(只回避、绝不出刀)。 */
|
|
161
|
+
private isSuspected(p: PlayerInfo, ctx: StrategyContext): boolean {
|
|
162
|
+
return !this.isTrusted(p, ctx) && !this.isHuntTarget(p, ctx);
|
|
218
163
|
}
|
|
219
164
|
|
|
220
165
|
/** 知识里 trusted 的玩家:可信同伴,永不击杀。 */
|
|
@@ -222,22 +167,28 @@ export class WarriorShrimpTop extends Goal {
|
|
|
222
167
|
return isKnowledgeTrusted(p, ctx);
|
|
223
168
|
}
|
|
224
169
|
|
|
225
|
-
/**
|
|
170
|
+
/** 坏人 / 明确猎杀目标:启动参数或知识库 hostile;被怀疑者不在这里。 */
|
|
226
171
|
private isHuntTarget(p: PlayerInfo, ctx: StrategyContext): boolean {
|
|
227
172
|
return !this.isTrusted(p, ctx)
|
|
228
173
|
&& (matchesAnyTarget(p, this.huntTargets, ctx) || isKnowledgeHostile(p, ctx));
|
|
229
174
|
}
|
|
230
175
|
|
|
231
|
-
/**
|
|
176
|
+
/** 潜在威胁 = 任何非 trusted(坏人 + 被怀疑);刀冷遇坏人时硬躲这一整组。 */
|
|
232
177
|
private isThreat(p: PlayerInfo, ctx: StrategyContext): boolean {
|
|
233
|
-
return !this.isTrusted(p, ctx)
|
|
234
|
-
&& (this.isHuntTarget(p, ctx) || isKnowledgeThreat(p, ctx));
|
|
178
|
+
return !this.isTrusted(p, ctx);
|
|
235
179
|
}
|
|
236
180
|
|
|
237
|
-
/**
|
|
238
|
-
|
|
181
|
+
/** 尸体场景出刀目标 = 视野内最近、在出刀范围内的非 trusted 非队友。hostileOnly=true 只取已确认敌对/启动猎杀目标
|
|
182
|
+
* (hostile / hunt 参数),用于「尸体旁敌对照杀、不受灭口开关限制」;false 含未报警的身份不明者(受开关控制)。 */
|
|
183
|
+
private nearestKillable(
|
|
184
|
+
state: GameState,
|
|
185
|
+
ctx: StrategyContext,
|
|
186
|
+
visible: PlayerInfo[],
|
|
187
|
+
hostileOnly: boolean,
|
|
188
|
+
): PlayerInfo | null {
|
|
239
189
|
return visible
|
|
240
190
|
.filter(p => !this.isTrusted(p, ctx))
|
|
191
|
+
.filter(p => !hostileOnly || this.isHuntTarget(p, ctx))
|
|
241
192
|
.map(p => ({ p, d: p.distance ?? dist(state.you.x, state.you.y, p.x, p.y) }))
|
|
242
193
|
.filter(x => x.d <= killCommitRange(state.you.role))
|
|
243
194
|
.sort((a, b) => a.d - b.d)[0]?.p ?? null;
|
|
@@ -249,191 +200,6 @@ export class WarriorShrimpTop extends Goal {
|
|
|
249
200
|
.sort((a, b) => a.d - b.d)[0].p;
|
|
250
201
|
}
|
|
251
202
|
|
|
252
|
-
/**
|
|
253
|
-
* 自卫击杀 / 变向试探:只处理「只剩 suspect、本应只回避」的情形(hostile 在上面已优先追杀)。出刀只能由
|
|
254
|
-
* 「主动变向 + 验证对方跟随」达成,绝不靠被动转角/方位,避免「对方只是顺着走廊转、并非在追我」被误判。
|
|
255
|
-
* 每帧:
|
|
256
|
-
* ① aimedPursuit 判定本帧是否「朝我贴身追击」,维护连续帧数(变向等待期内的一帧不朝我是预期的反应延迟,先容忍)。
|
|
257
|
-
* ② 若处在变向等待期:它重新指向我的新位置 = 跟随一次(攒一次);窗口内始终不重新瞄准 = 没跟 → 重置。
|
|
258
|
-
* ③ 攒够 SELF_DEFENSE_JUKE_FOLLOWS 次跟随、已进 killRangeFor 射程、planEscape 判定甩不掉、视线无墙 → 出刀,
|
|
259
|
-
* 并给 Agent 推一条「被动自卫」简报(区别于主动猎杀,免得之后发言/投票露馅)。
|
|
260
|
-
* ④ 否则若已被贴身追够 JUKE_STREAK 帧、甩不掉、且不在等待期 → 主动横向变一次向逼它暴露(窄道无处可变才交回常规逃跑)。
|
|
261
|
-
*
|
|
262
|
-
* 趁 reach 优势:武士虾出刀范围(160)远大于蟹(80),确认在追后在合拢阶段先手,而不是等贴脸拼手速。出刀确认前
|
|
263
|
-
* 不清零追击状态——空刀(极端情况)下进度不该白丢;真杀掉后对方消失,下一帧威胁清空自然重置。
|
|
264
|
-
*/
|
|
265
|
-
private selfDefenseKill(
|
|
266
|
-
state: GameState,
|
|
267
|
-
ctx: StrategyContext,
|
|
268
|
-
threats: PlayerInfo[],
|
|
269
|
-
killReady: boolean,
|
|
270
|
-
): BehaviorDecision[] | null {
|
|
271
|
-
if (!SELF_DEFENSE_ENABLED) return null; // 开关关闭:直接回退到「只回避」,不进入任何试探/出刀逻辑。
|
|
272
|
-
const suspects = threats.filter(p => !this.isHuntTarget(p, ctx));
|
|
273
|
-
if (suspects.length === 0) {
|
|
274
|
-
this.resetSelfDefense();
|
|
275
|
-
return null;
|
|
276
|
-
}
|
|
277
|
-
const nearest = this.nearestByDistance(state, suspects);
|
|
278
|
-
const aimed = this.aimedPursuit(state, nearest);
|
|
279
|
-
|
|
280
|
-
if (!killReady) return null;
|
|
281
|
-
|
|
282
|
-
// 维护「朝我贴身追击」连续帧数(决定何时开始试探)。某帧不再朝我 = 追击中断,清零进度但【保留当前目标身份】
|
|
283
|
-
// 继续跟它(softResetPursuit,不是 resetSelfDefense——后者会把目标也丢掉、下一帧又当「第一次见到」永远攒不起来)。
|
|
284
|
-
// 例外:变向等待期内的一帧不朝我是预期的反应延迟,先容忍不清零。
|
|
285
|
-
if (aimed) {
|
|
286
|
-
this.selfDefenseStreak++;
|
|
287
|
-
} else if (this.selfDefenseJukeWatch === 0) {
|
|
288
|
-
this.softResetPursuit();
|
|
289
|
-
return null;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
// 变向等待期:它重新指向我的【新】位置 = 跟随一次。但必须等我相对变向起点真的横向拉开够远
|
|
293
|
-
// (jukeFollowed:站在对方位置看,「我变向前」与「我现在」已分得比 cone 还开)才算数——否则我变向移动还没生效、
|
|
294
|
-
// 或位移太小直线仍落在 cone 内时,会把「持续朝旧/当前位置走」误判成「响应我变向重新咬住」。窗口内始终凑不出
|
|
295
|
-
// 一次有效跟随 = 没跟(不是在追我)→ 清零进度重新观察。
|
|
296
|
-
if (this.selfDefenseJukeWatch > 0) {
|
|
297
|
-
if (aimed && this.jukeFollowed(state, nearest)) {
|
|
298
|
-
this.selfDefenseJukeFollows++;
|
|
299
|
-
this.selfDefenseJukeWatch = 0;
|
|
300
|
-
} else if (--this.selfDefenseJukeWatch === 0) {
|
|
301
|
-
this.softResetPursuit();
|
|
302
|
-
return null;
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
const hopeless = this.escapeHopeless(state, threats);
|
|
307
|
-
const d = nearest.distance ?? dist(state.you.x, state.you.y, nearest.x, nearest.y);
|
|
308
|
-
if (
|
|
309
|
-
this.selfDefenseJukeFollows >= SELF_DEFENSE_JUKE_FOLLOWS
|
|
310
|
-
&& d <= killRangeFor(state.you.role)
|
|
311
|
-
&& hopeless
|
|
312
|
-
&& this.hasShotLine(state, nearest)
|
|
313
|
-
) {
|
|
314
|
-
this.clearSub();
|
|
315
|
-
if (!this.selfDefenseAlerted) {
|
|
316
|
-
this.selfDefenseAlerted = true;
|
|
317
|
-
ctx.notifications.push(`连续确认被${nearest.name}贴身追击、变向试探它每次都跟着咬住、退无可退,自卫先手出刀。`);
|
|
318
|
-
ctx.agentAlerts.push(
|
|
319
|
-
`我被${nearest.name}持续贴身追击、几次变向试探它都跟着甩不掉、已被逼到退无可退,刚出于自卫先下手把对方击杀了。`
|
|
320
|
-
+ `这是被动自卫不是主动猎杀:接下来发言/投票按「对方一直追着我跑、我被逼到死角才自保」的口径走,别承认无故先手。`,
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
return [{ action: Action.kill(nearest.name) }];
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// 还没攒够跟随:被贴身追够、甩不掉、且不在等待期时,主动横向变一次向逼它暴露。无处可变(窄道)才交回常规逃跑。
|
|
327
|
-
if (this.selfDefenseStreak >= SELF_DEFENSE_JUKE_STREAK && this.selfDefenseJukeWatch === 0 && hopeless) {
|
|
328
|
-
const juke = this.jukeTarget(state, nearest);
|
|
329
|
-
if (juke) {
|
|
330
|
-
this.selfDefenseJukeWatch = SELF_DEFENSE_JUKE_WINDOW;
|
|
331
|
-
this.selfDefenseJukeFromPos = { x: state.you.x, y: state.you.y };
|
|
332
|
-
this.clearSub();
|
|
333
|
-
return [{ action: Action.move(juke).withThinking('换个方向甩开') }];
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
return null;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
/**
|
|
340
|
-
* 变向跟随是否成立:站在 suspect 当前位置看,「我发起变向那刻的位置」与「我现在的位置」的夹角已超出 cone
|
|
341
|
-
* (半角≈31.8°)。成立才说明我确实横向拉开够远——此时它仍朝我(aimed)= 它跟着我的变向重新瞄准了;
|
|
342
|
-
* 直奔我变向前位置/顺着走廊直走的虾此刻必然落在 cone 外、aimed 不成立,不会被算作跟随。
|
|
343
|
-
*/
|
|
344
|
-
private jukeFollowed(state: GameState, suspect: PlayerInfo): boolean {
|
|
345
|
-
const from = this.selfDefenseJukeFromPos;
|
|
346
|
-
if (!from) return false;
|
|
347
|
-
const toFrom = unitVec(from.x - suspect.x, from.y - suspect.y);
|
|
348
|
-
const toNow = unitVec(state.you.x - suspect.x, state.you.y - suspect.y);
|
|
349
|
-
if (!toFrom || !toNow) return false;
|
|
350
|
-
return toFrom.x * toNow.x + toFrom.y * toNow.y < SELF_DEFENSE_TOWARD_COS;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* 本帧同一 suspect 是否「朝我贴身追击」:相对上一帧位移 ≥ MOVE_EPS(确实在动,排除站桩做任务)且位移方向
|
|
355
|
-
* 与「指向我当前位置」夹角余弦 ≥ TOWARD_COS(朝我来;cone 半角≈31.8°)。换目标时整体重置并返回 false。
|
|
356
|
-
* 只读对方位移与「指向我」的关系,参考点一致;不累计任何转角(转角会被走廊弯曲污染,确认改由变向跟随负责)。
|
|
357
|
-
*/
|
|
358
|
-
private aimedPursuit(state: GameState, nearest: PlayerInfo): boolean {
|
|
359
|
-
const key = nearest.name || String(nearest.seat ?? '');
|
|
360
|
-
const curS = { x: nearest.x, y: nearest.y };
|
|
361
|
-
if (key !== this.selfDefenseTargetKey) {
|
|
362
|
-
this.resetSelfDefense();
|
|
363
|
-
this.selfDefenseTargetKey = key;
|
|
364
|
-
this.selfDefenseSuspectPrev = curS;
|
|
365
|
-
return false;
|
|
366
|
-
}
|
|
367
|
-
const sPrev = this.selfDefenseSuspectPrev;
|
|
368
|
-
this.selfDefenseSuspectPrev = curS;
|
|
369
|
-
if (!sPrev) return false;
|
|
370
|
-
|
|
371
|
-
const heading = unitVec(curS.x - sPrev.x, curS.y - sPrev.y);
|
|
372
|
-
const aim = unitVec(state.you.x - sPrev.x, state.you.y - sPrev.y);
|
|
373
|
-
const movedFar = dist(sPrev.x, sPrev.y, curS.x, curS.y) >= SELF_DEFENSE_MOVE_EPS;
|
|
374
|
-
return !!heading && !!aim && movedFar
|
|
375
|
-
&& heading.x * aim.x + heading.y * aim.y >= SELF_DEFENSE_TOWARD_COS;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
/** planEscape 判定每条逃跑分支都会在推演内被追上(避不开);用与 KeepAwayGoal 一致的基线参数。 */
|
|
379
|
-
private escapeHopeless(state: GameState, threats: PlayerInfo[]): boolean {
|
|
380
|
-
const threatPoints = threats.map(p => ({ x: p.x, y: p.y }));
|
|
381
|
-
return planEscape(state.you, threatPoints, KEEP_AWAY_BASE_PLAN_OPTS).caught;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
/** 我到目标的连线是否无墙——确认了也别对着墙空刀(target_blocked_by_wall)。 */
|
|
385
|
-
private hasShotLine(state: GameState, target: PlayerInfo): boolean {
|
|
386
|
-
return segmentWalkable(loadWalkableGrid(), state.you.x, state.you.y, target.x, target.y);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
/**
|
|
390
|
-
* 主动变向试探的落点:垂直于「背离 suspect」轴的横向点(略带背离分量以免丢距离),取两侧中离 suspect 更远、
|
|
391
|
-
* 且我到落点整段无墙的一侧。两侧都不可走 / 反而明显贴近 suspect(窄道、贴墙)时返回 null,交回常规逃跑。
|
|
392
|
-
*/
|
|
393
|
-
private jukeTarget(state: GameState, suspect: PlayerInfo): Position | null {
|
|
394
|
-
const grid = loadWalkableGrid();
|
|
395
|
-
const me = state.you;
|
|
396
|
-
const curSep = dist(me.x, me.y, suspect.x, suspect.y);
|
|
397
|
-
const away = unitVec(me.x - suspect.x, me.y - suspect.y) ?? { x: 1, y: 0 };
|
|
398
|
-
const sides = [{ x: -away.y, y: away.x }, { x: away.y, y: -away.x }];
|
|
399
|
-
let best: { target: Position; sep: number } | null = null;
|
|
400
|
-
for (const perp of sides) {
|
|
401
|
-
const dir = unitVec(
|
|
402
|
-
perp.x * SELF_DEFENSE_JUKE_LATERAL + away.x * SELF_DEFENSE_JUKE_AWAY,
|
|
403
|
-
perp.y * SELF_DEFENSE_JUKE_LATERAL + away.y * SELF_DEFENSE_JUKE_AWAY,
|
|
404
|
-
);
|
|
405
|
-
if (!dir) continue;
|
|
406
|
-
const raw = { x: me.x + dir.x * SELF_DEFENSE_JUKE_DIST, y: me.y + dir.y * SELF_DEFENSE_JUKE_DIST };
|
|
407
|
-
const cell = grid.snapToWalkable(grid.worldToCell(raw.x, raw.y), 6);
|
|
408
|
-
if (cell < 0) continue;
|
|
409
|
-
const target = grid.cellToWorld(cell);
|
|
410
|
-
if (dist(me.x, me.y, target.x, target.y) < SELF_DEFENSE_JUKE_MIN_MOVE) continue;
|
|
411
|
-
if (!segmentWalkable(grid, me.x, me.y, target.x, target.y)) continue;
|
|
412
|
-
const sep = dist(target.x, target.y, suspect.x, suspect.y);
|
|
413
|
-
if (!best || sep > best.sep) best = { target, sep };
|
|
414
|
-
}
|
|
415
|
-
// 不往 suspect 身上凑:最优侧也比当前明显更近就放弃变向(交回常规逃跑)。
|
|
416
|
-
if (best && best.sep < curSep - SELF_DEFENSE_JUKE_MIN_MOVE) return null;
|
|
417
|
-
return best?.target ?? null;
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
/** 追击中断(某帧不再朝我 / 变向窗口内没凑出有效跟随):清零追击进度,但【保留当前目标身份与上一帧坐标】,
|
|
421
|
-
* 它若重新咬住可继续累计——区别于 resetSelfDefense 连目标一起丢(那样下一帧又当「第一次见到」永远攒不起来)。 */
|
|
422
|
-
private softResetPursuit(): void {
|
|
423
|
-
this.selfDefenseStreak = 0;
|
|
424
|
-
this.selfDefenseJukeWatch = 0;
|
|
425
|
-
this.selfDefenseJukeFromPos = null;
|
|
426
|
-
this.selfDefenseJukeFollows = 0;
|
|
427
|
-
this.selfDefenseAlerted = false;
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/** 整体重置:连当前追击目标身份一起丢(换目标、目标消失、开会、转入主动猎杀时用)。 */
|
|
431
|
-
private resetSelfDefense(): void {
|
|
432
|
-
this.selfDefenseTargetKey = null;
|
|
433
|
-
this.selfDefenseSuspectPrev = null;
|
|
434
|
-
this.softResetPursuit();
|
|
435
|
-
}
|
|
436
|
-
|
|
437
203
|
private setHunt(targetName: string): void {
|
|
438
204
|
const worker = this.subGoal;
|
|
439
205
|
if (worker instanceof KillVisibleTargetGoal && worker.targetName === targetName) return;
|
|
@@ -448,7 +214,8 @@ export class WarriorShrimpTop extends Goal {
|
|
|
448
214
|
this.setSubGoal(new KeepAwayGoal(
|
|
449
215
|
FLEE_KEY,
|
|
450
216
|
(s, c) => nonTeammatesVisible(s, c).filter(p => this.isThreat(p, c)),
|
|
451
|
-
|
|
217
|
+
// 行为不变(仍躲所有非 trusted);措辞按真实身份逐个标注,免得把一起躲的被怀疑者也叫成「认定坏人」。
|
|
218
|
+
{ threatRadius: Infinity, noun: (p, c) => this.isHuntTarget(p, c) ? '认定坏人' : '被怀疑者' } satisfies KeepAwayGoalOptions,
|
|
452
219
|
), SUB_PRIORITY);
|
|
453
220
|
}
|
|
454
221
|
|
|
@@ -458,10 +225,10 @@ export class WarriorShrimpTop extends Goal {
|
|
|
458
225
|
if (this.subGoal) this.removeSubGoal();
|
|
459
226
|
this.setSubGoal(new KeepAwayGoal(
|
|
460
227
|
STRANGER_KEY,
|
|
461
|
-
(s, c) => nonTeammatesVisible(s, c).filter(p => this.
|
|
228
|
+
(s, c) => nonTeammatesVisible(s, c).filter(p => this.isSuspected(p, c)),
|
|
462
229
|
{
|
|
463
230
|
threatRadius: STRANGER_RELEASE_RADIUS,
|
|
464
|
-
noun: '
|
|
231
|
+
noun: '被怀疑者',
|
|
465
232
|
planOpts: { steps: 4 },
|
|
466
233
|
} satisfies KeepAwayGoalOptions,
|
|
467
234
|
), SUB_PRIORITY);
|
|
@@ -484,11 +251,11 @@ export class WarriorShrimpTop extends Goal {
|
|
|
484
251
|
if (visible.length === 0) {
|
|
485
252
|
msg += ',附近无人,做任务/巡逻。';
|
|
486
253
|
} else if (tier === 'keep-distance') {
|
|
487
|
-
msg += '
|
|
254
|
+
msg += ',被怀疑者靠得太近,先拉开距离再做任务。';
|
|
488
255
|
} else {
|
|
489
|
-
const bad = visible.filter(p => this.
|
|
490
|
-
if (bad.length > 0) msg +=
|
|
491
|
-
else if (this.witnessExempt) msg += `,附近有${visible.length}
|
|
256
|
+
const bad = visible.filter(p => this.isHuntTarget(p, ctx)).map(p => p.name);
|
|
257
|
+
if (bad.length > 0) msg += `,发现坏人${bad.join('、')}`;
|
|
258
|
+
else if (this.witnessExempt) msg += `,附近有${visible.length}个被怀疑者互为目击者,正常做任务`;
|
|
492
259
|
else msg += `,附近有${visible.length}人,正常做任务`;
|
|
493
260
|
if (tier === 'flee-bad') msg += killCooldownSecs(state) > 0 ? ',刀在冷却,正在回避' : ',正在处理';
|
|
494
261
|
if (cd > 0) msg += `(攻击冷却${cd}s)`;
|