@rpgjs/action-battle 5.0.0-beta.3 → 5.0.0-beta.5
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/README.md +137 -0
- package/dist/ai.server.d.ts +8 -1
- package/dist/client/index.js +8 -4
- package/dist/client/index10.js +97 -330
- package/dist/client/index11.js +25 -0
- package/dist/client/index12.js +1222 -0
- package/dist/client/index13.js +46 -0
- package/dist/client/index14.js +10 -0
- package/dist/client/index15.js +448 -0
- package/dist/client/index2.js +30 -0
- package/dist/client/index3.js +33 -1
- package/dist/client/index4.js +7 -3
- package/dist/client/index7.js +76 -32
- package/dist/client/index8.js +24 -4
- package/dist/client/index9.js +94 -1165
- package/dist/core/context.d.ts +5 -0
- package/dist/core/defaults.d.ts +81 -0
- package/dist/core/hit.d.ts +2 -0
- package/dist/enemies/factory.d.ts +7 -0
- package/dist/index.d.ts +6 -1
- package/dist/server/index.js +7 -3
- package/dist/server/index10.js +10 -0
- package/dist/server/index2.js +23 -3
- package/dist/server/index3.js +30 -0
- package/dist/server/index4.js +137 -1163
- package/dist/server/index5.js +22 -34
- package/dist/server/index6.js +1190 -345
- package/dist/server/index7.js +37 -0
- package/dist/server/index8.js +46 -0
- package/dist/server/index9.js +447 -0
- package/dist/server.d.ts +2 -0
- package/dist/ui/state.d.ts +17 -0
- package/package.json +5 -5
- package/src/ai.server.ts +91 -24
- package/src/animations.ts +43 -4
- package/src/canvas-engine-shim.ts +4 -0
- package/src/client.ts +122 -2
- package/src/components/action-bar.ce +5 -3
- package/src/components/attack-preview.ce +90 -0
- package/src/config.ts +30 -0
- package/src/core/context.ts +35 -0
- package/src/core/contracts.ts +123 -0
- package/src/core/defaults.ts +162 -0
- package/src/core/hit.spec.ts +58 -0
- package/src/core/hit.ts +66 -0
- package/src/enemies/factory.ts +25 -0
- package/src/index.ts +40 -0
- package/src/server.ts +235 -71
- package/src/targeting.spec.ts +24 -0
- package/src/types/canvas-engine.d.ts +4 -0
- package/src/types.ts +46 -1
- package/src/ui/state.ts +57 -0
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ActionBattleOptions } from '../types';
|
|
2
|
+
import { ActionBattleSystems } from './contracts';
|
|
3
|
+
export declare const setActionBattleSystems: (options?: ActionBattleOptions) => void;
|
|
4
|
+
export declare const getActionBattleSystems: () => ActionBattleSystems;
|
|
5
|
+
export declare const createActionBattleSystems: (options?: ActionBattleOptions) => ActionBattleSystems;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { RpgPlayer } from '@rpgjs/server';
|
|
2
|
+
import { ActionBattleAiBehavior, ActionBattleAttackContext, ActionBattleCombatSystem, ActionBattleDamageContext, ActionBattleKnockbackContext, ActionBattleKnockbackResult, ActionBattleSystems } from './contracts';
|
|
3
|
+
export declare const DEFAULT_ZELDA_PLAYER_HITBOXES: {
|
|
4
|
+
up: {
|
|
5
|
+
offsetX: number;
|
|
6
|
+
offsetY: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
};
|
|
10
|
+
down: {
|
|
11
|
+
offsetX: number;
|
|
12
|
+
offsetY: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
};
|
|
16
|
+
left: {
|
|
17
|
+
offsetX: number;
|
|
18
|
+
offsetY: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
22
|
+
right: {
|
|
23
|
+
offsetX: number;
|
|
24
|
+
offsetY: number;
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
};
|
|
28
|
+
default: {
|
|
29
|
+
offsetX: number;
|
|
30
|
+
offsetY: number;
|
|
31
|
+
width: number;
|
|
32
|
+
height: number;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare const createDefaultPlayerHitboxResolver: (hitboxes?: {
|
|
36
|
+
up: {
|
|
37
|
+
offsetX: number;
|
|
38
|
+
offsetY: number;
|
|
39
|
+
width: number;
|
|
40
|
+
height: number;
|
|
41
|
+
};
|
|
42
|
+
down: {
|
|
43
|
+
offsetX: number;
|
|
44
|
+
offsetY: number;
|
|
45
|
+
width: number;
|
|
46
|
+
height: number;
|
|
47
|
+
};
|
|
48
|
+
left: {
|
|
49
|
+
offsetX: number;
|
|
50
|
+
offsetY: number;
|
|
51
|
+
width: number;
|
|
52
|
+
height: number;
|
|
53
|
+
};
|
|
54
|
+
right: {
|
|
55
|
+
offsetX: number;
|
|
56
|
+
offsetY: number;
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
};
|
|
60
|
+
default: {
|
|
61
|
+
offsetX: number;
|
|
62
|
+
offsetY: number;
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
};
|
|
66
|
+
}) => (context: ActionBattleAttackContext) => {
|
|
67
|
+
x: any;
|
|
68
|
+
y: any;
|
|
69
|
+
width: number;
|
|
70
|
+
height: number;
|
|
71
|
+
}[];
|
|
72
|
+
export declare const defaultRpgjsDamageResolver: (context: ActionBattleDamageContext) => {
|
|
73
|
+
damage: any;
|
|
74
|
+
defeated: boolean;
|
|
75
|
+
raw: any;
|
|
76
|
+
};
|
|
77
|
+
export declare const defaultKnockbackResolver: (context: ActionBattleKnockbackContext) => ActionBattleKnockbackResult;
|
|
78
|
+
export declare const defaultCombatSystem: ActionBattleCombatSystem;
|
|
79
|
+
export declare const defaultEnemyBehaviors: Record<string, ActionBattleAiBehavior>;
|
|
80
|
+
export declare const defaultActionBattleSystems: ActionBattleSystems;
|
|
81
|
+
export declare const getEntityWeaponKnockbackForce: (entity: RpgPlayer) => number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RpgEvent } from '@rpgjs/server';
|
|
2
|
+
import { BattleAi, BattleAiOptions } from '../ai.server';
|
|
3
|
+
export interface ActionBattleEnemyPreset extends BattleAiOptions {
|
|
4
|
+
stats?: (event: RpgEvent) => void;
|
|
5
|
+
}
|
|
6
|
+
export type ActionBattleEnemyPresetMap = Record<string, ActionBattleEnemyPreset>;
|
|
7
|
+
export declare const createActionEnemy: (event: RpgEvent, presetOrOptions: string | BattleAiOptions, presets?: ActionBattleEnemyPresetMap) => BattleAi;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { ActionBattleOptions } from './types';
|
|
2
2
|
export { BattleAi, AiState, EnemyType, AttackPattern, AiDebug, DEFAULT_KNOCKBACK } from './ai.server';
|
|
3
3
|
export type { HitResult, ApplyHitHooks, BattleAiOptions } from './ai.server';
|
|
4
|
-
export type { ActionBattleAnimationContext, ActionBattleAnimationEntity, ActionBattleAnimationKey, ActionBattleAnimationOptions, ActionBattleAnimationResolver, ActionBattleAnimationResult, ActionBattleOptions, ActionBattleActionBarData, ActionBattleActionBarItem, ActionBattleActionBarSkill, ActionBattleSkillTargeting, ActionBattleSkillTargetingResolver, ActionBattleUiOptions, ActionBattleUiActionBarOptions, ActionBattleUiTargetingOptions, } from './types';
|
|
4
|
+
export type { ActionBattleAnimationContext, ActionBattleAnimationEntity, ActionBattleAnimationKey, ActionBattleAnimationOptions, ActionBattleAnimationResolver, ActionBattleAnimationResult, ActionBattleOptions, ActionBattleActionBarData, ActionBattleActionBarItem, ActionBattleActionBarSkill, ActionBattleSkillTargeting, ActionBattleSkillTargetingResolver, ActionBattleAttackOptions, ActionBattleUiOptions, ActionBattleUiActionBarOptions, ActionBattleUiTargetingOptions, ActionBattleCombatOptions, ActionBattleSystemOptions, ActionBattleAiSystemOptions, } from './types';
|
|
5
|
+
export type { ActionBattleAiBehavior, ActionBattleAiContext, ActionBattleAiDecision, ActionBattleAttackContext, ActionBattleCombatSystem, ActionBattleDamageContext, ActionBattleDamageResult, ActionBattleDirection, ActionBattleEntity, ActionBattleHitContext, ActionBattleHitHooks, ActionBattleHitResult, ActionBattleHitbox, ActionBattleKnockbackContext, ActionBattleKnockbackResult, ActionBattleSystems, } from './core/contracts';
|
|
6
|
+
export { DEFAULT_ZELDA_PLAYER_HITBOXES, createDefaultPlayerHitboxResolver, defaultCombatSystem, defaultEnemyBehaviors, defaultKnockbackResolver, defaultRpgjsDamageResolver, } from './core/defaults';
|
|
7
|
+
export { createActionBattleSystems, getActionBattleSystems, } from './core/context';
|
|
8
|
+
export { applyActionBattleHit } from './core/hit';
|
|
9
|
+
export { createActionEnemy, type ActionBattleEnemyPreset, type ActionBattleEnemyPresetMap, } from './enemies/factory';
|
|
5
10
|
export { DEFAULT_PLAYER_ATTACK_HITBOXES, getPlayerWeaponKnockbackForce, applyPlayerHitToEvent, ACTION_BATTLE_ACTION_BAR_GUI_ID, openActionBattleActionBar, updateActionBattleActionBar, createActionBattleServer, } from './server';
|
|
6
11
|
export declare function provideActionBattle(options?: ActionBattleOptions): any[];
|
|
7
12
|
declare const _default: {
|
package/dist/server/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
1
|
+
import { DEFAULT_ZELDA_PLAYER_HITBOXES, createDefaultPlayerHitboxResolver, defaultCombatSystem, defaultEnemyBehaviors, defaultKnockbackResolver, defaultRpgjsDamageResolver } from "./index4.js";
|
|
2
|
+
import { createActionBattleSystems, getActionBattleSystems } from "./index5.js";
|
|
3
|
+
import { AiDebug, AiState, AttackPattern, BattleAi, DEFAULT_KNOCKBACK, EnemyType } from "./index6.js";
|
|
4
|
+
import { applyActionBattleHit } from "./index8.js";
|
|
5
|
+
import server_default, { ACTION_BATTLE_ACTION_BAR_GUI_ID, DEFAULT_PLAYER_ATTACK_HITBOXES, applyPlayerHitToEvent, createActionBattleServer, getPlayerWeaponKnockbackForce, openActionBattleActionBar, updateActionBattleActionBar } from "./index9.js";
|
|
6
|
+
import { createActionEnemy } from "./index10.js";
|
|
3
7
|
import { createModule } from "@rpgjs/common";
|
|
4
8
|
//#region src/index.ts
|
|
5
9
|
var client = null;
|
|
@@ -15,4 +19,4 @@ var src_default = {
|
|
|
15
19
|
client
|
|
16
20
|
};
|
|
17
21
|
//#endregion
|
|
18
|
-
export { ACTION_BATTLE_ACTION_BAR_GUI_ID, AiDebug, AiState, AttackPattern, BattleAi, DEFAULT_KNOCKBACK, DEFAULT_PLAYER_ATTACK_HITBOXES, EnemyType, applyPlayerHitToEvent, createActionBattleServer, src_default as default, getPlayerWeaponKnockbackForce, openActionBattleActionBar, provideActionBattle, updateActionBattleActionBar };
|
|
22
|
+
export { ACTION_BATTLE_ACTION_BAR_GUI_ID, AiDebug, AiState, AttackPattern, BattleAi, DEFAULT_KNOCKBACK, DEFAULT_PLAYER_ATTACK_HITBOXES, DEFAULT_ZELDA_PLAYER_HITBOXES, EnemyType, applyActionBattleHit, applyPlayerHitToEvent, createActionBattleServer, createActionBattleSystems, createActionEnemy, createDefaultPlayerHitboxResolver, src_default as default, defaultCombatSystem, defaultEnemyBehaviors, defaultKnockbackResolver, defaultRpgjsDamageResolver, getActionBattleSystems, getPlayerWeaponKnockbackForce, openActionBattleActionBar, provideActionBattle, updateActionBattleActionBar };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BattleAi } from "./index6.js";
|
|
2
|
+
//#region src/enemies/factory.ts
|
|
3
|
+
var createActionEnemy = (event, presetOrOptions, presets = {}) => {
|
|
4
|
+
const options = typeof presetOrOptions === "string" ? presets[presetOrOptions] : presetOrOptions;
|
|
5
|
+
if (!options) throw new Error(`Action battle enemy preset not found: ${presetOrOptions}`);
|
|
6
|
+
options.stats?.(event);
|
|
7
|
+
return new BattleAi(event, options);
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { createActionEnemy };
|
package/dist/server/index2.js
CHANGED
|
@@ -2,14 +2,34 @@ var DEFAULT_ANIMATION_BY_KEY = {
|
|
|
2
2
|
attack: "attack",
|
|
3
3
|
hurt: "hurt",
|
|
4
4
|
die: "die",
|
|
5
|
-
castSkill: "skill"
|
|
5
|
+
castSkill: "skill",
|
|
6
|
+
castSpell: "skill"
|
|
7
|
+
};
|
|
8
|
+
var getConfiguredAnimation = (key, animations) => {
|
|
9
|
+
if (!animations) return {
|
|
10
|
+
hasConfiguredAnimation: false,
|
|
11
|
+
configured: void 0
|
|
12
|
+
};
|
|
13
|
+
const hasConfiguredAnimation = Object.prototype.hasOwnProperty.call(animations, key);
|
|
14
|
+
if (hasConfiguredAnimation) return {
|
|
15
|
+
hasConfiguredAnimation,
|
|
16
|
+
configured: animations[key]
|
|
17
|
+
};
|
|
18
|
+
if (key === "castSkill") return {
|
|
19
|
+
hasConfiguredAnimation: Object.prototype.hasOwnProperty.call(animations, "castSpell"),
|
|
20
|
+
configured: animations.castSpell
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
hasConfiguredAnimation: false,
|
|
24
|
+
configured: void 0
|
|
25
|
+
};
|
|
6
26
|
};
|
|
7
27
|
function resolveActionBattleAnimation(key, entity, animations, context, defaults = {}) {
|
|
8
28
|
const defaultAnimationName = defaults.animationName ?? DEFAULT_ANIMATION_BY_KEY[key];
|
|
9
29
|
const defaultRepeat = defaults.repeat ?? 1;
|
|
10
|
-
const hasConfiguredAnimation
|
|
30
|
+
const { hasConfiguredAnimation, configured: configuredAnimation } = getConfiguredAnimation(key, animations);
|
|
11
31
|
if (!hasConfiguredAnimation && key !== "attack") return null;
|
|
12
|
-
const configured = hasConfiguredAnimation ?
|
|
32
|
+
const configured = hasConfiguredAnimation ? configuredAnimation : defaultAnimationName;
|
|
13
33
|
const result = typeof configured === "function" ? configured(entity, context) : configured;
|
|
14
34
|
if (result == null) return null;
|
|
15
35
|
if (typeof result === "string") return {
|
package/dist/server/index3.js
CHANGED
|
@@ -21,6 +21,14 @@ var DEFAULT_ACTION_BATTLE_OPTIONS = {
|
|
|
21
21
|
affects: "events",
|
|
22
22
|
allowEmptyTarget: true
|
|
23
23
|
},
|
|
24
|
+
attack: {
|
|
25
|
+
lockMovement: true,
|
|
26
|
+
lockDurationMs: 350,
|
|
27
|
+
showPreview: true,
|
|
28
|
+
previewDurationMs: 180,
|
|
29
|
+
previewColor: 16774064,
|
|
30
|
+
previewAccentColor: 16777215
|
|
31
|
+
},
|
|
24
32
|
animations: {}
|
|
25
33
|
};
|
|
26
34
|
var currentActionBattleOptions = DEFAULT_ACTION_BATTLE_OPTIONS;
|
|
@@ -48,9 +56,31 @@ function normalizeActionBattleOptions(options = {}) {
|
|
|
48
56
|
...DEFAULT_ACTION_BATTLE_OPTIONS.targeting,
|
|
49
57
|
...options.targeting
|
|
50
58
|
},
|
|
59
|
+
attack: {
|
|
60
|
+
...DEFAULT_ACTION_BATTLE_OPTIONS.attack,
|
|
61
|
+
...options.attack
|
|
62
|
+
},
|
|
51
63
|
animations: {
|
|
52
64
|
...DEFAULT_ACTION_BATTLE_OPTIONS.animations,
|
|
53
65
|
...options.animations
|
|
66
|
+
},
|
|
67
|
+
systems: {
|
|
68
|
+
combat: {
|
|
69
|
+
...DEFAULT_ACTION_BATTLE_OPTIONS.systems?.combat,
|
|
70
|
+
...options.systems?.combat,
|
|
71
|
+
hooks: {
|
|
72
|
+
...DEFAULT_ACTION_BATTLE_OPTIONS.systems?.combat?.hooks,
|
|
73
|
+
...options.systems?.combat?.hooks
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
ai: {
|
|
77
|
+
...DEFAULT_ACTION_BATTLE_OPTIONS.systems?.ai,
|
|
78
|
+
...options.systems?.ai,
|
|
79
|
+
behaviors: {
|
|
80
|
+
...DEFAULT_ACTION_BATTLE_OPTIONS.systems?.ai?.behaviors,
|
|
81
|
+
...options.systems?.ai?.behaviors
|
|
82
|
+
}
|
|
83
|
+
}
|
|
54
84
|
}
|
|
55
85
|
};
|
|
56
86
|
}
|