Release Healer Man 0.1.38
This commit is contained in:
1 parent
361734bc41
commit
b417b7c3c3
48 files changed
+1982
-90
No files matched your search
@@ -6,6 +6,7 @@ import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { inflateSync } from "node:zlib";
|
||||
import sharp from "sharp";
|
||||
import { vocationGrowth } from "./vocation-growth.mjs";
|
||||
|
||||
const scriptDirectory = path.dirname(fileURLToPath(import.meta.url));
|
||||
const projectRoot = path.resolve(scriptDirectory, "../..");
|
||||
@@ -38,17 +39,6 @@ const RACE_MATRIX = {
|
||||
"rom-dwarf": [1, 3, 4, 5, 9, 10],
|
||||
};
|
||||
|
||||
function vocationGrowth(classIndex) {
|
||||
const recordSize = 816;
|
||||
const offset = DATA_START + classIndex * recordSize + 8;
|
||||
const values = Array.from({ length: 21 }, (_, index) => cleanFloat(float32(buffers.vocationTable, offset + index * 4)));
|
||||
const keys = ["strength", "stamina", "intellect", "wisdom", "agility", "health", "mana"];
|
||||
return Object.fromEntries(keys.map((key, index) => [key, {
|
||||
levelOne: values[index],
|
||||
flatGrowth: values[index + 7],
|
||||
percentGrowth: values[index + 14],
|
||||
}]));
|
||||
}
|
||||
const DATA_START = 140;
|
||||
const LEARN_RECORD_SIZE = 12184;
|
||||
const LEARN_ENTRY_SIZE = 24;
|
||||
@@ -578,7 +568,7 @@ const catalog = {
|
||||
schemaVersion: 1,
|
||||
source: { rootHint: "RuneWaker source snapshot", hashes: sourceHashes },
|
||||
canonicalClasses: CLASS_IDS.map((id, index) => ({ id, sourceClassId: index + 1, name: CLASS_NAMES[index], resource: RESOURCES[index] })),
|
||||
baseStatGrowth: Object.fromEntries(CLASS_IDS.map((id, index) => [id, vocationGrowth(index + 1)])),
|
||||
baseStatGrowth: Object.fromEntries(CLASS_IDS.map((id, index) => [id, vocationGrowth(buffers.vocationTable, index + 1)])),
|
||||
raceMatrix: Object.fromEntries(Object.entries(RACE_MATRIX).map(([raceId, classes]) => [raceId, classes.map((index) => CLASS_IDS[index - 1])])),
|
||||
eliteLevels: ELITE_LEVELS,
|
||||
skills,
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
const DATA_START = 140;
|
||||
const RECORD_SIZE = 408;
|
||||
const STAT_KEYS = ["strength", "stamina", "intellect", "wisdom", "agility", "health", "mana"];
|
||||
|
||||
/** Players use FixArgTableID = 1; each vocation has two adjacent source records. */
|
||||
export function vocationGrowth(buffer, classIndex) {
|
||||
const recordId = 301000 + classIndex * 2 + 1;
|
||||
const offset = DATA_START + (classIndex * 2 + 1) * RECORD_SIZE;
|
||||
if (offset + RECORD_SIZE > buffer.length
|
||||
|| buffer.readInt32LE(offset) !== recordId || buffer.readInt32LE(offset + 4) !== recordId) {
|
||||
throw new Error(`Player vocation ${classIndex} record sentinel drifted.`);
|
||||
}
|
||||
const values = Array.from({ length: 21 }, (_, index) => {
|
||||
const value = buffer.readFloatLE(offset + 8 + index * 4);
|
||||
if (!Number.isFinite(value)) throw new Error(`Player vocation ${classIndex} has invalid growth.`);
|
||||
return Number(value.toFixed(5));
|
||||
});
|
||||
return Object.fromEntries(STAT_KEYS.map((key, index) => [key, {
|
||||
levelOne: values[index],
|
||||
flatGrowth: values[index + 7],
|
||||
percentGrowth: values[index + 14],
|
||||
}]));
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { test } from "node:test";
|
||||
import { vocationGrowth } from "./vocation-growth.mjs";
|
||||
|
||||
test("reads the player table instead of the adjacent alternate growth table", () => {
|
||||
const buffer = Buffer.alloc(140 + 22 * 408);
|
||||
const offset = 140 + 21 * 408;
|
||||
buffer.writeInt32LE(301021, offset);
|
||||
buffer.writeInt32LE(301021, offset + 4);
|
||||
const values = [14, 13, 5, 6, 12, 60, 20, 5, 4.5, 1.9, 2.1, 4.25, 2, 2, ...Array(7).fill(0.02)];
|
||||
values.forEach((value, index) => buffer.writeFloatLE(value, offset + 8 + index * 4));
|
||||
buffer.writeFloatLE(2.8, offset - 408 + 8 + 14 * 4);
|
||||
assert.deepEqual(vocationGrowth(buffer, 10).strength, { levelOne: 14, flatGrowth: 5, percentGrowth: 0.02 });
|
||||
buffer.writeInt32LE(301020, offset);
|
||||
assert.throws(() => vocationGrowth(buffer, 10), /sentinel drifted/);
|
||||
});
|
||||
Reference in new issue
Block a user