@rpgjs/action-battle 5.0.0-beta.11 → 5.0.0-beta.13
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 +22 -0
- package/dist/client/ai.server.d.ts +57 -8
- package/dist/client/attack-input.d.ts +3 -0
- package/dist/client/core/action-use.d.ts +18 -0
- package/dist/client/core/ai-behavior-tree.d.ts +99 -0
- package/dist/client/core/attack-runtime.d.ts +2 -0
- package/dist/client/core/defaults.d.ts +3 -2
- package/dist/client/core/equipment.d.ts +1 -0
- package/dist/client/core/targets.d.ts +15 -0
- package/dist/client/enemies/factory.d.ts +2 -0
- package/dist/client/index.d.ts +12 -7
- package/dist/client/index.js +16 -11
- package/dist/client/index10.js +32 -56
- package/dist/client/index11.js +99 -52
- package/dist/client/index12.js +76 -103
- package/dist/client/index13.js +72 -135
- package/dist/client/index14.js +67 -23
- package/dist/client/index15.js +197 -63
- package/dist/client/index16.js +112 -1337
- package/dist/client/index17.js +203 -7
- package/dist/client/index18.js +32 -58
- package/dist/client/index19.js +70 -8
- package/dist/client/index20.js +57 -501
- package/dist/client/index21.js +70 -0
- package/dist/client/index22.js +226 -0
- package/dist/client/index23.js +16 -0
- package/dist/client/index24.js +25 -0
- package/dist/client/index25.js +107 -0
- package/dist/client/index26.js +1949 -0
- package/dist/client/index27.js +12 -0
- package/dist/client/index28.js +589 -0
- package/dist/client/index4.js +79 -38
- package/dist/client/index6.js +65 -306
- package/dist/client/index7.js +33 -33
- package/dist/client/index8.js +24 -100
- package/dist/client/index9.js +293 -61
- package/dist/client/locomotion.d.ts +16 -0
- package/dist/client/movement.d.ts +14 -0
- package/dist/client/server.d.ts +7 -3
- package/dist/client/ui.d.ts +22 -0
- package/dist/client/visual.d.ts +15 -0
- package/dist/server/ai.server.d.ts +57 -8
- package/dist/server/attack-input.d.ts +3 -0
- package/dist/server/core/action-use.d.ts +18 -0
- package/dist/server/core/ai-behavior-tree.d.ts +99 -0
- package/dist/server/core/attack-runtime.d.ts +2 -0
- package/dist/server/core/defaults.d.ts +3 -2
- package/dist/server/core/equipment.d.ts +1 -0
- package/dist/server/core/targets.d.ts +15 -0
- package/dist/server/enemies/factory.d.ts +2 -0
- package/dist/server/index.d.ts +12 -7
- package/dist/server/index.js +14 -9
- package/dist/server/index10.js +64 -1336
- package/dist/server/index11.js +33 -33
- package/dist/server/index13.js +67 -11
- package/dist/server/index14.js +207 -484
- package/dist/server/index15.js +15 -9
- package/dist/server/index16.js +26 -0
- package/dist/server/index17.js +25 -0
- package/dist/server/index18.js +107 -0
- package/dist/server/index19.js +1949 -0
- package/dist/server/index2.js +10 -2
- package/dist/server/index20.js +37 -0
- package/dist/server/index21.js +588 -0
- package/dist/server/index22.js +78 -0
- package/dist/server/index23.js +12 -0
- package/dist/server/index5.js +79 -38
- package/dist/server/index6.js +192 -129
- package/dist/server/index7.js +208 -24
- package/dist/server/index8.js +28 -66
- package/dist/server/index9.js +68 -51
- package/dist/server/locomotion.d.ts +16 -0
- package/dist/server/movement.d.ts +14 -0
- package/dist/server/server.d.ts +7 -3
- package/dist/server/ui.d.ts +22 -0
- package/dist/server/visual.d.ts +15 -0
- package/package.json +5 -5
- package/src/ai.server.spec.ts +380 -1
- package/src/ai.server.ts +963 -137
- package/src/animations.spec.ts +40 -0
- package/src/animations.ts +31 -9
- package/src/attack-input.spec.ts +51 -0
- package/src/attack-input.ts +59 -0
- package/src/client.ts +75 -62
- package/src/config.ts +84 -37
- package/src/core/action-use.spec.ts +317 -0
- package/src/core/action-use.ts +387 -0
- package/src/core/ai-behavior-tree.spec.ts +116 -0
- package/src/core/ai-behavior-tree.ts +272 -0
- package/src/core/attack-profile.spec.ts +46 -0
- package/src/core/attack-runtime.spec.ts +35 -0
- package/src/core/attack-runtime.ts +32 -0
- package/src/core/context.ts +9 -0
- package/src/core/contracts.ts +146 -1
- package/src/core/defaults.ts +72 -1
- package/src/core/equipment.ts +9 -5
- package/src/core/hit.spec.ts +21 -0
- package/src/core/targets.spec.ts +124 -0
- package/src/core/targets.ts +150 -0
- package/src/enemies/factory.ts +8 -0
- package/src/index.ts +111 -2
- package/src/locomotion.spec.ts +51 -0
- package/src/locomotion.ts +48 -0
- package/src/movement.spec.ts +78 -0
- package/src/movement.ts +46 -0
- package/src/server.ts +242 -66
- package/src/types.ts +105 -35
- package/src/ui.ts +113 -0
- package/src/visual.spec.ts +166 -0
- package/src/visual.ts +285 -0
- package/README.md +0 -1242
package/dist/client/index15.js
CHANGED
|
@@ -1,72 +1,206 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { getActionBattleOptions } from "./index4.js";
|
|
2
|
+
import { playActionBattleAnimation } from "./index14.js";
|
|
3
|
+
//#region src/visual.ts
|
|
4
|
+
var ACTION_BATTLE_CLIENT_VISUAL_ID = "action-battle.visual";
|
|
5
|
+
var ACTION_BATTLE_HIT_FX_COMPONENT_ID = "action-battle-hit-fx";
|
|
6
|
+
var previewStarter;
|
|
7
|
+
function setActionBattlePreviewStarter(starter) {
|
|
8
|
+
previewStarter = starter;
|
|
9
|
+
}
|
|
10
|
+
var entityId = (entity) => typeof entity?.id === "string" ? entity.id : void 0;
|
|
11
|
+
var serializeSkill = (skill) => {
|
|
12
|
+
const id = skill?.id;
|
|
13
|
+
if (typeof id === "string") return { id };
|
|
14
|
+
if (typeof id === "function") {
|
|
15
|
+
const value = id.call(skill);
|
|
16
|
+
if (typeof value === "string") return { id: value };
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
var serializeResult = (result) => {
|
|
20
|
+
if (!result) return void 0;
|
|
21
|
+
return {
|
|
22
|
+
damage: result.damage,
|
|
23
|
+
knockbackForce: result.knockbackForce,
|
|
24
|
+
knockbackDuration: result.knockbackDuration,
|
|
25
|
+
defeated: result.defeated,
|
|
26
|
+
attackerId: entityId(result.attacker),
|
|
27
|
+
targetId: entityId(result.target),
|
|
28
|
+
rawDamage: result.rawDamage,
|
|
29
|
+
reaction: result.reaction,
|
|
30
|
+
cancelled: result.cancelled,
|
|
31
|
+
metadata: result.metadata
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
var serializeActionBattleVisualContext = (context) => ({
|
|
35
|
+
moment: context.moment,
|
|
36
|
+
objectId: entityId(context.entity),
|
|
37
|
+
sourceId: entityId(context.attacker ?? context.entity),
|
|
38
|
+
targetId: entityId(context.target),
|
|
39
|
+
damage: context.damage,
|
|
40
|
+
defeated: context.defeated,
|
|
41
|
+
result: serializeResult(context.result),
|
|
42
|
+
skill: serializeSkill(context.skill),
|
|
43
|
+
pattern: context.pattern,
|
|
44
|
+
animations: context.animations,
|
|
45
|
+
animationDefaults: context.animationDefaults
|
|
46
|
+
});
|
|
47
|
+
function emitActionBattleClientVisual(context) {
|
|
48
|
+
if (getActionBattleOptions().visual === "none") return;
|
|
49
|
+
const map = (context.entity ?? context.target ?? context.attacker)?.getCurrentMap?.();
|
|
50
|
+
if (!map?.clientVisual) return;
|
|
51
|
+
map.clientVisual(ACTION_BATTLE_CLIENT_VISUAL_ID, serializeActionBattleVisualContext(context));
|
|
52
|
+
}
|
|
53
|
+
function createActionBattleClientVisuals(options = getActionBattleOptions()) {
|
|
54
|
+
return { [ACTION_BATTLE_CLIENT_VISUAL_ID]: (context) => {
|
|
55
|
+
const data = context.data ?? {};
|
|
56
|
+
playActionBattleVisual(options.visual, {
|
|
57
|
+
moment: data.moment,
|
|
58
|
+
entity: context.object ?? context.source ?? context.target,
|
|
59
|
+
target: context.target,
|
|
60
|
+
attacker: context.source,
|
|
61
|
+
damage: data.damage,
|
|
62
|
+
defeated: data.defeated,
|
|
63
|
+
result: data.result,
|
|
64
|
+
skill: data.skill,
|
|
65
|
+
pattern: data.pattern,
|
|
66
|
+
animations: data.animations ?? options.animations,
|
|
67
|
+
animationDefaults: data.animationDefaults
|
|
68
|
+
});
|
|
69
|
+
} };
|
|
70
|
+
}
|
|
71
|
+
var callGraphic = (entity, keyOrOptions, context) => {
|
|
72
|
+
if (!entity || keyOrOptions == null) return;
|
|
73
|
+
if (typeof keyOrOptions === "string") {
|
|
74
|
+
playActionBattleAnimation(keyOrOptions, entity, context?.animations ?? getActionBattleOptions().animations, {
|
|
75
|
+
attacker: context?.attacker,
|
|
76
|
+
target: context?.target,
|
|
77
|
+
skill: context?.skill
|
|
78
|
+
}, context?.animationDefaults);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const animationName = keyOrOptions.animationName;
|
|
82
|
+
if (!animationName) return;
|
|
83
|
+
const repeat = keyOrOptions.repeat ?? 1;
|
|
84
|
+
const graphic = keyOrOptions.graphic;
|
|
85
|
+
if (typeof entity.setGraphicAnimation === "function") {
|
|
86
|
+
if (graphic !== void 0) entity.setGraphicAnimation(animationName, graphic, repeat);
|
|
87
|
+
else entity.setGraphicAnimation(animationName, repeat);
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (typeof entity.setAnimation === "function") if (graphic !== void 0) entity.setAnimation(animationName, graphic, repeat);
|
|
91
|
+
else entity.setAnimation(animationName, repeat);
|
|
92
|
+
};
|
|
93
|
+
var createHelpers = (context) => ({
|
|
94
|
+
graphic(entity, keyOrOptions) {
|
|
95
|
+
callGraphic(entity, keyOrOptions, context);
|
|
15
96
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
hitstunMs: 90,
|
|
25
|
-
staggerPower: .75
|
|
26
|
-
}
|
|
97
|
+
flash(entity, options = {}) {
|
|
98
|
+
entity?.flash?.({
|
|
99
|
+
type: "tint",
|
|
100
|
+
tint: "red",
|
|
101
|
+
duration: 200,
|
|
102
|
+
cycles: 1,
|
|
103
|
+
...options
|
|
104
|
+
});
|
|
27
105
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
106
|
+
damageText(entity, damageOrText) {
|
|
107
|
+
if (typeof damageOrText === "string") {
|
|
108
|
+
if (entity?.showHit) {
|
|
109
|
+
entity.showHit(damageOrText);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
entity?.showComponentAnimation?.("hit", {
|
|
113
|
+
text: damageOrText,
|
|
114
|
+
direction: entity?.direction?.() ?? entity?.direction
|
|
115
|
+
});
|
|
116
|
+
return;
|
|
38
117
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
cooldownMs: 950,
|
|
46
|
-
reaction: {
|
|
47
|
-
invincibilityMs: 300,
|
|
48
|
-
hitstunMs: 160,
|
|
49
|
-
staggerPower: 1.25
|
|
118
|
+
const damage = damageOrText ?? context.damage ?? context.result?.damage;
|
|
119
|
+
if (damage === void 0) return;
|
|
120
|
+
const text = `-${damage}`;
|
|
121
|
+
if (entity?.showHit) {
|
|
122
|
+
entity.showHit(text);
|
|
123
|
+
return;
|
|
50
124
|
}
|
|
125
|
+
entity?.showComponentAnimation?.("hit", {
|
|
126
|
+
text,
|
|
127
|
+
direction: entity?.direction?.() ?? entity?.direction
|
|
128
|
+
});
|
|
51
129
|
},
|
|
52
|
-
|
|
53
|
-
id
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
130
|
+
component(entity, id, params = {}) {
|
|
131
|
+
entity?.showComponentAnimation?.(id, params);
|
|
132
|
+
},
|
|
133
|
+
preview(entity, options = {}) {
|
|
134
|
+
previewStarter?.(entity, options);
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
var classicParts = {
|
|
138
|
+
attack({ entity }, fx) {
|
|
139
|
+
fx.graphic(entity, "attack");
|
|
140
|
+
},
|
|
141
|
+
castSkill({ entity }, fx) {
|
|
142
|
+
fx.graphic(entity, "castSkill");
|
|
143
|
+
},
|
|
144
|
+
preview({ entity }, fx) {
|
|
145
|
+
fx.preview(entity);
|
|
146
|
+
},
|
|
147
|
+
hit({ target, damage }, fx) {
|
|
148
|
+
fx.flash(target);
|
|
149
|
+
fx.damageText(target, damage);
|
|
150
|
+
},
|
|
151
|
+
hurt({ entity, target }, fx) {
|
|
152
|
+
const hurtTarget = target ?? entity;
|
|
153
|
+
fx.flash(hurtTarget);
|
|
154
|
+
fx.damageText(hurtTarget);
|
|
155
|
+
fx.graphic(hurtTarget, "hurt");
|
|
156
|
+
},
|
|
157
|
+
defeat({ entity, target }, fx) {
|
|
158
|
+
fx.graphic(target ?? entity, "die");
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
var fxParts = {
|
|
162
|
+
...classicParts,
|
|
163
|
+
hit(context, fx) {
|
|
164
|
+
classicParts.hit?.(context, fx);
|
|
165
|
+
fx.component(context.target, ACTION_BATTLE_HIT_FX_COMPONENT_ID, {
|
|
166
|
+
name: "hitSpark",
|
|
167
|
+
scale: .8,
|
|
168
|
+
zIndex: 1e3
|
|
169
|
+
});
|
|
170
|
+
},
|
|
171
|
+
hurt(context, fx) {
|
|
172
|
+
classicParts.hurt?.(context, fx);
|
|
173
|
+
fx.component(context.target ?? context.entity, ACTION_BATTLE_HIT_FX_COMPONENT_ID, {
|
|
174
|
+
name: "hitSpark",
|
|
175
|
+
scale: .8,
|
|
176
|
+
zIndex: 1e3
|
|
177
|
+
});
|
|
63
178
|
}
|
|
64
179
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
180
|
+
var resolveParts = (input) => {
|
|
181
|
+
const visual = input ?? "classic";
|
|
182
|
+
if (visual === "none") return null;
|
|
183
|
+
if (visual === "classic") return classicParts;
|
|
184
|
+
if (visual === "fx") return fxParts;
|
|
185
|
+
if (typeof visual === "function") return null;
|
|
186
|
+
return visual;
|
|
187
|
+
};
|
|
188
|
+
function createActionBattleVisual(input = "classic") {
|
|
189
|
+
if (typeof input === "function") return input;
|
|
190
|
+
const parts = resolveParts(input);
|
|
191
|
+
const composer = (context) => {
|
|
192
|
+
if (!parts) return;
|
|
193
|
+
const part = parts[context.moment];
|
|
194
|
+
if (!part) return;
|
|
195
|
+
part(context, createHelpers(context));
|
|
196
|
+
};
|
|
197
|
+
composer.__actionBattleUsesFx = input === "fx";
|
|
198
|
+
return composer;
|
|
199
|
+
}
|
|
200
|
+
var createClassicActionBattleVisual = () => createActionBattleVisual("classic");
|
|
201
|
+
var createFxActionBattleVisual = () => createActionBattleVisual("fx");
|
|
202
|
+
function playActionBattleVisual(visual, context) {
|
|
203
|
+
(typeof visual === "function" ? visual : createActionBattleVisual(visual))(context);
|
|
70
204
|
}
|
|
71
205
|
//#endregion
|
|
72
|
-
export {
|
|
206
|
+
export { ACTION_BATTLE_CLIENT_VISUAL_ID, ACTION_BATTLE_HIT_FX_COMPONENT_ID, createActionBattleClientVisuals, createActionBattleVisual, createClassicActionBattleVisual, createFxActionBattleVisual, emitActionBattleClientVisual, playActionBattleVisual, setActionBattlePreviewStarter };
|