@rpgjs/server 5.0.0-alpha.30 → 5.0.0-alpha.31
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/dist/Player/ParameterManager.d.ts +7 -6
- package/dist/Player/Player.d.ts +2 -0
- package/dist/index.js +69 -23
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/Player/MoveManager.ts +11 -7
- package/src/Player/ParameterManager.ts +22 -17
- package/src/Player/Player.ts +33 -16
- package/src/rooms/lobby.ts +1 -0
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { PlayerCtor } from '../../../common/src';
|
|
2
|
+
export type ExpCurve = {
|
|
3
|
+
basis: number;
|
|
4
|
+
extra: number;
|
|
5
|
+
accelerationA: number;
|
|
6
|
+
accelerationB: number;
|
|
7
|
+
};
|
|
2
8
|
/**
|
|
3
9
|
* Interface for Parameter Manager functionality
|
|
4
10
|
*
|
|
@@ -47,12 +53,7 @@ export interface IParameterManager {
|
|
|
47
53
|
* ```
|
|
48
54
|
* @memberof ParameterManager
|
|
49
55
|
* */
|
|
50
|
-
expCurve:
|
|
51
|
-
basis: number;
|
|
52
|
-
extra: number;
|
|
53
|
-
accelerationA: number;
|
|
54
|
-
accelerationB: number;
|
|
55
|
-
};
|
|
56
|
+
expCurve: ExpCurve;
|
|
56
57
|
/**
|
|
57
58
|
* Changes the health points
|
|
58
59
|
* - Cannot exceed the MaxHP parameter
|
package/dist/Player/Player.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ export declare class RpgPlayer extends RpgPlayer_base {
|
|
|
94
94
|
events: import('@signe/reactive').WritableArraySignal<RpgEvent[]>;
|
|
95
95
|
constructor();
|
|
96
96
|
_onInit(): void;
|
|
97
|
+
onGameStart(): void;
|
|
97
98
|
get hooks(): Hooks;
|
|
98
99
|
get server(): RpgMap | null;
|
|
99
100
|
setMap(map: RpgMap): void;
|
|
@@ -502,6 +503,7 @@ export declare class RpgPlayer extends RpgPlayer_base {
|
|
|
502
503
|
isEvent(): boolean;
|
|
503
504
|
}
|
|
504
505
|
export declare class RpgEvent extends RpgPlayer {
|
|
506
|
+
constructor();
|
|
505
507
|
execMethod(methodName: string, methodData?: any[], instance?: this): Promise<any>;
|
|
506
508
|
/**
|
|
507
509
|
* Remove this event from the map
|
package/dist/index.js
CHANGED
|
@@ -17005,13 +17005,13 @@ class RpgCommonMap {
|
|
|
17005
17005
|
const ownerHasAnimationName = animationNameSignal && typeof animationNameSignal === "object" && typeof animationNameSignal.set === "function";
|
|
17006
17006
|
if (isMoving && intensity > LOW_INTENSITY_THRESHOLD) {
|
|
17007
17007
|
if (hasSetAnimation) {
|
|
17008
|
-
owner2.
|
|
17008
|
+
owner2.setGraphicAnimation("walk");
|
|
17009
17009
|
} else if (ownerHasAnimationName) {
|
|
17010
17010
|
animationNameSignal.set("walk");
|
|
17011
17011
|
}
|
|
17012
17012
|
} else if (!isMoving) {
|
|
17013
17013
|
if (hasSetAnimation) {
|
|
17014
|
-
owner2.
|
|
17014
|
+
owner2.setGraphicAnimation("stand");
|
|
17015
17015
|
} else if (ownerHasAnimationName) {
|
|
17016
17016
|
animationNameSignal.set("stand");
|
|
17017
17017
|
}
|
|
@@ -19118,7 +19118,8 @@ function WithMoveManager(Base) {
|
|
|
19118
19118
|
* Move toward a target player or position using AI pathfinding
|
|
19119
19119
|
*
|
|
19120
19120
|
* Uses the `SeekAvoid` strategy to navigate toward the target while avoiding obstacles.
|
|
19121
|
-
* The movement speed is based on the player's current `speed`
|
|
19121
|
+
* The movement speed is based on the player's current `speed` and `frequency` settings,
|
|
19122
|
+
* scaled appropriately.
|
|
19122
19123
|
*
|
|
19123
19124
|
* @param target - Target player or position `{ x, y }` to move toward
|
|
19124
19125
|
*
|
|
@@ -19137,6 +19138,10 @@ function WithMoveManager(Base) {
|
|
|
19137
19138
|
const playerId = this.id;
|
|
19138
19139
|
const engine = map.physic;
|
|
19139
19140
|
const playerSpeed = this.speed();
|
|
19141
|
+
const rawFrequency = this.frequency;
|
|
19142
|
+
const playerFrequency = typeof rawFrequency === "function" ? rawFrequency() : rawFrequency;
|
|
19143
|
+
const frequencyScale = playerFrequency > 0 ? 100 /* High */ / playerFrequency : 1;
|
|
19144
|
+
const normalizedFrequencyScale = Number.isFinite(frequencyScale) && frequencyScale > 0 ? frequencyScale : 1;
|
|
19140
19145
|
const existingStrategies = this.getActiveMovements();
|
|
19141
19146
|
const conflictingStrategies = existingStrategies.filter(
|
|
19142
19147
|
(s) => s instanceof SeekAvoid || s instanceof Dash || s instanceof Knockback || s instanceof LinearRepulsion
|
|
@@ -19149,7 +19154,7 @@ function WithMoveManager(Base) {
|
|
|
19149
19154
|
const body = map.getBody(target.id) ?? null;
|
|
19150
19155
|
return body;
|
|
19151
19156
|
};
|
|
19152
|
-
const maxSpeed2 = playerSpeed * 45;
|
|
19157
|
+
const maxSpeed2 = playerSpeed * 45 * normalizedFrequencyScale;
|
|
19153
19158
|
map.moveManager.add(
|
|
19154
19159
|
playerId,
|
|
19155
19160
|
new SeekAvoid(engine, targetProvider, maxSpeed2, 140, 80, 48)
|
|
@@ -19161,7 +19166,7 @@ function WithMoveManager(Base) {
|
|
|
19161
19166
|
mass: Infinity
|
|
19162
19167
|
});
|
|
19163
19168
|
staticTarget.freeze();
|
|
19164
|
-
const maxSpeed = playerSpeed * 20;
|
|
19169
|
+
const maxSpeed = playerSpeed * 20 * normalizedFrequencyScale;
|
|
19165
19170
|
map.moveManager.add(
|
|
19166
19171
|
playerId,
|
|
19167
19172
|
new SeekAvoid(engine, () => staticTarget, maxSpeed, 140, 80, 48)
|
|
@@ -19259,8 +19264,8 @@ function WithMoveManager(Base) {
|
|
|
19259
19264
|
};
|
|
19260
19265
|
const hasActiveKnockback = () => this.getActiveMovements().some((s) => s instanceof Knockback || s instanceof AdditiveKnockback);
|
|
19261
19266
|
const setAnimationName = (name) => {
|
|
19262
|
-
if (typeof selfAny.
|
|
19263
|
-
selfAny.
|
|
19267
|
+
if (typeof selfAny.setGraphicAnimation === "function") {
|
|
19268
|
+
selfAny.setGraphicAnimation(name);
|
|
19264
19269
|
return;
|
|
19265
19270
|
}
|
|
19266
19271
|
const animSignal = selfAny.animationName;
|
|
@@ -20635,14 +20640,14 @@ function WithParameterManager(Base) {
|
|
|
20635
20640
|
* console.log(player.param[MAXHP]); // Updated value
|
|
20636
20641
|
* ```
|
|
20637
20642
|
*/
|
|
20638
|
-
this._paramsModifierSignal = signal({});
|
|
20643
|
+
this._paramsModifierSignal = type(signal({}), "_paramsModifierSignal", { persist: true }, this);
|
|
20639
20644
|
/**
|
|
20640
20645
|
* Signal for base parameters configuration
|
|
20641
20646
|
*
|
|
20642
20647
|
* Stores the start and end values for each parameter's level curve.
|
|
20643
20648
|
* Changes to this signal trigger recalculation of all parameter values.
|
|
20644
20649
|
*/
|
|
20645
|
-
this._parametersSignal = signal({});
|
|
20650
|
+
this._parametersSignal = type(signal({}), "_parametersSignal", { persist: true }, this);
|
|
20646
20651
|
/**
|
|
20647
20652
|
* Computed signal for all parameter values
|
|
20648
20653
|
*
|
|
@@ -20697,6 +20702,26 @@ function WithParameterManager(Base) {
|
|
|
20697
20702
|
* @memberof ParameterManager
|
|
20698
20703
|
* */
|
|
20699
20704
|
this.finalLevel = 99;
|
|
20705
|
+
/**
|
|
20706
|
+
* With Object-based syntax, you can use following options:
|
|
20707
|
+
* - `basis: number`
|
|
20708
|
+
* - `extra: number`
|
|
20709
|
+
* - `accelerationA: number`
|
|
20710
|
+
* - `accelerationB: number`
|
|
20711
|
+
* @title Change Experience Curve
|
|
20712
|
+
* @prop {object} player.expCurve
|
|
20713
|
+
* @default
|
|
20714
|
+
* ```ts
|
|
20715
|
+
* {
|
|
20716
|
+
* basis: 30,
|
|
20717
|
+
* extra: 20,
|
|
20718
|
+
* accelerationA: 30,
|
|
20719
|
+
* accelerationB: 30
|
|
20720
|
+
* }
|
|
20721
|
+
* ```
|
|
20722
|
+
* @memberof ParameterManager
|
|
20723
|
+
* */
|
|
20724
|
+
this._expCurveSignal = type(signal(""), "_expCurveSignal", { persist: true }, this);
|
|
20700
20725
|
}
|
|
20701
20726
|
/**
|
|
20702
20727
|
* Aggregates parameter modifiers from all sources (direct modifiers, states, equipment)
|
|
@@ -20744,6 +20769,12 @@ function WithParameterManager(Base) {
|
|
|
20744
20769
|
}
|
|
20745
20770
|
return params;
|
|
20746
20771
|
}
|
|
20772
|
+
get expCurve() {
|
|
20773
|
+
return JSON.parse(this._expCurveSignal());
|
|
20774
|
+
}
|
|
20775
|
+
set expCurve(val) {
|
|
20776
|
+
this._expCurveSignal.set(JSON.stringify(val));
|
|
20777
|
+
}
|
|
20747
20778
|
/**
|
|
20748
20779
|
* Changes the health points
|
|
20749
20780
|
* - Cannot exceed the MaxHP parameter
|
|
@@ -22284,19 +22315,6 @@ const _RpgPlayer = class _RpgPlayer extends BasicPlayerMixins(RpgCommonPlayer) {
|
|
|
22284
22315
|
this._lastFramePositions = null;
|
|
22285
22316
|
this.frames = [];
|
|
22286
22317
|
this.events = signal([]);
|
|
22287
|
-
this.expCurve = {
|
|
22288
|
-
basis: 30,
|
|
22289
|
-
extra: 20,
|
|
22290
|
-
accelerationA: 30,
|
|
22291
|
-
accelerationB: 30
|
|
22292
|
-
};
|
|
22293
|
-
this.addParameter(MAXHP, MAXHP_CURVE);
|
|
22294
|
-
this.addParameter(MAXSP, MAXSP_CURVE);
|
|
22295
|
-
this.addParameter(STR, STR_CURVE);
|
|
22296
|
-
this.addParameter(INT, INT_CURVE);
|
|
22297
|
-
this.addParameter(DEX, DEX_CURVE);
|
|
22298
|
-
this.addParameter(AGI, AGI_CURVE);
|
|
22299
|
-
this.allRecovery();
|
|
22300
22318
|
let lastEmitted = null;
|
|
22301
22319
|
let pendingUpdate = null;
|
|
22302
22320
|
let updateScheduled = false;
|
|
@@ -22375,6 +22393,21 @@ const _RpgPlayer = class _RpgPlayer extends BasicPlayerMixins(RpgCommonPlayer) {
|
|
|
22375
22393
|
_onInit() {
|
|
22376
22394
|
this.hooks.callHooks("server-playerProps-load", this).subscribe();
|
|
22377
22395
|
}
|
|
22396
|
+
onGameStart() {
|
|
22397
|
+
this.expCurve = {
|
|
22398
|
+
basis: 30,
|
|
22399
|
+
extra: 20,
|
|
22400
|
+
accelerationA: 30,
|
|
22401
|
+
accelerationB: 30
|
|
22402
|
+
};
|
|
22403
|
+
this.addParameter(MAXHP, MAXHP_CURVE);
|
|
22404
|
+
this.addParameter(MAXSP, MAXSP_CURVE);
|
|
22405
|
+
this.addParameter(STR, STR_CURVE);
|
|
22406
|
+
this.addParameter(INT, INT_CURVE);
|
|
22407
|
+
this.addParameter(DEX, DEX_CURVE);
|
|
22408
|
+
this.addParameter(AGI, AGI_CURVE);
|
|
22409
|
+
this.allRecovery();
|
|
22410
|
+
}
|
|
22378
22411
|
get hooks() {
|
|
22379
22412
|
return inject$1(this.context, ModulesToken);
|
|
22380
22413
|
}
|
|
@@ -22522,7 +22555,12 @@ const _RpgPlayer = class _RpgPlayer extends BasicPlayerMixins(RpgCommonPlayer) {
|
|
|
22522
22555
|
});
|
|
22523
22556
|
}
|
|
22524
22557
|
snapshot() {
|
|
22525
|
-
|
|
22558
|
+
const snapshot = createStatesSnapshotDeep(this);
|
|
22559
|
+
const expCurve = this.expCurve;
|
|
22560
|
+
if (expCurve) {
|
|
22561
|
+
snapshot.expCurve = { ...expCurve };
|
|
22562
|
+
}
|
|
22563
|
+
return snapshot;
|
|
22526
22564
|
}
|
|
22527
22565
|
async applySnapshot(snapshot) {
|
|
22528
22566
|
const data = typeof snapshot === "string" ? JSON.parse(snapshot) : snapshot;
|
|
@@ -22532,6 +22570,9 @@ const _RpgPlayer = class _RpgPlayer extends BasicPlayerMixins(RpgCommonPlayer) {
|
|
|
22532
22570
|
const withClass = this.resolveClassSnapshot?.(withStates) ?? withStates;
|
|
22533
22571
|
const resolvedSnapshot = this.resolveEquipmentsSnapshot?.(withClass) ?? withClass;
|
|
22534
22572
|
load(this, resolvedSnapshot);
|
|
22573
|
+
if (resolvedSnapshot.expCurve) {
|
|
22574
|
+
this.expCurve = resolvedSnapshot.expCurve;
|
|
22575
|
+
}
|
|
22535
22576
|
if (Array.isArray(resolvedSnapshot.items)) {
|
|
22536
22577
|
this.items.set(resolvedSnapshot.items);
|
|
22537
22578
|
}
|
|
@@ -23222,6 +23263,10 @@ __decorateClass$3([
|
|
|
23222
23263
|
], _RpgPlayer.prototype, "events");
|
|
23223
23264
|
let RpgPlayer = _RpgPlayer;
|
|
23224
23265
|
class RpgEvent extends RpgPlayer {
|
|
23266
|
+
constructor() {
|
|
23267
|
+
super();
|
|
23268
|
+
this.onGameStart();
|
|
23269
|
+
}
|
|
23225
23270
|
async execMethod(methodName, methodData = [], instance = this) {
|
|
23226
23271
|
await lastValueFrom(this.hooks.callHooks(`server-event-${methodName}`, instance, ...methodData));
|
|
23227
23272
|
if (!instance[methodName]) {
|
|
@@ -29491,6 +29536,7 @@ let LobbyRoom = class extends BaseRoom {
|
|
|
29491
29536
|
async guiInteraction(player, value) {
|
|
29492
29537
|
const id = value.data.id;
|
|
29493
29538
|
if (id === "start") {
|
|
29539
|
+
player.onGameStart();
|
|
29494
29540
|
this.hooks.callHooks("server-player-onStart", player).subscribe();
|
|
29495
29541
|
}
|
|
29496
29542
|
}
|