@rpgjs/action-battle 5.0.0-beta.2 → 5.0.0-beta.3

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.
@@ -1,1332 +1,53 @@
1
- import { playActionBattleAnimation, getActionBattleAnimationRemovalDelay } from "./index9.js";
2
- import { getActionBattleOptions } from "./index8.js";
3
- const MAXHP = null;
4
- const RpgPlayer = null;
5
- const AiDebug = {
6
- /** Enable/disable all AI debug logs */
7
- enabled: typeof process !== "undefined" && process.env?.RPGJS_DEBUG_AI === "1" || false,
8
- /** Filter logs to a specific event ID (null = all events) */
9
- filterEventId: null,
10
- /** Log categories to enable (empty = all) */
11
- categories: [],
12
- /**
13
- * Log an AI debug message
14
- *
15
- * @param category - Log category (e.g., 'state', 'attack', 'movement', 'damage')
16
- * @param eventId - Event ID for filtering
17
- * @param message - Log message
18
- * @param data - Optional additional data
19
- */
20
- log(category, eventId, message, data) {
21
- if (!this.enabled) return;
22
- if (this.filterEventId && eventId !== this.filterEventId) return;
23
- if (this.categories.length > 0 && !this.categories.includes(category)) return;
24
- const prefix = `[AI:${category}]${eventId ? ` [${eventId.substring(0, 8)}]` : ""}`;
25
- if (data !== void 0) {
26
- console.log(prefix, message, data);
27
- } else {
28
- console.log(prefix, message);
29
- }
30
- }
1
+ import { DEFAULT_ACTION_BATTLE_OPTIONS, normalizeActionBattleOptions } from "./index2.js";
2
+ import { signal } from "canvasengine";
3
+ //#region src/ui/state.ts
4
+ var defaultTargetingState = {
5
+ active: false,
6
+ skill: null,
7
+ range: 0,
8
+ offset: {
9
+ x: 0,
10
+ y: 0
11
+ },
12
+ aoeMask: DEFAULT_ACTION_BATTLE_OPTIONS.skills?.defaultAoeMask || ["#"]
31
13
  };
32
- var AiState = /* @__PURE__ */ ((AiState2) => {
33
- AiState2["Idle"] = "idle";
34
- AiState2["Alert"] = "alert";
35
- AiState2["Combat"] = "combat";
36
- AiState2["Flee"] = "flee";
37
- AiState2["Stunned"] = "stunned";
38
- return AiState2;
39
- })(AiState || {});
40
- var EnemyType = /* @__PURE__ */ ((EnemyType2) => {
41
- EnemyType2["Aggressive"] = "aggressive";
42
- EnemyType2["Defensive"] = "defensive";
43
- EnemyType2["Ranged"] = "ranged";
44
- EnemyType2["Tank"] = "tank";
45
- EnemyType2["Berserker"] = "berserker";
46
- return EnemyType2;
47
- })(EnemyType || {});
48
- var AttackPattern = /* @__PURE__ */ ((AttackPattern2) => {
49
- AttackPattern2["Melee"] = "melee";
50
- AttackPattern2["Combo"] = "combo";
51
- AttackPattern2["Charged"] = "charged";
52
- AttackPattern2["Zone"] = "zone";
53
- AttackPattern2["DashAttack"] = "dashAttack";
54
- return AttackPattern2;
55
- })(AttackPattern || {});
56
- const DEFAULT_KNOCKBACK = {
57
- /** Default knockback force */
58
- force: 50,
59
- /** Default knockback duration in milliseconds */
60
- duration: 300
14
+ var actionBattleUiOptions = signal(normalizeActionBattleOptions({}).ui || {});
15
+ var actionBattleSkillOptions = signal(normalizeActionBattleOptions({}).skills || {});
16
+ var actionBattleTargetingState = signal({ ...defaultTargetingState });
17
+ var setActionBattleOptions = (options = {}) => {
18
+ const normalized = normalizeActionBattleOptions(options);
19
+ actionBattleUiOptions.set(normalized.ui || {});
20
+ actionBattleSkillOptions.set(normalized.skills || {});
61
21
  };
62
- class BattleAi {
63
- /**
64
- * Create a new Battle AI Controller
65
- *
66
- * The AI controls behavior only. Stats should be set on the event
67
- * using standard RPGJS methods (hp, param, learnSkill, etc.)
68
- *
69
- * @param event - The event to control
70
- * @param options - AI behavior configuration
71
- *
72
- * @example
73
- * ```ts
74
- * // In your event's onInit
75
- * this.hp = 100;
76
- * this.param[ATK] = 20;
77
- * this.learnSkill(FireBall);
78
- *
79
- * new BattleAi(this, {
80
- * enemyType: EnemyType.Ranged,
81
- * attackSkill: FireBall,
82
- * visionRange: 200,
83
- * fleeThreshold: 0.2
84
- * });
85
- * ```
86
- */
87
- constructor(event, options = {}) {
88
- this.target = null;
89
- this.lastAttackTime = 0;
90
- this.state = "idle";
91
- this.stateStartTime = 0;
92
- this.stunnedUntil = 0;
93
- this.lastDodgeTime = 0;
94
- this.comboCount = 0;
95
- this.comboMax = 3;
96
- this.chargingAttack = false;
97
- this.nearbyEnemies = [];
98
- this.groupUpdateInterval = 0;
99
- this.patrolWaypoints = [];
100
- this.currentPatrolIndex = 0;
101
- this.lastHpCheck = 0;
102
- this.recentDamageTaken = 0;
103
- this.damageCheckInterval = 2e3;
104
- this.isMovingToTarget = false;
105
- this.lastFacingDirection = null;
106
- this.behaviorScore = 50;
107
- this.behaviorMode = "tactical";
108
- this.behaviorLastUpdate = 0;
109
- this.behaviorUpdateInterval = 400;
110
- this.behaviorAssaultThreshold = 65;
111
- this.behaviorRetreatThreshold = 35;
112
- this.behaviorMinStateDuration = 600;
113
- this.behaviorEnabled = false;
114
- this.moveToCooldown = 400;
115
- this.lastMoveToTime = 0;
116
- this.retreatCooldown = 600;
117
- this.lastRetreatTime = 0;
118
- event.battleAi = this;
119
- this.event = event;
120
- this.enemyType = options.enemyType || "aggressive";
121
- this.applyEnemyTypeBehavior(options);
122
- this.attackSkill = options.attackSkill || null;
123
- this.animations = {
124
- ...getActionBattleOptions().animations,
125
- ...options.animations
126
- };
127
- this.attackPatterns = options.attackPatterns || [
128
- "melee",
129
- "combo",
130
- "dashAttack"
131
- /* DashAttack */
132
- ];
133
- this.groupBehavior = options.groupBehavior || false;
134
- this.patrolWaypoints = options.patrolWaypoints || [];
135
- this.currentPatrolIndex = 0;
136
- this.onDefeatedCallback = options.onDefeated;
137
- if (options.behavior) {
138
- this.behaviorEnabled = true;
139
- if (options.behavior.baseScore !== void 0) {
140
- this.behaviorScore = options.behavior.baseScore;
141
- }
142
- if (options.behavior.updateInterval !== void 0) {
143
- this.behaviorUpdateInterval = options.behavior.updateInterval;
144
- }
145
- if (options.behavior.minStateDuration !== void 0) {
146
- this.behaviorMinStateDuration = options.behavior.minStateDuration;
147
- }
148
- if (options.behavior.assaultThreshold !== void 0) {
149
- this.behaviorAssaultThreshold = options.behavior.assaultThreshold;
150
- }
151
- if (options.behavior.retreatThreshold !== void 0) {
152
- this.behaviorRetreatThreshold = options.behavior.retreatThreshold;
153
- }
154
- }
155
- if (options.moveToCooldown !== void 0) {
156
- this.moveToCooldown = options.moveToCooldown;
157
- }
158
- if (options.retreatCooldown !== void 0) {
159
- this.retreatCooldown = options.retreatCooldown;
160
- }
161
- this.setupVision();
162
- this.startAiBehaviorLoop();
163
- this.changeState(
164
- "idle"
165
- /* Idle */
166
- );
167
- this.debugLog("init", `AI created (type=${this.enemyType}, visionRange=${this.visionRange}, attackRange=${this.attackRange})`);
168
- }
169
- /**
170
- * Log AI debug message for this event
171
- */
172
- debugLog(category, message, data) {
173
- AiDebug.log(category, this.event.id, message, data);
174
- }
175
- /**
176
- * Apply enemy type-specific behavior modifiers
177
- *
178
- * This only affects AI behavior (cooldowns, ranges, dodge).
179
- * Stats should be set on the event itself.
180
- */
181
- applyEnemyTypeBehavior(options) {
182
- switch (this.enemyType) {
183
- case "aggressive":
184
- this.attackCooldown = options.attackCooldown ?? 600;
185
- this.visionRange = options.visionRange ?? 150;
186
- this.attackRange = options.attackRange ?? 50;
187
- this.dodgeChance = options.dodgeChance ?? 0.1;
188
- this.dodgeCooldown = options.dodgeCooldown ?? 3e3;
189
- this.fleeThreshold = options.fleeThreshold ?? 0.15;
190
- break;
191
- case "defensive":
192
- this.attackCooldown = options.attackCooldown ?? 1500;
193
- this.visionRange = options.visionRange ?? 120;
194
- this.attackRange = options.attackRange ?? 60;
195
- this.dodgeChance = options.dodgeChance ?? 0.5;
196
- this.dodgeCooldown = options.dodgeCooldown ?? 1500;
197
- this.fleeThreshold = options.fleeThreshold ?? 0.3;
198
- break;
199
- case "ranged":
200
- this.attackCooldown = options.attackCooldown ?? 1200;
201
- this.visionRange = options.visionRange ?? 200;
202
- this.attackRange = options.attackRange ?? 120;
203
- this.dodgeChance = options.dodgeChance ?? 0.4;
204
- this.dodgeCooldown = options.dodgeCooldown ?? 2e3;
205
- this.fleeThreshold = options.fleeThreshold ?? 0.25;
206
- break;
207
- case "tank":
208
- this.attackCooldown = options.attackCooldown ?? 2e3;
209
- this.visionRange = options.visionRange ?? 100;
210
- this.attackRange = options.attackRange ?? 50;
211
- this.dodgeChance = 0;
212
- this.dodgeCooldown = options.dodgeCooldown ?? 5e3;
213
- this.fleeThreshold = options.fleeThreshold ?? 0.1;
214
- break;
215
- case "berserker":
216
- this.attackCooldown = options.attackCooldown ?? 800;
217
- this.visionRange = options.visionRange ?? 180;
218
- this.attackRange = options.attackRange ?? 55;
219
- this.dodgeChance = options.dodgeChance ?? 0.15;
220
- this.dodgeCooldown = options.dodgeCooldown ?? 2500;
221
- this.fleeThreshold = options.fleeThreshold ?? 0.05;
222
- break;
223
- default:
224
- this.attackCooldown = options.attackCooldown ?? 1e3;
225
- this.visionRange = options.visionRange ?? 150;
226
- this.attackRange = options.attackRange ?? 60;
227
- this.dodgeChance = options.dodgeChance ?? 0.2;
228
- this.dodgeCooldown = options.dodgeCooldown ?? 2e3;
229
- this.fleeThreshold = options.fleeThreshold ?? 0.2;
230
- }
231
- }
232
- /**
233
- * Setup vision detection
234
- */
235
- setupVision() {
236
- const diameter = this.visionRange * 2;
237
- this.event.attachShape(`vision_${this.event.id}`, {
238
- radius: this.visionRange,
239
- width: diameter,
240
- height: diameter,
241
- angle: 360
242
- });
243
- }
244
- /**
245
- * Start the AI behavior loop
246
- */
247
- startAiBehaviorLoop() {
248
- const updateInterval = setInterval(() => {
249
- if (!this.event.getCurrentMap()) {
250
- this.destroy();
251
- return;
252
- }
253
- this.updateAiBehavior();
254
- }, 100);
255
- this.updateInterval = updateInterval;
256
- }
257
- /**
258
- * Change AI state with validated transitions
259
- */
260
- changeState(newState) {
261
- const validTransitions = {
262
- [
263
- "idle"
264
- /* Idle */
265
- ]: [
266
- "alert",
267
- "combat"
268
- /* Combat */
269
- ],
270
- [
271
- "alert"
272
- /* Alert */
273
- ]: [
274
- "idle",
275
- "combat"
276
- /* Combat */
277
- ],
278
- [
279
- "combat"
280
- /* Combat */
281
- ]: [
282
- "idle",
283
- "flee",
284
- "stunned"
285
- /* Stunned */
286
- ],
287
- [
288
- "flee"
289
- /* Flee */
290
- ]: [
291
- "idle",
292
- "combat"
293
- /* Combat */
294
- ],
295
- [
296
- "stunned"
297
- /* Stunned */
298
- ]: [
299
- "combat",
300
- "idle"
301
- /* Idle */
302
- ]
303
- };
304
- if (!validTransitions[this.state].includes(newState)) {
305
- this.debugLog("state", `INVALID transition ${this.state} -> ${newState}`);
306
- return;
307
- }
308
- this.debugLog("state", `STATE change: ${this.state} -> ${newState}`);
309
- this.state = newState;
310
- this.stateStartTime = Date.now();
311
- switch (newState) {
312
- case "idle":
313
- if (this.patrolWaypoints.length > 0) {
314
- this.startPatrol();
315
- }
316
- break;
317
- case "alert":
318
- this.event.stopMoveTo();
319
- break;
320
- case "combat":
321
- this.comboCount = 0;
322
- break;
323
- case "flee":
324
- if (this.target) {
325
- this.fleeFromTarget();
326
- }
327
- break;
328
- case "stunned":
329
- this.event.stopMoveTo();
330
- break;
331
- }
332
- }
333
- /**
334
- * Main AI behavior update loop
335
- */
336
- updateAiBehavior() {
337
- const currentTime = Date.now();
338
- if (this.groupBehavior) {
339
- this.updateGroupBehavior();
340
- }
341
- if (this.state === "stunned") {
342
- if (currentTime >= this.stunnedUntil) {
343
- this.changeState(
344
- "combat"
345
- /* Combat */
346
- );
347
- }
348
- return;
349
- }
350
- if (this.enemyType === "berserker" && this.event.param[MAXHP]) {
351
- const hpPercent = this.event.hp / this.event.param[MAXHP];
352
- const berserkerModifier = Math.max(0.3, hpPercent);
353
- this.attackCooldown = 800 * berserkerModifier;
354
- }
355
- if (this.behaviorEnabled) {
356
- this.updateBehavior(currentTime);
357
- }
358
- switch (this.state) {
359
- case "idle":
360
- this.updateIdleBehavior();
361
- break;
362
- case "alert":
363
- this.updateAlertBehavior();
364
- break;
365
- case "combat":
366
- this.updateCombatBehavior(currentTime);
367
- break;
368
- case "flee":
369
- this.updateFleeBehavior();
370
- break;
371
- }
372
- this.checkDamageTaken();
373
- }
374
- /**
375
- * Update idle behavior (patrolling)
376
- */
377
- updateIdleBehavior() {
378
- if (this.patrolWaypoints.length > 0) {
379
- const waypoint = this.patrolWaypoints[this.currentPatrolIndex];
380
- const distance = this.getDistance(this.event, {
381
- x: () => waypoint.x,
382
- y: () => waypoint.y
383
- });
384
- if (distance < 10) {
385
- this.currentPatrolIndex = (this.currentPatrolIndex + 1) % this.patrolWaypoints.length;
386
- }
387
- }
388
- }
389
- /**
390
- * Update alert behavior
391
- */
392
- updateAlertBehavior() {
393
- if (this.target) {
394
- this.faceTarget();
395
- const distance = this.getDistance(this.event, this.target);
396
- if (distance <= this.attackRange * 1.5) {
397
- this.changeState(
398
- "combat"
399
- /* Combat */
400
- );
401
- }
402
- } else {
403
- this.changeState(
404
- "idle"
405
- /* Idle */
406
- );
407
- }
408
- }
409
- /**
410
- * Update combat behavior
411
- */
412
- updateCombatBehavior(currentTime) {
413
- if (!this.target) {
414
- this.debugLog("combat", "No target, returning to idle");
415
- this.changeState(
416
- "idle"
417
- /* Idle */
418
- );
419
- return;
420
- }
421
- const distance = this.getDistance(this.event, this.target);
422
- if (distance > this.visionRange * 1.5) {
423
- this.debugLog("combat", `Target out of range (dist=${distance.toFixed(1)}, maxRange=${(this.visionRange * 1.5).toFixed(1)})`);
424
- this.target = null;
425
- this.isMovingToTarget = false;
426
- this.event.stopMoveTo();
427
- this.changeState(
428
- "idle"
429
- /* Idle */
430
- );
431
- return;
432
- }
433
- if (this.event.param[MAXHP]) {
434
- const hpPercent = this.event.hp / this.event.param[MAXHP];
435
- if (hpPercent <= this.fleeThreshold) {
436
- this.debugLog("combat", `HP low (${(hpPercent * 100).toFixed(0)}%), fleeing`);
437
- this.isMovingToTarget = false;
438
- this.changeState(
439
- "flee"
440
- /* Flee */
441
- );
442
- return;
443
- }
444
- }
445
- if (this.canDodge() && this.shouldDodge()) {
446
- this.debugLog("combat", "Attempting dodge");
447
- this.isMovingToTarget = false;
448
- this.tryDodge();
449
- return;
450
- }
451
- if (this.behaviorEnabled) {
452
- if (this.behaviorMode === "tactical") {
453
- this.handleTacticalMovement(distance);
454
- } else if (this.behaviorMode === "assault") {
455
- this.handleAssaultMovement(distance);
456
- } else if (this.behaviorMode === "retreat") {
457
- this.isMovingToTarget = false;
458
- this.fleeFromTarget();
459
- return;
460
- }
461
- }
462
- if (this.behaviorEnabled && this.behaviorMode === "assault") ;
463
- else if (this.behaviorEnabled && this.behaviorMode === "tactical") ;
464
- else if (this.enemyType === "ranged") {
465
- if (distance < this.attackRange * 0.6) {
466
- this.debugLog("movement", `Retreating (dist=${distance.toFixed(1)}, minRange=${(this.attackRange * 0.6).toFixed(1)})`);
467
- this.isMovingToTarget = false;
468
- this.retreatFromTarget();
469
- } else if (distance > this.attackRange) {
470
- if (!this.isMovingToTarget) {
471
- this.debugLog("movement", `Moving to target (dist=${distance.toFixed(1)}, attackRange=${this.attackRange})`);
472
- this.isMovingToTarget = true;
473
- this.requestMoveTo(this.target);
474
- }
475
- } else {
476
- if (this.isMovingToTarget) {
477
- this.debugLog("movement", `In range, stopping (dist=${distance.toFixed(1)})`);
478
- this.isMovingToTarget = false;
479
- this.event.stopMoveTo();
480
- }
481
- }
482
- } else {
483
- if (distance > this.attackRange) {
484
- if (!this.isMovingToTarget) {
485
- this.debugLog("movement", `Moving to target (dist=${distance.toFixed(1)}, attackRange=${this.attackRange})`);
486
- this.isMovingToTarget = true;
487
- this.requestMoveTo(this.target);
488
- }
489
- } else {
490
- if (this.isMovingToTarget) {
491
- this.debugLog("movement", `In range, stopping (dist=${distance.toFixed(1)})`);
492
- this.isMovingToTarget = false;
493
- this.event.stopMoveTo();
494
- }
495
- }
496
- }
497
- if (distance <= this.attackRange && currentTime - this.lastAttackTime >= this.attackCooldown) {
498
- if (!this.chargingAttack) {
499
- this.debugLog("attack", `Attacking (dist=${distance.toFixed(1)}, cooldown=${this.attackCooldown}ms)`);
500
- this.selectAndPerformAttack();
501
- this.lastAttackTime = currentTime;
502
- }
503
- }
504
- }
505
- /**
506
- * Update flee behavior
507
- */
508
- updateFleeBehavior() {
509
- if (!this.target) {
510
- this.changeState(
511
- "idle"
512
- /* Idle */
513
- );
514
- return;
515
- }
516
- const distance = this.getDistance(this.event, this.target);
517
- if (this.event.param[MAXHP]) {
518
- const hpPercent = this.event.hp / this.event.param[MAXHP];
519
- if (hpPercent > this.fleeThreshold * 1.5 || distance > this.visionRange * 2) {
520
- this.changeState(
521
- "combat"
522
- /* Combat */
523
- );
524
- return;
525
- }
526
- }
527
- this.fleeFromTarget();
528
- }
529
- /**
530
- * Select and perform an attack pattern
531
- */
532
- selectAndPerformAttack() {
533
- if (!this.target) return;
534
- if (this.comboCount > 0 && this.comboCount < this.comboMax) {
535
- this.debugLog("attack", `Continuing combo (${this.comboCount}/${this.comboMax})`);
536
- this.performComboAttack();
537
- return;
538
- }
539
- const pattern = this.selectAttackPattern();
540
- this.debugLog("attack", `Selected pattern: ${pattern}`);
541
- this.performAttackPattern(pattern);
542
- }
543
- /**
544
- * Select attack pattern with weighted probability
545
- */
546
- selectAttackPattern() {
547
- const weights = {
548
- [
549
- "melee"
550
- /* Melee */
551
- ]: 40,
552
- [
553
- "combo"
554
- /* Combo */
555
- ]: 25,
556
- [
557
- "charged"
558
- /* Charged */
559
- ]: 15,
560
- [
561
- "zone"
562
- /* Zone */
563
- ]: 10,
564
- [
565
- "dashAttack"
566
- /* DashAttack */
567
- ]: 10
568
- };
569
- switch (this.enemyType) {
570
- case "aggressive":
571
- weights[
572
- "combo"
573
- /* Combo */
574
- ] += 20;
575
- weights[
576
- "dashAttack"
577
- /* DashAttack */
578
- ] += 15;
579
- break;
580
- case "defensive":
581
- weights[
582
- "charged"
583
- /* Charged */
584
- ] += 25;
585
- break;
586
- case "ranged":
587
- weights[
588
- "zone"
589
- /* Zone */
590
- ] += 20;
591
- break;
592
- case "tank":
593
- weights[
594
- "charged"
595
- /* Charged */
596
- ] += 30;
597
- weights[
598
- "zone"
599
- /* Zone */
600
- ] += 15;
601
- break;
602
- case "berserker":
603
- weights[
604
- "combo"
605
- /* Combo */
606
- ] += 35;
607
- break;
608
- }
609
- let total = 0;
610
- const available = [];
611
- this.attackPatterns.forEach((p) => {
612
- const weight = weights[p] || 10;
613
- total += weight;
614
- available.push({ pattern: p, weight });
615
- });
616
- let random = Math.random() * total;
617
- for (const item of available) {
618
- random -= item.weight;
619
- if (random <= 0) return item.pattern;
620
- }
621
- return this.attackPatterns[0] || "melee";
622
- }
623
- /**
624
- * Perform attack pattern
625
- */
626
- performAttackPattern(pattern) {
627
- switch (pattern) {
628
- case "melee":
629
- this.performMeleeAttack();
630
- break;
631
- case "combo":
632
- this.performComboAttack();
633
- break;
634
- case "charged":
635
- this.performChargedAttack();
636
- break;
637
- case "zone":
638
- this.performZoneAttack();
639
- break;
640
- case "dashAttack":
641
- this.performDashAttack();
642
- break;
643
- }
644
- }
645
- /**
646
- * Perform melee attack
647
- * Uses skill if configured, otherwise creates hitbox
648
- */
649
- performMeleeAttack() {
650
- if (!this.target) return;
651
- this.faceTarget();
652
- playActionBattleAnimation("attack", this.event, this.animations, {
653
- target: this.target
654
- });
655
- if (this.attackSkill) {
656
- try {
657
- playActionBattleAnimation("castSkill", this.event, this.animations, {
658
- skill: this.attackSkill,
659
- target: this.target
660
- });
661
- this.event.useSkill(this.attackSkill, this.target);
662
- } catch (e) {
663
- this.performBasicHitbox();
664
- }
665
- } else {
666
- this.performBasicHitbox();
667
- }
668
- }
669
- /**
670
- * Perform basic hitbox attack when no skill is set
671
- */
672
- performBasicHitbox() {
673
- if (!this.target) return;
674
- const eventX = this.event.x();
675
- const eventY = this.event.y();
676
- const dx = this.target.x() - eventX;
677
- const dy = this.target.y() - eventY;
678
- const dist = Math.sqrt(dx * dx + dy * dy);
679
- if (dist === 0) return;
680
- const dirX = dx / dist;
681
- const dirY = dy / dist;
682
- const hitboxes = [{
683
- x: eventX + dirX * 30,
684
- y: eventY + dirY * 30,
685
- width: 40,
686
- height: 40
687
- }];
688
- const map = this.event.getCurrentMap();
689
- map?.createMovingHitbox(hitboxes, { speed: 5 }).subscribe({
690
- next: (hits) => {
691
- hits.forEach((hit) => {
692
- if (hit instanceof RpgPlayer && hit !== this.event) {
693
- this.applyHit(hit);
694
- }
695
- });
696
- }
697
- });
698
- }
699
- /**
700
- * Apply hit to target using RPGJS damage system with knockback
701
- *
702
- * Calculates damage using RPGJS formula, applies knockback based on
703
- * equipped weapon's knockbackForce property, and triggers visual effects.
704
- * Supports hooks for customizing behavior.
705
- *
706
- * @param target - The player or entity being hit
707
- * @param hooks - Optional hooks for customizing hit behavior
708
- * @returns The hit result containing damage and knockback info
709
- *
710
- * @example
711
- * ```ts
712
- * // Basic hit
713
- * this.applyHit(player);
714
- *
715
- * // With custom hooks
716
- * this.applyHit(player, {
717
- * onBeforeHit(result) {
718
- * result.knockbackForce *= 1.5; // Increase knockback
719
- * return result;
720
- * },
721
- * onAfterHit(result) {
722
- * console.log(`Dealt ${result.damage} damage!`);
723
- * }
724
- * });
725
- * ```
726
- */
727
- applyHit(target, hooks) {
728
- const { damage } = target.applyDamage(this.event);
729
- const knockbackForce = this.getWeaponKnockbackForce();
730
- const knockbackDuration = DEFAULT_KNOCKBACK.duration;
731
- let hitResult = {
732
- damage,
733
- knockbackForce,
734
- knockbackDuration,
735
- defeated: target.hp <= 0,
736
- attacker: this.event,
737
- target
738
- };
739
- if (hooks?.onBeforeHit) {
740
- const modified = hooks.onBeforeHit(hitResult);
741
- if (modified) {
742
- hitResult = modified;
743
- }
744
- }
745
- target.flash({
746
- type: "tint",
747
- tint: "red",
748
- duration: 200,
749
- cycles: 1
750
- });
751
- target.showHit(`-${hitResult.damage}`);
752
- if (hitResult.knockbackForce > 0) {
753
- const dx = target.x() - this.event.x();
754
- const dy = target.y() - this.event.y();
755
- const distance = Math.sqrt(dx * dx + dy * dy);
756
- if (distance > 0) {
757
- const knockbackDirection = {
758
- x: dx / distance,
759
- y: dy / distance
760
- };
761
- target.knockback(knockbackDirection, hitResult.knockbackForce, hitResult.knockbackDuration);
762
- }
763
- }
764
- if (hooks?.onAfterHit) {
765
- hooks.onAfterHit(hitResult);
766
- }
767
- return hitResult;
768
- }
769
- /**
770
- * Get knockback force from equipped weapon
771
- *
772
- * Retrieves the knockbackForce property from the event's equipped weapon.
773
- * Falls back to DEFAULT_KNOCKBACK.force if no weapon or property is set.
774
- *
775
- * @returns Knockback force value
776
- *
777
- * @example
778
- * ```ts
779
- * // Weapon with knockbackForce: 80
780
- * const force = this.getWeaponKnockbackForce(); // 80
781
- *
782
- * // No weapon equipped
783
- * const force = this.getWeaponKnockbackForce(); // 50 (default)
784
- * ```
785
- */
786
- getWeaponKnockbackForce() {
787
- try {
788
- const equipments = this.event.equipments?.() || [];
789
- for (const item of equipments) {
790
- const itemData = this.event.databaseById?.(item.id());
791
- if (itemData?._type === "weapon" && itemData.knockbackForce !== void 0) {
792
- return itemData.knockbackForce;
793
- }
794
- }
795
- } catch {
796
- }
797
- return DEFAULT_KNOCKBACK.force;
798
- }
799
- /**
800
- * Perform combo attack
801
- */
802
- performComboAttack() {
803
- if (!this.target) return;
804
- this.comboCount++;
805
- this.performMeleeAttack();
806
- if (this.comboCount < this.comboMax) {
807
- setTimeout(() => {
808
- if (this.target && this.state === "combat") {
809
- this.performComboAttack();
810
- } else {
811
- this.comboCount = 0;
812
- }
813
- }, 300);
814
- } else {
815
- this.comboCount = 0;
816
- }
817
- }
818
- /**
819
- * Perform charged attack
820
- */
821
- performChargedAttack() {
822
- if (!this.target) return;
823
- this.chargingAttack = true;
824
- this.faceTarget();
825
- playActionBattleAnimation(
826
- "attack",
827
- this.event,
828
- this.animations,
829
- {
830
- target: this.target
831
- },
832
- { repeat: 2 }
833
- );
834
- setTimeout(() => {
835
- if (!this.target || this.state !== "combat") {
836
- this.chargingAttack = false;
837
- return;
838
- }
839
- if (this.attackSkill) {
840
- try {
841
- playActionBattleAnimation("castSkill", this.event, this.animations, {
842
- skill: this.attackSkill,
843
- target: this.target
844
- });
845
- this.event.useSkill(this.attackSkill, this.target);
846
- } catch (e) {
847
- this.performBasicHitbox();
848
- }
849
- } else {
850
- this.performBasicHitbox();
851
- }
852
- this.chargingAttack = false;
853
- }, 800);
854
- }
855
- /**
856
- * Perform zone attack (360 degrees)
857
- */
858
- performZoneAttack() {
859
- playActionBattleAnimation("attack", this.event, this.animations, {
860
- target: this.target ?? void 0
861
- });
862
- const eventX = this.event.x();
863
- const eventY = this.event.y();
864
- const radius = 50;
865
- const hitboxes = [];
866
- const angles = [0, 90, 180, 270];
867
- angles.forEach((angle) => {
868
- const rad = angle * Math.PI / 180;
869
- hitboxes.push({
870
- x: eventX + Math.cos(rad) * radius,
871
- y: eventY + Math.sin(rad) * radius,
872
- width: 40,
873
- height: 40
874
- });
875
- });
876
- const map = this.event.getCurrentMap();
877
- map?.createMovingHitbox(hitboxes, { speed: 5 }).subscribe({
878
- next: (hits) => {
879
- hits.forEach((hit) => {
880
- if (hit instanceof RpgPlayer && hit !== this.event) {
881
- this.applyHit(hit);
882
- }
883
- });
884
- }
885
- });
886
- }
887
- /**
888
- * Perform dash attack
889
- */
890
- performDashAttack() {
891
- if (!this.target) return;
892
- const dx = this.target.x() - this.event.x();
893
- const dy = this.target.y() - this.event.y();
894
- const dist = Math.sqrt(dx * dx + dy * dy);
895
- if (dist === 0) return;
896
- const dirX = dx / dist;
897
- const dirY = dy / dist;
898
- this.faceTarget();
899
- this.event.dash({ x: dirX, y: dirY }, 10, 200);
900
- setTimeout(() => {
901
- if (!this.target || this.state !== "combat") return;
902
- this.performMeleeAttack();
903
- }, 200);
904
- }
905
- /**
906
- * Face the current target with hysteresis to prevent animation flickering
907
- *
908
- * Uses multiple strategies to prevent flickering:
909
- * 1. When very close to target (collision), keep current direction
910
- * 2. When near diagonal, require significant difference to change
911
- * 3. Only change if direction is clearly wrong (opposite)
912
- */
913
- faceTarget() {
914
- if (!this.target) return;
915
- const dx = this.target.x() - this.event.x();
916
- const dy = this.target.y() - this.event.y();
917
- const absX = Math.abs(dx);
918
- const absY = Math.abs(dy);
919
- const distance = Math.sqrt(dx * dx + dy * dy);
920
- const minDistanceForDirectionChange = 40;
921
- if (this.lastFacingDirection && distance < minDistanceForDirectionChange) {
922
- return;
923
- }
924
- let newDirection;
925
- if (absX >= absY) {
926
- newDirection = dx >= 0 ? "right" : "left";
927
- } else {
928
- newDirection = dy >= 0 ? "down" : "up";
929
- }
930
- const hysteresisThreshold = 0.2;
931
- const ratio = absX > 0 || absY > 0 ? Math.min(absX, absY) / Math.max(absX, absY) : 0;
932
- if (this.lastFacingDirection && ratio > 1 - hysteresisThreshold) {
933
- const isOpposite = this.lastFacingDirection === "left" && dx > 20 || this.lastFacingDirection === "right" && dx < -20 || this.lastFacingDirection === "up" && dy > 20 || this.lastFacingDirection === "down" && dy < -20;
934
- if (!isOpposite) {
935
- return;
936
- }
937
- }
938
- this.lastFacingDirection = newDirection;
939
- this.event.changeDirection(newDirection);
940
- }
941
- /**
942
- * Try to dodge
943
- */
944
- tryDodge() {
945
- const currentTime = Date.now();
946
- if (currentTime - this.lastDodgeTime < this.dodgeCooldown) {
947
- this.debugLog("dodge", `Dodge on cooldown (${this.dodgeCooldown - (currentTime - this.lastDodgeTime)}ms remaining)`);
948
- return;
949
- }
950
- if (Math.random() > this.dodgeChance) {
951
- this.debugLog("dodge", `Dodge roll failed (chance=${(this.dodgeChance * 100).toFixed(0)}%)`);
952
- return;
953
- }
954
- if (!this.target) return;
955
- const dx = this.target.x() - this.event.x();
956
- const dy = this.target.y() - this.event.y();
957
- const dist = Math.sqrt(dx * dx + dy * dy);
958
- if (dist === 0) return;
959
- const dodgeDirX = -dy / dist;
960
- const dodgeDirY = dx / dist;
961
- const side = Math.random() > 0.5 ? 1 : -1;
962
- this.debugLog("dodge", `Dodging (dir=${side > 0 ? "right" : "left"})`);
963
- this.event.dash({ x: dodgeDirX * side, y: dodgeDirY * side }, 12, 300);
964
- this.lastDodgeTime = currentTime;
965
- if (this.enemyType === "defensive" && Math.random() < 0.5) {
966
- this.debugLog("dodge", "Counter-attack after dodge");
967
- setTimeout(() => {
968
- if (this.target && this.state === "combat") {
969
- this.selectAndPerformAttack();
970
- }
971
- }, 400);
972
- }
973
- }
974
- canDodge() {
975
- if (this.dodgeChance === 0) return false;
976
- return Date.now() - this.lastDodgeTime >= this.dodgeCooldown;
977
- }
978
- shouldDodge() {
979
- if (!this.target) return false;
980
- const distance = this.getDistance(this.event, this.target);
981
- return distance < this.attackRange * 0.8;
982
- }
983
- /**
984
- * Flee from target
985
- */
986
- fleeFromTarget() {
987
- if (!this.target) return;
988
- const dx = this.event.x() - this.target.x();
989
- const dy = this.event.y() - this.target.y();
990
- const dist = Math.sqrt(dx * dx + dy * dy);
991
- if (dist === 0) return;
992
- const fleeTarget = {
993
- x: () => this.event.x() + dx / dist * 200,
994
- y: () => this.event.y() + dy / dist * 200
995
- };
996
- this.requestMoveTo(fleeTarget);
997
- }
998
- /**
999
- * Retreat from target (temporary)
1000
- */
1001
- retreatFromTarget() {
1002
- if (!this.target) return;
1003
- const currentTime = Date.now();
1004
- if (currentTime - this.lastRetreatTime < this.retreatCooldown) {
1005
- return;
1006
- }
1007
- const dx = this.event.x() - this.target.x();
1008
- const dy = this.event.y() - this.target.y();
1009
- const dist = Math.sqrt(dx * dx + dy * dy);
1010
- if (dist === 0) return;
1011
- this.event.dash({ x: dx / dist, y: dy / dist }, 8, 200);
1012
- this.lastRetreatTime = currentTime;
1013
- }
1014
- /**
1015
- * Check damage taken for retreat decision
1016
- */
1017
- checkDamageTaken() {
1018
- const currentTime = Date.now();
1019
- if (currentTime - this.lastHpCheck >= this.damageCheckInterval) {
1020
- this.recentDamageTaken = 0;
1021
- this.lastHpCheck = currentTime;
1022
- }
1023
- }
1024
- /**
1025
- * Start patrol
1026
- */
1027
- startPatrol() {
1028
- if (this.patrolWaypoints.length === 0) return;
1029
- const waypoint = this.patrolWaypoints[this.currentPatrolIndex];
1030
- this.requestMoveTo({ x: () => waypoint.x, y: () => waypoint.y });
1031
- }
1032
- /**
1033
- * Update group behavior
1034
- */
1035
- updateGroupBehavior() {
1036
- if (!this.groupBehavior) return;
1037
- this.groupUpdateInterval++;
1038
- if (this.groupUpdateInterval >= 20) {
1039
- this.groupUpdateInterval = 0;
1040
- this.findNearbyEnemies();
1041
- }
1042
- if (this.nearbyEnemies.length > 0 && this.target && this.state === "combat") {
1043
- this.applyFormation();
1044
- }
1045
- }
1046
- /**
1047
- * Find nearby enemies
1048
- */
1049
- findNearbyEnemies() {
1050
- this.nearbyEnemies = [];
1051
- const map = this.event.getCurrentMap();
1052
- if (!map) return;
1053
- const allEvents = Object.values(map.events());
1054
- const groupRadius = 150;
1055
- allEvents.forEach((event) => {
1056
- if (event === this.event) return;
1057
- const ai = event.battleAi;
1058
- if (ai && ai.groupBehavior) {
1059
- const distance = this.getDistance(this.event, event);
1060
- if (distance <= groupRadius) {
1061
- this.nearbyEnemies.push(ai);
1062
- }
1063
- }
1064
- });
1065
- }
1066
- /**
1067
- * Apply formation around target
1068
- */
1069
- applyFormation() {
1070
- if (!this.target || this.nearbyEnemies.length === 0) return;
1071
- const totalEnemies = this.nearbyEnemies.length + 1;
1072
- const angleStep = 2 * Math.PI / totalEnemies;
1073
- let ourIndex = 0;
1074
- for (let i = 0; i < this.nearbyEnemies.length; i++) {
1075
- if (this.nearbyEnemies[i].event.id < this.event.id) {
1076
- ourIndex++;
1077
- }
1078
- }
1079
- const angle = angleStep * ourIndex;
1080
- const formationRadius = this.attackRange * 1.2;
1081
- const formationX = this.target.x() + Math.cos(angle) * formationRadius;
1082
- const formationY = this.target.y() + Math.sin(angle) * formationRadius;
1083
- const distanceToFormation = Math.sqrt(
1084
- Math.pow(this.event.x() - formationX, 2) + Math.pow(this.event.y() - formationY, 2)
1085
- );
1086
- if (distanceToFormation > 20) {
1087
- this.requestMoveTo({ x: () => formationX, y: () => formationY });
1088
- }
1089
- }
1090
- /**
1091
- * Handle player entering vision
1092
- */
1093
- onDetectInShape(player, shape) {
1094
- this.debugLog("vision", `Player ${player.id} entered vision (state=${this.state})`);
1095
- this.target = player;
1096
- if (this.state === "idle") {
1097
- this.changeState(
1098
- "alert"
1099
- /* Alert */
1100
- );
1101
- } else if (this.state === "alert") {
1102
- this.changeState(
1103
- "combat"
1104
- /* Combat */
1105
- );
1106
- }
1107
- }
1108
- /**
1109
- * Handle player leaving vision
1110
- */
1111
- onDetectOutShape(player, shape) {
1112
- this.debugLog("vision", `Player ${player.id} left vision (wasTarget=${this.target === player})`);
1113
- if (this.target === player) {
1114
- this.target = null;
1115
- this.isMovingToTarget = false;
1116
- this.event.stopMoveTo();
1117
- this.changeState(
1118
- "idle"
1119
- /* Idle */
1120
- );
1121
- }
1122
- }
1123
- /**
1124
- * Handle taking damage (called from server.ts)
1125
- *
1126
- * This triggers state changes like stun and flee check.
1127
- * The actual damage is applied externally via RPGJS API.
1128
- */
1129
- takeDamage(attacker) {
1130
- const { damage } = this.event.applyDamage(attacker);
1131
- this.debugLog("damage", `Took ${damage} damage from ${attacker.id} (HP: ${this.event.hp}/${this.event.param[MAXHP] || "?"})`);
1132
- this.event.flash({
1133
- type: "tint",
1134
- tint: "red",
1135
- duration: 200,
1136
- cycles: 1
1137
- });
1138
- this.event.showHit(`-${damage}`);
1139
- playActionBattleAnimation("hurt", this.event, this.animations, {
1140
- attacker
1141
- });
1142
- this.recentDamageTaken += damage;
1143
- if (this.state !== "stunned" && this.state !== "flee") {
1144
- this.debugLog("damage", "Stunned from damage");
1145
- this.isMovingToTarget = false;
1146
- this.stunnedUntil = Date.now() + 150;
1147
- this.changeState(
1148
- "stunned"
1149
- /* Stunned */
1150
- );
1151
- }
1152
- if (this.event.hp <= 0) {
1153
- this.debugLog("damage", "Defeated!");
1154
- this.kill(attacker);
1155
- return true;
1156
- }
1157
- return false;
1158
- }
1159
- /**
1160
- * Kill this AI
1161
- *
1162
- * Stops all movements, cleans up resources, calls the onDefeated hook,
1163
- * and removes the event from the map.
1164
- */
1165
- kill(attacker) {
1166
- const dieAnimation = playActionBattleAnimation(
1167
- "die",
1168
- this.event,
1169
- this.animations,
1170
- {
1171
- attacker
1172
- }
1173
- );
1174
- const removeDelay = getActionBattleAnimationRemovalDelay(dieAnimation);
1175
- if (this.onDefeatedCallback) {
1176
- this.onDefeatedCallback(this.event, attacker);
1177
- }
1178
- this.destroy();
1179
- if (removeDelay > 0) {
1180
- setTimeout(() => this.event.remove(), removeDelay);
1181
- } else {
1182
- this.event.remove();
1183
- }
1184
- }
1185
- /**
1186
- * Get distance between entities
1187
- */
1188
- getDistance(entity1, entity2) {
1189
- const dx = entity1.x() - entity2.x();
1190
- const dy = entity1.y() - entity2.y();
1191
- return Math.sqrt(dx * dx + dy * dy);
1192
- }
1193
- updateBehavior(currentTime) {
1194
- if (currentTime - this.behaviorLastUpdate < this.behaviorUpdateInterval) {
1195
- return;
1196
- }
1197
- this.behaviorLastUpdate = currentTime;
1198
- let score = this.behaviorScore;
1199
- const maxHp = this.event.param[MAXHP];
1200
- if (maxHp) {
1201
- const hpPercent = this.event.hp / maxHp;
1202
- score += (hpPercent - 0.5) * 40;
1203
- }
1204
- if (this.recentDamageTaken > 0) {
1205
- score -= Math.min(30, this.recentDamageTaken * 0.5);
1206
- }
1207
- if (this.target) {
1208
- const distance = this.getDistance(this.event, this.target);
1209
- if (distance <= this.attackRange) {
1210
- score += 10;
1211
- } else if (distance > this.visionRange) {
1212
- score -= 10;
1213
- }
1214
- }
1215
- if (this.groupBehavior && this.nearbyEnemies.length > 0) {
1216
- score += Math.min(15, this.nearbyEnemies.length * 5);
1217
- }
1218
- score = Math.max(0, Math.min(100, score));
1219
- this.behaviorScore = score;
1220
- const previousMode = this.behaviorMode;
1221
- if (score >= this.behaviorAssaultThreshold) {
1222
- this.behaviorMode = "assault";
1223
- } else if (score <= this.behaviorRetreatThreshold) {
1224
- this.behaviorMode = "retreat";
1225
- } else {
1226
- this.behaviorMode = "tactical";
1227
- }
1228
- if (previousMode !== this.behaviorMode) {
1229
- this.debugLog("state", `Behavior mode: ${previousMode} -> ${this.behaviorMode} (score=${score.toFixed(0)})`);
1230
- }
1231
- if (this.behaviorMode === "retreat" && this.state === "combat") {
1232
- if (currentTime - this.stateStartTime >= this.behaviorMinStateDuration) {
1233
- this.isMovingToTarget = false;
1234
- this.changeState(
1235
- "flee"
1236
- /* Flee */
1237
- );
1238
- }
1239
- } else if (this.behaviorMode === "assault" && this.state === "flee") {
1240
- if (currentTime - this.stateStartTime >= this.behaviorMinStateDuration) {
1241
- this.changeState(
1242
- "combat"
1243
- /* Combat */
1244
- );
1245
- }
1246
- }
1247
- }
1248
- handleTacticalMovement(distance) {
1249
- if (!this.target) return;
1250
- const minRange = this.attackRange * 0.7;
1251
- const maxRange = this.attackRange * 1.2;
1252
- if (distance < minRange) {
1253
- this.debugLog("movement", `Tactical retreat (dist=${distance.toFixed(1)}, minRange=${minRange.toFixed(1)})`);
1254
- this.isMovingToTarget = false;
1255
- this.retreatFromTarget();
1256
- return;
1257
- }
1258
- if (distance > maxRange) {
1259
- if (!this.isMovingToTarget) {
1260
- this.debugLog("movement", `Tactical approach (dist=${distance.toFixed(1)}, maxRange=${maxRange.toFixed(1)})`);
1261
- this.isMovingToTarget = true;
1262
- this.requestMoveTo(this.target);
1263
- }
1264
- return;
1265
- }
1266
- if (this.isMovingToTarget) {
1267
- this.debugLog("movement", `Tactical hold (dist=${distance.toFixed(1)})`);
1268
- this.isMovingToTarget = false;
1269
- this.event.stopMoveTo();
1270
- }
1271
- }
1272
- handleAssaultMovement(distance) {
1273
- if (!this.target) return;
1274
- if (distance > this.attackRange) {
1275
- if (!this.isMovingToTarget) {
1276
- this.debugLog("movement", `Assault approach (dist=${distance.toFixed(1)}, attackRange=${this.attackRange})`);
1277
- this.isMovingToTarget = true;
1278
- this.requestMoveTo(this.target);
1279
- }
1280
- return;
1281
- }
1282
- if (this.isMovingToTarget) {
1283
- this.debugLog("movement", `Assault hold (dist=${distance.toFixed(1)})`);
1284
- this.isMovingToTarget = false;
1285
- this.event.stopMoveTo();
1286
- }
1287
- }
1288
- requestMoveTo(target) {
1289
- const currentTime = Date.now();
1290
- if (currentTime - this.lastMoveToTime < this.moveToCooldown) {
1291
- return false;
1292
- }
1293
- this.event.moveTo(target);
1294
- this.lastMoveToTime = currentTime;
1295
- return true;
1296
- }
1297
- // Public getters
1298
- getHealth() {
1299
- return this.event.hp;
1300
- }
1301
- getMaxHealth() {
1302
- return this.event.param[MAXHP];
1303
- }
1304
- getTarget() {
1305
- return this.target;
1306
- }
1307
- getState() {
1308
- return this.state;
1309
- }
1310
- getEnemyType() {
1311
- return this.enemyType;
1312
- }
1313
- /**
1314
- * Clean up
1315
- */
1316
- destroy() {
1317
- if (this.updateInterval) {
1318
- clearInterval(this.updateInterval);
1319
- this.updateInterval = void 0;
1320
- }
1321
- this.target = null;
1322
- this.nearbyEnemies = [];
1323
- }
1324
- }
1325
- export {
1326
- AiDebug,
1327
- AiState,
1328
- AttackPattern,
1329
- BattleAi,
1330
- DEFAULT_KNOCKBACK,
1331
- EnemyType
22
+ var startTargeting = (skill) => {
23
+ const skillsOptions = actionBattleSkillOptions();
24
+ const mask = skill.aoeMask || skillsOptions.defaultAoeMask || ["#"];
25
+ actionBattleTargetingState.set({
26
+ active: true,
27
+ skill,
28
+ range: skill.range ?? 0,
29
+ offset: {
30
+ x: 0,
31
+ y: 0
32
+ },
33
+ aoeMask: mask
34
+ });
1332
35
  };
36
+ var stopTargeting = () => {
37
+ actionBattleTargetingState.set({ ...defaultTargetingState });
38
+ };
39
+ var moveTargetingOffset = (dx, dy) => {
40
+ const state = actionBattleTargetingState();
41
+ if (!state.active) return;
42
+ const next = {
43
+ x: state.offset.x + dx,
44
+ y: state.offset.y + dy
45
+ };
46
+ if (Math.abs(next.x) + Math.abs(next.y) > state.range) return;
47
+ actionBattleTargetingState.set({
48
+ ...state,
49
+ offset: next
50
+ });
51
+ };
52
+ //#endregion
53
+ export { actionBattleTargetingState, actionBattleUiOptions, moveTargetingOffset, setActionBattleOptions, startTargeting, stopTargeting };