BlueGit

timfa questward

Add bow art, chicken loot, and crafting-bench tier pairs.

Wire dual-tint bows and feathers, draw weapons under legs, give chickens feather/egg drops, and label crafting-bench materials as metal/wood pairs.

timfa Tim Falken · pushed by timfa

Authored 2026-08-27 · 2 months ago

Hash
12a56499c19fa5b5fae23eb3334a02b4991866b0
Parent
b7733356
17 files changed +139 −27
client/assets/items/bow/bow-equip.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/bow/bow.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/bow/bowstring.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/bow/unstrung-bow.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/egg/egg.png added Binary file +0 −0

The contents of this binary file are not shown.

client/assets/items/feather/feather.png Binary file +0 −0

The contents of this binary file are not shown.

client/assets/mobs/chicken/chicken.png Binary file +0 −0

The contents of this binary file are not shown.

client/src/play/crafting.js +15 −0
@@ -228,6 +228,21 @@ export function initCrafting ({
228 228 fallback: WoodTier.pine
229 229 };
230 230 }
231 // Crafting bench mixes metal tools and wood bows — show matched pairs.
232 if (isCraftingBenchStation())
233 {
234 const names = {};
235 for (const metal of MATERIAL_TIER_ORDER)
236 {
237 const wood = woodTierForMetal(metal);
238 names[metal] = `${MATERIAL_DISPLAY_NAME[metal] ?? metal}/${MATERIAL_DISPLAY_NAME[wood] ?? wood}`;
239 }
240 return {
241 order: MATERIAL_TIER_ORDER,
242 names,
243 fallback: MaterialTier.bronze
244 };
245 }
231 246 return {
232 247 order: MATERIAL_TIER_ORDER,
233 248 names: MATERIAL_DISPLAY_NAME,
@@ -228,6 +228,21 @@ export function initCrafting ({
228 fallback: WoodTier.pine
228 fallback: WoodTier.pine
229 };
229 };
230 }
230 }
231 // Crafting bench mixes metal tools and wood bows — show matched pairs.
232 if (isCraftingBenchStation())
233 {
234 const names = {};
235 for (const metal of MATERIAL_TIER_ORDER)
236 {
237 const wood = woodTierForMetal(metal);
238 names[metal] = `${MATERIAL_DISPLAY_NAME[metal] ?? metal}/${MATERIAL_DISPLAY_NAME[wood] ?? wood}`;
239 }
240 return {
241 order: MATERIAL_TIER_ORDER,
242 names,
243 fallback: MaterialTier.bronze
244 };
245 }
231 return {
246 return {
232 order: MATERIAL_TIER_ORDER,
247 order: MATERIAL_TIER_ORDER,
233 names: MATERIAL_DISPLAY_NAME,
248 names: MATERIAL_DISPLAY_NAME,
client/src/render/worldView.js +1 −1
@@ -144,7 +144,7 @@ const TINT_LIT_SPRITE_FRAG = [
144 144 "}"
145 145 ].join("\n");
146 146
147 /** Dual-channel arrow tint: red = shaft, blue = tip, white unchanged; then darkness. */
147 /** Dual-channel tint: red = shaft/wood, blue = tip/string, white unchanged; then darkness. */
148 148 const DUAL_TINT_LIT_SPRITE_FRAG = [
149 149 "precision mediump float;",
150 150 "varying vec2 v_texCoord;",
@@ -144,7 +144,7 @@ const TINT_LIT_SPRITE_FRAG = [
144 "}"
144 "}"
145].join("\n");
145].join("\n");
146
146
147/** Dual-channel arrow tint: red = shaft, blue = tip, white unchanged; then darkness. */
147/** Dual-channel tint: red = shaft/wood, blue = tip/string, white unchanged; then darkness. */
148const DUAL_TINT_LIT_SPRITE_FRAG = [
148const DUAL_TINT_LIT_SPRITE_FRAG = [
149 "precision mediump float;",
149 "precision mediump float;",
150 "varying vec2 v_texCoord;",
150 "varying vec2 v_texCoord;",
server/src/combat/service.js +15 −1
@@ -226,6 +226,18 @@ function consumeArrow (ecs, handle)
226 226 return true;
227 227 }
228 228
229 /** Fixed `quantity`, or inclusive `quantityMin`/`quantityMax` range (default 1). */
230 function rollDropQuantity (drop)
231 {
232 if (drop.quantityMin != null || drop.quantityMax != null)
233 {
234 const min = Math.max(0, Math.floor(Number(drop.quantityMin ?? 1)));
235 const max = Math.max(min, Math.floor(Number(drop.quantityMax ?? min)));
236 return min + Math.floor(Math.random() * (max - min + 1));
237 }
238 return Math.max(1, Math.floor(Number(drop.quantity ?? 1)));
239 }
240
229 241 function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = null)
230 242 {
231 243 const creature = world.ecs.get(targetHandle, Component.creature);
@@ -248,7 +260,9 @@ function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = nul
248 260 {
249 261 if (Math.random() > (drop.chance ?? 1))
250 262 { continue; }
251 const quantity = drop.quantity ?? 1;
263 const quantity = rollDropQuantity(drop);
264 if (quantity <= 0)
265 { continue; }
252 266 const groundItemId = (world.nextGroundItemId = (world.nextGroundItemId ?? 1) + 1);
253 267 const stack = attachOrigins({
254 268 itemId: drop.itemId,
@@ -226,6 +226,18 @@ function consumeArrow (ecs, handle)
226 return true;
226 return true;
227}
227}
228
228
229/** Fixed `quantity`, or inclusive `quantityMin`/`quantityMax` range (default 1). */
230function rollDropQuantity (drop)
231{
232 if (drop.quantityMin != null || drop.quantityMax != null)
233 {
234 const min = Math.max(0, Math.floor(Number(drop.quantityMin ?? 1)));
235 const max = Math.max(min, Math.floor(Number(drop.quantityMax ?? min)));
236 return min + Math.floor(Math.random() * (max - min + 1));
237 }
238 return Math.max(1, Math.floor(Number(drop.quantity ?? 1)));
239}
240
229function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = null)
241function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = null)
230{
242{
231 const creature = world.ecs.get(targetHandle, Component.creature);
243 const creature = world.ecs.get(targetHandle, Component.creature);
@@ -248,7 +260,9 @@ function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = nul
248 {
260 {
249 if (Math.random() > (drop.chance ?? 1))
261 if (Math.random() > (drop.chance ?? 1))
250 { continue; }
262 { continue; }
251 const quantity = drop.quantity ?? 1;
263 const quantity = rollDropQuantity(drop);
264 if (quantity <= 0)
265 { continue; }
252 const groundItemId = (world.nextGroundItemId = (world.nextGroundItemId ?? 1) + 1);
266 const groundItemId = (world.nextGroundItemId = (world.nextGroundItemId ?? 1) + 1);
253 const stack = attachOrigins({
267 const stack = attachOrigins({
254 itemId: drop.itemId,
268 itemId: drop.itemId,
server/tests/ranged.test.js +28 −1
@@ -13,6 +13,26 @@ test("ranged items: bow is ranged weapon, arrows stack in offhand", () =>
13 13 const bow = itemDefinition(RangedItemId.pineBow);
14 14 assert.equal(bow?.equipment?.attack?.mode, "ranged");
15 15 assert.equal(bow?.equipment?.kind, EquipmentKind.bow);
16 assert.equal(bow?.iconKey, "bow");
17 assert.equal(bow?.defaultState, "bow");
18 assert.equal(bow?.dualTintFromTier, true);
19 assert.equal(bow?.clothTier, "cotton");
20 assert.equal(bow?.tintFromTier, undefined);
21
22 const unstrung = itemDefinition(RangedItemId.pineUnstrungBow);
23 assert.equal(unstrung?.iconKey, "bow");
24 assert.equal(unstrung?.defaultState, "unstrung-bow");
25 assert.equal(unstrung?.dualTintFromTier, true);
26 assert.equal(unstrung?.clothTier, undefined);
27
28 const bowstring = itemDefinition(RangedItemId.cottonBowstring);
29 assert.equal(bowstring?.iconKey, "bow");
30 assert.equal(bowstring?.defaultState, "bowstring");
31 assert.equal(bowstring?.tintFromTier, true);
32
33 const feather = itemDefinition(RangedItemId.feather);
34 assert.equal(feather?.iconKey, "feather");
35 assert.equal(feather?.defaultState, "feather");
16 36
17 37 const arrow = itemDefinition(RangedItemId.bronzeArrow);
18 38 assert.equal(arrow?.equipment?.kind, EquipmentKind.arrowAmmo);
@@ -36,5 +56,12 @@ test("ranged recipes load on crafting stations", () =>
36 56 test("chicken drops feathers", () =>
37 57 {
38 58 const chicken = mobDefinition(MobId.chicken);
39 assert.ok(chicken?.drops?.some((drop) => drop.itemId === RangedItemId.feather));
59 const feather = chicken?.drops?.find((drop) => drop.itemId === RangedItemId.feather);
60 assert.ok(feather);
61 assert.equal(feather.chance, 1);
62 assert.equal(feather.quantityMin, 1);
63 assert.equal(feather.quantityMax, 3);
64 const egg = chicken?.drops?.find((drop) => drop.itemId === ItemId.egg);
65 assert.ok(egg);
66 assert.equal(egg.chance, 0.2);
40 67 });
@@ -13,6 +13,26 @@ test("ranged items: bow is ranged weapon, arrows stack in offhand", () =>
13 const bow = itemDefinition(RangedItemId.pineBow);
13 const bow = itemDefinition(RangedItemId.pineBow);
14 assert.equal(bow?.equipment?.attack?.mode, "ranged");
14 assert.equal(bow?.equipment?.attack?.mode, "ranged");
15 assert.equal(bow?.equipment?.kind, EquipmentKind.bow);
15 assert.equal(bow?.equipment?.kind, EquipmentKind.bow);
16 assert.equal(bow?.iconKey, "bow");
17 assert.equal(bow?.defaultState, "bow");
18 assert.equal(bow?.dualTintFromTier, true);
19 assert.equal(bow?.clothTier, "cotton");
20 assert.equal(bow?.tintFromTier, undefined);
21
22 const unstrung = itemDefinition(RangedItemId.pineUnstrungBow);
23 assert.equal(unstrung?.iconKey, "bow");
24 assert.equal(unstrung?.defaultState, "unstrung-bow");
25 assert.equal(unstrung?.dualTintFromTier, true);
26 assert.equal(unstrung?.clothTier, undefined);
27
28 const bowstring = itemDefinition(RangedItemId.cottonBowstring);
29 assert.equal(bowstring?.iconKey, "bow");
30 assert.equal(bowstring?.defaultState, "bowstring");
31 assert.equal(bowstring?.tintFromTier, true);
32
33 const feather = itemDefinition(RangedItemId.feather);
34 assert.equal(feather?.iconKey, "feather");
35 assert.equal(feather?.defaultState, "feather");
16
36
17 const arrow = itemDefinition(RangedItemId.bronzeArrow);
37 const arrow = itemDefinition(RangedItemId.bronzeArrow);
18 assert.equal(arrow?.equipment?.kind, EquipmentKind.arrowAmmo);
38 assert.equal(arrow?.equipment?.kind, EquipmentKind.arrowAmmo);
@@ -36,5 +56,12 @@ test("ranged recipes load on crafting stations", () =>
36test("chicken drops feathers", () =>
56test("chicken drops feathers", () =>
37{
57{
38 const chicken = mobDefinition(MobId.chicken);
58 const chicken = mobDefinition(MobId.chicken);
39 assert.ok(chicken?.drops?.some((drop) => drop.itemId === RangedItemId.feather));
59 const feather = chicken?.drops?.find((drop) => drop.itemId === RangedItemId.feather);
60 assert.ok(feather);
61 assert.equal(feather.chance, 1);
62 assert.equal(feather.quantityMin, 1);
63 assert.equal(feather.quantityMax, 3);
64 const egg = chicken?.drops?.find((drop) => drop.itemId === ItemId.egg);
65 assert.ok(egg);
66 assert.equal(egg.chance, 0.2);
40});
67});
server/tests/tint.test.js +13 −0
@@ -105,6 +105,19 @@ test("hafted tools dual-tint wood handle and metal head", () =>
105 105 assert.deepEqual(ironAxe.tip, tierTintColor(MaterialTier.iron));
106 106 });
107 107
108 test("bows dual-tint wood frame and cloth string; unstrung wood only", () =>
109 {
110 const bow = resolveItemDualTint({ itemId: RangedItemId.pineBow });
111 assert.deepEqual(bow.shaft, tierTintColor("pine"));
112 assert.deepEqual(bow.tip, tierTintColor("cotton"));
113 assert.equal(resolveItemTint({ itemId: RangedItemId.pineBow }), null);
114
115 const unstrung = resolveItemDualTint({ itemId: RangedItemId.pineUnstrungBow });
116 assert.deepEqual(unstrung.shaft, tierTintColor("pine"));
117 assert.deepEqual(unstrung.tip, tierTintColor("pine"));
118 assert.equal(resolveItemTint({ itemId: RangedItemId.pineUnstrungBow }), null);
119 });
120
108 121 test("material tint hex converts to 0-1 rgb at load", () =>
109 122 {
110 123 assert.deepEqual(MATERIAL_TINT_HEX[MaterialTier.bronze], rgb(184, 122, 71));
@@ -105,6 +105,19 @@ test("hafted tools dual-tint wood handle and metal head", () =>
105 assert.deepEqual(ironAxe.tip, tierTintColor(MaterialTier.iron));
105 assert.deepEqual(ironAxe.tip, tierTintColor(MaterialTier.iron));
106});
106});
107
107
108test("bows dual-tint wood frame and cloth string; unstrung wood only", () =>
109{
110 const bow = resolveItemDualTint({ itemId: RangedItemId.pineBow });
111 assert.deepEqual(bow.shaft, tierTintColor("pine"));
112 assert.deepEqual(bow.tip, tierTintColor("cotton"));
113 assert.equal(resolveItemTint({ itemId: RangedItemId.pineBow }), null);
114
115 const unstrung = resolveItemDualTint({ itemId: RangedItemId.pineUnstrungBow });
116 assert.deepEqual(unstrung.shaft, tierTintColor("pine"));
117 assert.deepEqual(unstrung.tip, tierTintColor("pine"));
118 assert.equal(resolveItemTint({ itemId: RangedItemId.pineUnstrungBow }), null);
119});
120
108test("material tint hex converts to 0-1 rgb at load", () =>
121test("material tint hex converts to 0-1 rgb at load", () =>
109{
122{
110 assert.deepEqual(MATERIAL_TINT_HEX[MaterialTier.bronze], rgb(184, 122, 71));
123 assert.deepEqual(MATERIAL_TINT_HEX[MaterialTier.bronze], rgb(184, 122, 71));
shared/appearance/hair.js +1 −1
@@ -212,7 +212,7 @@ export function hairLayerFromAppearance (appearance)
212 212 }
213 213
214 214 /**
215 * Shared draw order: body → boots/legs/chest → hair (if visible) → head → offhand → weapon.
215 * Shared draw order: body → boots → chest → weapon → legs → hair (if visible) → head → offhand.
216 216 */
217 217 export function composeAppearanceLayers (appearance, equipmentSlots)
218 218 {
@@ -212,7 +212,7 @@ export function hairLayerFromAppearance (appearance)
212}
212}
213
213
214/**
214/**
215 * Shared draw order: body → boots/legs/chest → hair (if visible) → head → offhand → weapon.
215 * Shared draw order: body → boots → chest → weapon → legs → hair (if visible) → head → offhand.
216 */
216 */
217export function composeAppearanceLayers (appearance, equipmentSlots)
217export function composeAppearanceLayers (appearance, equipmentSlots)
218{
218{
shared/definitions/items.js +17 −3
@@ -34,6 +34,7 @@ export const ItemId = Object.freeze({
34 34 glassBottle: 29,
35 35 potion: 32,
36 36 recipePaper: 33,
37 egg: 275,
37 38 ...SpellbookItemId,
38 39 ...MetalItemId,
39 40 ...WoodItemId,
@@ -54,13 +55,14 @@ export const EQUIPMENT_SLOT = Object.freeze({
54 55 offhand: "offhand"
55 56 });
56 57
58 /** Back → front. Weapon sits above chest but under legs (legs also cover shirt hem). */
57 59 export const EQUIPMENT_DRAW_ORDER = Object.freeze([
58 60 EQUIPMENT_SLOT.boots,
59 EQUIPMENT_SLOT.legs,
60 61 EQUIPMENT_SLOT.chest,
62 EQUIPMENT_SLOT.weapon,
63 EQUIPMENT_SLOT.legs,
61 64 EQUIPMENT_SLOT.head,
62 EQUIPMENT_SLOT.offhand,
63 EQUIPMENT_SLOT.weapon
65 EQUIPMENT_SLOT.offhand
64 66 ]);
65 67
66 68 export const DEFAULT_MAX_STACK = 99;
@@ -114,6 +116,18 @@ export const ITEM_DEFINITIONS = Object.freeze({
114 116 category: "food",
115 117 healing: 4
116 118 }),
119 [ItemId.egg]: Object.freeze({
120 itemId: ItemId.egg,
121 key: "egg",
122 displayName: "Egg",
123 description: "A fresh egg, still warm from the nest.",
124 seedValue: 1,
125 stackable: true,
126 maxStackSize: DEFAULT_MAX_STACK,
127 uniqueInstance: false,
128 category: "food",
129 healing: 2
130 }),
117 131 [ItemId.stick]: Object.freeze({
118 132 itemId: ItemId.stick,
119 133 key: "stick",
@@ -34,6 +34,7 @@ export const ItemId = Object.freeze({
34 glassBottle: 29,
34 glassBottle: 29,
35 potion: 32,
35 potion: 32,
36 recipePaper: 33,
36 recipePaper: 33,
37 egg: 275,
37 ...SpellbookItemId,
38 ...SpellbookItemId,
38 ...MetalItemId,
39 ...MetalItemId,
39 ...WoodItemId,
40 ...WoodItemId,
@@ -54,13 +55,14 @@ export const EQUIPMENT_SLOT = Object.freeze({
54 offhand: "offhand"
55 offhand: "offhand"
55});
56});
56
57
58/** Back → front. Weapon sits above chest but under legs (legs also cover shirt hem). */
57export const EQUIPMENT_DRAW_ORDER = Object.freeze([
59export const EQUIPMENT_DRAW_ORDER = Object.freeze([
58 EQUIPMENT_SLOT.boots,
60 EQUIPMENT_SLOT.boots,
59 EQUIPMENT_SLOT.legs,
60 EQUIPMENT_SLOT.chest,
61 EQUIPMENT_SLOT.chest,
62 EQUIPMENT_SLOT.weapon,
63 EQUIPMENT_SLOT.legs,
61 EQUIPMENT_SLOT.head,
64 EQUIPMENT_SLOT.head,
62 EQUIPMENT_SLOT.offhand,
65 EQUIPMENT_SLOT.offhand
63 EQUIPMENT_SLOT.weapon
64]);
66]);
65
67
66export const DEFAULT_MAX_STACK = 99;
68export const DEFAULT_MAX_STACK = 99;
@@ -114,6 +116,18 @@ export const ITEM_DEFINITIONS = Object.freeze({
114 category: "food",
116 category: "food",
115 healing: 4
117 healing: 4
116 }),
118 }),
119 [ItemId.egg]: Object.freeze({
120 itemId: ItemId.egg,
121 key: "egg",
122 displayName: "Egg",
123 description: "A fresh egg, still warm from the nest.",
124 seedValue: 1,
125 stackable: true,
126 maxStackSize: DEFAULT_MAX_STACK,
127 uniqueInstance: false,
128 category: "food",
129 healing: 2
130 }),
117 [ItemId.stick]: Object.freeze({
131 [ItemId.stick]: Object.freeze({
118 itemId: ItemId.stick,
132 itemId: ItemId.stick,
119 key: "stick",
133 key: "stick",
shared/definitions/mobs.js +4 −2
@@ -2,6 +2,7 @@ import { spriteImageName } from "./tileSprites.js";
2 2 import { centralExchangeStaffCount } from "../market/exchange.js";
3 3 import { LeatherItemId } from "./leatherItems.js";
4 4 import { RangedItemId } from "./rangedItems.js";
5 import { ItemId } from "./items.js";
5 6
6 7 export const MobId = Object.freeze({
7 8 deer: "deer",
@@ -15,7 +16,7 @@ export const MobId = Object.freeze({
15 16 centralExchange: "central-exchange"
16 17 });
17 18
18 /** @typedef {{ itemId: number, chance: number }} MobDrop */
19 /** @typedef {{ itemId: number, chance: number, quantity?: number, quantityMin?: number, quantityMax?: number }} MobDrop */
19 20 /** @typedef {{ isPlayer: boolean, text: string }} DialogueLine */
20 21 /** @typedef {{ trigger: string, text: string, available?: (ctx: object) => boolean }} DialogueResponse */
21 22
@@ -121,7 +122,8 @@ export const MOB_DEFINITIONS = Object.freeze({
121 122 attackSkill: 1,
122 123 attackCooldownMs: 1200,
123 124 drops: Object.freeze([
124 { itemId: RangedItemId.feather, chance: 1 }
125 { itemId: RangedItemId.feather, chance: 1, quantityMin: 1, quantityMax: 3 },
126 { itemId: ItemId.egg, chance: 0.2 }
125 127 ]),
126 128 sells: Object.freeze([]),
127 129 dialogue: Object.freeze([]),
@@ -2,6 +2,7 @@ import { spriteImageName } from "./tileSprites.js";
2import { centralExchangeStaffCount } from "../market/exchange.js";
2import { centralExchangeStaffCount } from "../market/exchange.js";
3import { LeatherItemId } from "./leatherItems.js";
3import { LeatherItemId } from "./leatherItems.js";
4import { RangedItemId } from "./rangedItems.js";
4import { RangedItemId } from "./rangedItems.js";
5import { ItemId } from "./items.js";
5
6
6export const MobId = Object.freeze({
7export const MobId = Object.freeze({
7 deer: "deer",
8 deer: "deer",
@@ -15,7 +16,7 @@ export const MobId = Object.freeze({
15 centralExchange: "central-exchange"
16 centralExchange: "central-exchange"
16});
17});
17
18
18/** @typedef {{ itemId: number, chance: number }} MobDrop */
19/** @typedef {{ itemId: number, chance: number, quantity?: number, quantityMin?: number, quantityMax?: number }} MobDrop */
19/** @typedef {{ isPlayer: boolean, text: string }} DialogueLine */
20/** @typedef {{ isPlayer: boolean, text: string }} DialogueLine */
20/** @typedef {{ trigger: string, text: string, available?: (ctx: object) => boolean }} DialogueResponse */
21/** @typedef {{ trigger: string, text: string, available?: (ctx: object) => boolean }} DialogueResponse */
21
22
@@ -121,7 +122,8 @@ export const MOB_DEFINITIONS = Object.freeze({
121 attackSkill: 1,
122 attackSkill: 1,
122 attackCooldownMs: 1200,
123 attackCooldownMs: 1200,
123 drops: Object.freeze([
124 drops: Object.freeze([
124 { itemId: RangedItemId.feather, chance: 1 }
125 { itemId: RangedItemId.feather, chance: 1, quantityMin: 1, quantityMax: 3 },
126 { itemId: ItemId.egg, chance: 0.2 }
125 ]),
127 ]),
126 sells: Object.freeze([]),
128 sells: Object.freeze([]),
127 dialogue: Object.freeze([]),
129 dialogue: Object.freeze([]),
shared/definitions/tierFamilies.js +7 −6
@@ -223,11 +223,12 @@ export const ITEM_FAMILIES = Object.freeze({
223 223 description: () => "A carved bow frame awaiting a string.",
224 224 category: ItemCategory.intermediate,
225 225 iconKey: "bow",
226 defaultState: "bow",
226 defaultState: "unstrung-bow",
227 227 stackable: false,
228 228 maxStackSize: 1,
229 229 seedValue: 6,
230 tintFromTier: true
230 /** Red = wood; blue unused (same dual shader as bows/arrows). */
231 dualTintFromTier: true
231 232 }),
232 233 [ItemFamilyId.bow]: Object.freeze({
233 234 familyId: ItemFamilyId.bow,
@@ -240,10 +241,10 @@ export const ITEM_FAMILIES = Object.freeze({
240 241 stackable: false,
241 242 maxStackSize: 1,
242 243 seedValue: 12,
243 tintFromTier: true,
244 /** Red = wood, blue = string (cloth tier). */
245 dualTintFromTier: true,
244 246 clothTierFromWood: true,
245 247 equipmentKind: EquipmentKind.bow,
246 equipmentTintFromTier: true,
247 248 equipmentAttack: Object.freeze({
248 249 mode: "ranged",
249 250 rangeTiles: COMBAT_RANGE_TILES,
@@ -259,8 +260,8 @@ export const ITEM_FAMILIES = Object.freeze({
259 260 label: "bowstring",
260 261 description: () => "Twisted yarn spun tight for a bow.",
261 262 category: ItemCategory.intermediate,
262 iconKey: "cloth",
263 defaultState: "yarn",
263 iconKey: "bow",
264 defaultState: "bowstring",
264 265 stackable: true,
265 266 maxStackSize: DEFAULT_STACK,
266 267 seedValue: 2,
@@ -223,11 +223,12 @@ export const ITEM_FAMILIES = Object.freeze({
223 description: () => "A carved bow frame awaiting a string.",
223 description: () => "A carved bow frame awaiting a string.",
224 category: ItemCategory.intermediate,
224 category: ItemCategory.intermediate,
225 iconKey: "bow",
225 iconKey: "bow",
226 defaultState: "bow",
226 defaultState: "unstrung-bow",
227 stackable: false,
227 stackable: false,
228 maxStackSize: 1,
228 maxStackSize: 1,
229 seedValue: 6,
229 seedValue: 6,
230 tintFromTier: true
230 /** Red = wood; blue unused (same dual shader as bows/arrows). */
231 dualTintFromTier: true
231 }),
232 }),
232 [ItemFamilyId.bow]: Object.freeze({
233 [ItemFamilyId.bow]: Object.freeze({
233 familyId: ItemFamilyId.bow,
234 familyId: ItemFamilyId.bow,
@@ -240,10 +241,10 @@ export const ITEM_FAMILIES = Object.freeze({
240 stackable: false,
241 stackable: false,
241 maxStackSize: 1,
242 maxStackSize: 1,
242 seedValue: 12,
243 seedValue: 12,
243 tintFromTier: true,
244 /** Red = wood, blue = string (cloth tier). */
245 dualTintFromTier: true,
244 clothTierFromWood: true,
246 clothTierFromWood: true,
245 equipmentKind: EquipmentKind.bow,
247 equipmentKind: EquipmentKind.bow,
246 equipmentTintFromTier: true,
247 equipmentAttack: Object.freeze({
248 equipmentAttack: Object.freeze({
248 mode: "ranged",
249 mode: "ranged",
249 rangeTiles: COMBAT_RANGE_TILES,
250 rangeTiles: COMBAT_RANGE_TILES,
@@ -259,8 +260,8 @@ export const ITEM_FAMILIES = Object.freeze({
259 label: "bowstring",
260 label: "bowstring",
260 description: () => "Twisted yarn spun tight for a bow.",
261 description: () => "Twisted yarn spun tight for a bow.",
261 category: ItemCategory.intermediate,
262 category: ItemCategory.intermediate,
262 iconKey: "cloth",
263 iconKey: "bow",
263 defaultState: "yarn",
264 defaultState: "bowstring",
264 stackable: true,
265 stackable: true,
265 maxStackSize: DEFAULT_STACK,
266 maxStackSize: DEFAULT_STACK,
266 seedValue: 2,
267 seedValue: 2,
shared/render/tint.js +38 −12
@@ -1,4 +1,4 @@
1 import { MATERIAL_TIER_ORDER, materialTintColor, GatherMaterialId, woodTierForMetal } from "../definitions/materialTiers.js";
1 import { MATERIAL_TIER_ORDER, materialTintColor, GatherMaterialId } from "../definitions/materialTiers.js";
2 2 import { itemDefinition } from "../definitions/items.js";
3 3
4 4 /**
@@ -10,9 +10,9 @@ import { itemDefinition } from "../definitions/items.js";
10 10 * so dark target colours stay dark: mix(tint, vec3(luma(tint)), G/R) * L.
11 11 * - Otherwise leave RGB as-is. World shaders apply darkness after this pass.
12 12 *
13 * Dual-channel arrows / tools ({@link applyDualChannelTintToImageData}):
14 * - Dominant red (R > G,B): shaft / handle mask; lightness = R; tint with shaft colour.
15 * - Dominant blue (B > R,G): tip / metal mask; lightness = B; tint with tip colour.
13 * Dual-channel arrows / tools / bows ({@link applyDualChannelTintToImageData}):
14 * - Dominant red (R > G,B): shaft / wood / handle mask; lightness = R; tint with shaft colour.
15 * - Dominant blue (B > R,G): tip / metal / string mask; lightness = B; tint with tip colour.
16 16 * - Neutral / white (fletching): neither channel dominates — RGB unchanged.
17 17 */
18 18
@@ -88,7 +88,8 @@ export function applyDualChannelTintToImageData (imageData, { shaft, tip })
88 88 return imageData;
89 89 }
90 90
91 /** Dual shaft/tip tier tints for assembled arrows and hafted tools (`dualTintFromTier`). */
91 /** Dual shaft/tip tier tints for assembled arrows, hafted tools, and bows (`dualTintFromTier`).
92 * Red channel = shaft (wood); blue channel = tip/string (metal or cloth). */
92 93 export function resolveItemDualTint (stackOrDef, def = null)
93 94 {
94 95 const stack = stackOrDef?.itemId != null ? stackOrDef : null;
@@ -97,14 +98,39 @@ export function resolveItemDualTint (stackOrDef, def = null)
97 98 ?? null;
98 99 if (!definition?.dualTintFromTier)
99 100 { return null; }
100 const metalTier = definition.tier ?? definition.equipment?.tier ?? null;
101 const woodTier = definition.woodTier ?? (metalTier ? woodTierForMetal(metalTier) : null);
102 if (!metalTier || !woodTier)
101
102 // Tools / arrows: metal primary tier + matching wood shaft.
103 if (definition.woodTier)
104 {
105 const metalTier = definition.tier ?? definition.equipment?.tier ?? null;
106 const woodTier = definition.woodTier;
107 if (!metalTier || !woodTier)
108 { return null; }
109 return {
110 shaft: tierTintColor(woodTier),
111 tip: tierTintColor(metalTier)
112 };
113 }
114
115 // Strung bow: wood frame + cloth string.
116 if (definition.clothTier)
117 {
118 const woodTier = definition.tier ?? null;
119 const clothTier = definition.clothTier;
120 if (!woodTier || !clothTier)
121 { return null; }
122 return {
123 shaft: tierTintColor(woodTier),
124 tip: tierTintColor(clothTier)
125 };
126 }
127
128 // Unstrung bow (and similar): wood on red only; tip unused in art.
129 const woodTier = definition.tier ?? definition.equipment?.tier ?? null;
130 if (!woodTier)
103 131 { return null; }
104 return {
105 shaft: tierTintColor(woodTier),
106 tip: tierTintColor(metalTier)
107 };
132 const wood = tierTintColor(woodTier);
133 return { shaft: wood, tip: wood };
108 134 }
109 135
110 136 /** Max |R − B| in 0–255 channel units for near-magenta pixels. */
@@ -1,4 +1,4 @@
1import { MATERIAL_TIER_ORDER, materialTintColor, GatherMaterialId, woodTierForMetal } from "../definitions/materialTiers.js";
1import { MATERIAL_TIER_ORDER, materialTintColor, GatherMaterialId } from "../definitions/materialTiers.js";
2import { itemDefinition } from "../definitions/items.js";
2import { itemDefinition } from "../definitions/items.js";
3
3
4/**
4/**
@@ -10,9 +10,9 @@ import { itemDefinition } from "../definitions/items.js";
10 * so dark target colours stay dark: mix(tint, vec3(luma(tint)), G/R) * L.
10 * so dark target colours stay dark: mix(tint, vec3(luma(tint)), G/R) * L.
11 * - Otherwise leave RGB as-is. World shaders apply darkness after this pass.
11 * - Otherwise leave RGB as-is. World shaders apply darkness after this pass.
12 *
12 *
13 * Dual-channel arrows / tools ({@link applyDualChannelTintToImageData}):
13 * Dual-channel arrows / tools / bows ({@link applyDualChannelTintToImageData}):
14 * - Dominant red (R > G,B): shaft / handle mask; lightness = R; tint with shaft colour.
14 * - Dominant red (R > G,B): shaft / wood / handle mask; lightness = R; tint with shaft colour.
15 * - Dominant blue (B > R,G): tip / metal mask; lightness = B; tint with tip colour.
15 * - Dominant blue (B > R,G): tip / metal / string mask; lightness = B; tint with tip colour.
16 * - Neutral / white (fletching): neither channel dominates — RGB unchanged.
16 * - Neutral / white (fletching): neither channel dominates — RGB unchanged.
17 */
17 */
18
18
@@ -88,7 +88,8 @@ export function applyDualChannelTintToImageData (imageData, { shaft, tip })
88 return imageData;
88 return imageData;
89}
89}
90
90
91/** Dual shaft/tip tier tints for assembled arrows and hafted tools (`dualTintFromTier`). */
91/** Dual shaft/tip tier tints for assembled arrows, hafted tools, and bows (`dualTintFromTier`).
92 * Red channel = shaft (wood); blue channel = tip/string (metal or cloth). */
92export function resolveItemDualTint (stackOrDef, def = null)
93export function resolveItemDualTint (stackOrDef, def = null)
93{
94{
94 const stack = stackOrDef?.itemId != null ? stackOrDef : null;
95 const stack = stackOrDef?.itemId != null ? stackOrDef : null;
@@ -97,14 +98,39 @@ export function resolveItemDualTint (stackOrDef, def = null)
97 ?? null;
98 ?? null;
98 if (!definition?.dualTintFromTier)
99 if (!definition?.dualTintFromTier)
99 { return null; }
100 { return null; }
100 const metalTier = definition.tier ?? definition.equipment?.tier ?? null;
101
101 const woodTier = definition.woodTier ?? (metalTier ? woodTierForMetal(metalTier) : null);
102 // Tools / arrows: metal primary tier + matching wood shaft.
102 if (!metalTier || !woodTier)
103 if (definition.woodTier)
104 {
105 const metalTier = definition.tier ?? definition.equipment?.tier ?? null;
106 const woodTier = definition.woodTier;
107 if (!metalTier || !woodTier)
108 { return null; }
109 return {
110 shaft: tierTintColor(woodTier),
111 tip: tierTintColor(metalTier)
112 };
113 }
114
115 // Strung bow: wood frame + cloth string.
116 if (definition.clothTier)
117 {
118 const woodTier = definition.tier ?? null;
119 const clothTier = definition.clothTier;
120 if (!woodTier || !clothTier)
121 { return null; }
122 return {
123 shaft: tierTintColor(woodTier),
124 tip: tierTintColor(clothTier)
125 };
126 }
127
128 // Unstrung bow (and similar): wood on red only; tip unused in art.
129 const woodTier = definition.tier ?? definition.equipment?.tier ?? null;
130 if (!woodTier)
103 { return null; }
131 { return null; }
104 return {
132 const wood = tierTintColor(woodTier);
105 shaft: tierTintColor(woodTier),
133 return { shaft: wood, tip: wood };
106 tip: tierTintColor(metalTier)
107 };
108}
134}
109
135
110/** Max |R − B| in 0–255 channel units for near-magenta pixels. */
136/** Max |R − B| in 0–255 channel units for near-magenta pixels. */