homm3-parsers
Version:
Collection of binary parsers able to parse various file formats related to Heroes of Might and Magic III
65 lines • 4 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const binary_markup_1 = require("binary-markup");
const common_bml_1 = require("../common.bml");
const spell_1 = require("../enums/spell");
const objects_1 = require("../../../helpers/objects");
const Building_1 = require("../contracts/enums/Building");
const buildingsBits = [
[
[],
[],
[],
[],
[],
[],
[],
[],
],
[
[],
[],
[],
[],
[],
[],
[],
[],
],
[
[],
[],
[],
[],
[],
[],
[],
[],
],
[
[],
[],
[],
[],
[],
[],
[],
[],
],
[
[],
[],
[],
[],
[],
[],
[],
[],
],
[[1, Building_1.Building.DwellingUp7]],
];
const buildingsAdapter = objects_1.bitMasksArray(binary_markup_1.bytes(6), buildingsBits);
const townEvent = binary_markup_1.struct(common_bml_1.hommString `name`, common_bml_1.hommString `message`, common_bml_1.resources `resources`, binary_markup_1.flag `appliesToPlayers`, binary_markup_1.when(common_bml_1.isSoD, binary_markup_1.flag) `appliesToHuman`, binary_markup_1.flag `appliesToComputer`, binary_markup_1.uint16 `firstOccurence`, binary_markup_1.byte `subsequentOccurences`, binary_markup_1.skip(17), buildingsAdapter `buildings`, binary_markup_1.array(binary_markup_1.uint16, 7) `creatureQuantities`, // 1 for each generator
binary_markup_1.skip(4));
exports.town = binary_markup_1.struct(binary_markup_1.when(common_bml_1.isNotRoE, binary_markup_1.uint32) `absodId`, common_bml_1.owner `owner`, binary_markup_1.byte `hasName`, binary_markup_1.when(binary_markup_1.ctx `hasName`, common_bml_1.hommString) `name`, binary_markup_1.byte `hasGarrison`, binary_markup_1.when(binary_markup_1.ctx `hasGarrison`, common_bml_1.army) `garrison`, binary_markup_1.byte `formation`, binary_markup_1.flag `buildingsCustomized`, binary_markup_1.when(binary_markup_1.ctx `buildingsCustomized`, binary_markup_1.struct(buildingsAdapter `built`, buildingsAdapter `disabled`)) `buildings`, binary_markup_1.when(binary_markup_1.ctx `buildingsCustomized`.eq(false), binary_markup_1.flag) `hasFort`, binary_markup_1.when(common_bml_1.isNotRoE, spell_1.spellsMask) `mustHaveSpells`, spell_1.spellsMask `mayHaveSpells`, binary_markup_1.uint32 `eventCount`, binary_markup_1.array(townEvent, binary_markup_1.ctx `eventCount`) `events`, binary_markup_1.when(common_bml_1.isSoD, binary_markup_1.byte) `alignment`, binary_markup_1.skip(3));
//# sourceMappingURL=town.bml.js.map