@myclaw163/clawclaw-cli 0.8.39 → 0.8.41

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.
@@ -4,19 +4,18 @@ import {
4
4
  type ReactionResult,
5
5
  } from '@myclaw163/clawclaw-cli/perception-plugin';
6
6
 
7
- // Demonstration only: proximity is a visible fact, not proof that a player is hostile.
7
+ // 教学规则:靠近不代表敌意;撤离点需先在当前地图中验证。
8
8
  export default class NearbyEscape extends ClawclawReaction {
9
9
  static readonly manifest = {
10
10
  apiVersion: 2,
11
11
  kind: 'reaction',
12
12
  id: 'nearby_escape',
13
- description: '可见玩家靠近时记录一次提醒,并请求已装配的逃离策略。',
13
+ description: '可见玩家靠近时记录通知,并请求前往已配置的撤离点。',
14
14
  consumes: [],
15
15
  produces: ['reaction.player_close'],
16
16
  behaviors: {
17
17
  escape: {
18
- name: 'escape',
19
- // resourceId: 'optional-preferred-hub-resource-id',
18
+ name: 'community.go-to-point',
20
19
  layer: 'reflex',
21
20
  reflexPriority: 10,
22
21
  cooldownMs: 3000,
@@ -24,8 +23,12 @@ export default class NearbyEscape extends ClawclawReaction {
24
23
  maxRuntimeMs: 10000,
25
24
  },
26
25
  },
27
- inputs: [{ id: 'distance', type: 'number', description: '靠近阈值,单位像素。', default: 160 }],
28
- config: { distance: 160 },
26
+ inputs: [
27
+ { id: 'distance', type: 'number', description: '靠近阈值,单位像素。', default: 160 },
28
+ { id: 'retreatX', type: 'number', description: '撤离点 X 坐标。', default: 640 },
29
+ { id: 'retreatY', type: 'number', description: '撤离点 Y 坐标。', default: 360 },
30
+ ],
31
+ config: { distance: 160, retreatX: 640, retreatY: 360 },
29
32
  } as const;
30
33
 
31
34
  evaluate(input: Readonly<ReactionInput>): ReactionResult {
@@ -41,9 +44,13 @@ export default class NearbyEscape extends ClawclawReaction {
41
44
  type: 'reaction.player_close',
42
45
  key: `close:${input.gameState!.tick}`,
43
46
  wakeAgent: false,
44
- payload: { text: '有可见玩家靠近,已请求自动逃离。' },
47
+ payload: { text: '有可见玩家靠近,触发撤离规则。' },
48
+ }] : [],
49
+ activations: close ? [{
50
+ behavior: 'escape',
51
+ input: { x: Number(input.config.retreatX), y: Number(input.config.retreatY) },
52
+ reason: 'visible_player_close',
45
53
  }] : [],
46
- activations: close ? [{ behavior: 'escape', reason: 'visible_player_close' }] : [],
47
54
  };
48
55
  }
49
56
  }
@@ -0,0 +1,36 @@
1
+ import {
2
+ ClawclawReaction,
3
+ type ReactionInput,
4
+ type ReactionResult,
5
+ } from '@myclaw163/clawclaw-cli/perception-plugin';
6
+
7
+ export default class NearbyNotice extends ClawclawReaction {
8
+ static readonly manifest = {
9
+ apiVersion: 2,
10
+ kind: 'reaction',
11
+ id: 'nearby_notice',
12
+ description: '其他可见玩家靠近时记录一条通知。',
13
+ consumes: [],
14
+ produces: ['reaction.player_close'],
15
+ inputs: [{ id: 'distance', type: 'number', description: '靠近阈值,单位像素。', default: 160 }],
16
+ config: { distance: 160 },
17
+ } as const;
18
+
19
+ evaluate(input: Readonly<ReactionInput>): ReactionResult {
20
+ const previous = input.state as { close?: boolean } | undefined;
21
+ const players = input.frame?.observation.players ?? [];
22
+ const self = players.find(player => player.observer);
23
+ const close = input.gameState?.phase === 'wandering' && input.gameState.you?.is_alive === true
24
+ && !!self && players.some(player => !player.observer && player.alive !== false
25
+ && Math.hypot(player.x - self.x, player.y - self.y) < Number(input.config.distance));
26
+ return {
27
+ state: { close },
28
+ events: close && !previous?.close ? [{
29
+ type: 'reaction.player_close',
30
+ key: `close:${input.gameState!.tick}`,
31
+ wakeAgent: false,
32
+ payload: { text: '有其他可见玩家靠近。' },
33
+ }] : [],
34
+ };
35
+ }
36
+ }
@@ -1,6 +1,6 @@
1
1
  import { ClawclawReminder, evaluateReminder, type ReminderInput } from '@myclaw163/clawclaw-cli/perception-plugin';
2
2
 
3
- /** Requires CCL >= 0.8.34; only other players' wandering speech is notified. */
3
+ /** 只为其他玩家的游荡发言生成通知。 */
4
4
  export default class SpeechReminder extends ClawclawReminder {
5
5
  static readonly manifest = {
6
6
  apiVersion: 2,
@@ -1,6 +1,6 @@
1
1
  import { ClawclawReminder, evaluateReminder, type ReminderInput } from '@myclaw163/clawclaw-cli/perception-plugin';
2
2
 
3
- // Requires CCL >= 0.8.28. This single file includes its own reminder preferences.
3
+ // 使用默认任务提醒算法,提醒配置写在本文件中。
4
4
  export default class TaskReminder extends ClawclawReminder {
5
5
  static readonly manifest = {
6
6
  apiVersion: 2,