Wire jewellery worn effects and combat-level equip gates.
Each piece now has a unique in-world effect (regen, resists, luck, teleports, fairy companion, and more). Wearing jewellery requires combat level; crafting still uses Jewelering.
@@ -40,12 +40,14 @@ import
40
40
clothTierForWood
41
41
} from "/shared/definitions/materialTiers.js";
42
42
import { craftDurationMs } from "/shared/definitions/gathering.js";
43
import { craftDurationMultiplier } from "/shared/equipment/jewelryEffects.js";
43
44
import { applyItemIcon } from "../render/potionIcon.js";
44
45
45
46
export function initCrafting ({
46
47
socket,
47
48
MessageType,
48
49
getInventorySlots,
50
getEquipment,
49
51
getSkillLevel
50
52
})
51
53
{
@@ -675,7 +677,11 @@ export function initCrafting ({
675
677
? `Crafting ${options.batchCount}…`
676
678
: "Crafting…";
677
679
craftStartedAt = performance.now();
678
const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);
680
const equipment = { slots: getEquipment?.() ?? {} };
681
const durationMs = Math.max(
682
1,
683
Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
684
);
679
685
const payload = {
680
686
type: MessageType.startCraft,
681
687
stationId,
@@ -811,7 +817,11 @@ export function initCrafting ({
811
817
progressFill.style.width = "0%";
812
818
statusEl.textContent = "Crafting…";
813
819
craftStartedAt = performance.now();
814
const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);
820
const equipment = { slots: getEquipment?.() ?? {} };
821
const durationMs = Math.max(
822
1,
823
Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
824
);
815
825
if (craftTimer != null)
816
826
{ clearTimeout(craftTimer); }
817
827
if (craftAnimFrame != null)
@@ -40,12 +40,14 @@ import40
clothTierForWood40
clothTierForWood41
} from "/shared/definitions/materialTiers.js";41
} from "/shared/definitions/materialTiers.js";42
import { craftDurationMs } from "/shared/definitions/gathering.js";42
import { craftDurationMs } from "/shared/definitions/gathering.js";43
import { craftDurationMultiplier } from "/shared/equipment/jewelryEffects.js";43
import { applyItemIcon } from "../render/potionIcon.js";44
import { applyItemIcon } from "../render/potionIcon.js";44
45
45
export function initCrafting ({46
export function initCrafting ({46
socket,47
socket,47
MessageType,48
MessageType,48
getInventorySlots,49
getInventorySlots,50
getEquipment,49
getSkillLevel51
getSkillLevel50
})52
})51
{53
{@@ -675,7 +677,11 @@ export function initCrafting ({675
? `Crafting ${options.batchCount}…`677
? `Crafting ${options.batchCount}…`676
: "Crafting…";678
: "Crafting…";677
craftStartedAt = performance.now();679
craftStartedAt = performance.now();678
const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);680
const equipment = { slots: getEquipment?.() ?? {} };681
const durationMs = Math.max(682
1,683
Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))684
);679
const payload = {685
const payload = {680
type: MessageType.startCraft,686
type: MessageType.startCraft,681
stationId,687
stationId,@@ -811,7 +817,11 @@ export function initCrafting ({811
progressFill.style.width = "0%";817
progressFill.style.width = "0%";812
statusEl.textContent = "Crafting…";818
statusEl.textContent = "Crafting…";813
craftStartedAt = performance.now();819
craftStartedAt = performance.now();814
const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);820
const equipment = { slots: getEquipment?.() ?? {} };821
const durationMs = Math.max(822
1,823
Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))824
);815
if (craftTimer != null)825
if (craftTimer != null)816
{ clearTimeout(craftTimer); }826
{ clearTimeout(craftTimer); }817
if (craftAnimFrame != null)827
if (craftAnimFrame != null)@@ -977,6 +977,8 @@ export class WorldView
977
977
if (!existing)
978
978
{ return; }
979
979
existing.lightRadiusTiles = payload.lightRadiusTiles ?? 0;
980
if (payload.lightIntensity != null)
981
{ existing.lightIntensity = Number(payload.lightIntensity) || 1; }
980
982
if (payload.visualScale != null)
981
983
{ existing.visualScale = Number(payload.visualScale) || 1; }
982
984
this.#applyLayers(existing, payload.layers ?? [{ sprite: payload.sprite }]);
@@ -2332,6 +2334,10 @@ export class WorldView
2332
2334
entity.untargetable = payload.untargetable != null ? !!payload.untargetable : !!entity.untargetable;
2333
2335
entity.freeFlight = payload.freeFlight != null ? !!payload.freeFlight : !!entity.freeFlight;
2334
2336
entity.lightRadiusTiles = payload.lightRadiusTiles ?? entity.lightRadiusTiles ?? 0;
2337
if (payload.lightIntensity != null)
2338
{ entity.lightIntensity = Number(payload.lightIntensity) || 1; }
2339
else if (entity.lightIntensity == null)
2340
{ entity.lightIntensity = 1; }
2335
2341
if (payload.visualScale != null)
2336
2342
{ entity.visualScale = Number(payload.visualScale) || 1; }
2337
2343
else if (entity.visualScale == null)
@@ -3996,7 +4002,7 @@ export class WorldView
3996
4002
tileX: Math.floor(entity.visualX / tileSize),
3997
4003
tileY: Math.floor(entity.visualY / tileSize),
3998
4004
range,
3999
intensity: 1
4005
intensity: entity.lightIntensity ?? 1
4000
4006
});
4001
4007
}
4002
4008
@@ -977,6 +977,8 @@ export class WorldView977
if (!existing)977
if (!existing)978
{ return; }978
{ return; }979
existing.lightRadiusTiles = payload.lightRadiusTiles ?? 0;979
existing.lightRadiusTiles = payload.lightRadiusTiles ?? 0;980
if (payload.lightIntensity != null)981
{ existing.lightIntensity = Number(payload.lightIntensity) || 1; }980
if (payload.visualScale != null)982
if (payload.visualScale != null)981
{ existing.visualScale = Number(payload.visualScale) || 1; }983
{ existing.visualScale = Number(payload.visualScale) || 1; }982
this.#applyLayers(existing, payload.layers ?? [{ sprite: payload.sprite }]);984
this.#applyLayers(existing, payload.layers ?? [{ sprite: payload.sprite }]);@@ -2332,6 +2334,10 @@ export class WorldView2332
entity.untargetable = payload.untargetable != null ? !!payload.untargetable : !!entity.untargetable;2334
entity.untargetable = payload.untargetable != null ? !!payload.untargetable : !!entity.untargetable;2333
entity.freeFlight = payload.freeFlight != null ? !!payload.freeFlight : !!entity.freeFlight;2335
entity.freeFlight = payload.freeFlight != null ? !!payload.freeFlight : !!entity.freeFlight;2334
entity.lightRadiusTiles = payload.lightRadiusTiles ?? entity.lightRadiusTiles ?? 0;2336
entity.lightRadiusTiles = payload.lightRadiusTiles ?? entity.lightRadiusTiles ?? 0;2337
if (payload.lightIntensity != null)2338
{ entity.lightIntensity = Number(payload.lightIntensity) || 1; }2339
else if (entity.lightIntensity == null)2340
{ entity.lightIntensity = 1; }2335
if (payload.visualScale != null)2341
if (payload.visualScale != null)2336
{ entity.visualScale = Number(payload.visualScale) || 1; }2342
{ entity.visualScale = Number(payload.visualScale) || 1; }2337
else if (entity.visualScale == null)2343
else if (entity.visualScale == null)@@ -3996,7 +4002,7 @@ export class WorldView3996
tileX: Math.floor(entity.visualX / tileSize),4002
tileX: Math.floor(entity.visualX / tileSize),3997
tileY: Math.floor(entity.visualY / tileSize),4003
tileY: Math.floor(entity.visualY / tileSize),3998
range,4004
range,3999
intensity: 14005
intensity: entity.lightIntensity ?? 14000
});4006
});4001
}4007
}4002
4008
@@ -444,7 +444,12 @@ function bottle (world, sessionId, command)
444
444
const amount = craftXpForConsumedInputs(xpInputs, SkillId.alchemy);
445
445
if (amount > 0)
446
446
{
447
const result = applySkillXp(skills, SkillId.alchemy, amount);
447
const result = applySkillXp(
448
skills,
449
SkillId.alchemy,
450
amount,
451
world.ecs.get(handle, Component.equipment)
452
);
448
453
if (result.changed)
449
454
{
450
455
events.push({
@@ -566,7 +571,8 @@ function createDye (world, sessionId, command)
566
571
const result = applySkillXp(
567
572
skills,
568
573
SkillId.alchemy,
569
flowerCount * craftXpMultiplierForSkill(SkillId.alchemy)
574
flowerCount * craftXpMultiplierForSkill(SkillId.alchemy),
575
world.ecs.get(handle, Component.equipment)
570
576
);
571
577
if (result.changed)
572
578
{
@@ -444,7 +444,12 @@ function bottle (world, sessionId, command)444
const amount = craftXpForConsumedInputs(xpInputs, SkillId.alchemy);444
const amount = craftXpForConsumedInputs(xpInputs, SkillId.alchemy);445
if (amount > 0)445
if (amount > 0)446
{446
{447
const result = applySkillXp(skills, SkillId.alchemy, amount);447
const result = applySkillXp(448
skills,449
SkillId.alchemy,450
amount,451
world.ecs.get(handle, Component.equipment)452
);448
if (result.changed)453
if (result.changed)449
{454
{450
events.push({455
events.push({@@ -566,7 +571,8 @@ function createDye (world, sessionId, command)566
const result = applySkillXp(571
const result = applySkillXp(567
skills,572
skills,568
SkillId.alchemy,573
SkillId.alchemy,569
flowerCount * craftXpMultiplierForSkill(SkillId.alchemy)574
flowerCount * craftXpMultiplierForSkill(SkillId.alchemy),575
world.ecs.get(handle, Component.equipment)570
);576
);571
if (result.changed)577
if (result.changed)572
{578
{@@ -24,6 +24,7 @@ import
24
24
CraftOriginVerb
25
25
} from "../../../shared/items/origin.js";
26
26
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
27
import { craftDurationMultiplier } from "../../../shared/equipment/jewelryEffects.js";
27
28
import { bagView } from "../items/bags.js";
28
29
import { tileToChunk, tileToLocal } from "../world/coordinates.js";
29
30
import { CHUNK_SIZE } from "../../../shared/protocol/constants.js";
@@ -220,7 +221,11 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,
220
221
}
221
222
222
223
const sessions = ensureCraftSessions(world);
223
const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);
224
const equipment = world.ecs.get(handle, Component.equipment);
225
const durationMs = Math.max(
226
1,
227
Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
228
);
224
229
let batchRemaining = 1;
225
230
if (stationId === CraftingStationId.craftingBench)
226
231
{
@@ -435,7 +440,8 @@ export function stepCrafting (world, now)
435
440
const result = applySkillXp(
436
441
skills,
437
442
stationDef.skillId,
438
craftXpForConsumedInputs(recipe.inputs, stationDef.skillId)
443
craftXpForConsumedInputs(recipe.inputs, stationDef.skillId),
444
world.ecs.get(handle, Component.equipment)
439
445
);
440
446
if (result.changed)
441
447
{ skillsChanged = true; }
@@ -477,7 +483,11 @@ export function stepCrafting (world, now)
477
483
{ dyeColorKey: session.dyeColorKey, dyeSlotIndex: null }
478
484
))
479
485
{
480
const durationMs = session.durationMs ?? craftDurationMs(recipe, CRAFT_DURATION_MS);
486
const equipment = world.ecs.get(handle, Component.equipment);
487
const durationMs = session.durationMs ?? Math.max(
488
1,
489
Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))
490
);
481
491
sessions.set(characterId, {
482
492
...session,
483
493
recipe,
@@ -24,6 +24,7 @@ import24
CraftOriginVerb24
CraftOriginVerb25
} from "../../../shared/items/origin.js";25
} from "../../../shared/items/origin.js";26
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";26
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";27
import { craftDurationMultiplier } from "../../../shared/equipment/jewelryEffects.js";27
import { bagView } from "../items/bags.js";28
import { bagView } from "../items/bags.js";28
import { tileToChunk, tileToLocal } from "../world/coordinates.js";29
import { tileToChunk, tileToLocal } from "../world/coordinates.js";29
import { CHUNK_SIZE } from "../../../shared/protocol/constants.js";30
import { CHUNK_SIZE } from "../../../shared/protocol/constants.js";@@ -220,7 +221,11 @@ export function startCraft (world, sessionId, characterId, stationId, recipeId,220
}221
}221
222
222
const sessions = ensureCraftSessions(world);223
const sessions = ensureCraftSessions(world);223
const durationMs = craftDurationMs(recipe, CRAFT_DURATION_MS);224
const equipment = world.ecs.get(handle, Component.equipment);225
const durationMs = Math.max(226
1,227
Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))228
);224
let batchRemaining = 1;229
let batchRemaining = 1;225
if (stationId === CraftingStationId.craftingBench)230
if (stationId === CraftingStationId.craftingBench)226
{231
{@@ -435,7 +440,8 @@ export function stepCrafting (world, now)435
const result = applySkillXp(440
const result = applySkillXp(436
skills,441
skills,437
stationDef.skillId,442
stationDef.skillId,438
craftXpForConsumedInputs(recipe.inputs, stationDef.skillId)443
craftXpForConsumedInputs(recipe.inputs, stationDef.skillId),444
world.ecs.get(handle, Component.equipment)439
);445
);440
if (result.changed)446
if (result.changed)441
{ skillsChanged = true; }447
{ skillsChanged = true; }@@ -477,7 +483,11 @@ export function stepCrafting (world, now)477
{ dyeColorKey: session.dyeColorKey, dyeSlotIndex: null }483
{ dyeColorKey: session.dyeColorKey, dyeSlotIndex: null }478
))484
))479
{485
{480
const durationMs = session.durationMs ?? craftDurationMs(recipe, CRAFT_DURATION_MS);486
const equipment = world.ecs.get(handle, Component.equipment);487
const durationMs = session.durationMs ?? Math.max(488
1,489
Math.floor(craftDurationMs(recipe, CRAFT_DURATION_MS) * craftDurationMultiplier(equipment))490
);481
sessions.set(characterId, {491
sessions.set(characterId, {482
...session,492
...session,483
recipe,493
recipe,@@ -1,6 +1,6 @@
1
1
import { Component } from "./components.js";
2
2
import { OVERWORLD_ID, normalizeDimensionId } from "../../../shared/world/dimensions.js";
3
import { equippedLightRadiusTiles } from "../../../shared/definitions/items.js";
3
import { equippedLightRadiusTiles, equippedLightIntensity } from "../../../shared/definitions/items.js";
4
4
import {
5
5
statusExtraLightRadius,
6
6
statusVisualScale,
@@ -80,6 +80,7 @@ export function publicEntityView (ecs, entityId)
80
80
const mob = creature ? mobDefinition(creature.mobTypeId) : null;
81
81
const isMob = !!creature && !character;
82
82
const gearLight = equippedLightRadiusTiles(equipment);
83
const gearIntensity = equippedLightIntensity(equipment);
83
84
const effectLight = statusExtraLightRadius(statusEffects, now);
84
85
const creatureLight = creature?.lightRadiusTiles
85
86
?? (mob?.lightRadiusTiles ?? 0);
@@ -112,6 +113,9 @@ export function publicEntityView (ecs, entityId)
112
113
sprite: layers[0]?.sprite ?? null,
113
114
layers,
114
115
lightRadiusTiles: Math.max(gearLight, effectLight, creatureLight),
116
lightIntensity: Math.max(gearLight, effectLight, creatureLight) > 0
117
? (gearLight >= effectLight && gearLight >= creatureLight ? gearIntensity : 1)
118
: 1,
115
119
visualScale: statusVisualScale(statusEffects, now),
116
120
statusEffects: publicStatusEffectsView(statusEffects, now)
117
121
};
@@ -154,6 +158,7 @@ export function replicationSpawn (view)
154
158
health: view.health,
155
159
maxHealth: view.maxHealth,
156
160
lightRadiusTiles: view.lightRadiusTiles ?? 0,
161
lightIntensity: view.lightIntensity ?? 1,
157
162
visualScale: view.visualScale ?? 1,
158
163
skullValue: view.skullValue | 0
159
164
};
@@ -189,6 +194,7 @@ export function replicationAppearance (view)
189
194
sprite: view.sprite ?? null,
190
195
layers: view.layers ?? [],
191
196
lightRadiusTiles: view.lightRadiusTiles ?? 0,
197
lightIntensity: view.lightIntensity ?? 1,
192
198
visualScale: view.visualScale ?? 1
193
199
};
194
200
}
@@ -1,6 +1,6 @@1
import { Component } from "./components.js";1
import { Component } from "./components.js";2
import { OVERWORLD_ID, normalizeDimensionId } from "../../../shared/world/dimensions.js";2
import { OVERWORLD_ID, normalizeDimensionId } from "../../../shared/world/dimensions.js";3
import { equippedLightRadiusTiles } from "../../../shared/definitions/items.js";3
import { equippedLightRadiusTiles, equippedLightIntensity } from "../../../shared/definitions/items.js";4
import {4
import {5
statusExtraLightRadius,5
statusExtraLightRadius,6
statusVisualScale,6
statusVisualScale,@@ -80,6 +80,7 @@ export function publicEntityView (ecs, entityId)80
const mob = creature ? mobDefinition(creature.mobTypeId) : null;80
const mob = creature ? mobDefinition(creature.mobTypeId) : null;81
const isMob = !!creature && !character;81
const isMob = !!creature && !character;82
const gearLight = equippedLightRadiusTiles(equipment);82
const gearLight = equippedLightRadiusTiles(equipment);83
const gearIntensity = equippedLightIntensity(equipment);83
const effectLight = statusExtraLightRadius(statusEffects, now);84
const effectLight = statusExtraLightRadius(statusEffects, now);84
const creatureLight = creature?.lightRadiusTiles85
const creatureLight = creature?.lightRadiusTiles85
?? (mob?.lightRadiusTiles ?? 0);86
?? (mob?.lightRadiusTiles ?? 0);@@ -112,6 +113,9 @@ export function publicEntityView (ecs, entityId)112
sprite: layers[0]?.sprite ?? null,113
sprite: layers[0]?.sprite ?? null,113
layers,114
layers,114
lightRadiusTiles: Math.max(gearLight, effectLight, creatureLight),115
lightRadiusTiles: Math.max(gearLight, effectLight, creatureLight),116
lightIntensity: Math.max(gearLight, effectLight, creatureLight) > 0117
? (gearLight >= effectLight && gearLight >= creatureLight ? gearIntensity : 1)118
: 1,115
visualScale: statusVisualScale(statusEffects, now),119
visualScale: statusVisualScale(statusEffects, now),116
statusEffects: publicStatusEffectsView(statusEffects, now)120
statusEffects: publicStatusEffectsView(statusEffects, now)117
};121
};@@ -154,6 +158,7 @@ export function replicationSpawn (view)154
health: view.health,158
health: view.health,155
maxHealth: view.maxHealth,159
maxHealth: view.maxHealth,156
lightRadiusTiles: view.lightRadiusTiles ?? 0,160
lightRadiusTiles: view.lightRadiusTiles ?? 0,161
lightIntensity: view.lightIntensity ?? 1,157
visualScale: view.visualScale ?? 1,162
visualScale: view.visualScale ?? 1,158
skullValue: view.skullValue | 0163
skullValue: view.skullValue | 0159
};164
};@@ -189,6 +194,7 @@ export function replicationAppearance (view)189
sprite: view.sprite ?? null,194
sprite: view.sprite ?? null,190
layers: view.layers ?? [],195
layers: view.layers ?? [],191
lightRadiusTiles: view.lightRadiusTiles ?? 0,196
lightRadiusTiles: view.lightRadiusTiles ?? 0,197
lightIntensity: view.lightIntensity ?? 1,192
visualScale: view.visualScale ?? 1198
visualScale: view.visualScale ?? 1193
};199
};194
}200
}@@ -360,7 +360,12 @@ function succeedLight (world, handle, entityId, characterId, session, events, pr
360
360
const levelUps = [];
361
361
if (skills?.xp)
362
362
{
363
const result = applySkillXp(skills, SkillId.firestarting, session.difficulty);
363
const result = applySkillXp(
364
skills,
365
SkillId.firestarting,
366
session.difficulty,
367
world.ecs.get(handle, Component.equipment)
368
);
364
369
if (result.changed)
365
370
{ skillsChanged = true; }
366
371
if (result.levelUp)
@@ -360,7 +360,12 @@ function succeedLight (world, handle, entityId, characterId, session, events, pr360
const levelUps = [];360
const levelUps = [];361
if (skills?.xp)361
if (skills?.xp)362
{362
{363
const result = applySkillXp(skills, SkillId.firestarting, session.difficulty);363
const result = applySkillXp(364
skills,365
SkillId.firestarting,366
session.difficulty,367
world.ecs.get(handle, Component.equipment)368
);364
if (result.changed)369
if (result.changed)365
{ skillsChanged = true; }370
{ skillsChanged = true; }366
if (result.levelUp)371
if (result.levelUp)@@ -27,6 +27,11 @@ import { yarnItemId } from "../../../shared/definitions/clothItems.js";
27
27
import { itemDefinition } from "../../../shared/definitions/items.js";
28
28
import { SkillId, skillLevel } from "../../../shared/definitions/skills.js";
29
29
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
30
import
31
{
32
gatherDurationMultiplier,
33
harvestYieldMultiplier
34
} from "../../../shared/equipment/jewelryEffects.js";
30
35
import { rollSkill } from "../../../shared/combat/rolls.js";
31
36
import {
32
37
insertStack,
@@ -277,7 +282,10 @@ export function startFish (world, sessionId, characterId, tileX, tileY, now = Da
277
282
attemptsLeft: MAX_FISH_ATTEMPTS,
278
283
attemptStartedAt: now,
279
284
nextShoveAt: now,
280
attemptEndsAt: now + FISH_ATTEMPT_MS
285
attemptEndsAt: now + Math.max(
286
1,
287
Math.floor(FISH_ATTEMPT_MS * gatherDurationMultiplier(equipment))
288
)
281
289
});
282
290
283
291
return {
@@ -326,10 +334,11 @@ function completeCatch (world, handle, entityId, characterId, session, events, p
326
334
const inventory = world.ecs.get(handle, Component.inventory);
327
335
const def = itemDefinition(pick);
328
336
const origin = gatherOrigin(GatherOriginVerb.caught, characterDisplayName(world, handle));
337
const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
329
338
const stack = attachOrigins({
330
339
itemId: pick,
331
quantity: 1,
332
origins: [{ origin, quantity: 1 }]
340
quantity,
341
origins: [{ origin, quantity }]
333
342
});
334
343
const inserted = insertStack(inventory.slots, stack, def);
335
344
if (!inserted.ok || inserted.remainder > 0)
@@ -350,7 +359,12 @@ function completeCatch (world, handle, entityId, characterId, session, events, p
350
359
const levelUps = [];
351
360
if (skills?.xp && xpAmount > 0)
352
361
{
353
const result = applySkillXp(skills, SkillId.fishing, xpAmount);
362
const result = applySkillXp(
363
skills,
364
SkillId.fishing,
365
xpAmount,
366
world.ecs.get(handle, Component.equipment)
367
);
354
368
if (result.changed)
355
369
{ skillsChanged = true; }
356
370
if (result.levelUp)
@@ -466,7 +480,10 @@ export function stepFishing (world, now)
466
480
467
481
session.attemptStartedAt = now;
468
482
session.nextShoveAt = now;
469
session.attemptEndsAt = now + FISH_ATTEMPT_MS;
483
session.attemptEndsAt = now + Math.max(
484
1,
485
Math.floor(FISH_ATTEMPT_MS * gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
486
);
470
487
}
471
488
472
489
return { events, privates };
@@ -27,6 +27,11 @@ import { yarnItemId } from "../../../shared/definitions/clothItems.js";27
import { itemDefinition } from "../../../shared/definitions/items.js";27
import { itemDefinition } from "../../../shared/definitions/items.js";28
import { SkillId, skillLevel } from "../../../shared/definitions/skills.js";28
import { SkillId, skillLevel } from "../../../shared/definitions/skills.js";29
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";29
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";30
import31
{32
gatherDurationMultiplier,33
harvestYieldMultiplier34
} from "../../../shared/equipment/jewelryEffects.js";30
import { rollSkill } from "../../../shared/combat/rolls.js";35
import { rollSkill } from "../../../shared/combat/rolls.js";31
import {36
import {32
insertStack,37
insertStack,@@ -277,7 +282,10 @@ export function startFish (world, sessionId, characterId, tileX, tileY, now = Da277
attemptsLeft: MAX_FISH_ATTEMPTS,282
attemptsLeft: MAX_FISH_ATTEMPTS,278
attemptStartedAt: now,283
attemptStartedAt: now,279
nextShoveAt: now,284
nextShoveAt: now,280
attemptEndsAt: now + FISH_ATTEMPT_MS285
attemptEndsAt: now + Math.max(286
1,287
Math.floor(FISH_ATTEMPT_MS * gatherDurationMultiplier(equipment))288
)281
});289
});282
290
283
return {291
return {@@ -326,10 +334,11 @@ function completeCatch (world, handle, entityId, characterId, session, events, p326
const inventory = world.ecs.get(handle, Component.inventory);334
const inventory = world.ecs.get(handle, Component.inventory);327
const def = itemDefinition(pick);335
const def = itemDefinition(pick);328
const origin = gatherOrigin(GatherOriginVerb.caught, characterDisplayName(world, handle));336
const origin = gatherOrigin(GatherOriginVerb.caught, characterDisplayName(world, handle));337
const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));329
const stack = attachOrigins({338
const stack = attachOrigins({330
itemId: pick,339
itemId: pick,331
quantity: 1,340
quantity,332
origins: [{ origin, quantity: 1 }]341
origins: [{ origin, quantity }]333
});342
});334
const inserted = insertStack(inventory.slots, stack, def);343
const inserted = insertStack(inventory.slots, stack, def);335
if (!inserted.ok || inserted.remainder > 0)344
if (!inserted.ok || inserted.remainder > 0)@@ -350,7 +359,12 @@ function completeCatch (world, handle, entityId, characterId, session, events, p350
const levelUps = [];359
const levelUps = [];351
if (skills?.xp && xpAmount > 0)360
if (skills?.xp && xpAmount > 0)352
{361
{353
const result = applySkillXp(skills, SkillId.fishing, xpAmount);362
const result = applySkillXp(363
skills,364
SkillId.fishing,365
xpAmount,366
world.ecs.get(handle, Component.equipment)367
);354
if (result.changed)368
if (result.changed)355
{ skillsChanged = true; }369
{ skillsChanged = true; }356
if (result.levelUp)370
if (result.levelUp)@@ -466,7 +480,10 @@ export function stepFishing (world, now)466
480
467
session.attemptStartedAt = now;481
session.attemptStartedAt = now;468
session.nextShoveAt = now;482
session.nextShoveAt = now;469
session.attemptEndsAt = now + FISH_ATTEMPT_MS;483
session.attemptEndsAt = now + Math.max(484
1,485
Math.floor(FISH_ATTEMPT_MS * gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))486
);470
}487
}471
488
472
return { events, privates };489
return { events, privates };@@ -35,6 +35,11 @@ import { herbDefinition, isHerbId } from "../../../shared/definitions/herbs.js";
35
35
import { insertStack } from "../../../shared/items/inventory.js";
36
36
import { attachOrigins, GatherOriginVerb, gatherOrigin } from "../../../shared/items/origin.js";
37
37
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
38
import
39
{
40
gatherDurationMultiplier,
41
harvestYieldMultiplier
42
} from "../../../shared/equipment/jewelryEffects.js";
38
43
import {
39
44
seasonIdAt,
40
45
treeStumpStateForSeason,
@@ -381,7 +386,11 @@ export function startMine (world, sessionId, characterId, tileX, tileY, now)
381
386
if (!pickaxe.ok)
382
387
{ throw userError(pickaxe.reason); }
383
388
384
const durationMs = miningDurationMs(materialId, pickaxe.tool.tier);
389
const durationMs = Math.max(
390
1,
391
Math.floor(miningDurationMs(materialId, pickaxe.tool.tier)
392
* gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
393
);
385
394
const toolItemId = pickaxe.tool.stack?.itemId ?? null;
386
395
return beginGatherSwing(world, handle, entityId, position, {
387
396
kind: "mining",
@@ -425,7 +434,11 @@ export function startChop (world, sessionId, characterId, tileX, tileY, now)
425
434
if (!axe.ok)
426
435
{ throw userError(axe.reason); }
427
436
428
const durationMs = woodcuttingDurationMs(woodTier, axe.tool.tier);
437
const durationMs = Math.max(
438
1,
439
Math.floor(woodcuttingDurationMs(woodTier, axe.tool.tier)
440
* gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
441
);
429
442
const toolItemId = axe.tool.stack?.itemId ?? null;
430
443
return beginGatherSwing(world, handle, entityId, position, {
431
444
kind: "woodcutting",
@@ -488,7 +501,11 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)
488
501
}
489
502
490
503
const toolTier = clippers.tool?.tier ?? null;
491
const durationMs = herbalismDurationMs(plant.kind, toolTier, herbTier);
504
const durationMs = Math.max(
505
1,
506
Math.floor(herbalismDurationMs(plant.kind, toolTier, herbTier)
507
* gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))
508
);
492
509
const toolItemId = clippers.tool?.stack?.itemId ?? null;
493
510
const prefixEvents = [];
494
511
let flowerColorId = null;
@@ -559,10 +576,11 @@ function completeMining (world, handle, entityId, character, gather, events, pri
559
576
return;
560
577
}
561
578
const origin = gatherOrigin(GatherOriginVerb.mined, characterDisplayName(world, handle));
579
const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
562
580
const stack = attachOrigins({
563
581
itemId: oreItemId,
564
quantity: 1,
565
origins: [{ origin, quantity: 1 }]
582
quantity,
583
origins: [{ origin, quantity }]
566
584
});
567
585
const inserted = insertStack(inventory.slots, stack, def);
568
586
if (!inserted.ok || inserted.remainder > 0)
@@ -582,7 +600,12 @@ function completeMining (world, handle, entityId, character, gather, events, pri
582
600
const levelUps = [];
583
601
if (skills?.xp)
584
602
{
585
const result = applySkillXp(skills, SkillId.mining, miningXpForMaterial(gather.materialId));
603
const result = applySkillXp(
604
skills,
605
SkillId.mining,
606
miningXpForMaterial(gather.materialId),
607
world.ecs.get(handle, Component.equipment)
608
);
586
609
if (result.changed)
587
610
{ skillsChanged = true; }
588
611
if (result.levelUp)
@@ -628,10 +651,11 @@ function completeWoodcutting (world, handle, entityId, character, gather, events
628
651
return;
629
652
}
630
653
const origin = gatherOrigin(GatherOriginVerb.felled, characterDisplayName(world, handle));
654
const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
631
655
const stack = attachOrigins({
632
656
itemId: logItemId,
633
quantity: 1,
634
origins: [{ origin, quantity: 1 }]
657
quantity,
658
origins: [{ origin, quantity }]
635
659
});
636
660
const inserted = insertStack(inventory.slots, stack, def);
637
661
if (!inserted.ok || inserted.remainder > 0)
@@ -651,7 +675,12 @@ function completeWoodcutting (world, handle, entityId, character, gather, events
651
675
const levelUps = [];
652
676
if (skills?.xp)
653
677
{
654
const result = applySkillXp(skills, SkillId.woodcutting, woodcuttingXpForWood(gather.woodTier));
678
const result = applySkillXp(
679
skills,
680
SkillId.woodcutting,
681
woodcuttingXpForWood(gather.woodTier),
682
world.ecs.get(handle, Component.equipment)
683
);
655
684
if (result.changed)
656
685
{ skillsChanged = true; }
657
686
if (result.levelUp)
@@ -740,11 +769,12 @@ function completePlant (world, handle, entityId, character, gather, events, priv
740
769
}
741
770
742
771
const origin = gatherOrigin(GatherOriginVerb.picked, characterDisplayName(world, handle));
772
const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));
743
773
const stack = attachOrigins({
744
774
itemId,
745
quantity: 1,
775
quantity,
746
776
instance,
747
origins: [{ origin, quantity: 1 }]
777
origins: [{ origin, quantity }]
748
778
});
749
779
const inserted = insertStack(inventory.slots, stack, def);
750
780
if (!inserted.ok || inserted.remainder > 0)
@@ -764,7 +794,12 @@ function completePlant (world, handle, entityId, character, gather, events, priv
764
794
const levelUps = [];
765
795
if (skills?.xp)
766
796
{
767
const result = applySkillXp(skills, SkillId.herbalism, herbalismXpForPick(gather.plantKind, gather.herbTier));
797
const result = applySkillXp(
798
skills,
799
SkillId.herbalism,
800
herbalismXpForPick(gather.plantKind, gather.herbTier),
801
world.ecs.get(handle, Component.equipment)
802
);
768
803
if (result.changed)
769
804
{ skillsChanged = true; }
770
805
if (result.levelUp)
@@ -35,6 +35,11 @@ import { herbDefinition, isHerbId } from "../../../shared/definitions/herbs.js";35
import { insertStack } from "../../../shared/items/inventory.js";35
import { insertStack } from "../../../shared/items/inventory.js";36
import { attachOrigins, GatherOriginVerb, gatherOrigin } from "../../../shared/items/origin.js";36
import { attachOrigins, GatherOriginVerb, gatherOrigin } from "../../../shared/items/origin.js";37
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";37
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";38
import39
{40
gatherDurationMultiplier,41
harvestYieldMultiplier42
} from "../../../shared/equipment/jewelryEffects.js";38
import {43
import {39
seasonIdAt,44
seasonIdAt,40
treeStumpStateForSeason,45
treeStumpStateForSeason,@@ -381,7 +386,11 @@ export function startMine (world, sessionId, characterId, tileX, tileY, now)381
if (!pickaxe.ok)386
if (!pickaxe.ok)382
{ throw userError(pickaxe.reason); }387
{ throw userError(pickaxe.reason); }383
388
384
const durationMs = miningDurationMs(materialId, pickaxe.tool.tier);389
const durationMs = Math.max(390
1,391
Math.floor(miningDurationMs(materialId, pickaxe.tool.tier)392
* gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))393
);385
const toolItemId = pickaxe.tool.stack?.itemId ?? null;394
const toolItemId = pickaxe.tool.stack?.itemId ?? null;386
return beginGatherSwing(world, handle, entityId, position, {395
return beginGatherSwing(world, handle, entityId, position, {387
kind: "mining",396
kind: "mining",@@ -425,7 +434,11 @@ export function startChop (world, sessionId, characterId, tileX, tileY, now)425
if (!axe.ok)434
if (!axe.ok)426
{ throw userError(axe.reason); }435
{ throw userError(axe.reason); }427
436
428
const durationMs = woodcuttingDurationMs(woodTier, axe.tool.tier);437
const durationMs = Math.max(438
1,439
Math.floor(woodcuttingDurationMs(woodTier, axe.tool.tier)440
* gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))441
);429
const toolItemId = axe.tool.stack?.itemId ?? null;442
const toolItemId = axe.tool.stack?.itemId ?? null;430
return beginGatherSwing(world, handle, entityId, position, {443
return beginGatherSwing(world, handle, entityId, position, {431
kind: "woodcutting",444
kind: "woodcutting",@@ -488,7 +501,11 @@ export function startPick (world, sessionId, characterId, tileX, tileY, now)488
}501
}489
502
490
const toolTier = clippers.tool?.tier ?? null;503
const toolTier = clippers.tool?.tier ?? null;491
const durationMs = herbalismDurationMs(plant.kind, toolTier, herbTier);504
const durationMs = Math.max(505
1,506
Math.floor(herbalismDurationMs(plant.kind, toolTier, herbTier)507
* gatherDurationMultiplier(world.ecs.get(handle, Component.equipment)))508
);492
const toolItemId = clippers.tool?.stack?.itemId ?? null;509
const toolItemId = clippers.tool?.stack?.itemId ?? null;493
const prefixEvents = [];510
const prefixEvents = [];494
let flowerColorId = null;511
let flowerColorId = null;@@ -559,10 +576,11 @@ function completeMining (world, handle, entityId, character, gather, events, pri559
return;576
return;560
}577
}561
const origin = gatherOrigin(GatherOriginVerb.mined, characterDisplayName(world, handle));578
const origin = gatherOrigin(GatherOriginVerb.mined, characterDisplayName(world, handle));579
const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));562
const stack = attachOrigins({580
const stack = attachOrigins({563
itemId: oreItemId,581
itemId: oreItemId,564
quantity: 1,582
quantity,565
origins: [{ origin, quantity: 1 }]583
origins: [{ origin, quantity }]566
});584
});567
const inserted = insertStack(inventory.slots, stack, def);585
const inserted = insertStack(inventory.slots, stack, def);568
if (!inserted.ok || inserted.remainder > 0)586
if (!inserted.ok || inserted.remainder > 0)@@ -582,7 +600,12 @@ function completeMining (world, handle, entityId, character, gather, events, pri582
const levelUps = [];600
const levelUps = [];583
if (skills?.xp)601
if (skills?.xp)584
{602
{585
const result = applySkillXp(skills, SkillId.mining, miningXpForMaterial(gather.materialId));603
const result = applySkillXp(604
skills,605
SkillId.mining,606
miningXpForMaterial(gather.materialId),607
world.ecs.get(handle, Component.equipment)608
);586
if (result.changed)609
if (result.changed)587
{ skillsChanged = true; }610
{ skillsChanged = true; }588
if (result.levelUp)611
if (result.levelUp)@@ -628,10 +651,11 @@ function completeWoodcutting (world, handle, entityId, character, gather, events628
return;651
return;629
}652
}630
const origin = gatherOrigin(GatherOriginVerb.felled, characterDisplayName(world, handle));653
const origin = gatherOrigin(GatherOriginVerb.felled, characterDisplayName(world, handle));654
const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));631
const stack = attachOrigins({655
const stack = attachOrigins({632
itemId: logItemId,656
itemId: logItemId,633
quantity: 1,657
quantity,634
origins: [{ origin, quantity: 1 }]658
origins: [{ origin, quantity }]635
});659
});636
const inserted = insertStack(inventory.slots, stack, def);660
const inserted = insertStack(inventory.slots, stack, def);637
if (!inserted.ok || inserted.remainder > 0)661
if (!inserted.ok || inserted.remainder > 0)@@ -651,7 +675,12 @@ function completeWoodcutting (world, handle, entityId, character, gather, events651
const levelUps = [];675
const levelUps = [];652
if (skills?.xp)676
if (skills?.xp)653
{677
{654
const result = applySkillXp(skills, SkillId.woodcutting, woodcuttingXpForWood(gather.woodTier));678
const result = applySkillXp(679
skills,680
SkillId.woodcutting,681
woodcuttingXpForWood(gather.woodTier),682
world.ecs.get(handle, Component.equipment)683
);655
if (result.changed)684
if (result.changed)656
{ skillsChanged = true; }685
{ skillsChanged = true; }657
if (result.levelUp)686
if (result.levelUp)@@ -740,11 +769,12 @@ function completePlant (world, handle, entityId, character, gather, events, priv740
}769
}741
770
742
const origin = gatherOrigin(GatherOriginVerb.picked, characterDisplayName(world, handle));771
const origin = gatherOrigin(GatherOriginVerb.picked, characterDisplayName(world, handle));772
const quantity = Math.max(1, Math.floor(1 * harvestYieldMultiplier(world.ecs.get(handle, Component.equipment))));743
const stack = attachOrigins({773
const stack = attachOrigins({744
itemId,774
itemId,745
quantity: 1,775
quantity,746
instance,776
instance,747
origins: [{ origin, quantity: 1 }]777
origins: [{ origin, quantity }]748
});778
});749
const inserted = insertStack(inventory.slots, stack, def);779
const inserted = insertStack(inventory.slots, stack, def);750
if (!inserted.ok || inserted.remainder > 0)780
if (!inserted.ok || inserted.remainder > 0)@@ -764,7 +794,12 @@ function completePlant (world, handle, entityId, character, gather, events, priv764
const levelUps = [];794
const levelUps = [];765
if (skills?.xp)795
if (skills?.xp)766
{796
{767
const result = applySkillXp(skills, SkillId.herbalism, herbalismXpForPick(gather.plantKind, gather.herbTier));797
const result = applySkillXp(798
skills,799
SkillId.herbalism,800
herbalismXpForPick(gather.plantKind, gather.herbTier),801
world.ecs.get(handle, Component.equipment)802
);768
if (result.changed)803
if (result.changed)769
{ skillsChanged = true; }804
{ skillsChanged = true; }770
if (result.levelUp)805
if (result.levelUp)@@ -400,7 +400,8 @@ function equipItem (world, sessionId, command)
400
400
}
401
401
inventory.slots = slots;
402
402
equipment.slots[slot] = taken.taken;
403
return { events: [], private: bagView(world.ecs, handle), appearanceChanged: false };
403
syncPlayerHealth(world.ecs, handle);
404
return { events: [], private: bagView(world.ecs, handle), appearanceChanged: false, healthChanged: true };
404
405
}
405
406
406
407
const toEquip = singleItemFromStack(taken.taken);
@@ -419,7 +420,8 @@ function equipItem (world, sessionId, command)
419
420
else
420
421
{ inventory.slots = taken.slots; }
421
422
equipment.slots[slot] = toEquip;
422
return { events: [], private: bagView(world.ecs, handle), appearanceChanged: true };
423
syncPlayerHealth(world.ecs, handle);
424
return { events: [], private: bagView(world.ecs, handle), appearanceChanged: true, healthChanged: true };
423
425
}
424
426
425
427
function unequipItem (world, sessionId, command)
@@ -439,8 +441,9 @@ function unequipItem (world, sessionId, command)
439
441
{ throw userError("Your inventory cannot hold that."); }
440
442
inventory.slots = inserted.slots;
441
443
equipment.slots[command.equipSlot] = null;
444
syncPlayerHealth(world.ecs, handle);
442
445
const appearanceChanged = def?.equipment?.kind !== EquipmentKind.arrowAmmo;
443
return { events: [], private: bagView(world.ecs, handle), appearanceChanged };
446
return { events: [], private: bagView(world.ecs, handle), appearanceChanged, healthChanged: true };
444
447
}
445
448
446
449
function moveInventorySlotCommand (world, sessionId, command)
@@ -400,7 +400,8 @@ function equipItem (world, sessionId, command)400
}400
}401
inventory.slots = slots;401
inventory.slots = slots;402
equipment.slots[slot] = taken.taken;402
equipment.slots[slot] = taken.taken;403
return { events: [], private: bagView(world.ecs, handle), appearanceChanged: false };403
syncPlayerHealth(world.ecs, handle);404
return { events: [], private: bagView(world.ecs, handle), appearanceChanged: false, healthChanged: true };404
}405
}405
406
406
const toEquip = singleItemFromStack(taken.taken);407
const toEquip = singleItemFromStack(taken.taken);@@ -419,7 +420,8 @@ function equipItem (world, sessionId, command)419
else420
else420
{ inventory.slots = taken.slots; }421
{ inventory.slots = taken.slots; }421
equipment.slots[slot] = toEquip;422
equipment.slots[slot] = toEquip;422
return { events: [], private: bagView(world.ecs, handle), appearanceChanged: true };423
syncPlayerHealth(world.ecs, handle);424
return { events: [], private: bagView(world.ecs, handle), appearanceChanged: true, healthChanged: true };423
}425
}424
426
425
function unequipItem (world, sessionId, command)427
function unequipItem (world, sessionId, command)@@ -439,8 +441,9 @@ function unequipItem (world, sessionId, command)439
{ throw userError("Your inventory cannot hold that."); }441
{ throw userError("Your inventory cannot hold that."); }440
inventory.slots = inserted.slots;442
inventory.slots = inserted.slots;441
equipment.slots[command.equipSlot] = null;443
equipment.slots[command.equipSlot] = null;444
syncPlayerHealth(world.ecs, handle);442
const appearanceChanged = def?.equipment?.kind !== EquipmentKind.arrowAmmo;445
const appearanceChanged = def?.equipment?.kind !== EquipmentKind.arrowAmmo;443
return { events: [], private: bagView(world.ecs, handle), appearanceChanged };446
return { events: [], private: bagView(world.ecs, handle), appearanceChanged, healthChanged: true };444
}447
}445
448
446
function moveInventorySlotCommand (world, sessionId, command)449
function moveInventorySlotCommand (world, sessionId, command)@@ -251,7 +251,7 @@ function completeShear (world, handle, entityId, characterId, session, events, p
251
251
{
252
252
const result = applySkillXp(skills, SkillId.herbalism, 4 + Math.max(1, Math.floor(
253
253
(clothExhaustDurationMs(session.clothTier) / 10_000)
254
)));
254
)), world.ecs.get(handle, Component.equipment));
255
255
if (result.changed)
256
256
{ skillsChanged = true; }
257
257
if (result.levelUp)
@@ -251,7 +251,7 @@ function completeShear (world, handle, entityId, characterId, session, events, p251
{251
{252
const result = applySkillXp(skills, SkillId.herbalism, 4 + Math.max(1, Math.floor(252
const result = applySkillXp(skills, SkillId.herbalism, 4 + Math.max(1, Math.floor(253
(clothExhaustDurationMs(session.clothTier) / 10_000)253
(clothExhaustDurationMs(session.clothTier) / 10_000)254
)));254
)), world.ecs.get(handle, Component.equipment));255
if (result.changed)255
if (result.changed)256
{ skillsChanged = true; }256
{ skillsChanged = true; }257
if (result.levelUp)257
if (result.levelUp)@@ -2,6 +2,7 @@ import { Component } from "../ecs/components.js";
2
2
import { SkillId, playerMaxHealth, playerMaxStamina } from "../../../shared/definitions/skills.js";
3
3
import { combatDamageXp, spellCastXpFromDifficulty } from "../../../shared/skills/progression.js";
4
4
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";
5
import { maxHealthMultiplier } from "../../../shared/equipment/jewelryEffects.js";
5
6
6
7
export function syncPlayerHealth (ecs, handle)
7
8
{
@@ -12,7 +13,8 @@ export function syncPlayerHealth (ecs, handle)
12
13
const health = ecs.get(handle, Component.health);
13
14
if (!skills || !health)
14
15
{ return; }
15
const max = playerMaxHealth(skills);
16
const equipment = ecs.get(handle, Component.equipment);
17
const max = Math.max(1, Math.floor(playerMaxHealth(skills) * maxHealthMultiplier(equipment)));
16
18
health.max = max;
17
19
health.current = Math.min(health.current | 0, max);
18
20
}
@@ -39,11 +41,12 @@ export function awardCombatHitXp (ecs, attackerHandle, profile, damage)
39
41
const skills = ecs.get(attackerHandle, Component.skills);
40
42
if (!skills?.xp)
41
43
{ return null; }
44
const equipment = ecs.get(attackerHandle, Component.equipment);
42
45
const levelUps = [];
43
const hit = applySkillXp(skills, profile.hitSkillId, amount);
46
const hit = applySkillXp(skills, profile.hitSkillId, amount, equipment);
44
47
if (hit.levelUp)
45
48
{ levelUps.push(hit.levelUp); }
46
const damageSkill = applySkillXp(skills, profile.damageSkillId, amount);
49
const damageSkill = applySkillXp(skills, profile.damageSkillId, amount, equipment);
47
50
if (damageSkill.levelUp)
48
51
{ levelUps.push(damageSkill.levelUp); }
49
52
if (!hit.changed && !damageSkill.changed)
@@ -62,7 +65,8 @@ export function awardSpellCastXp (ecs, casterHandle, spellDifficulty)
62
65
const skills = ecs.get(casterHandle, Component.skills);
63
66
if (!skills?.xp)
64
67
{ return null; }
65
const result = applySkillXp(skills, SkillId.magic, amount);
68
const equipment = ecs.get(casterHandle, Component.equipment);
69
const result = applySkillXp(skills, SkillId.magic, amount, equipment);
66
70
if (!result.changed)
67
71
{ return null; }
68
72
const character = ecs.get(casterHandle, Component.character);
@@ -89,7 +93,8 @@ export function awardDamageHealthXp (ecs, targetHandle, damage)
89
93
const skills = ecs.get(targetHandle, Component.skills);
90
94
if (!skills?.xp)
91
95
{ return null; }
92
const result = applySkillXp(skills, SkillId.health, amount);
96
const equipment = ecs.get(targetHandle, Component.equipment);
97
const result = applySkillXp(skills, SkillId.health, amount, equipment);
93
98
if (!result.changed)
94
99
{ return null; }
95
100
syncPlayerHealth(ecs, targetHandle);
@@ -113,7 +118,8 @@ export function awardCombatAvoidanceXp (ecs, targetHandle, skillId, avoidedDamag
113
118
const skills = ecs.get(targetHandle, Component.skills);
114
119
if (!skills?.xp)
115
120
{ return null; }
116
const result = applySkillXp(skills, skillId, amount);
121
const equipment = ecs.get(targetHandle, Component.equipment);
122
const result = applySkillXp(skills, skillId, amount, equipment);
117
123
if (!result.changed)
118
124
{ return null; }
119
125
return {
@@ -2,6 +2,7 @@ import { Component } from "../ecs/components.js";2
import { SkillId, playerMaxHealth, playerMaxStamina } from "../../../shared/definitions/skills.js";2
import { SkillId, playerMaxHealth, playerMaxStamina } from "../../../shared/definitions/skills.js";3
import { combatDamageXp, spellCastXpFromDifficulty } from "../../../shared/skills/progression.js";3
import { combatDamageXp, spellCastXpFromDifficulty } from "../../../shared/skills/progression.js";4
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";4
import { applySkillXp, publicSkillsPayload, storedSkillXp } from "../../../shared/skills/state.js";5
import { maxHealthMultiplier } from "../../../shared/equipment/jewelryEffects.js";5
6
6
export function syncPlayerHealth (ecs, handle)7
export function syncPlayerHealth (ecs, handle)7
{8
{@@ -12,7 +13,8 @@ export function syncPlayerHealth (ecs, handle)12
const health = ecs.get(handle, Component.health);13
const health = ecs.get(handle, Component.health);13
if (!skills || !health)14
if (!skills || !health)14
{ return; }15
{ return; }15
const max = playerMaxHealth(skills);16
const equipment = ecs.get(handle, Component.equipment);17
const max = Math.max(1, Math.floor(playerMaxHealth(skills) * maxHealthMultiplier(equipment)));16
health.max = max;18
health.max = max;17
health.current = Math.min(health.current | 0, max);19
health.current = Math.min(health.current | 0, max);18
}20
}@@ -39,11 +41,12 @@ export function awardCombatHitXp (ecs, attackerHandle, profile, damage)39
const skills = ecs.get(attackerHandle, Component.skills);41
const skills = ecs.get(attackerHandle, Component.skills);40
if (!skills?.xp)42
if (!skills?.xp)41
{ return null; }43
{ return null; }44
const equipment = ecs.get(attackerHandle, Component.equipment);42
const levelUps = [];45
const levelUps = [];43
const hit = applySkillXp(skills, profile.hitSkillId, amount);46
const hit = applySkillXp(skills, profile.hitSkillId, amount, equipment);44
if (hit.levelUp)47
if (hit.levelUp)45
{ levelUps.push(hit.levelUp); }48
{ levelUps.push(hit.levelUp); }46
const damageSkill = applySkillXp(skills, profile.damageSkillId, amount);49
const damageSkill = applySkillXp(skills, profile.damageSkillId, amount, equipment);47
if (damageSkill.levelUp)50
if (damageSkill.levelUp)48
{ levelUps.push(damageSkill.levelUp); }51
{ levelUps.push(damageSkill.levelUp); }49
if (!hit.changed && !damageSkill.changed)52
if (!hit.changed && !damageSkill.changed)@@ -62,7 +65,8 @@ export function awardSpellCastXp (ecs, casterHandle, spellDifficulty)62
const skills = ecs.get(casterHandle, Component.skills);65
const skills = ecs.get(casterHandle, Component.skills);63
if (!skills?.xp)66
if (!skills?.xp)64
{ return null; }67
{ return null; }65
const result = applySkillXp(skills, SkillId.magic, amount);68
const equipment = ecs.get(casterHandle, Component.equipment);69
const result = applySkillXp(skills, SkillId.magic, amount, equipment);66
if (!result.changed)70
if (!result.changed)67
{ return null; }71
{ return null; }68
const character = ecs.get(casterHandle, Component.character);72
const character = ecs.get(casterHandle, Component.character);@@ -89,7 +93,8 @@ export function awardDamageHealthXp (ecs, targetHandle, damage)89
const skills = ecs.get(targetHandle, Component.skills);93
const skills = ecs.get(targetHandle, Component.skills);90
if (!skills?.xp)94
if (!skills?.xp)91
{ return null; }95
{ return null; }92
const result = applySkillXp(skills, SkillId.health, amount);96
const equipment = ecs.get(targetHandle, Component.equipment);97
const result = applySkillXp(skills, SkillId.health, amount, equipment);93
if (!result.changed)98
if (!result.changed)94
{ return null; }99
{ return null; }95
syncPlayerHealth(ecs, targetHandle);100
syncPlayerHealth(ecs, targetHandle);@@ -113,7 +118,8 @@ export function awardCombatAvoidanceXp (ecs, targetHandle, skillId, avoidedDamag113
const skills = ecs.get(targetHandle, Component.skills);118
const skills = ecs.get(targetHandle, Component.skills);114
if (!skills?.xp)119
if (!skills?.xp)115
{ return null; }120
{ return null; }116
const result = applySkillXp(skills, skillId, amount);121
const equipment = ecs.get(targetHandle, Component.equipment);122
const result = applySkillXp(skills, skillId, amount, equipment);117
if (!result.changed)123
if (!result.changed)118
{ return null; }124
{ return null; }119
return {125
return {@@ -34,6 +34,13 @@ import { rollSpellDamage } from "../../../shared/combat/rolls.js";
34
34
import { mobDefinition } from "../../../shared/definitions/mobs.js";
35
35
import { awardCombatHitXp, awardDamageHealthXp, awardSpellCastXp, syncPlayerHealth } from "../skills/service.js";
36
36
import { equipmentBonusesFromSlots, effectiveSkillLevel } from "../../../shared/equipment/stats.js";
37
import
38
{
39
attackerSpellCastRng,
40
hitSkillBonus,
41
jewelryDamageAffinities,
42
mergeAffinities
43
} from "../../../shared/equipment/jewelryEffects.js";
37
44
import { statusSkillBonuses, applyStatusEffect, emptyStatusEffects, StatusEffectType, publicStatusEffectsView, hasStatusEffect } from "../../../shared/statusEffects/rules.js";
38
45
import
39
46
{
@@ -274,8 +281,9 @@ function casterMagicLevels (ecs, handle, settings = null)
274
281
const bonuses = equipmentBonusesFromSlots(equipment?.slots, settings);
275
282
const status = statusSkillBonuses(ecs.get(handle, Component.statusEffects), Date.now());
276
283
bonuses[SkillId.mind] = (bonuses[SkillId.mind] ?? 0) + (status.mind ?? 0);
284
const hitBonus = hitSkillBonus(equipment);
277
285
return {
278
magic: effectiveSkillLevel(skills, SkillId.magic, bonuses),
286
magic: effectiveSkillLevel(skills, SkillId.magic, bonuses) + hitBonus,
279
287
mind: effectiveSkillLevel(skills, SkillId.mind, bonuses)
280
288
};
281
289
}
@@ -428,9 +436,11 @@ function executeCast (world, sessionId, characterId, spellId, target, now)
428
436
429
437
const levels = casterMagicLevels(world.ecs, handle, world.settings);
430
438
const difficulty = spellDifficulty(def);
439
const equipment = world.ecs.get(handle, Component.equipment);
431
440
const cast = resolveSpellCast({
432
441
magicSkillLevel: levels.magic,
433
spellDifficulty: difficulty
442
spellDifficulty: difficulty,
443
rng: attackerSpellCastRng(equipment)
434
444
});
435
445
436
446
const events = [];
@@ -564,9 +574,11 @@ function targetAffinitiesForEntity (world, entityId)
564
574
if (handle == null)
565
575
{ return {}; }
566
576
const creature = world.ecs.get(handle, Component.creature);
567
if (!creature)
568
{ return {}; }
569
return mobDamageAffinities(mobDefinition(creature.mobTypeId));
577
const mobAffinities = creature
578
? mobDamageAffinities(mobDefinition(creature.mobTypeId))
579
: {};
580
const equipment = world.ecs.get(handle, Component.equipment);
581
return mergeAffinities(mobAffinities, jewelryDamageAffinities(equipment));
570
582
}
571
583
572
584
function applySpellImpact (world, impact, now)
@@ -34,6 +34,13 @@ import { rollSpellDamage } from "../../../shared/combat/rolls.js";34
import { mobDefinition } from "../../../shared/definitions/mobs.js";34
import { mobDefinition } from "../../../shared/definitions/mobs.js";35
import { awardCombatHitXp, awardDamageHealthXp, awardSpellCastXp, syncPlayerHealth } from "../skills/service.js";35
import { awardCombatHitXp, awardDamageHealthXp, awardSpellCastXp, syncPlayerHealth } from "../skills/service.js";36
import { equipmentBonusesFromSlots, effectiveSkillLevel } from "../../../shared/equipment/stats.js";36
import { equipmentBonusesFromSlots, effectiveSkillLevel } from "../../../shared/equipment/stats.js";37
import38
{39
attackerSpellCastRng,40
hitSkillBonus,41
jewelryDamageAffinities,42
mergeAffinities43
} from "../../../shared/equipment/jewelryEffects.js";37
import { statusSkillBonuses, applyStatusEffect, emptyStatusEffects, StatusEffectType, publicStatusEffectsView, hasStatusEffect } from "../../../shared/statusEffects/rules.js";44
import { statusSkillBonuses, applyStatusEffect, emptyStatusEffects, StatusEffectType, publicStatusEffectsView, hasStatusEffect } from "../../../shared/statusEffects/rules.js";38
import45
import39
{46
{@@ -274,8 +281,9 @@ function casterMagicLevels (ecs, handle, settings = null)274
const bonuses = equipmentBonusesFromSlots(equipment?.slots, settings);281
const bonuses = equipmentBonusesFromSlots(equipment?.slots, settings);275
const status = statusSkillBonuses(ecs.get(handle, Component.statusEffects), Date.now());282
const status = statusSkillBonuses(ecs.get(handle, Component.statusEffects), Date.now());276
bonuses[SkillId.mind] = (bonuses[SkillId.mind] ?? 0) + (status.mind ?? 0);283
bonuses[SkillId.mind] = (bonuses[SkillId.mind] ?? 0) + (status.mind ?? 0);284
const hitBonus = hitSkillBonus(equipment);277
return {285
return {278
magic: effectiveSkillLevel(skills, SkillId.magic, bonuses),286
magic: effectiveSkillLevel(skills, SkillId.magic, bonuses) + hitBonus,279
mind: effectiveSkillLevel(skills, SkillId.mind, bonuses)287
mind: effectiveSkillLevel(skills, SkillId.mind, bonuses)280
};288
};281
}289
}@@ -428,9 +436,11 @@ function executeCast (world, sessionId, characterId, spellId, target, now)428
436
429
const levels = casterMagicLevels(world.ecs, handle, world.settings);437
const levels = casterMagicLevels(world.ecs, handle, world.settings);430
const difficulty = spellDifficulty(def);438
const difficulty = spellDifficulty(def);439
const equipment = world.ecs.get(handle, Component.equipment);431
const cast = resolveSpellCast({440
const cast = resolveSpellCast({432
magicSkillLevel: levels.magic,441
magicSkillLevel: levels.magic,433
spellDifficulty: difficulty442
spellDifficulty: difficulty,443
rng: attackerSpellCastRng(equipment)434
});444
});435
445
436
const events = [];446
const events = [];@@ -564,9 +574,11 @@ function targetAffinitiesForEntity (world, entityId)564
if (handle == null)574
if (handle == null)565
{ return {}; }575
{ return {}; }566
const creature = world.ecs.get(handle, Component.creature);576
const creature = world.ecs.get(handle, Component.creature);567
if (!creature)577
const mobAffinities = creature568
{ return {}; }578
? mobDamageAffinities(mobDefinition(creature.mobTypeId))569
return mobDamageAffinities(mobDefinition(creature.mobTypeId));579
: {};580
const equipment = world.ecs.get(handle, Component.equipment);581
return mergeAffinities(mobAffinities, jewelryDamageAffinities(equipment));570
}582
}571
583
572
function applySpellImpact (world, impact, now)584
function applySpellImpact (world, impact, now)