Drop Dark essence from wild shades, not summons.
Spawner shades always leave Dark essence on death; Shade spell companions still leave nothing.
@@ -406,6 +406,9 @@ function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = nul
406
406
const creature = world.ecs.get(targetHandle, Component.creature);
407
407
if (!creature)
408
408
{ return []; }
409
// Summons (e.g. Shade spell) never drop loot — only wild / spawner mobs.
410
if (world.ecs.get(targetHandle, Component.summon))
411
{ return []; }
409
412
const def = mobDefinition(creature.mobTypeId);
410
413
const mobName = entityCombatDisplayName(world.ecs, targetHandle)
411
414
|| def?.displayName
@@ -406,6 +406,9 @@ function spawnMobDrops (world, targetHandle, tileX, tileY, now, attackerId = nul406
const creature = world.ecs.get(targetHandle, Component.creature);406
const creature = world.ecs.get(targetHandle, Component.creature);407
if (!creature)407
if (!creature)408
{ return []; }408
{ return []; }409
// Summons (e.g. Shade spell) never drop loot — only wild / spawner mobs.410
if (world.ecs.get(targetHandle, Component.summon))411
{ return []; }409
const def = mobDefinition(creature.mobTypeId);412
const def = mobDefinition(creature.mobTypeId);410
const mobName = entityCombatDisplayName(world.ecs, targetHandle)413
const mobName = entityCombatDisplayName(world.ecs, targetHandle)411
|| def?.displayName414
|| def?.displayName@@ -4,10 +4,12 @@ import { dirname, join } from "node:path";
4
4
import { fileURLToPath } from "node:url";
5
5
import { MobId, mobDefinition, mobSpriteName } from "../../shared/definitions/mobs.js";
6
6
import { mobIsAggressive } from "../../shared/definitions/mobCombat.js";
7
import { EssenceItemId } from "../../shared/definitions/essenceItems.js";
8
import { MagicElement } from "../../shared/definitions/attackTypes.js";
7
9
import { buildSpriteCatalog } from "../src/assets/spriteCatalog.js";
8
10
import { mobComponents } from "../src/simulation/spawners.js";
9
11
import { shadeSummonComponents, stepSummons } from "../src/spells/summons.js";
10
import { stepAggression } from "../src/combat/service.js";
12
import { applyDamageAndKill, stepAggression } from "../src/combat/service.js";
11
13
import { Component } from "../src/ecs/components.js";
12
14
import { makeCharacter, makeSimulation } from "./helpers/simulationHarness.js";
13
15
@@ -31,6 +33,9 @@ test("shade uses own static body and animated bloom sprites", () =>
31
33
assert.equal(shade.bloomAnimationSpeed, 0.5);
32
34
assert.equal(shade.aggressive, true);
33
35
assert.equal(mobIsAggressive(shade), true);
36
assert.equal(shade.drops.length, 1);
37
assert.equal(shade.drops[0].itemId, EssenceItemId[MagicElement.dark]);
38
assert.equal(shade.drops[0].chance, 1);
34
39
35
40
const catalog = buildSpriteCatalog(ASSET_ROOT);
36
41
const body = catalog.images.find((entry) => entry.name === "mob:shade:shade");
@@ -107,3 +112,52 @@ test("summoned shade uses companion targeting, not player aggro", () =>
107
112
finally
108
113
{ harness.close(); }
109
114
});
115
116
test("wild shade drops dark essence; summoned shade does not", () =>
117
{
118
const harness = makeSimulation({ workerCount: 1 });
119
try
120
{
121
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });
122
const playerId = harness.simulation.spawnCharacter(1, character);
123
124
const wildId = harness.simulation.spawnEntity(mobComponents({
125
tileX: 10,
126
tileY: 8,
127
mobTypeId: MobId.shade,
128
spawnerId: "0:0:shade",
129
originTileX: 10,
130
originTileY: 8,
131
level: 1
132
}));
133
const worker = workerOf(harness.simulation, wildId);
134
const world = worker.world;
135
const wildHandle = world.ecs.handleOf(wildId);
136
const wildHp = world.ecs.get(wildHandle, Component.health)?.max ?? 10;
137
const wildEvents = applyDamageAndKill(world, playerId, wildId, wildHp, Date.now());
138
const wildDrop = wildEvents.find((event) =>
139
event.type === "ground-item-appear"
140
&& event.stack?.itemId === EssenceItemId[MagicElement.dark]
141
);
142
assert.ok(wildDrop, "spawner shade must drop dark essence");
143
assert.equal(wildDrop.stack.quantity, 1);
144
145
const summonId = harness.simulation.spawnEntity(shadeSummonComponents({
146
tileX: 12,
147
tileY: 8,
148
level: 10,
149
ownerEntityId: playerId,
150
expiresAt: Date.now() + 60_000
151
}));
152
const summonHandle = world.ecs.handleOf(summonId);
153
const summonHp = world.ecs.get(summonHandle, Component.health)?.max ?? 10;
154
const summonEvents = applyDamageAndKill(world, playerId, summonId, summonHp, Date.now());
155
assert.equal(
156
summonEvents.some((event) => event.type === "ground-item-appear"),
157
false,
158
"summoned shade must not drop loot"
159
);
160
}
161
finally
162
{ harness.close(); }
163
});
@@ -4,10 +4,12 @@ import { dirname, join } from "node:path";4
import { fileURLToPath } from "node:url";4
import { fileURLToPath } from "node:url";5
import { MobId, mobDefinition, mobSpriteName } from "../../shared/definitions/mobs.js";5
import { MobId, mobDefinition, mobSpriteName } from "../../shared/definitions/mobs.js";6
import { mobIsAggressive } from "../../shared/definitions/mobCombat.js";6
import { mobIsAggressive } from "../../shared/definitions/mobCombat.js";7
import { EssenceItemId } from "../../shared/definitions/essenceItems.js";8
import { MagicElement } from "../../shared/definitions/attackTypes.js";7
import { buildSpriteCatalog } from "../src/assets/spriteCatalog.js";9
import { buildSpriteCatalog } from "../src/assets/spriteCatalog.js";8
import { mobComponents } from "../src/simulation/spawners.js";10
import { mobComponents } from "../src/simulation/spawners.js";9
import { shadeSummonComponents, stepSummons } from "../src/spells/summons.js";11
import { shadeSummonComponents, stepSummons } from "../src/spells/summons.js";10
import { stepAggression } from "../src/combat/service.js";12
import { applyDamageAndKill, stepAggression } from "../src/combat/service.js";11
import { Component } from "../src/ecs/components.js";13
import { Component } from "../src/ecs/components.js";12
import { makeCharacter, makeSimulation } from "./helpers/simulationHarness.js";14
import { makeCharacter, makeSimulation } from "./helpers/simulationHarness.js";13
15
@@ -31,6 +33,9 @@ test("shade uses own static body and animated bloom sprites", () =>31
assert.equal(shade.bloomAnimationSpeed, 0.5);33
assert.equal(shade.bloomAnimationSpeed, 0.5);32
assert.equal(shade.aggressive, true);34
assert.equal(shade.aggressive, true);33
assert.equal(mobIsAggressive(shade), true);35
assert.equal(mobIsAggressive(shade), true);36
assert.equal(shade.drops.length, 1);37
assert.equal(shade.drops[0].itemId, EssenceItemId[MagicElement.dark]);38
assert.equal(shade.drops[0].chance, 1);34
39
35
const catalog = buildSpriteCatalog(ASSET_ROOT);40
const catalog = buildSpriteCatalog(ASSET_ROOT);36
const body = catalog.images.find((entry) => entry.name === "mob:shade:shade");41
const body = catalog.images.find((entry) => entry.name === "mob:shade:shade");@@ -107,3 +112,52 @@ test("summoned shade uses companion targeting, not player aggro", () =>107
finally112
finally108
{ harness.close(); }113
{ harness.close(); }109
});114
});115
116
test("wild shade drops dark essence; summoned shade does not", () =>117
{118
const harness = makeSimulation({ workerCount: 1 });119
try120
{121
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });122
const playerId = harness.simulation.spawnCharacter(1, character);123
124
const wildId = harness.simulation.spawnEntity(mobComponents({125
tileX: 10,126
tileY: 8,127
mobTypeId: MobId.shade,128
spawnerId: "0:0:shade",129
originTileX: 10,130
originTileY: 8,131
level: 1132
}));133
const worker = workerOf(harness.simulation, wildId);134
const world = worker.world;135
const wildHandle = world.ecs.handleOf(wildId);136
const wildHp = world.ecs.get(wildHandle, Component.health)?.max ?? 10;137
const wildEvents = applyDamageAndKill(world, playerId, wildId, wildHp, Date.now());138
const wildDrop = wildEvents.find((event) =>139
event.type === "ground-item-appear"140
&& event.stack?.itemId === EssenceItemId[MagicElement.dark]141
);142
assert.ok(wildDrop, "spawner shade must drop dark essence");143
assert.equal(wildDrop.stack.quantity, 1);144
145
const summonId = harness.simulation.spawnEntity(shadeSummonComponents({146
tileX: 12,147
tileY: 8,148
level: 10,149
ownerEntityId: playerId,150
expiresAt: Date.now() + 60_000151
}));152
const summonHandle = world.ecs.handleOf(summonId);153
const summonHp = world.ecs.get(summonHandle, Component.health)?.max ?? 10;154
const summonEvents = applyDamageAndKill(world, playerId, summonId, summonHp, Date.now());155
assert.equal(156
summonEvents.some((event) => event.type === "ground-item-appear"),157
false,158
"summoned shade must not drop loot"159
);160
}161
finally162
{ harness.close(); }163
});