Strict dual-channel tint and full fairy mob presentation.
RGB blend only when the winning channel has equal secondaries; fairies use their own bloom sprite with random hair/shirt/skirt tints, soft light, and per-swing elemental melee.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
@@ -164,7 +164,8 @@ const TINT_LIT_SPRITE_FRAG = [
164
164
].join("\n");
165
165
166
166
/** Dual/triple-channel tint: red = shaft, blue = tip, green = coat; then darkness.
167
* Equal non-dominant channels lighten the assigned tint toward white. */
167
* Only when the primary channel is highest and the other two are equal;
168
* equal non-zero secondaries lighten the assigned tint toward white. */
168
169
const DUAL_TINT_LIT_SPRITE_FRAG = [
169
170
"precision mediump float;",
170
171
"varying vec2 v_texCoord;",
@@ -178,12 +179,13 @@ const DUAL_TINT_LIT_SPRITE_FRAG = [
178
179
"uniform vec3 u_tipTint;",
179
180
"uniform vec3 u_coatTint;",
180
181
"uniform float u_hasCoat;",
181
"vec3 channelTint(float L, float o1, float o2, vec3 tint) {",
182
"vec3 channelTint(float L, float secondary, vec3 tint) {",
183
" float blend = L > 0.0 ? clamp(secondary / L, 0.0, 1.0) : 0.0;",
184
" return mix(tint, vec3(1.0), blend) * L;",
185
"}",
186
"float channelMask(float primary, float o1, float o2) {",
182
187
" float equal = step(abs(o1 - o2), 0.04);",
183
" float blend = L > 0.0 ? clamp(mix(min(o1, o2), o1, equal) / L, 0.0, 1.0) : 0.0;",
184
" float tintLuma = dot(tint, vec3(0.2126, 0.7152, 0.0722));",
185
" vec3 toward = mix(vec3(tintLuma), vec3(1.0), equal);",
186
" return mix(tint, toward, blend) * L;",
188
" return clamp((primary - max(o1, o2)) * 1.75, 0.0, 1.0) * equal;",
187
189
"}",
188
190
"void main() {",
189
191
" vec4 color = texture2D(u_texture, v_texCoord);",
@@ -192,20 +194,20 @@ const DUAL_TINT_LIT_SPRITE_FRAG = [
192
194
" if (u_wade > 0.5 && fromBottom < 4.0) { discard; }",
193
195
" vec3 rgb = color.rgb;",
194
196
" if (u_hasCoat > 0.5) {",
195
" float coatMask = clamp((color.g - max(color.r, color.b)) * 1.75, 0.0, 1.0);",
197
" float coatMask = channelMask(color.g, color.r, color.b);",
196
198
" if (coatMask > 0.0) {",
197
" vec3 coatCol = channelTint(color.g, color.r, color.b, u_coatTint);",
199
" vec3 coatCol = channelTint(color.g, color.r, u_coatTint);",
198
200
" rgb = mix(rgb, coatCol, coatMask);",
199
201
" }",
200
202
" }",
201
" float tipMask = clamp((color.b - max(color.r, color.g)) * 1.75, 0.0, 1.0);",
203
" float tipMask = channelMask(color.b, color.r, color.g);",
202
204
" if (tipMask > 0.0) {",
203
" vec3 tipCol = channelTint(color.b, color.r, color.g, u_tipTint);",
205
" vec3 tipCol = channelTint(color.b, color.r, u_tipTint);",
204
206
" rgb = mix(rgb, tipCol, tipMask);",
205
207
" }",
206
" float shaftMask = clamp((color.r - max(color.g, color.b)) * 1.75, 0.0, 1.0);",
208
" float shaftMask = channelMask(color.r, color.g, color.b);",
207
209
" if (shaftMask > 0.0) {",
208
" vec3 shaftCol = channelTint(color.r, color.g, color.b, u_shaftTint);",
210
" vec3 shaftCol = channelTint(color.r, color.g, u_shaftTint);",
209
211
" rgb = mix(rgb, shaftCol, shaftMask);",
210
212
" }",
211
213
" if (u_wade > 0.5 && fromBottom < 5.0) {",
@@ -2368,6 +2370,15 @@ export class WorldView
2368
2370
this.#startIdleAnimation(entity.object);
2369
2371
}
2370
2372
entity.bodyTint = layers[0]?.tint ? normalizeRgb(layers[0].tint) : null;
2373
entity.bodyDualTint = layers[0]?.dualTint
2374
? {
2375
shaft: normalizeRgb(layers[0].dualTint.shaft),
2376
tip: normalizeRgb(layers[0].dualTint.tip),
2377
...(layers[0].dualTint.coat
2378
? { coat: normalizeRgb(layers[0].dualTint.coat) }
2379
: {})
2380
}
2381
: null;
2371
2382
entity.bloomBody = !!layers[0]?.bloomBody;
2372
2383
for (const overlay of entity.overlays ?? [])
2373
2384
{ overlay.destroy(); }
@@ -2379,6 +2390,7 @@ export class WorldView
2379
2390
entity.overlayTightFit = [];
2380
2391
entity.bloomOverlays = [];
2381
2392
entity.bloomOverlayTints = [];
2393
entity.bloomOverlayDualTints = [];
2382
2394
if (entity.bloomBody && this.game.images[base])
2383
2395
{
2384
2396
const bloomName = bloomCompanionName(base);
@@ -2391,6 +2403,7 @@ export class WorldView
2391
2403
this.scene.addObject(bloom);
2392
2404
entity.bloomOverlays.push(bloom);
2393
2405
entity.bloomOverlayTints.push(entity.bodyTint);
2406
entity.bloomOverlayDualTints.push(entity.bodyDualTint);
2394
2407
}
2395
2408
}
2396
2409
for (const layer of layers.slice(1))
@@ -2452,7 +2465,21 @@ export class WorldView
2452
2465
const wade = isWadeGroundInSeason(this.#groundTypeAt(entity.tileX, entity.tileY), this.worldSeason);
2453
2466
2454
2467
entity.object.transform.rotation = walkTilt;
2455
this.#syncLitSprite(entity.object, tileShade, flashStrength, wade, entity.bodyTint ?? null, flashColor);
2468
if (entity.bodyDualTint)
2469
{
2470
this.#syncDualTintLitSprite(
2471
entity.object,
2472
tileShade,
2473
entity.bodyDualTint,
2474
flashStrength,
2475
wade,
2476
flashColor
2477
);
2478
}
2479
else
2480
{
2481
this.#syncLitSprite(entity.object, tileShade, flashStrength, wade, entity.bodyTint ?? null, flashColor);
2482
}
2456
2483
const flight = !!entity.freeFlight;
2457
2484
this.#placePivoted(entity.object, pivotX, pivotY, pivotY, SORT_ENTITY, entity.visualScale ?? 1, flight);
2458
2485
for (let index = 0; index < (entity.overlays ?? []).length; index++)
@@ -2496,8 +2523,11 @@ export class WorldView
2496
2523
overlay.renderer.subImage = entity.object.renderer.subImage | 0;
2497
2524
}
2498
2525
overlay.transform.rotation = walkTilt;
2526
const bloomDual = entity.bloomOverlayDualTints?.[index] ?? null;
2499
2527
const bloomTint = entity.bloomOverlayTints?.[index] ?? entity.bodyTint ?? null;
2500
if (bloomTint)
2528
if (bloomDual)
2529
{ this.#syncDualTintLitSprite(overlay, 0, bloomDual); }
2530
else if (bloomTint)
2501
2531
{ this.#syncUnlitTintSprite(overlay, bloomTint); }
2502
2532
else
2503
2533
{ this.#syncLitSprite(overlay, tileShade, flashStrength, wade, null, flashColor); }
@@ -2648,13 +2678,16 @@ export class WorldView
2648
2678
2649
2679
#syncDualTintLitSprite (object, darkness, dualTint, flashStrength = 0, wade = false, flashColor = null)
2650
2680
{
2651
if (!object?.renderer || object._lit === false || !dualTint)
2681
if (!object?.renderer || !dualTint)
2652
2682
{ return; }
2653
object._lit = true;
2654
2683
const shaft = normalizeRgb(dualTint.shaft);
2655
2684
const tip = normalizeRgb(dualTint.tip);
2656
2685
const coat = dualTint.coat ? normalizeRgb(dualTint.coat) : null;
2657
const dark = Math.min(1, Math.max(0, darkness ?? 0));
2686
const dark = object._lit === false
2687
? 0
2688
: Math.min(1, Math.max(0, darkness ?? 0));
2689
if (object._lit !== false)
2690
{ object._lit = true; }
2658
2691
const flash = Math.min(1, Math.max(0, flashStrength ?? 0));
2659
2692
const height = object.renderer.sprite?.height ?? SPRITE_SIZE_PX;
2660
2693
object.renderer.shader = getDualTintLitSpriteShader();
@@ -164,7 +164,8 @@ const TINT_LIT_SPRITE_FRAG = [164
].join("\n");164
].join("\n");165
165
166
/** Dual/triple-channel tint: red = shaft, blue = tip, green = coat; then darkness.166
/** Dual/triple-channel tint: red = shaft, blue = tip, green = coat; then darkness.167
* Equal non-dominant channels lighten the assigned tint toward white. */167
* Only when the primary channel is highest and the other two are equal;168
* equal non-zero secondaries lighten the assigned tint toward white. */168
const DUAL_TINT_LIT_SPRITE_FRAG = [169
const DUAL_TINT_LIT_SPRITE_FRAG = [169
"precision mediump float;",170
"precision mediump float;",170
"varying vec2 v_texCoord;",171
"varying vec2 v_texCoord;",@@ -178,12 +179,13 @@ const DUAL_TINT_LIT_SPRITE_FRAG = [178
"uniform vec3 u_tipTint;",179
"uniform vec3 u_tipTint;",179
"uniform vec3 u_coatTint;",180
"uniform vec3 u_coatTint;",180
"uniform float u_hasCoat;",181
"uniform float u_hasCoat;",181
"vec3 channelTint(float L, float o1, float o2, vec3 tint) {",182
"vec3 channelTint(float L, float secondary, vec3 tint) {",183
" float blend = L > 0.0 ? clamp(secondary / L, 0.0, 1.0) : 0.0;",184
" return mix(tint, vec3(1.0), blend) * L;",185
"}",186
"float channelMask(float primary, float o1, float o2) {",182
" float equal = step(abs(o1 - o2), 0.04);",187
" float equal = step(abs(o1 - o2), 0.04);",183
" float blend = L > 0.0 ? clamp(mix(min(o1, o2), o1, equal) / L, 0.0, 1.0) : 0.0;",188
" return clamp((primary - max(o1, o2)) * 1.75, 0.0, 1.0) * equal;",184
" float tintLuma = dot(tint, vec3(0.2126, 0.7152, 0.0722));",185
" vec3 toward = mix(vec3(tintLuma), vec3(1.0), equal);",186
" return mix(tint, toward, blend) * L;",187
"}",189
"}",188
"void main() {",190
"void main() {",189
" vec4 color = texture2D(u_texture, v_texCoord);",191
" vec4 color = texture2D(u_texture, v_texCoord);",@@ -192,20 +194,20 @@ const DUAL_TINT_LIT_SPRITE_FRAG = [192
" if (u_wade > 0.5 && fromBottom < 4.0) { discard; }",194
" if (u_wade > 0.5 && fromBottom < 4.0) { discard; }",193
" vec3 rgb = color.rgb;",195
" vec3 rgb = color.rgb;",194
" if (u_hasCoat > 0.5) {",196
" if (u_hasCoat > 0.5) {",195
" float coatMask = clamp((color.g - max(color.r, color.b)) * 1.75, 0.0, 1.0);",197
" float coatMask = channelMask(color.g, color.r, color.b);",196
" if (coatMask > 0.0) {",198
" if (coatMask > 0.0) {",197
" vec3 coatCol = channelTint(color.g, color.r, color.b, u_coatTint);",199
" vec3 coatCol = channelTint(color.g, color.r, u_coatTint);",198
" rgb = mix(rgb, coatCol, coatMask);",200
" rgb = mix(rgb, coatCol, coatMask);",199
" }",201
" }",200
" }",202
" }",201
" float tipMask = clamp((color.b - max(color.r, color.g)) * 1.75, 0.0, 1.0);",203
" float tipMask = channelMask(color.b, color.r, color.g);",202
" if (tipMask > 0.0) {",204
" if (tipMask > 0.0) {",203
" vec3 tipCol = channelTint(color.b, color.r, color.g, u_tipTint);",205
" vec3 tipCol = channelTint(color.b, color.r, u_tipTint);",204
" rgb = mix(rgb, tipCol, tipMask);",206
" rgb = mix(rgb, tipCol, tipMask);",205
" }",207
" }",206
" float shaftMask = clamp((color.r - max(color.g, color.b)) * 1.75, 0.0, 1.0);",208
" float shaftMask = channelMask(color.r, color.g, color.b);",207
" if (shaftMask > 0.0) {",209
" if (shaftMask > 0.0) {",208
" vec3 shaftCol = channelTint(color.r, color.g, color.b, u_shaftTint);",210
" vec3 shaftCol = channelTint(color.r, color.g, u_shaftTint);",209
" rgb = mix(rgb, shaftCol, shaftMask);",211
" rgb = mix(rgb, shaftCol, shaftMask);",210
" }",212
" }",211
" if (u_wade > 0.5 && fromBottom < 5.0) {",213
" if (u_wade > 0.5 && fromBottom < 5.0) {",@@ -2368,6 +2370,15 @@ export class WorldView2368
this.#startIdleAnimation(entity.object);2370
this.#startIdleAnimation(entity.object);2369
}2371
}2370
entity.bodyTint = layers[0]?.tint ? normalizeRgb(layers[0].tint) : null;2372
entity.bodyTint = layers[0]?.tint ? normalizeRgb(layers[0].tint) : null;2373
entity.bodyDualTint = layers[0]?.dualTint2374
? {2375
shaft: normalizeRgb(layers[0].dualTint.shaft),2376
tip: normalizeRgb(layers[0].dualTint.tip),2377
...(layers[0].dualTint.coat2378
? { coat: normalizeRgb(layers[0].dualTint.coat) }2379
: {})2380
}2381
: null;2371
entity.bloomBody = !!layers[0]?.bloomBody;2382
entity.bloomBody = !!layers[0]?.bloomBody;2372
for (const overlay of entity.overlays ?? [])2383
for (const overlay of entity.overlays ?? [])2373
{ overlay.destroy(); }2384
{ overlay.destroy(); }@@ -2379,6 +2390,7 @@ export class WorldView2379
entity.overlayTightFit = [];2390
entity.overlayTightFit = [];2380
entity.bloomOverlays = [];2391
entity.bloomOverlays = [];2381
entity.bloomOverlayTints = [];2392
entity.bloomOverlayTints = [];2393
entity.bloomOverlayDualTints = [];2382
if (entity.bloomBody && this.game.images[base])2394
if (entity.bloomBody && this.game.images[base])2383
{2395
{2384
const bloomName = bloomCompanionName(base);2396
const bloomName = bloomCompanionName(base);@@ -2391,6 +2403,7 @@ export class WorldView2391
this.scene.addObject(bloom);2403
this.scene.addObject(bloom);2392
entity.bloomOverlays.push(bloom);2404
entity.bloomOverlays.push(bloom);2393
entity.bloomOverlayTints.push(entity.bodyTint);2405
entity.bloomOverlayTints.push(entity.bodyTint);2406
entity.bloomOverlayDualTints.push(entity.bodyDualTint);2394
}2407
}2395
}2408
}2396
for (const layer of layers.slice(1))2409
for (const layer of layers.slice(1))@@ -2452,7 +2465,21 @@ export class WorldView2452
const wade = isWadeGroundInSeason(this.#groundTypeAt(entity.tileX, entity.tileY), this.worldSeason);2465
const wade = isWadeGroundInSeason(this.#groundTypeAt(entity.tileX, entity.tileY), this.worldSeason);2453
2466
2454
entity.object.transform.rotation = walkTilt;2467
entity.object.transform.rotation = walkTilt;2455
this.#syncLitSprite(entity.object, tileShade, flashStrength, wade, entity.bodyTint ?? null, flashColor);2468
if (entity.bodyDualTint)2469
{2470
this.#syncDualTintLitSprite(2471
entity.object,2472
tileShade,2473
entity.bodyDualTint,2474
flashStrength,2475
wade,2476
flashColor2477
);2478
}2479
else2480
{2481
this.#syncLitSprite(entity.object, tileShade, flashStrength, wade, entity.bodyTint ?? null, flashColor);2482
}2456
const flight = !!entity.freeFlight;2483
const flight = !!entity.freeFlight;2457
this.#placePivoted(entity.object, pivotX, pivotY, pivotY, SORT_ENTITY, entity.visualScale ?? 1, flight);2484
this.#placePivoted(entity.object, pivotX, pivotY, pivotY, SORT_ENTITY, entity.visualScale ?? 1, flight);2458
for (let index = 0; index < (entity.overlays ?? []).length; index++)2485
for (let index = 0; index < (entity.overlays ?? []).length; index++)@@ -2496,8 +2523,11 @@ export class WorldView2496
overlay.renderer.subImage = entity.object.renderer.subImage | 0;2523
overlay.renderer.subImage = entity.object.renderer.subImage | 0;2497
}2524
}2498
overlay.transform.rotation = walkTilt;2525
overlay.transform.rotation = walkTilt;2526
const bloomDual = entity.bloomOverlayDualTints?.[index] ?? null;2499
const bloomTint = entity.bloomOverlayTints?.[index] ?? entity.bodyTint ?? null;2527
const bloomTint = entity.bloomOverlayTints?.[index] ?? entity.bodyTint ?? null;2500
if (bloomTint)2528
if (bloomDual)2529
{ this.#syncDualTintLitSprite(overlay, 0, bloomDual); }2530
else if (bloomTint)2501
{ this.#syncUnlitTintSprite(overlay, bloomTint); }2531
{ this.#syncUnlitTintSprite(overlay, bloomTint); }2502
else2532
else2503
{ this.#syncLitSprite(overlay, tileShade, flashStrength, wade, null, flashColor); }2533
{ this.#syncLitSprite(overlay, tileShade, flashStrength, wade, null, flashColor); }@@ -2648,13 +2678,16 @@ export class WorldView2648
2678
2649
#syncDualTintLitSprite (object, darkness, dualTint, flashStrength = 0, wade = false, flashColor = null)2679
#syncDualTintLitSprite (object, darkness, dualTint, flashStrength = 0, wade = false, flashColor = null)2650
{2680
{2651
if (!object?.renderer || object._lit === false || !dualTint)2681
if (!object?.renderer || !dualTint)2652
{ return; }2682
{ return; }2653
object._lit = true;2654
const shaft = normalizeRgb(dualTint.shaft);2683
const shaft = normalizeRgb(dualTint.shaft);2655
const tip = normalizeRgb(dualTint.tip);2684
const tip = normalizeRgb(dualTint.tip);2656
const coat = dualTint.coat ? normalizeRgb(dualTint.coat) : null;2685
const coat = dualTint.coat ? normalizeRgb(dualTint.coat) : null;2657
const dark = Math.min(1, Math.max(0, darkness ?? 0));2686
const dark = object._lit === false2687
? 02688
: Math.min(1, Math.max(0, darkness ?? 0));2689
if (object._lit !== false)2690
{ object._lit = true; }2658
const flash = Math.min(1, Math.max(0, flashStrength ?? 0));2691
const flash = Math.min(1, Math.max(0, flashStrength ?? 0));2659
const height = object.renderer.sprite?.height ?? SPRITE_SIZE_PX;2692
const height = object.renderer.sprite?.height ?? SPRITE_SIZE_PX;2660
object.renderer.shader = getDualTintLitSpriteShader();2693
object.renderer.shader = getDualTintLitSpriteShader();@@ -14,7 +14,7 @@ import
14
14
import { spellDefinition, spellMinMagicLevel } from "../../../shared/definitions/spells.js";
15
15
import { resolvePhysicalAttack } from "../../../shared/combat/rolls.js";
16
16
import { mobDamageAffinities } from "../../../shared/combat/magic.js";
17
import { AttackType } from "../../../shared/definitions/attackTypes.js";
17
import { AttackType, MAGIC_ELEMENT_ORDER } from "../../../shared/definitions/attackTypes.js";
18
18
import
19
19
{
20
20
effectiveHitSkillInDarkness,
@@ -324,14 +324,25 @@ function arrowStackInOffhand (equipment)
324
324
return stack;
325
325
}
326
326
327
/** Physical attack type, or tipped-arrow magic element when present. */
327
/** Physical attack type, tipped-arrow element, or per-swing random fairy element. */
328
328
function resolveAttackDamageType (ecs, attackerHandle, profile)
329
329
{
330
if (attackerHandle != null && profile?.mode === "ranged")
330
if (attackerHandle != null)
331
331
{
332
const stack = arrowStackInOffhand(ecs.get(attackerHandle, Component.equipment));
333
if (stack?.instance?.kind === "tipped-arrow" && stack.instance.element)
334
{ return stack.instance.element; }
332
const creature = ecs.get(attackerHandle, Component.creature);
333
const def = creature ? mobDefinition(creature.mobTypeId) : null;
334
if (def?.randomElementMelee)
335
{
336
return MAGIC_ELEMENT_ORDER[
337
Math.floor(Math.random() * MAGIC_ELEMENT_ORDER.length)
338
];
339
}
340
if (profile?.mode === "ranged")
341
{
342
const stack = arrowStackInOffhand(ecs.get(attackerHandle, Component.equipment));
343
if (stack?.instance?.kind === "tipped-arrow" && stack.instance.element)
344
{ return stack.instance.element; }
345
}
335
346
}
336
347
return profile?.attackType ?? AttackType.blunt;
337
348
}
@@ -14,7 +14,7 @@ import14
import { spellDefinition, spellMinMagicLevel } from "../../../shared/definitions/spells.js";14
import { spellDefinition, spellMinMagicLevel } from "../../../shared/definitions/spells.js";15
import { resolvePhysicalAttack } from "../../../shared/combat/rolls.js";15
import { resolvePhysicalAttack } from "../../../shared/combat/rolls.js";16
import { mobDamageAffinities } from "../../../shared/combat/magic.js";16
import { mobDamageAffinities } from "../../../shared/combat/magic.js";17
import { AttackType } from "../../../shared/definitions/attackTypes.js";17
import { AttackType, MAGIC_ELEMENT_ORDER } from "../../../shared/definitions/attackTypes.js";18
import18
import19
{19
{20
effectiveHitSkillInDarkness,20
effectiveHitSkillInDarkness,@@ -324,14 +324,25 @@ function arrowStackInOffhand (equipment)324
return stack;324
return stack;325
}325
}326
326
327
/** Physical attack type, or tipped-arrow magic element when present. */327
/** Physical attack type, tipped-arrow element, or per-swing random fairy element. */328
function resolveAttackDamageType (ecs, attackerHandle, profile)328
function resolveAttackDamageType (ecs, attackerHandle, profile)329
{329
{330
if (attackerHandle != null && profile?.mode === "ranged")330
if (attackerHandle != null)331
{331
{332
const stack = arrowStackInOffhand(ecs.get(attackerHandle, Component.equipment));332
const creature = ecs.get(attackerHandle, Component.creature);333
if (stack?.instance?.kind === "tipped-arrow" && stack.instance.element)333
const def = creature ? mobDefinition(creature.mobTypeId) : null;334
{ return stack.instance.element; }334
if (def?.randomElementMelee)335
{336
return MAGIC_ELEMENT_ORDER[337
Math.floor(Math.random() * MAGIC_ELEMENT_ORDER.length)338
];339
}340
if (profile?.mode === "ranged")341
{342
const stack = arrowStackInOffhand(ecs.get(attackerHandle, Component.equipment));343
if (stack?.instance?.kind === "tipped-arrow" && stack.instance.element)344
{ return stack.instance.element; }345
}335
}346
}336
return profile?.attackType ?? AttackType.blunt;347
return profile?.attackType ?? AttackType.blunt;337
}348
}@@ -24,7 +24,7 @@ import { LeatherItemId } from "../../../shared/definitions/leatherItems.js";
24
24
import { CENTRAL_EXCHANGE_STAFF } from "../../../shared/market/exchange.js";
25
25
import { emptyEquipment } from "../../../shared/items/inventory.js";
26
26
import { itemDefinition } from "../../../shared/definitions/items.js";
27
import { appearanceHairFields, hairFromNameSeed } from "../../../shared/appearance/hair.js";
27
import { appearanceHairFields, hairFromNameSeed, randomNpcHairColor, randomBrightOrPastelColor } from "../../../shared/appearance/hair.js";
28
28
import { npcDefaultEquipment } from "../../../shared/appearance/npcEquipment.js";
29
29
import { Component } from "../ecs/components.js";
30
30
import { tileToChunk, tileToRegion, parseChunkKey } from "../world/coordinates.js";
@@ -241,6 +241,19 @@ export function mobComponents (request)
241
241
{ appearance.sprite = sprite; }
242
242
}
243
243
244
if (def.dualChannelAppearance || def.mobTypeId === MobId.fairy)
245
{
246
appearance.dualTint = {
247
/** Red channel — shirt. */
248
shaft: randomBrightOrPastelColor(),
249
/** Blue channel — skirt. */
250
tip: randomBrightOrPastelColor(),
251
/** Green channel — hair. */
252
coat: randomNpcHairColor()
253
};
254
appearance.bloomBody = !!def.bloomBody;
255
}
256
244
257
let element = request.element ?? null;
245
258
if ((def.randomElementOnSpawn || def.mobTypeId === MobId.sprite) && !element)
246
259
{
@@ -24,7 +24,7 @@ import { LeatherItemId } from "../../../shared/definitions/leatherItems.js";24
import { CENTRAL_EXCHANGE_STAFF } from "../../../shared/market/exchange.js";24
import { CENTRAL_EXCHANGE_STAFF } from "../../../shared/market/exchange.js";25
import { emptyEquipment } from "../../../shared/items/inventory.js";25
import { emptyEquipment } from "../../../shared/items/inventory.js";26
import { itemDefinition } from "../../../shared/definitions/items.js";26
import { itemDefinition } from "../../../shared/definitions/items.js";27
import { appearanceHairFields, hairFromNameSeed } from "../../../shared/appearance/hair.js";27
import { appearanceHairFields, hairFromNameSeed, randomNpcHairColor, randomBrightOrPastelColor } from "../../../shared/appearance/hair.js";28
import { npcDefaultEquipment } from "../../../shared/appearance/npcEquipment.js";28
import { npcDefaultEquipment } from "../../../shared/appearance/npcEquipment.js";29
import { Component } from "../ecs/components.js";29
import { Component } from "../ecs/components.js";30
import { tileToChunk, tileToRegion, parseChunkKey } from "../world/coordinates.js";30
import { tileToChunk, tileToRegion, parseChunkKey } from "../world/coordinates.js";@@ -241,6 +241,19 @@ export function mobComponents (request)241
{ appearance.sprite = sprite; }241
{ appearance.sprite = sprite; }242
}242
}243
243
244
if (def.dualChannelAppearance || def.mobTypeId === MobId.fairy)245
{246
appearance.dualTint = {247
/** Red channel — shirt. */248
shaft: randomBrightOrPastelColor(),249
/** Blue channel — skirt. */250
tip: randomBrightOrPastelColor(),251
/** Green channel — hair. */252
coat: randomNpcHairColor()253
};254
appearance.bloomBody = !!def.bloomBody;255
}256
244
let element = request.element ?? null;257
let element = request.element ?? null;245
if ((def.randomElementOnSpawn || def.mobTypeId === MobId.sprite) && !element)258
if ((def.randomElementOnSpawn || def.mobTypeId === MobId.sprite) && !element)246
{259
{@@ -111,11 +111,16 @@ test("sheep and cashmere goat are shearable with fleece/shorn sprites", () =>
111
111
assert.equal(mobSpriteName(MobId.cashmereGoat, "fleece"), "mob:cashmere-goat:fleece");
112
112
});
113
113
114
test("fairy reuses sprite art and drops fairy silk", () =>
114
test("fairy uses own sprites, dual-channel kit, and random-element melee", () =>
115
115
{
116
116
const fairy = mobDefinition(MobId.fairy);
117
assert.equal(fairy.spriteKey, "sprite");
118
assert.equal(mobSpriteName(MobId.fairy), "mob:sprite:sprite");
117
assert.equal(fairy.spriteKey, undefined);
118
assert.equal(mobSpriteName(MobId.fairy), "mob:fairy:fairy");
119
assert.equal(fairy.bloomBody, true);
120
assert.equal(fairy.dualChannelAppearance, true);
121
assert.equal(fairy.randomElementMelee, true);
122
assert.equal(fairy.lightRadiusTiles, 1);
123
assert.equal(fairy.frames, 2);
119
124
assert.equal(fairy.drops.length, 1);
120
125
assert.equal(fairy.drops[0].itemId, ClothItemId.fairySilk);
121
126
assert.equal(fairy.drops[0].chance, 0.7);
@@ -111,11 +111,16 @@ test("sheep and cashmere goat are shearable with fleece/shorn sprites", () =>111
assert.equal(mobSpriteName(MobId.cashmereGoat, "fleece"), "mob:cashmere-goat:fleece");111
assert.equal(mobSpriteName(MobId.cashmereGoat, "fleece"), "mob:cashmere-goat:fleece");112
});112
});113
113
114
test("fairy reuses sprite art and drops fairy silk", () =>114
test("fairy uses own sprites, dual-channel kit, and random-element melee", () =>115
{115
{116
const fairy = mobDefinition(MobId.fairy);116
const fairy = mobDefinition(MobId.fairy);117
assert.equal(fairy.spriteKey, "sprite");117
assert.equal(fairy.spriteKey, undefined);118
assert.equal(mobSpriteName(MobId.fairy), "mob:sprite:sprite");118
assert.equal(mobSpriteName(MobId.fairy), "mob:fairy:fairy");119
assert.equal(fairy.bloomBody, true);120
assert.equal(fairy.dualChannelAppearance, true);121
assert.equal(fairy.randomElementMelee, true);122
assert.equal(fairy.lightRadiusTiles, 1);123
assert.equal(fairy.frames, 2);119
assert.equal(fairy.drops.length, 1);124
assert.equal(fairy.drops.length, 1);120
assert.equal(fairy.drops[0].itemId, ClothItemId.fairySilk);125
assert.equal(fairy.drops[0].itemId, ClothItemId.fairySilk);121
assert.equal(fairy.drops[0].chance, 0.7);126
assert.equal(fairy.drops[0].chance, 0.7);@@ -86,6 +86,11 @@ test("dual-channel arrow tints shaft red and tip blue, leaves white fletching",
86
86
assert.equal(white.r, 1);
87
87
assert.equal(white.g, 1);
88
88
assert.equal(white.b, 1);
89
const unequal = dualChannelTintedRgb(0.9, 0.4, 0.1, pine, bronze);
90
assert.equal(unequal.r, 0.9);
91
assert.equal(unequal.g, 0.4);
92
assert.equal(unequal.b, 0.1);
93
assert.equal(channelDominanceMask(0.9, 0.4, 0.1, "shaft"), 0);
89
94
const dual = resolveItemDualTint({ itemId: RangedItemId.bronzeArrow });
90
95
assert.ok(dual?.shaft);
91
96
assert.ok(dual?.tip);
@@ -86,6 +86,11 @@ test("dual-channel arrow tints shaft red and tip blue, leaves white fletching",86
assert.equal(white.r, 1);86
assert.equal(white.r, 1);87
assert.equal(white.g, 1);87
assert.equal(white.g, 1);88
assert.equal(white.b, 1);88
assert.equal(white.b, 1);89
const unequal = dualChannelTintedRgb(0.9, 0.4, 0.1, pine, bronze);90
assert.equal(unequal.r, 0.9);91
assert.equal(unequal.g, 0.4);92
assert.equal(unequal.b, 0.1);93
assert.equal(channelDominanceMask(0.9, 0.4, 0.1, "shaft"), 0);89
const dual = resolveItemDualTint({ itemId: RangedItemId.bronzeArrow });94
const dual = resolveItemDualTint({ itemId: RangedItemId.bronzeArrow });90
assert.ok(dual?.shaft);95
assert.ok(dual?.shaft);91
assert.ok(dual?.tip);96
assert.ok(dual?.tip);