@rpgjs/action-battle 5.0.0-alpha.28

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.
@@ -0,0 +1,93 @@
1
+ import { RpgEvent, RpgPlayer } from '@rpgjs/server';
2
+ import { HitResult, ApplyHitHooks } from './ai.server';
3
+ /**
4
+ * Default player attack hitboxes offsets for each direction
5
+ *
6
+ * These hitboxes define the attack areas relative to the player's position
7
+ * for each cardinal direction. They are converted to absolute coordinates
8
+ * when creating the moving hitbox.
9
+ */
10
+ export declare const DEFAULT_PLAYER_ATTACK_HITBOXES: {
11
+ up: {
12
+ offsetX: number;
13
+ offsetY: number;
14
+ width: number;
15
+ height: number;
16
+ };
17
+ down: {
18
+ offsetX: number;
19
+ offsetY: number;
20
+ width: number;
21
+ height: number;
22
+ };
23
+ left: {
24
+ offsetX: number;
25
+ offsetY: number;
26
+ width: number;
27
+ height: number;
28
+ };
29
+ right: {
30
+ offsetX: number;
31
+ offsetY: number;
32
+ width: number;
33
+ height: number;
34
+ };
35
+ default: {
36
+ offsetX: number;
37
+ offsetY: number;
38
+ width: number;
39
+ height: number;
40
+ };
41
+ };
42
+ /**
43
+ * Get knockback force from player's equipped weapon
44
+ *
45
+ * Retrieves the knockbackForce property from the player's equipped weapon.
46
+ * Falls back to DEFAULT_KNOCKBACK.force if no weapon or property is set.
47
+ *
48
+ * @param player - The player to get weapon knockback from
49
+ * @returns Knockback force value
50
+ *
51
+ * @example
52
+ * ```ts
53
+ * // Player with weapon having knockbackForce: 80
54
+ * const force = getPlayerWeaponKnockbackForce(player); // 80
55
+ *
56
+ * // No weapon equipped
57
+ * const force = getPlayerWeaponKnockbackForce(player); // 50 (default)
58
+ * ```
59
+ */
60
+ export declare function getPlayerWeaponKnockbackForce(player: RpgPlayer): number;
61
+ /**
62
+ * Apply hit from player to target (event with AI)
63
+ *
64
+ * Handles damage calculation, knockback based on weapon, and visual effects.
65
+ * Can be customized using hooks.
66
+ *
67
+ * @param player - The attacking player
68
+ * @param target - The event being hit
69
+ * @param hooks - Optional hooks for customizing hit behavior
70
+ * @returns Hit result if AI exists, undefined otherwise
71
+ *
72
+ * @example
73
+ * ```ts
74
+ * // Basic hit
75
+ * const result = applyPlayerHitToEvent(player, event);
76
+ *
77
+ * // With custom hooks
78
+ * const result = applyPlayerHitToEvent(player, event, {
79
+ * onBeforeHit(result) {
80
+ * result.knockbackForce *= 2; // Double knockback
81
+ * return result;
82
+ * },
83
+ * onAfterHit(result) {
84
+ * if (result.defeated) {
85
+ * player.gold += 10;
86
+ * }
87
+ * }
88
+ * });
89
+ * ```
90
+ */
91
+ export declare function applyPlayerHitToEvent(player: RpgPlayer, target: RpgEvent, hooks?: ApplyHitHooks): HitResult | undefined;
92
+ declare const _default: any;
93
+ export default _default;
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@rpgjs/action-battle",
3
+ "version": "5.0.0-alpha.28",
4
+ "main": "dist/index.js",
5
+ "types": "dist/index.d.ts",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./dist/client/index.js",
9
+ "types": "./dist/index.d.ts"
10
+ },
11
+ "./client": {
12
+ "import": "./dist/client/index.js",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "./server": {
16
+ "import": "./dist/server/index.js",
17
+ "types": "./dist/server.d.ts"
18
+ }
19
+ },
20
+ "keywords": [],
21
+ "author": "",
22
+ "license": "MIT",
23
+ "description": "RPGJS is a framework for creating RPG/MMORPG games",
24
+ "peerDependencies": {
25
+ "@canvasengine/presets": "*",
26
+ "@rpgjs/client": "5.0.0-alpha.28",
27
+ "@rpgjs/common": "5.0.0-alpha.28",
28
+ "@rpgjs/server": "5.0.0-alpha.28",
29
+ "@rpgjs/vite": "5.0.0-alpha.28",
30
+ "canvasengine": "*"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "devDependencies": {
36
+ "@canvasengine/compiler": "^2.0.0-beta.42",
37
+ "vite": "^7.3.0",
38
+ "vite-plugin-dts": "^4.5.4"
39
+ },
40
+ "type": "module",
41
+ "scripts": {
42
+ "dev": "vite build --watch",
43
+ "build": "vite build"
44
+ }
45
+ }