Merge branch 'feature/content-manifest-all-items'
@@ -8,7 +8,8 @@ import
8
8
MobId,
9
9
isHumanoidMob,
10
10
isCentralExchangeSpawner,
11
spawnerEquipmentSlot
11
spawnerEquipmentSlot,
12
mobDefinition
12
13
} from "/shared/definitions/mobs.js";
13
14
import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";
14
15
import { SPELL_DEFINITIONS, spellMinMagicLevel } from "/shared/definitions/spells.js";
@@ -687,12 +688,13 @@ export function initTileConfigModal ({
687
688
}
688
689
}
689
690
690
function renderHumanoidFields (config)
691
function renderCommonSpawnerFields (config)
691
692
{
692
693
const wrap = document.createElement("div");
693
wrap.className = "spawner-humanoid-fields";
694
wrap.dataset.humanoid = "1";
694
wrap.className = "spawner-common-fields";
695
wrap.dataset.commonSpawner = "1";
695
696
const exchange = isCentralExchangeSpawner(config);
697
696
698
if (exchange)
697
699
{
698
700
const note = document.createElement("p");
@@ -702,45 +704,17 @@ export function initTileConfigModal ({
702
704
}
703
705
else
704
706
{
707
const def = mobDefinition(config.mobTypeId);
708
const placeholder = def?.displayName || "Name";
705
709
wrap.append(
706
field("Display name", textInput("displayName", config.displayName || "Shopkeeper")),
707
field("Sex", sexSelect("sex", config.sex))
710
field("Display name", textInput("displayName", config.displayName || ""))
708
711
);
712
const nameHint = document.createElement("p");
713
nameHint.className = "hint";
714
nameHint.textContent = `Optional. Empty uses the mob default (${placeholder}).`;
715
wrap.append(nameHint);
709
716
}
710
717
711
const aggressiveLabel = document.createElement("label");
712
aggressiveLabel.className = "spawner-buys-row";
713
const aggressive = document.createElement("input");
714
aggressive.type = "checkbox";
715
aggressive.name = "aggressive";
716
aggressive.checked = !!config.aggressive;
717
aggressive.addEventListener("change", () => syncBountyForAggressive());
718
aggressiveLabel.append(aggressive, document.createTextNode(" Aggressive (attacks players in range)"));
719
wrap.append(aggressiveLabel);
720
const aggressiveHint = document.createElement("p");
721
aggressiveHint.className = "hint";
722
aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0.";
723
wrap.append(aggressiveHint);
724
725
wrap.append(field("Dialogue", dialogueSelect("dialogueId", config.dialogueId ?? "", dialogueOptions)));
726
727
const equipHeader = document.createElement("div");
728
equipHeader.className = "spawner-sells-header";
729
const equipTitle = document.createElement("strong");
730
equipTitle.textContent = "Equipment";
731
equipHeader.append(equipTitle);
732
wrap.append(equipHeader);
733
734
const equipList = document.createElement("div");
735
equipList.className = "spawner-equip-list";
736
equipList.dataset.equipmentList = "1";
737
wrap.append(equipList);
738
739
equipmentDraft = {};
740
for (const slot of EQUIPMENT_SLOTS)
741
{ equipmentDraft[slot] = equipDraftFromConfig(config.equipment?.[slot]); }
742
queueMicrotask(() => renderEquipmentRows());
743
744
718
const dropsHeader = document.createElement("div");
745
719
dropsHeader.className = "spawner-sells-header";
746
720
const dropsTitle = document.createElement("strong");
@@ -760,7 +734,7 @@ export function initTileConfigModal ({
760
734
761
735
const dropsHint = document.createElement("p");
762
736
dropsHint.className = "hint";
763
dropsHint.textContent = "On death each line rolls its chance; if it hits, quantity is random between min and max (inclusive).";
737
dropsHint.textContent = "Configured drops replace the mob's default loot table. Leave empty to keep defaults. Each line rolls its chance; quantity is random between min and max (inclusive).";
764
738
wrap.append(dropsHint);
765
739
766
740
dropsDraft = (config.drops ?? []).map((line) =>
@@ -790,6 +764,52 @@ export function initTileConfigModal ({
790
764
}).filter(Boolean);
791
765
792
766
queueMicrotask(() => renderDropsList());
767
return wrap;
768
}
769
770
function renderHumanoidFields (config)
771
{
772
const wrap = document.createElement("div");
773
wrap.className = "spawner-humanoid-fields";
774
wrap.dataset.humanoid = "1";
775
const exchange = isCentralExchangeSpawner(config);
776
if (!exchange)
777
{
778
wrap.append(field("Sex", sexSelect("sex", config.sex)));
779
}
780
781
const aggressiveLabel = document.createElement("label");
782
aggressiveLabel.className = "spawner-buys-row";
783
const aggressive = document.createElement("input");
784
aggressive.type = "checkbox";
785
aggressive.name = "aggressive";
786
aggressive.checked = !!config.aggressive;
787
aggressive.addEventListener("change", () => syncBountyForAggressive());
788
aggressiveLabel.append(aggressive, document.createTextNode(" Aggressive (attacks players in range)"));
789
wrap.append(aggressiveLabel);
790
const aggressiveHint = document.createElement("p");
791
aggressiveHint.className = "hint";
792
aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0.";
793
wrap.append(aggressiveHint);
794
795
wrap.append(field("Dialogue", dialogueSelect("dialogueId", config.dialogueId ?? "", dialogueOptions)));
796
797
const equipHeader = document.createElement("div");
798
equipHeader.className = "spawner-sells-header";
799
const equipTitle = document.createElement("strong");
800
equipTitle.textContent = "Equipment";
801
equipHeader.append(equipTitle);
802
wrap.append(equipHeader);
803
804
const equipList = document.createElement("div");
805
equipList.className = "spawner-equip-list";
806
equipList.dataset.equipmentList = "1";
807
wrap.append(equipList);
808
809
equipmentDraft = {};
810
for (const slot of EQUIPMENT_SLOTS)
811
{ equipmentDraft[slot] = equipDraftFromConfig(config.equipment?.[slot]); }
812
queueMicrotask(() => renderEquipmentRows());
793
813
794
814
if (!exchange)
795
815
{
@@ -840,6 +860,21 @@ export function initTileConfigModal ({
840
860
return wrap;
841
861
}
842
862
863
function syncCommonSpawnerSection (config)
864
{
865
form.querySelector("[data-common-spawner]")?.remove();
866
const mobTypeId = form.querySelector('[name="mobTypeId"]')?.value
867
|| config?.mobTypeId
868
|| MobId.deer;
869
const normalized = config ?? normalizeSpawnerConfig({ mobTypeId }, "spawner");
870
const anchor = form.querySelector("[data-humanoid]") || form.querySelector("[data-spells]");
871
const section = renderCommonSpawnerFields(normalized);
872
if (anchor)
873
{ form.insertBefore(section, anchor); }
874
else
875
{ form.append(section); }
876
}
877
843
878
function syncHumanoidSection (config)
844
879
{
845
880
form.querySelector("[data-humanoid]")?.remove();
@@ -847,7 +882,6 @@ export function initTileConfigModal ({
847
882
if (!isHumanoidMob(mobTypeId))
848
883
{
849
884
sellsDraft = [];
850
dropsDraft = [];
851
885
equipmentDraft = {};
852
886
return;
853
887
}
@@ -1041,6 +1075,7 @@ export function initTileConfigModal ({
1041
1075
form.querySelector('[name="level"]').value = String(defaults.level ?? 1);
1042
1076
form.querySelector('[name="bounty"]').value = String(defaults.bounty ?? 0);
1043
1077
syncWanderMin();
1078
syncCommonSpawnerSection(defaults);
1044
1079
syncHumanoidSection(defaults);
1045
1080
syncSpellsSection(defaults);
1046
1081
syncBountyForAggressive();
@@ -1048,6 +1083,7 @@ export function initTileConfigModal ({
1048
1083
spellsDraft = (config.spells ?? []).map((line) => ({
1049
1084
spellId: String(line.spellId ?? "")
1050
1085
})).filter((line) => line.spellId);
1086
syncCommonSpawnerSection(config);
1051
1087
syncHumanoidSection(config);
1052
1088
syncSpellsSection(config);
1053
1089
syncBountyForAggressive();
@@ -8,7 +8,8 @@ import8
MobId,8
MobId,9
isHumanoidMob,9
isHumanoidMob,10
isCentralExchangeSpawner,10
isCentralExchangeSpawner,11
spawnerEquipmentSlot11
spawnerEquipmentSlot,12
mobDefinition12
} from "/shared/definitions/mobs.js";13
} from "/shared/definitions/mobs.js";13
import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";14
import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";14
import { SPELL_DEFINITIONS, spellMinMagicLevel } from "/shared/definitions/spells.js";15
import { SPELL_DEFINITIONS, spellMinMagicLevel } from "/shared/definitions/spells.js";@@ -687,12 +688,13 @@ export function initTileConfigModal ({687
}688
}688
}689
}689
690
690
function renderHumanoidFields (config)691
function renderCommonSpawnerFields (config)691
{692
{692
const wrap = document.createElement("div");693
const wrap = document.createElement("div");693
wrap.className = "spawner-humanoid-fields";694
wrap.className = "spawner-common-fields";694
wrap.dataset.humanoid = "1";695
wrap.dataset.commonSpawner = "1";695
const exchange = isCentralExchangeSpawner(config);696
const exchange = isCentralExchangeSpawner(config);697
696
if (exchange)698
if (exchange)697
{699
{698
const note = document.createElement("p");700
const note = document.createElement("p");@@ -702,45 +704,17 @@ export function initTileConfigModal ({702
}704
}703
else705
else704
{706
{707
const def = mobDefinition(config.mobTypeId);708
const placeholder = def?.displayName || "Name";705
wrap.append(709
wrap.append(706
field("Display name", textInput("displayName", config.displayName || "Shopkeeper")),710
field("Display name", textInput("displayName", config.displayName || ""))707
field("Sex", sexSelect("sex", config.sex))708
);711
);712
const nameHint = document.createElement("p");713
nameHint.className = "hint";714
nameHint.textContent = `Optional. Empty uses the mob default (${placeholder}).`;715
wrap.append(nameHint);709
}716
}710
717
711
const aggressiveLabel = document.createElement("label");712
aggressiveLabel.className = "spawner-buys-row";713
const aggressive = document.createElement("input");714
aggressive.type = "checkbox";715
aggressive.name = "aggressive";716
aggressive.checked = !!config.aggressive;717
aggressive.addEventListener("change", () => syncBountyForAggressive());718
aggressiveLabel.append(aggressive, document.createTextNode(" Aggressive (attacks players in range)"));719
wrap.append(aggressiveLabel);720
const aggressiveHint = document.createElement("p");721
aggressiveHint.className = "hint";722
aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0.";723
wrap.append(aggressiveHint);724
725
wrap.append(field("Dialogue", dialogueSelect("dialogueId", config.dialogueId ?? "", dialogueOptions)));726
727
const equipHeader = document.createElement("div");728
equipHeader.className = "spawner-sells-header";729
const equipTitle = document.createElement("strong");730
equipTitle.textContent = "Equipment";731
equipHeader.append(equipTitle);732
wrap.append(equipHeader);733
734
const equipList = document.createElement("div");735
equipList.className = "spawner-equip-list";736
equipList.dataset.equipmentList = "1";737
wrap.append(equipList);738
739
equipmentDraft = {};740
for (const slot of EQUIPMENT_SLOTS)741
{ equipmentDraft[slot] = equipDraftFromConfig(config.equipment?.[slot]); }742
queueMicrotask(() => renderEquipmentRows());743
744
const dropsHeader = document.createElement("div");718
const dropsHeader = document.createElement("div");745
dropsHeader.className = "spawner-sells-header";719
dropsHeader.className = "spawner-sells-header";746
const dropsTitle = document.createElement("strong");720
const dropsTitle = document.createElement("strong");@@ -760,7 +734,7 @@ export function initTileConfigModal ({760
734
761
const dropsHint = document.createElement("p");735
const dropsHint = document.createElement("p");762
dropsHint.className = "hint";736
dropsHint.className = "hint";763
dropsHint.textContent = "On death each line rolls its chance; if it hits, quantity is random between min and max (inclusive).";737
dropsHint.textContent = "Configured drops replace the mob's default loot table. Leave empty to keep defaults. Each line rolls its chance; quantity is random between min and max (inclusive).";764
wrap.append(dropsHint);738
wrap.append(dropsHint);765
739
766
dropsDraft = (config.drops ?? []).map((line) =>740
dropsDraft = (config.drops ?? []).map((line) =>@@ -790,6 +764,52 @@ export function initTileConfigModal ({790
}).filter(Boolean);764
}).filter(Boolean);791
765
792
queueMicrotask(() => renderDropsList());766
queueMicrotask(() => renderDropsList());767
return wrap;768
}769
770
function renderHumanoidFields (config)771
{772
const wrap = document.createElement("div");773
wrap.className = "spawner-humanoid-fields";774
wrap.dataset.humanoid = "1";775
const exchange = isCentralExchangeSpawner(config);776
if (!exchange)777
{778
wrap.append(field("Sex", sexSelect("sex", config.sex)));779
}780
781
const aggressiveLabel = document.createElement("label");782
aggressiveLabel.className = "spawner-buys-row";783
const aggressive = document.createElement("input");784
aggressive.type = "checkbox";785
aggressive.name = "aggressive";786
aggressive.checked = !!config.aggressive;787
aggressive.addEventListener("change", () => syncBountyForAggressive());788
aggressiveLabel.append(aggressive, document.createTextNode(" Aggressive (attacks players in range)"));789
wrap.append(aggressiveLabel);790
const aggressiveHint = document.createElement("p");791
aggressiveHint.className = "hint";792
aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0.";793
wrap.append(aggressiveHint);794
795
wrap.append(field("Dialogue", dialogueSelect("dialogueId", config.dialogueId ?? "", dialogueOptions)));796
797
const equipHeader = document.createElement("div");798
equipHeader.className = "spawner-sells-header";799
const equipTitle = document.createElement("strong");800
equipTitle.textContent = "Equipment";801
equipHeader.append(equipTitle);802
wrap.append(equipHeader);803
804
const equipList = document.createElement("div");805
equipList.className = "spawner-equip-list";806
equipList.dataset.equipmentList = "1";807
wrap.append(equipList);808
809
equipmentDraft = {};810
for (const slot of EQUIPMENT_SLOTS)811
{ equipmentDraft[slot] = equipDraftFromConfig(config.equipment?.[slot]); }812
queueMicrotask(() => renderEquipmentRows());793
813
794
if (!exchange)814
if (!exchange)795
{815
{@@ -840,6 +860,21 @@ export function initTileConfigModal ({840
return wrap;860
return wrap;841
}861
}842
862
863
function syncCommonSpawnerSection (config)864
{865
form.querySelector("[data-common-spawner]")?.remove();866
const mobTypeId = form.querySelector('[name="mobTypeId"]')?.value867
|| config?.mobTypeId868
|| MobId.deer;869
const normalized = config ?? normalizeSpawnerConfig({ mobTypeId }, "spawner");870
const anchor = form.querySelector("[data-humanoid]") || form.querySelector("[data-spells]");871
const section = renderCommonSpawnerFields(normalized);872
if (anchor)873
{ form.insertBefore(section, anchor); }874
else875
{ form.append(section); }876
}877
843
function syncHumanoidSection (config)878
function syncHumanoidSection (config)844
{879
{845
form.querySelector("[data-humanoid]")?.remove();880
form.querySelector("[data-humanoid]")?.remove();@@ -847,7 +882,6 @@ export function initTileConfigModal ({847
if (!isHumanoidMob(mobTypeId))882
if (!isHumanoidMob(mobTypeId))848
{883
{849
sellsDraft = [];884
sellsDraft = [];850
dropsDraft = [];851
equipmentDraft = {};885
equipmentDraft = {};852
return;886
return;853
}887
}@@ -1041,6 +1075,7 @@ export function initTileConfigModal ({1041
form.querySelector('[name="level"]').value = String(defaults.level ?? 1);1075
form.querySelector('[name="level"]').value = String(defaults.level ?? 1);1042
form.querySelector('[name="bounty"]').value = String(defaults.bounty ?? 0);1076
form.querySelector('[name="bounty"]').value = String(defaults.bounty ?? 0);1043
syncWanderMin();1077
syncWanderMin();1078
syncCommonSpawnerSection(defaults);1044
syncHumanoidSection(defaults);1079
syncHumanoidSection(defaults);1045
syncSpellsSection(defaults);1080
syncSpellsSection(defaults);1046
syncBountyForAggressive();1081
syncBountyForAggressive();@@ -1048,6 +1083,7 @@ export function initTileConfigModal ({1048
spellsDraft = (config.spells ?? []).map((line) => ({1083
spellsDraft = (config.spells ?? []).map((line) => ({1049
spellId: String(line.spellId ?? "")1084
spellId: String(line.spellId ?? "")1050
})).filter((line) => line.spellId);1085
})).filter((line) => line.spellId);1086
syncCommonSpawnerSection(config);1051
syncHumanoidSection(config);1087
syncHumanoidSection(config);1052
syncSpellsSection(config);1088
syncSpellsSection(config);1053
syncBountyForAggressive();1089
syncBountyForAggressive();@@ -25,7 +25,8 @@ import
25
25
tierMineSkillLevel,
26
26
associatedBarTier,
27
27
isGemstoneMaterial,
28
metalTierForCloth
28
metalTierForCloth,
29
metalTierForHerbTier
29
30
} from "../shared/definitions/materialTiers.js";
30
31
import
31
32
{
@@ -37,7 +38,7 @@ import { CRAFT_RECIPES } from "../shared/crafting/stationRecipes.js";
37
38
import { ALCHEMY_POTION_DEFINITIONS } from "../shared/definitions/alchemy.js";
38
39
import { formatAlchemyStep, alchemyItemLabel } from "../shared/alchemy/recipes.js";
39
40
import { MOB_DEFINITIONS, defaultSpawnerConfig } from "../shared/definitions/mobs.js";
40
import { itemDefinition } from "../shared/definitions/items.js";
41
import { ITEM_DEFINITIONS, itemDefinition } from "../shared/definitions/items.js";
41
42
import { ARMOUR_CRAFT_PIECES } from "../shared/definitions/armourItems.js";
42
43
import { LEATHER_ARMOUR_PIECES } from "../shared/definitions/leatherArmourItems.js";
43
44
import { WIZARD_PIECES } from "../shared/definitions/wizardItems.js";
@@ -347,11 +348,12 @@ function buildMarkdown ()
347
348
const rows = HERB_ORDER.map((herbId) =>
348
349
{
349
350
const herb = HERB_DEFINITIONS[herbId];
351
const metal = metalTierForHerbTier(herb.tier);
350
352
return [
351
353
herb.displayName,
352
354
String(herb.tier),
353
355
String(herbGatherSkillLevel(herb.tier)),
354
"Plant clippers (any equippable tier)"
356
`${toolLabel(metal, "plant clippers")} or better`
355
357
];
356
358
});
357
359
lines.push(mdTable(["Herb", "Herb tier", "Herbalism level", "Tool"], rows));
@@ -558,6 +560,25 @@ function buildMarkdown ()
558
560
}
559
561
lines.push("");
560
562
563
// --- All items ---
564
lines.push("## All items");
565
lines.push("");
566
{
567
const rows = Object.values(ITEM_DEFINITIONS)
568
.filter((def) => def?.itemId != null)
569
.slice()
570
.sort((a, b) => String(a.displayName ?? "").localeCompare(String(b.displayName ?? ""))
571
|| ((a.itemId | 0) - (b.itemId | 0)))
572
.map((def) => [
573
def.displayName ?? String(def.itemId),
574
String(def.itemId),
575
def.key ?? "—",
576
def.description ?? "—"
577
]);
578
lines.push(mdTable(["Name", "Id", "Key", "Description"], rows));
579
}
580
lines.push("");
581
561
582
return `${lines.join("\n")}\n`;
562
583
}
563
584
@@ -25,7 +25,8 @@ import25
tierMineSkillLevel,25
tierMineSkillLevel,26
associatedBarTier,26
associatedBarTier,27
isGemstoneMaterial,27
isGemstoneMaterial,28
metalTierForCloth28
metalTierForCloth,29
metalTierForHerbTier29
} from "../shared/definitions/materialTiers.js";30
} from "../shared/definitions/materialTiers.js";30
import31
import31
{32
{@@ -37,7 +38,7 @@ import { CRAFT_RECIPES } from "../shared/crafting/stationRecipes.js";37
import { ALCHEMY_POTION_DEFINITIONS } from "../shared/definitions/alchemy.js";38
import { ALCHEMY_POTION_DEFINITIONS } from "../shared/definitions/alchemy.js";38
import { formatAlchemyStep, alchemyItemLabel } from "../shared/alchemy/recipes.js";39
import { formatAlchemyStep, alchemyItemLabel } from "../shared/alchemy/recipes.js";39
import { MOB_DEFINITIONS, defaultSpawnerConfig } from "../shared/definitions/mobs.js";40
import { MOB_DEFINITIONS, defaultSpawnerConfig } from "../shared/definitions/mobs.js";40
import { itemDefinition } from "../shared/definitions/items.js";41
import { ITEM_DEFINITIONS, itemDefinition } from "../shared/definitions/items.js";41
import { ARMOUR_CRAFT_PIECES } from "../shared/definitions/armourItems.js";42
import { ARMOUR_CRAFT_PIECES } from "../shared/definitions/armourItems.js";42
import { LEATHER_ARMOUR_PIECES } from "../shared/definitions/leatherArmourItems.js";43
import { LEATHER_ARMOUR_PIECES } from "../shared/definitions/leatherArmourItems.js";43
import { WIZARD_PIECES } from "../shared/definitions/wizardItems.js";44
import { WIZARD_PIECES } from "../shared/definitions/wizardItems.js";@@ -347,11 +348,12 @@ function buildMarkdown ()347
const rows = HERB_ORDER.map((herbId) =>348
const rows = HERB_ORDER.map((herbId) =>348
{349
{349
const herb = HERB_DEFINITIONS[herbId];350
const herb = HERB_DEFINITIONS[herbId];351
const metal = metalTierForHerbTier(herb.tier);350
return [352
return [351
herb.displayName,353
herb.displayName,352
String(herb.tier),354
String(herb.tier),353
String(herbGatherSkillLevel(herb.tier)),355
String(herbGatherSkillLevel(herb.tier)),354
"Plant clippers (any equippable tier)"356
`${toolLabel(metal, "plant clippers")} or better`355
];357
];356
});358
});357
lines.push(mdTable(["Herb", "Herb tier", "Herbalism level", "Tool"], rows));359
lines.push(mdTable(["Herb", "Herb tier", "Herbalism level", "Tool"], rows));@@ -558,6 +560,25 @@ function buildMarkdown ()558
}560
}559
lines.push("");561
lines.push("");560
562
563
// --- All items ---564
lines.push("## All items");565
lines.push("");566
{567
const rows = Object.values(ITEM_DEFINITIONS)568
.filter((def) => def?.itemId != null)569
.slice()570
.sort((a, b) => String(a.displayName ?? "").localeCompare(String(b.displayName ?? ""))571
|| ((a.itemId | 0) - (b.itemId | 0)))572
.map((def) => [573
def.displayName ?? String(def.itemId),574
String(def.itemId),575
def.key ?? "—",576
def.description ?? "—"577
]);578
lines.push(mdTable(["Name", "Id", "Key", "Description"], rows));579
}580
lines.push("");581
561
return `${lines.join("\n")}\n`;582
return `${lines.join("\n")}\n`;562
}583
}563
584
@@ -707,9 +707,10 @@ function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = nul
707
707
const origin = lootOrigin(mobName, killerName);
708
708
const events = [];
709
709
const spawnOrigin = world.ecs.get(targetHandle, Component.spawnOrigin);
710
const customDrops = Array.isArray(spawnOrigin?.drops) ? spawnOrigin.drops : [];
711
/** Spawner loot picker replaces the mob's default table when any lines are set. */
710
712
const dropTable = [
711
...(def?.drops ?? []),
712
...(Array.isArray(spawnOrigin?.drops) ? spawnOrigin.drops : [])
713
...(customDrops.length > 0 ? customDrops : (def?.drops ?? []))
713
714
];
714
715
if (creature.element && (def?.essenceDropChance ?? 0) > 0)
715
716
{
@@ -707,9 +707,10 @@ function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = nul707
const origin = lootOrigin(mobName, killerName);707
const origin = lootOrigin(mobName, killerName);708
const events = [];708
const events = [];709
const spawnOrigin = world.ecs.get(targetHandle, Component.spawnOrigin);709
const spawnOrigin = world.ecs.get(targetHandle, Component.spawnOrigin);710
const customDrops = Array.isArray(spawnOrigin?.drops) ? spawnOrigin.drops : [];711
/** Spawner loot picker replaces the mob's default table when any lines are set. */710
const dropTable = [712
const dropTable = [711
...(def?.drops ?? []),713
...(customDrops.length > 0 ? customDrops : (def?.drops ?? []))712
...(Array.isArray(spawnOrigin?.drops) ? spawnOrigin.drops : [])713
];714
];714
if (creature.element && (def?.essenceDropChance ?? 0) > 0)715
if (creature.element && (def?.essenceDropChance ?? 0) > 0)715
{716
{@@ -24,7 +24,7 @@ import {
24
24
PLANT_EXHAUST_MS
25
25
} from "../../../shared/definitions/gathering.js";
26
26
import { rawClothItemId } from "../../../shared/definitions/clothItems.js";
27
import { ClothTier } from "../../../shared/definitions/materialTiers.js";
27
import { ClothTier, metalTierForHerbTier } from "../../../shared/definitions/materialTiers.js";
28
28
import {
29
29
flowerItemInstance,
30
30
flowerColorIdFromBlockState,
@@ -623,18 +623,10 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)
623
623
const inventory = world.ecs.get(handle, Component.inventory);
624
624
const equipment = world.ecs.get(handle, Component.equipment);
625
625
const skills = world.ecs.get(handle, Component.skills);
626
const clippers = resolvePlantClippers({
627
inventorySlots: inventory?.slots,
628
equipmentSlots: equipment?.slots,
629
skills,
630
requireTool: !!plant.requiresClippers,
631
minClothTier: plant.minClothTier ?? null
632
});
633
if (!clippers.ok)
634
{ throw userError(clippers.reason); }
635
626
636
627
let herbId = null;
637
628
let herbTier = null;
629
let minMetalTier = null;
638
630
if (plant.kind === "herb")
639
631
{
640
632
const gate = resolveHerbGather({ herbId: block.state, skills });
@@ -642,8 +634,20 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)
642
634
{ throw userError(gate.reason); }
643
635
herbId = gate.herb.herbId;
644
636
herbTier = gate.herb.tier;
637
minMetalTier = metalTierForHerbTier(gate.herb.tier);
645
638
}
646
639
640
const clippers = resolvePlantClippers({
641
inventorySlots: inventory?.slots,
642
equipmentSlots: equipment?.slots,
643
skills,
644
requireTool: !!plant.requiresClippers,
645
minClothTier: plant.minClothTier ?? null,
646
minMetalTier
647
});
648
if (!clippers.ok)
649
{ throw userError(clippers.reason); }
650
647
651
const toolTier = clippers.tool?.tier ?? null;
648
652
const durationMs = Math.max(
649
653
1,
@@ -24,7 +24,7 @@ import {24
PLANT_EXHAUST_MS24
PLANT_EXHAUST_MS25
} from "../../../shared/definitions/gathering.js";25
} from "../../../shared/definitions/gathering.js";26
import { rawClothItemId } from "../../../shared/definitions/clothItems.js";26
import { rawClothItemId } from "../../../shared/definitions/clothItems.js";27
import { ClothTier } from "../../../shared/definitions/materialTiers.js";27
import { ClothTier, metalTierForHerbTier } from "../../../shared/definitions/materialTiers.js";28
import {28
import {29
flowerItemInstance,29
flowerItemInstance,30
flowerColorIdFromBlockState,30
flowerColorIdFromBlockState,@@ -623,18 +623,10 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)623
const inventory = world.ecs.get(handle, Component.inventory);623
const inventory = world.ecs.get(handle, Component.inventory);624
const equipment = world.ecs.get(handle, Component.equipment);624
const equipment = world.ecs.get(handle, Component.equipment);625
const skills = world.ecs.get(handle, Component.skills);625
const skills = world.ecs.get(handle, Component.skills);626
const clippers = resolvePlantClippers({627
inventorySlots: inventory?.slots,628
equipmentSlots: equipment?.slots,629
skills,630
requireTool: !!plant.requiresClippers,631
minClothTier: plant.minClothTier ?? null632
});633
if (!clippers.ok)634
{ throw userError(clippers.reason); }635
626
636
let herbId = null;627
let herbId = null;637
let herbTier = null;628
let herbTier = null;629
let minMetalTier = null;638
if (plant.kind === "herb")630
if (plant.kind === "herb")639
{631
{640
const gate = resolveHerbGather({ herbId: block.state, skills });632
const gate = resolveHerbGather({ herbId: block.state, skills });@@ -642,8 +634,20 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)642
{ throw userError(gate.reason); }634
{ throw userError(gate.reason); }643
herbId = gate.herb.herbId;635
herbId = gate.herb.herbId;644
herbTier = gate.herb.tier;636
herbTier = gate.herb.tier;637
minMetalTier = metalTierForHerbTier(gate.herb.tier);645
}638
}646
639
640
const clippers = resolvePlantClippers({641
inventorySlots: inventory?.slots,642
equipmentSlots: equipment?.slots,643
skills,644
requireTool: !!plant.requiresClippers,645
minClothTier: plant.minClothTier ?? null,646
minMetalTier647
});648
if (!clippers.ok)649
{ throw userError(clippers.reason); }650
647
const toolTier = clippers.tool?.tier ?? null;651
const toolTier = clippers.tool?.tier ?? null;648
const durationMs = Math.max(652
const durationMs = Math.max(649
1,653
1,@@ -268,7 +268,8 @@ export function mobComponents (request)
268
268
const tint = magicElementTint(element);
269
269
appearance.tint = { r: tint.r, g: tint.g, b: tint.b };
270
270
appearance.bloomBody = !!def.bloomBody;
271
if (def.mobTypeId === MobId.sprite || def.randomElementOnSpawn)
271
if ((def.mobTypeId === MobId.sprite || def.randomElementOnSpawn)
272
&& !String(request.displayName || "").trim())
272
273
{
273
274
const label = essenceElementDisplayName(element);
274
275
appearance.firstName = `${label} Sprite`;
@@ -268,7 +268,8 @@ export function mobComponents (request)268
const tint = magicElementTint(element);268
const tint = magicElementTint(element);269
appearance.tint = { r: tint.r, g: tint.g, b: tint.b };269
appearance.tint = { r: tint.r, g: tint.g, b: tint.b };270
appearance.bloomBody = !!def.bloomBody;270
appearance.bloomBody = !!def.bloomBody;271
if (def.mobTypeId === MobId.sprite || def.randomElementOnSpawn)271
if ((def.mobTypeId === MobId.sprite || def.randomElementOnSpawn)272
&& !String(request.displayName || "").trim())272
{273
{273
const label = essenceElementDisplayName(element);274
const label = essenceElementDisplayName(element);274
appearance.firstName = `${label} Sprite`;275
appearance.firstName = `${label} Sprite`;@@ -37,7 +37,7 @@ function countItem (slots, itemId)
37
37
.reduce((sum, slot) => sum + (slot.quantity | 0), 0);
38
38
}
39
39
40
test("sage herb plant yields sage with clippers", () =>
40
test("sage herb plant yields sage with matching-tier clippers", () =>
41
41
{
42
42
const harness = makeSimulation({ workerCount: 1 });
43
43
try
@@ -48,7 +48,7 @@ test("sage herb plant yields sage with clippers", () =>
48
48
const entityId = harness.simulation.spawnCharacter(1, character);
49
49
const bag = harness.simulation.bagOf(entityId);
50
50
bag.inventory = emptySlots();
51
bag.inventory[0] = { itemId: ItemId.bronzePlantClippers, quantity: 1 };
51
bag.inventory[0] = { itemId: ItemId.ironPlantClippers, quantity: 1 };
52
52
bag.equipment = emptyEquipment();
53
53
harness.simulation.applyBag(entityId, bag);
54
54
@@ -56,7 +56,8 @@ test("sage herb plant yields sage with clippers", () =>
56
56
const worker = harness.simulation.workers[record.workerId];
57
57
const handle = worker.world.ecs.handleOf(entityId);
58
58
const skills = worker.world.ecs.get(handle, Component.skills);
59
skills.xp[SkillId.herbalism] = totalXpForLevel(5);
59
/** Iron clippers need herbalism 10 to equip (sage gather gate is only 5). */
60
skills.xp[SkillId.herbalism] = totalXpForLevel(10);
60
61
61
62
harness.simulation.enqueue(1, {
62
63
type: "pick",
@@ -73,6 +74,42 @@ test("sage herb plant yields sage with clippers", () =>
73
74
{ harness.close(); }
74
75
});
75
76
77
test("sage herb plant rejects under-tier clippers", () =>
78
{
79
const harness = makeSimulation({ workerCount: 1 });
80
try
81
{
82
placeBlock(harness.worldDb, 8, 8, BlockType.herbPlant, HerbId.sage);
83
harness.simulation.reloadWorld();
84
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 9 });
85
const entityId = harness.simulation.spawnCharacter(1, character);
86
const bag = harness.simulation.bagOf(entityId);
87
bag.inventory = emptySlots();
88
bag.inventory[0] = { itemId: ItemId.bronzePlantClippers, quantity: 1 };
89
bag.equipment = emptyEquipment();
90
harness.simulation.applyBag(entityId, bag);
91
92
const record = harness.simulation.entityRecord(entityId);
93
const worker = harness.simulation.workers[record.workerId];
94
const handle = worker.world.ecs.handleOf(entityId);
95
const skills = worker.world.ecs.get(handle, Component.skills);
96
skills.xp[SkillId.herbalism] = totalXpForLevel(10);
97
98
harness.simulation.enqueue(1, {
99
type: "pick",
100
characterId: character.character_id,
101
tileX: 8,
102
tileY: 8
103
});
104
const result = harness.simulation.step();
105
const error = result.events.find((event) => event.type === "command-error");
106
assert.ok(error);
107
assert.match(error.message, /Iron plant clippers/i);
108
}
109
finally
110
{ harness.close(); }
111
});
112
76
113
test("aconite herb plant rejects low herbalism", () =>
77
114
{
78
115
const harness = makeSimulation({ workerCount: 1 });
@@ -37,7 +37,7 @@ function countItem (slots, itemId)37
.reduce((sum, slot) => sum + (slot.quantity | 0), 0);37
.reduce((sum, slot) => sum + (slot.quantity | 0), 0);38
}38
}39
39
40
test("sage herb plant yields sage with clippers", () =>40
test("sage herb plant yields sage with matching-tier clippers", () =>41
{41
{42
const harness = makeSimulation({ workerCount: 1 });42
const harness = makeSimulation({ workerCount: 1 });43
try43
try@@ -48,7 +48,7 @@ test("sage herb plant yields sage with clippers", () =>48
const entityId = harness.simulation.spawnCharacter(1, character);48
const entityId = harness.simulation.spawnCharacter(1, character);49
const bag = harness.simulation.bagOf(entityId);49
const bag = harness.simulation.bagOf(entityId);50
bag.inventory = emptySlots();50
bag.inventory = emptySlots();51
bag.inventory[0] = { itemId: ItemId.bronzePlantClippers, quantity: 1 };51
bag.inventory[0] = { itemId: ItemId.ironPlantClippers, quantity: 1 };52
bag.equipment = emptyEquipment();52
bag.equipment = emptyEquipment();53
harness.simulation.applyBag(entityId, bag);53
harness.simulation.applyBag(entityId, bag);54
54
@@ -56,7 +56,8 @@ test("sage herb plant yields sage with clippers", () =>56
const worker = harness.simulation.workers[record.workerId];56
const worker = harness.simulation.workers[record.workerId];57
const handle = worker.world.ecs.handleOf(entityId);57
const handle = worker.world.ecs.handleOf(entityId);58
const skills = worker.world.ecs.get(handle, Component.skills);58
const skills = worker.world.ecs.get(handle, Component.skills);59
skills.xp[SkillId.herbalism] = totalXpForLevel(5);59
/** Iron clippers need herbalism 10 to equip (sage gather gate is only 5). */60
skills.xp[SkillId.herbalism] = totalXpForLevel(10);60
61
61
harness.simulation.enqueue(1, {62
harness.simulation.enqueue(1, {62
type: "pick",63
type: "pick",@@ -73,6 +74,42 @@ test("sage herb plant yields sage with clippers", () =>73
{ harness.close(); }74
{ harness.close(); }74
});75
});75
76
77
test("sage herb plant rejects under-tier clippers", () =>78
{79
const harness = makeSimulation({ workerCount: 1 });80
try81
{82
placeBlock(harness.worldDb, 8, 8, BlockType.herbPlant, HerbId.sage);83
harness.simulation.reloadWorld();84
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 9 });85
const entityId = harness.simulation.spawnCharacter(1, character);86
const bag = harness.simulation.bagOf(entityId);87
bag.inventory = emptySlots();88
bag.inventory[0] = { itemId: ItemId.bronzePlantClippers, quantity: 1 };89
bag.equipment = emptyEquipment();90
harness.simulation.applyBag(entityId, bag);91
92
const record = harness.simulation.entityRecord(entityId);93
const worker = harness.simulation.workers[record.workerId];94
const handle = worker.world.ecs.handleOf(entityId);95
const skills = worker.world.ecs.get(handle, Component.skills);96
skills.xp[SkillId.herbalism] = totalXpForLevel(10);97
98
harness.simulation.enqueue(1, {99
type: "pick",100
characterId: character.character_id,101
tileX: 8,102
tileY: 8103
});104
const result = harness.simulation.step();105
const error = result.events.find((event) => event.type === "command-error");106
assert.ok(error);107
assert.match(error.message, /Iron plant clippers/i);108
}109
finally110
{ harness.close(); }111
});112
76
test("aconite herb plant rejects low herbalism", () =>113
test("aconite herb plant rejects low herbalism", () =>77
{114
{78
const harness = makeSimulation({ workerCount: 1 });115
const harness = makeSimulation({ workerCount: 1 });@@ -10,6 +10,7 @@ import {
10
10
ClothTier,
11
11
MaterialTier,
12
12
metalTierForCloth,
13
metalTierForHerbTier,
13
14
clothExhaustDurationMs,
14
15
tierRank
15
16
} from "../../shared/definitions/materialTiers.js";
@@ -188,6 +189,28 @@ test("silk cocoons need adamantium-or-better clippers", () =>
188
189
assert.equal(plant.minClothTier, "silk");
189
190
});
190
191
192
test("herb clippers require matching metal tier (sage → iron+)", () =>
193
{
194
assert.equal(metalTierForHerbTier(2), MaterialTier.iron);
195
assert.equal(metalTierForHerbTier(7), MaterialTier.dragon);
196
const skills = normalizePlayerSkills(null);
197
skills.xp[SkillId.herbalism] = totalXpForLevel(10);
198
const bronze = resolvePlantClippers({
199
inventorySlots: [{ itemId: MetalItemId.bronzePlantClippers, quantity: 1 }],
200
equipmentSlots: emptyEquipment().slots,
201
skills,
202
minMetalTier: metalTierForHerbTier(2)
203
});
204
assert.equal(bronze.ok, false);
205
const iron = resolvePlantClippers({
206
inventorySlots: [{ itemId: MetalItemId.ironPlantClippers, quantity: 1 }],
207
equipmentSlots: emptyEquipment().slots,
208
skills,
209
minMetalTier: metalTierForHerbTier(2)
210
});
211
assert.equal(iron.ok, true);
212
});
213
191
214
test("shearing a sheep grants wool and sets shorn state", () =>
192
215
{
193
216
const harness = makeSimulation({ workerCount: 1 });
@@ -10,6 +10,7 @@ import {10
ClothTier,10
ClothTier,11
MaterialTier,11
MaterialTier,12
metalTierForCloth,12
metalTierForCloth,13
metalTierForHerbTier,13
clothExhaustDurationMs,14
clothExhaustDurationMs,14
tierRank15
tierRank15
} from "../../shared/definitions/materialTiers.js";16
} from "../../shared/definitions/materialTiers.js";@@ -188,6 +189,28 @@ test("silk cocoons need adamantium-or-better clippers", () =>188
assert.equal(plant.minClothTier, "silk");189
assert.equal(plant.minClothTier, "silk");189
});190
});190
191
192
test("herb clippers require matching metal tier (sage → iron+)", () =>193
{194
assert.equal(metalTierForHerbTier(2), MaterialTier.iron);195
assert.equal(metalTierForHerbTier(7), MaterialTier.dragon);196
const skills = normalizePlayerSkills(null);197
skills.xp[SkillId.herbalism] = totalXpForLevel(10);198
const bronze = resolvePlantClippers({199
inventorySlots: [{ itemId: MetalItemId.bronzePlantClippers, quantity: 1 }],200
equipmentSlots: emptyEquipment().slots,201
skills,202
minMetalTier: metalTierForHerbTier(2)203
});204
assert.equal(bronze.ok, false);205
const iron = resolvePlantClippers({206
inventorySlots: [{ itemId: MetalItemId.ironPlantClippers, quantity: 1 }],207
equipmentSlots: emptyEquipment().slots,208
skills,209
minMetalTier: metalTierForHerbTier(2)210
});211
assert.equal(iron.ok, true);212
});213
191
test("shearing a sheep grants wool and sets shorn state", () =>214
test("shearing a sheep grants wool and sets shorn state", () =>192
{215
{193
const harness = makeSimulation({ workerCount: 1 });216
const harness = makeSimulation({ workerCount: 1 });@@ -52,6 +52,41 @@ test("shade spawner defaults level 28", () =>
52
52
assert.equal(config.level, 28);
53
53
});
54
54
55
test("wildlife spawners keep display name and custom drops", () =>
56
{
57
const config = normalizeSpawnerConfig({
58
mobTypeId: MobId.deer,
59
displayName: "Stag",
60
drops: [{ itemId: ItemId.bones, chance: 0.5, quantityMin: 1, quantityMax: 2 }]
61
}, "deer-named");
62
assert.equal(config.displayName, "Stag");
63
assert.equal(config.drops.length, 1);
64
assert.equal(config.drops[0].itemId, ItemId.bones);
65
assert.equal(config.drops[0].chance, 0.5);
66
67
const components = mobComponents({
68
...config,
69
tileX: 4,
70
tileY: 4,
71
spawnerId: config.spawnerId,
72
wanderRangeTiles: config.maxWanderRangeTiles
73
});
74
assert.equal(components.appearance.firstName, "Stag");
75
assert.deepEqual(components.spawnOrigin.drops, config.drops);
76
});
77
78
test("central exchange spawners clear authored display names", () =>
79
{
80
const config = normalizeSpawnerConfig({
81
mobTypeId: MobId.centralExchange,
82
displayName: "Should Not Stick",
83
drops: [{ itemId: ItemId.coins, chance: 1, quantityMin: 1, quantityMax: 1 }]
84
}, "ce-1");
85
assert.equal(config.displayName, "");
86
assert.equal(config.centralExchange, true);
87
assert.equal(config.drops.length, 1);
88
});
89
55
90
test("goblin spawns with slashing melee profile from mob definition", () =>
56
91
{
57
92
const harness = makeSimulation({ workerCount: 1 });
@@ -52,6 +52,41 @@ test("shade spawner defaults level 28", () =>52
assert.equal(config.level, 28);52
assert.equal(config.level, 28);53
});53
});54
54
55
test("wildlife spawners keep display name and custom drops", () =>56
{57
const config = normalizeSpawnerConfig({58
mobTypeId: MobId.deer,59
displayName: "Stag",60
drops: [{ itemId: ItemId.bones, chance: 0.5, quantityMin: 1, quantityMax: 2 }]61
}, "deer-named");62
assert.equal(config.displayName, "Stag");63
assert.equal(config.drops.length, 1);64
assert.equal(config.drops[0].itemId, ItemId.bones);65
assert.equal(config.drops[0].chance, 0.5);66
67
const components = mobComponents({68
...config,69
tileX: 4,70
tileY: 4,71
spawnerId: config.spawnerId,72
wanderRangeTiles: config.maxWanderRangeTiles73
});74
assert.equal(components.appearance.firstName, "Stag");75
assert.deepEqual(components.spawnOrigin.drops, config.drops);76
});77
78
test("central exchange spawners clear authored display names", () =>79
{80
const config = normalizeSpawnerConfig({81
mobTypeId: MobId.centralExchange,82
displayName: "Should Not Stick",83
drops: [{ itemId: ItemId.coins, chance: 1, quantityMin: 1, quantityMax: 1 }]84
}, "ce-1");85
assert.equal(config.displayName, "");86
assert.equal(config.centralExchange, true);87
assert.equal(config.drops.length, 1);88
});89
55
test("goblin spawns with slashing melee profile from mob definition", () =>90
test("goblin spawns with slashing melee profile from mob definition", () =>56
{91
{57
const harness = makeSimulation({ workerCount: 1 });92
const harness = makeSimulation({ workerCount: 1 });