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.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
@@ -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.pine228
fallback: WoodTier.pine229
};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.bronze244
};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,@@ -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. */148
const DUAL_TINT_LIT_SPRITE_FRAG = [148
const DUAL_TINT_LIT_SPRITE_FRAG = [149
"precision mediump float;",149
"precision mediump float;",150
"varying vec2 v_texCoord;",150
"varying vec2 v_texCoord;",@@ -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). */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
function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = null)241
function 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 = nul248
{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,@@ -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", () =>36
test("chicken drops feathers", () =>56
test("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
});@@ -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
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
test("material tint hex converts to 0-1 rgb at load", () =>121
test("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));