@rpgjs/action-battle 5.0.0-beta.1 → 5.0.0-beta.10
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/CHANGELOG.md +38 -0
- package/LICENSE +19 -0
- package/README.md +392 -22
- package/dist/{ai.server.d.ts → client/ai.server.d.ts} +90 -28
- package/dist/client/animations.d.ts +16 -0
- package/dist/{client.d.ts → client/client.d.ts} +3 -2
- package/dist/{config.d.ts → client/config.d.ts} +2 -0
- package/dist/client/core/attack-profile.d.ts +9 -0
- package/dist/client/core/attack-runtime.d.ts +20 -0
- package/dist/client/core/context.d.ts +5 -0
- package/dist/client/core/defaults.d.ts +81 -0
- package/dist/client/core/enemy-attack-profiles.d.ts +6 -0
- package/dist/client/core/equipment.d.ts +2 -0
- package/dist/client/core/hit-reaction.d.ts +5 -0
- package/dist/client/core/hit.d.ts +2 -0
- package/dist/client/enemies/factory.d.ts +7 -0
- package/dist/client/index.d.ts +21 -0
- package/dist/client/index.js +24 -31
- package/dist/client/index10.js +61 -0
- package/dist/client/index11.js +55 -0
- package/dist/client/index12.js +106 -0
- package/dist/client/index13.js +143 -0
- package/dist/client/index14.js +25 -0
- package/dist/client/index15.js +72 -0
- package/dist/client/index16.js +1343 -0
- package/dist/client/index17.js +13 -0
- package/dist/client/index18.js +60 -0
- package/dist/client/index19.js +10 -0
- package/dist/client/index2.js +30 -45
- package/dist/client/index20.js +504 -0
- package/dist/client/index3.js +45 -1288
- package/dist/client/index4.js +105 -330
- package/dist/client/index5.js +84 -291
- package/dist/client/index6.js +309 -95
- package/dist/client/index7.js +35 -59
- package/dist/client/index8.js +101 -54
- package/dist/client/index9.js +79 -30
- package/dist/{server.d.ts → client/server.d.ts} +12 -4
- package/dist/client/ui/state.d.ts +35 -0
- package/dist/server/ai.server.d.ts +569 -0
- package/dist/server/animations.d.ts +16 -0
- package/dist/server/config.d.ts +5 -0
- package/dist/server/core/attack-profile.d.ts +9 -0
- package/dist/server/core/attack-runtime.d.ts +20 -0
- package/dist/server/core/context.d.ts +5 -0
- package/dist/server/core/defaults.d.ts +81 -0
- package/dist/server/core/enemy-attack-profiles.d.ts +6 -0
- package/dist/server/core/equipment.d.ts +2 -0
- package/dist/server/core/hit-reaction.d.ts +5 -0
- package/dist/server/core/hit.d.ts +2 -0
- package/dist/server/enemies/factory.d.ts +7 -0
- package/dist/server/index.d.ts +21 -0
- package/dist/server/index.js +23 -31
- package/dist/server/index10.js +1342 -0
- package/dist/server/index11.js +37 -0
- package/dist/server/index12.js +60 -0
- package/dist/server/index13.js +13 -0
- package/dist/server/index14.js +503 -0
- package/dist/server/index15.js +10 -0
- package/dist/server/index2.js +59 -332
- package/dist/server/index3.js +29 -1286
- package/dist/server/index4.js +45 -53
- package/dist/server/index5.js +107 -29
- package/dist/server/index6.js +143 -0
- package/dist/server/index7.js +25 -0
- package/dist/server/index8.js +72 -0
- package/dist/server/index9.js +55 -0
- package/dist/server/server.d.ts +106 -0
- package/dist/server/targeting.d.ts +19 -0
- package/package.json +12 -12
- package/src/ai.server.spec.ts +120 -0
- package/src/ai.server.ts +515 -91
- package/src/animations.ts +149 -0
- package/src/canvas-engine-shim.ts +4 -0
- package/src/client.ts +130 -2
- package/src/components/action-bar.ce +5 -3
- package/src/components/attack-preview.ce +90 -0
- package/src/config.ts +61 -0
- package/src/core/attack-profile.spec.ts +118 -0
- package/src/core/attack-profile.ts +100 -0
- package/src/core/attack-runtime.spec.ts +103 -0
- package/src/core/attack-runtime.ts +83 -0
- package/src/core/context.ts +35 -0
- package/src/core/contracts.ts +126 -0
- package/src/core/defaults.ts +162 -0
- package/src/core/enemy-attack-profiles.spec.ts +35 -0
- package/src/core/enemy-attack-profiles.ts +103 -0
- package/src/core/equipment.spec.ts +37 -0
- package/src/core/equipment.ts +17 -0
- package/src/core/hit-reaction.spec.ts +43 -0
- package/src/core/hit-reaction.ts +70 -0
- package/src/core/hit.spec.ts +111 -0
- package/src/core/hit.ts +92 -0
- package/src/enemies/factory.ts +25 -0
- package/src/index.ts +94 -1
- package/src/server.ts +427 -93
- package/src/targeting.spec.ts +24 -0
- package/src/types/canvas-engine.d.ts +4 -0
- package/src/types.ts +148 -0
- package/src/ui/state.ts +57 -0
- package/dist/index.d.ts +0 -11
- package/dist/ui/state.d.ts +0 -18
- /package/dist/{targeting.d.ts → client/targeting.d.ts} +0 -0
package/dist/client/index9.js
CHANGED
|
@@ -1,30 +1,79 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { actionBattleAttackPreviewState } from "./index5.js";
|
|
2
|
+
import { RpgClientEngine, inject } from "@rpgjs/client";
|
|
3
|
+
import { Container, Graphics, computed, cond, h, signal, tick, useDefineProps, useProps } from "canvasengine";
|
|
4
|
+
//#region src/components/attack-preview.ce
|
|
5
|
+
function component($$props) {
|
|
6
|
+
useProps($$props);
|
|
7
|
+
const { object } = useDefineProps($$props)();
|
|
8
|
+
const engine = inject(RpgClientEngine);
|
|
9
|
+
const now = signal(Date.now());
|
|
10
|
+
tick(() => {
|
|
11
|
+
if (actionBattleAttackPreviewState().active) now.set(Date.now());
|
|
12
|
+
});
|
|
13
|
+
const isCurrentPlayer = computed(() => {
|
|
14
|
+
if (!object?.id) return false;
|
|
15
|
+
return (typeof object.id === "function" ? object.id() : object.id) === engine.playerId;
|
|
16
|
+
});
|
|
17
|
+
const preview = computed(() => actionBattleAttackPreviewState());
|
|
18
|
+
const progress = computed(() => {
|
|
19
|
+
const state = preview();
|
|
20
|
+
if (!state.active) return 1;
|
|
21
|
+
const elapsed = now() - state.startedAt;
|
|
22
|
+
return Math.max(0, Math.min(1, elapsed / state.durationMs));
|
|
23
|
+
});
|
|
24
|
+
const shouldRender = computed(() => {
|
|
25
|
+
const state = preview();
|
|
26
|
+
return isCurrentPlayer() && state.active && progress() < 1;
|
|
27
|
+
});
|
|
28
|
+
const getHitbox = () => object.hitbox?.() || {
|
|
29
|
+
w: 32,
|
|
30
|
+
h: 32
|
|
31
|
+
};
|
|
32
|
+
const drawRect = (g, x, y, width, height, color, alpha) => {
|
|
33
|
+
g.rect(x, y, width, height);
|
|
34
|
+
g.fill({
|
|
35
|
+
color,
|
|
36
|
+
alpha
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const drawSlash = (g) => {
|
|
40
|
+
g.clear();
|
|
41
|
+
if (!shouldRender()) return;
|
|
42
|
+
const state = preview();
|
|
43
|
+
const p = progress();
|
|
44
|
+
const alpha = Math.sin(Math.PI * p);
|
|
45
|
+
if (alpha <= 0) return;
|
|
46
|
+
const hitbox = getHitbox();
|
|
47
|
+
const width = hitbox.w || 32;
|
|
48
|
+
const height = hitbox.h || 32;
|
|
49
|
+
const reach = 16 + 18 * p;
|
|
50
|
+
const thickness = 4 + 3 * (1 - p);
|
|
51
|
+
const color = state.color;
|
|
52
|
+
const accent = state.accentColor;
|
|
53
|
+
if (state.direction === "left") {
|
|
54
|
+
drawRect(g, -reach - 6, height * .24, reach, thickness, accent, alpha * .55);
|
|
55
|
+
drawRect(g, -reach - 10, height * .46, reach + 4, thickness + 2, color, alpha);
|
|
56
|
+
drawRect(g, -reach - 6, height * .7, reach, thickness, accent, alpha * .4);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
if (state.direction === "right") {
|
|
60
|
+
drawRect(g, width + 6, height * .24, reach, thickness, accent, alpha * .55);
|
|
61
|
+
drawRect(g, width + 6, height * .46, reach + 4, thickness + 2, color, alpha);
|
|
62
|
+
drawRect(g, width + 6, height * .7, reach, thickness, accent, alpha * .4);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (state.direction === "up") {
|
|
66
|
+
drawRect(g, width * .24, -reach - 6, thickness, reach, accent, alpha * .55);
|
|
67
|
+
drawRect(g, width * .46, -reach - 10, thickness + 2, reach + 4, color, alpha);
|
|
68
|
+
drawRect(g, width * .7, -reach - 6, thickness, reach, accent, alpha * .4);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
drawRect(g, width * .24, height + 6, thickness, reach, accent, alpha * .55);
|
|
72
|
+
drawRect(g, width * .46, height + 6, thickness + 2, reach + 4, color, alpha);
|
|
73
|
+
drawRect(g, width * .7, height + 6, thickness, reach, accent, alpha * .4);
|
|
74
|
+
};
|
|
75
|
+
return h(Container, null, cond(shouldRender, () => h(Graphics, { draw: drawSlash })));
|
|
76
|
+
}
|
|
77
|
+
var __ce_component = component;
|
|
78
|
+
//#endregion
|
|
79
|
+
export { __ce_component as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RpgEvent, RpgPlayer } from '@rpgjs/server';
|
|
1
|
+
import { RpgEvent, RpgPlayer, RpgServer } from '@rpgjs/server';
|
|
2
2
|
import { HitResult, ApplyHitHooks } from './ai.server';
|
|
3
3
|
import { ActionBattleOptions } from './types';
|
|
4
4
|
export declare const ACTION_BATTLE_ACTION_BAR_GUI_ID = "action-battle-action-bar";
|
|
@@ -90,9 +90,17 @@ export declare function getPlayerWeaponKnockbackForce(player: RpgPlayer): number
|
|
|
90
90
|
* });
|
|
91
91
|
* ```
|
|
92
92
|
*/
|
|
93
|
-
export declare function applyPlayerHitToEvent(player: RpgPlayer, target: RpgEvent, hooks?: ApplyHitHooks): HitResult | undefined;
|
|
93
|
+
export declare function applyPlayerHitToEvent(player: RpgPlayer, target: RpgEvent, hooks?: ApplyHitHooks, metadata?: Record<string, any>): HitResult | undefined;
|
|
94
94
|
export declare const openActionBattleActionBar: (player: RpgPlayer, rawOptions?: ActionBattleOptions) => void;
|
|
95
95
|
export declare const updateActionBattleActionBar: (player: RpgPlayer, rawOptions?: ActionBattleOptions) => void;
|
|
96
|
-
export declare const createActionBattleServer: (rawOptions?: ActionBattleOptions) =>
|
|
97
|
-
declare const _default:
|
|
96
|
+
export declare const createActionBattleServer: (rawOptions?: ActionBattleOptions) => RpgServer;
|
|
97
|
+
declare const _default: RpgServer;
|
|
98
98
|
export default _default;
|
|
99
|
+
export { ACTION_BATTLE_HITBOX_FRAME_MS, ActionBattleHitTracker, createActionBattleAttackId, getNormalizedActionBattleAttackProfile, resolveActionBattleHitboxSpeed, scheduleActionBattleStartup, } from './core/attack-runtime';
|
|
100
|
+
export { DEFAULT_ACTION_BATTLE_ATTACK_PROFILE, normalizeActionBattleAttackProfile, type ActionBattleAttackProfileFallbacks, } from './core/attack-profile';
|
|
101
|
+
export type { ActionBattleAttackDirection, ActionBattleAttackHitboxConfig, ActionBattleAttackHitboxMap, ActionBattleAttackHitPolicy, ActionBattleAttackProfile, ActionBattleDebugOptions, ActionBattleHitReactionProfile, NormalizedActionBattleHitReactionProfile, NormalizedActionBattleAttackProfile, } from './types';
|
|
102
|
+
export { DEFAULT_ACTION_BATTLE_HIT_REACTION, isActionBattleEntityInvincible, normalizeActionBattleHitReaction, setActionBattleInvincibility, } from './core/hit-reaction';
|
|
103
|
+
export { DEFAULT_ACTION_BATTLE_ENEMY_ATTACK_PROFILES, normalizeActionBattleEnemyAttackProfiles, type ActionBattleEnemyAttackProfileKey, type ActionBattleEnemyAttackProfileMap, type NormalizedActionBattleEnemyAttackProfileMap, } from './core/enemy-attack-profiles';
|
|
104
|
+
export { resolveActionBattleWeaponAttackProfile } from './core/equipment';
|
|
105
|
+
export { AiDebug, AiState, AttackPattern, BattleAi, DEFAULT_KNOCKBACK, EnemyType, } from './ai.server';
|
|
106
|
+
export type { ApplyHitHooks, BattleAiDefeatedCallback, BattleAiDefeatedContext, BattleAiDefeatReward, BattleAiLegacyDefeatedCallback, BattleAiLegacyOptions, BattleAiOptions, BattleAiRewardItem, BattleAiRewards, HitResult, } from './ai.server';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ActionBattleActionBarSkill, ActionBattleOptions } from '../types';
|
|
2
|
+
export interface ActionBattleAttackPreviewState {
|
|
3
|
+
active: boolean;
|
|
4
|
+
id: number;
|
|
5
|
+
direction: string;
|
|
6
|
+
startedAt: number;
|
|
7
|
+
durationMs: number;
|
|
8
|
+
color: number;
|
|
9
|
+
accentColor: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ActionBattleTargetingState {
|
|
12
|
+
active: boolean;
|
|
13
|
+
skill: ActionBattleActionBarSkill | null;
|
|
14
|
+
range: number;
|
|
15
|
+
offset: {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
aoeMask: string[] | string;
|
|
20
|
+
}
|
|
21
|
+
export declare const actionBattleUiOptions: import('canvasengine').WritableObjectSignal<import('..').ActionBattleUiOptions>;
|
|
22
|
+
export declare const actionBattleSkillOptions: import('canvasengine').WritableObjectSignal<import('../types').ActionBattleSkillOptions>;
|
|
23
|
+
export declare const actionBattleTargetingState: import('canvasengine').WritableObjectSignal<ActionBattleTargetingState>;
|
|
24
|
+
export declare const actionBattleAttackPreviewState: import('canvasengine').WritableObjectSignal<ActionBattleAttackPreviewState>;
|
|
25
|
+
export declare const setActionBattleOptions: (options?: ActionBattleOptions) => void;
|
|
26
|
+
export declare const startTargeting: (skill: ActionBattleActionBarSkill) => void;
|
|
27
|
+
export declare const stopTargeting: () => void;
|
|
28
|
+
export declare const moveTargetingOffset: (dx: number, dy: number) => void;
|
|
29
|
+
export declare const startAttackPreview: (options: {
|
|
30
|
+
direction: string;
|
|
31
|
+
durationMs?: number;
|
|
32
|
+
color?: number;
|
|
33
|
+
accentColor?: number;
|
|
34
|
+
}) => number;
|
|
35
|
+
export declare const stopAttackPreview: (id?: number) => void;
|