Add Passive spawner flag: take hits without retaliating.
Passive is mutually exclusive with Aggressive in the editor and normalize path; runtime skips engage-on-hit for passive spawnOrigin.
@@ -713,6 +713,27 @@ export function initTileConfigModal ({
713
713
nameHint.className = "hint";
714
714
nameHint.textContent = `Optional. Empty uses the mob default (${placeholder}).`;
715
715
wrap.append(nameHint);
716
717
// Wildlife: Passive without Aggressive checkbox (Aggressive comes from mob def).
718
if (!isHumanoidMob(config.mobTypeId) && !isCentralExchangeSpawner(config))
719
{
720
const defAggressive = !!def?.aggressive;
721
const passiveLabel = document.createElement("label");
722
passiveLabel.className = "spawner-buys-row";
723
const passive = document.createElement("input");
724
passive.type = "checkbox";
725
passive.name = "passive";
726
passive.checked = !!config.passive && !defAggressive;
727
passive.disabled = defAggressive;
728
passiveLabel.append(passive, document.createTextNode(" Passive (takes hits, does not fight back)"));
729
wrap.append(passiveLabel);
730
const passiveHint = document.createElement("p");
731
passiveHint.className = "hint";
732
passiveHint.textContent = defAggressive
733
? "Unavailable: this mob type is Aggressive by definition."
734
: "Passive mobs take hits but never retaliate when attacked.";
735
wrap.append(passiveHint);
736
}
716
737
}
717
738
718
739
const dropsHeader = document.createElement("div");
@@ -784,14 +805,28 @@ export function initTileConfigModal ({
784
805
aggressive.type = "checkbox";
785
806
aggressive.name = "aggressive";
786
807
aggressive.checked = !!config.aggressive;
787
aggressive.addEventListener("change", () => syncBountyForAggressive());
808
aggressive.addEventListener("change", () => syncAggressivePassive());
788
809
aggressiveLabel.append(aggressive, document.createTextNode(" Aggressive (attacks players in range)"));
789
810
wrap.append(aggressiveLabel);
790
811
const aggressiveHint = document.createElement("p");
791
812
aggressiveHint.className = "hint";
792
aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0.";
813
aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0 and Passive is unavailable.";
793
814
wrap.append(aggressiveHint);
794
815
816
const passiveLabel = document.createElement("label");
817
passiveLabel.className = "spawner-buys-row";
818
const passive = document.createElement("input");
819
passive.type = "checkbox";
820
passive.name = "passive";
821
passive.checked = !!config.passive && !config.aggressive;
822
passive.disabled = !!config.aggressive;
823
passiveLabel.append(passive, document.createTextNode(" Passive (takes hits, does not fight back)"));
824
wrap.append(passiveLabel);
825
const passiveHint = document.createElement("p");
826
passiveHint.className = "hint";
827
passiveHint.textContent = "Only available while Aggressive is off. Passive mobs never retaliate when attacked.";
828
wrap.append(passiveHint);
829
795
830
wrap.append(field("Dialogue", dialogueSelect("dialogueId", config.dialogueId ?? "", dialogueOptions)));
796
831
797
832
const equipHeader = document.createElement("div");
@@ -1016,20 +1051,32 @@ export function initTileConfigModal ({
1016
1051
}
1017
1052
}
1018
1053
1019
function syncBountyForAggressive ()
1054
function syncAggressivePassive ()
1020
1055
{
1021
1056
const bountyInput = form.querySelector('[name="bounty"]');
1022
1057
const aggressiveInput = form.querySelector('[name="aggressive"]');
1023
if (!bountyInput)
1024
{ return; }
1058
const passiveInput = form.querySelector('[name="passive"]');
1025
1059
const aggressive = !!aggressiveInput?.checked;
1026
if (aggressive)
1060
if (bountyInput)
1061
{
1062
if (aggressive)
1063
{
1064
bountyInput.value = "0";
1065
bountyInput.disabled = true;
1066
}
1067
else
1068
{ bountyInput.disabled = false; }
1069
}
1070
if (passiveInput)
1027
1071
{
1028
bountyInput.value = "0";
1029
bountyInput.disabled = true;
1072
if (aggressive)
1073
{
1074
passiveInput.checked = false;
1075
passiveInput.disabled = true;
1076
}
1077
else
1078
{ passiveInput.disabled = false; }
1030
1079
}
1031
else
1032
{ bountyInput.disabled = false; }
1033
1080
}
1034
1081
1035
1082
function openSpawner (ctx)
@@ -1078,7 +1125,7 @@ export function initTileConfigModal ({
1078
1125
syncCommonSpawnerSection(defaults);
1079
1126
syncHumanoidSection(defaults);
1080
1127
syncSpellsSection(defaults);
1081
syncBountyForAggressive();
1128
syncAggressivePassive();
1082
1129
});
1083
1130
spellsDraft = (config.spells ?? []).map((line) => ({
1084
1131
spellId: String(line.spellId ?? "")
@@ -1086,7 +1133,7 @@ export function initTileConfigModal ({
1086
1133
syncCommonSpawnerSection(config);
1087
1134
syncHumanoidSection(config);
1088
1135
syncSpellsSection(config);
1089
syncBountyForAggressive();
1136
syncAggressivePassive();
1090
1137
show(true);
1091
1138
}
1092
1139
@@ -1298,6 +1345,7 @@ export function initTileConfigModal ({
1298
1345
level: Number(data.get("level") || 1),
1299
1346
bounty: Number(data.get("bounty") || 0),
1300
1347
aggressive: data.get("aggressive") === "on",
1348
passive: data.get("aggressive") === "on" ? false : data.get("passive") === "on",
1301
1349
spawnerId: String(data.get("spawnerId") || context.config.spawnerId),
1302
1350
sex: String(data.get("sex") || "male"),
1303
1351
displayName: String(data.get("displayName") || ""),
@@ -713,6 +713,27 @@ export function initTileConfigModal ({713
nameHint.className = "hint";713
nameHint.className = "hint";714
nameHint.textContent = `Optional. Empty uses the mob default (${placeholder}).`;714
nameHint.textContent = `Optional. Empty uses the mob default (${placeholder}).`;715
wrap.append(nameHint);715
wrap.append(nameHint);716
717
// Wildlife: Passive without Aggressive checkbox (Aggressive comes from mob def).718
if (!isHumanoidMob(config.mobTypeId) && !isCentralExchangeSpawner(config))719
{720
const defAggressive = !!def?.aggressive;721
const passiveLabel = document.createElement("label");722
passiveLabel.className = "spawner-buys-row";723
const passive = document.createElement("input");724
passive.type = "checkbox";725
passive.name = "passive";726
passive.checked = !!config.passive && !defAggressive;727
passive.disabled = defAggressive;728
passiveLabel.append(passive, document.createTextNode(" Passive (takes hits, does not fight back)"));729
wrap.append(passiveLabel);730
const passiveHint = document.createElement("p");731
passiveHint.className = "hint";732
passiveHint.textContent = defAggressive733
? "Unavailable: this mob type is Aggressive by definition."734
: "Passive mobs take hits but never retaliate when attacked.";735
wrap.append(passiveHint);736
}716
}737
}717
738
718
const dropsHeader = document.createElement("div");739
const dropsHeader = document.createElement("div");@@ -784,14 +805,28 @@ export function initTileConfigModal ({784
aggressive.type = "checkbox";805
aggressive.type = "checkbox";785
aggressive.name = "aggressive";806
aggressive.name = "aggressive";786
aggressive.checked = !!config.aggressive;807
aggressive.checked = !!config.aggressive;787
aggressive.addEventListener("change", () => syncBountyForAggressive());808
aggressive.addEventListener("change", () => syncAggressivePassive());788
aggressiveLabel.append(aggressive, document.createTextNode(" Aggressive (attacks players in range)"));809
aggressiveLabel.append(aggressive, document.createTextNode(" Aggressive (attacks players in range)"));789
wrap.append(aggressiveLabel);810
wrap.append(aggressiveLabel);790
const aggressiveHint = document.createElement("p");811
const aggressiveHint = document.createElement("p");791
aggressiveHint.className = "hint";812
aggressiveHint.className = "hint";792
aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0.";813
aggressiveHint.textContent = "When Aggressive is on, Bounty is forced to 0 and Passive is unavailable.";793
wrap.append(aggressiveHint);814
wrap.append(aggressiveHint);794
815
816
const passiveLabel = document.createElement("label");817
passiveLabel.className = "spawner-buys-row";818
const passive = document.createElement("input");819
passive.type = "checkbox";820
passive.name = "passive";821
passive.checked = !!config.passive && !config.aggressive;822
passive.disabled = !!config.aggressive;823
passiveLabel.append(passive, document.createTextNode(" Passive (takes hits, does not fight back)"));824
wrap.append(passiveLabel);825
const passiveHint = document.createElement("p");826
passiveHint.className = "hint";827
passiveHint.textContent = "Only available while Aggressive is off. Passive mobs never retaliate when attacked.";828
wrap.append(passiveHint);829
795
wrap.append(field("Dialogue", dialogueSelect("dialogueId", config.dialogueId ?? "", dialogueOptions)));830
wrap.append(field("Dialogue", dialogueSelect("dialogueId", config.dialogueId ?? "", dialogueOptions)));796
831
797
const equipHeader = document.createElement("div");832
const equipHeader = document.createElement("div");@@ -1016,20 +1051,32 @@ export function initTileConfigModal ({1016
}1051
}1017
}1052
}1018
1053
1019
function syncBountyForAggressive ()1054
function syncAggressivePassive ()1020
{1055
{1021
const bountyInput = form.querySelector('[name="bounty"]');1056
const bountyInput = form.querySelector('[name="bounty"]');1022
const aggressiveInput = form.querySelector('[name="aggressive"]');1057
const aggressiveInput = form.querySelector('[name="aggressive"]');1023
if (!bountyInput)1058
const passiveInput = form.querySelector('[name="passive"]');1024
{ return; }1025
const aggressive = !!aggressiveInput?.checked;1059
const aggressive = !!aggressiveInput?.checked;1026
if (aggressive)1060
if (bountyInput)1061
{1062
if (aggressive)1063
{1064
bountyInput.value = "0";1065
bountyInput.disabled = true;1066
}1067
else1068
{ bountyInput.disabled = false; }1069
}1070
if (passiveInput)1027
{1071
{1028
bountyInput.value = "0";1072
if (aggressive)1029
bountyInput.disabled = true;1073
{1074
passiveInput.checked = false;1075
passiveInput.disabled = true;1076
}1077
else1078
{ passiveInput.disabled = false; }1030
}1079
}1031
else1032
{ bountyInput.disabled = false; }1033
}1080
}1034
1081
1035
function openSpawner (ctx)1082
function openSpawner (ctx)@@ -1078,7 +1125,7 @@ export function initTileConfigModal ({1078
syncCommonSpawnerSection(defaults);1125
syncCommonSpawnerSection(defaults);1079
syncHumanoidSection(defaults);1126
syncHumanoidSection(defaults);1080
syncSpellsSection(defaults);1127
syncSpellsSection(defaults);1081
syncBountyForAggressive();1128
syncAggressivePassive();1082
});1129
});1083
spellsDraft = (config.spells ?? []).map((line) => ({1130
spellsDraft = (config.spells ?? []).map((line) => ({1084
spellId: String(line.spellId ?? "")1131
spellId: String(line.spellId ?? "")@@ -1086,7 +1133,7 @@ export function initTileConfigModal ({1086
syncCommonSpawnerSection(config);1133
syncCommonSpawnerSection(config);1087
syncHumanoidSection(config);1134
syncHumanoidSection(config);1088
syncSpellsSection(config);1135
syncSpellsSection(config);1089
syncBountyForAggressive();1136
syncAggressivePassive();1090
show(true);1137
show(true);1091
}1138
}1092
1139
@@ -1298,6 +1345,7 @@ export function initTileConfigModal ({1298
level: Number(data.get("level") || 1),1345
level: Number(data.get("level") || 1),1299
bounty: Number(data.get("bounty") || 0),1346
bounty: Number(data.get("bounty") || 0),1300
aggressive: data.get("aggressive") === "on",1347
aggressive: data.get("aggressive") === "on",1348
passive: data.get("aggressive") === "on" ? false : data.get("passive") === "on",1301
spawnerId: String(data.get("spawnerId") || context.config.spawnerId),1349
spawnerId: String(data.get("spawnerId") || context.config.spawnerId),1302
sex: String(data.get("sex") || "male"),1350
sex: String(data.get("sex") || "male"),1303
displayName: String(data.get("displayName") || ""),1351
displayName: String(data.get("displayName") || ""),@@ -299,6 +299,17 @@ export function ensureMobCombat (ecs, entityId)
299
299
return true;
300
300
}
301
301
302
/** Spawner Passive: take hits but do not enter combat / retaliate. Aggressive overrides. */
303
export function entityIsPassive (ecs, handle)
304
{
305
const origin = ecs.get(handle, Component.spawnOrigin);
306
if (!origin?.passive)
307
{ return false; }
308
if (origin.aggressive)
309
{ return false; }
310
return true;
311
}
312
302
313
function attackerSkillLevel (skills, profile, skillId)
303
314
{
304
315
if (profile.mobAttackSkill != null)
@@ -2264,7 +2275,12 @@ function applyLocalMeleeHit (
2264
2275
: (attackerHandle != null ? !!world.ecs.get(attackerHandle, Component.character) : null);
2265
2276
2266
2277
// Retaliate on the first resolved swing (hit or miss), not on Attack-click engage.
2267
if (attackerIsPlayer === true && ensureMobCombat(world.ecs, targetId))
2278
// Passive spawners take hits but do not fight back.
2279
if (
2280
attackerIsPlayer === true
2281
&& !entityIsPassive(world.ecs, targetHandle)
2282
&& ensureMobCombat(world.ecs, targetId)
2283
)
2268
2284
{
2269
2285
engageTarget(world.ecs, targetId, attackerId, now);
2270
2286
if (profile?.mode === "ranged")
@@ -2607,7 +2623,11 @@ export function applyDamageAndKill (world, attackerId, targetId, damage, now = D
2607
2623
});
2608
2624
2609
2625
const attackerHandle = world.ecs.handleOf(attackerId);
2610
if (attackerHandle != null && ensureMobCombat(world.ecs, targetId))
2626
if (
2627
attackerHandle != null
2628
&& !entityIsPassive(world.ecs, targetHandle)
2629
&& ensureMobCombat(world.ecs, targetId)
2630
)
2611
2631
{
2612
2632
const attackerIsPlayer = !!world.ecs.get(attackerHandle, Component.character);
2613
2633
const targetCombat = world.ecs.get(targetHandle, Component.combat);
@@ -299,6 +299,17 @@ export function ensureMobCombat (ecs, entityId)299
return true;299
return true;300
}300
}301
301
302
/** Spawner Passive: take hits but do not enter combat / retaliate. Aggressive overrides. */303
export function entityIsPassive (ecs, handle)304
{305
const origin = ecs.get(handle, Component.spawnOrigin);306
if (!origin?.passive)307
{ return false; }308
if (origin.aggressive)309
{ return false; }310
return true;311
}312
302
function attackerSkillLevel (skills, profile, skillId)313
function attackerSkillLevel (skills, profile, skillId)303
{314
{304
if (profile.mobAttackSkill != null)315
if (profile.mobAttackSkill != null)@@ -2264,7 +2275,12 @@ function applyLocalMeleeHit (2264
: (attackerHandle != null ? !!world.ecs.get(attackerHandle, Component.character) : null);2275
: (attackerHandle != null ? !!world.ecs.get(attackerHandle, Component.character) : null);2265
2276
2266
// Retaliate on the first resolved swing (hit or miss), not on Attack-click engage.2277
// Retaliate on the first resolved swing (hit or miss), not on Attack-click engage.2267
if (attackerIsPlayer === true && ensureMobCombat(world.ecs, targetId))2278
// Passive spawners take hits but do not fight back.2279
if (2280
attackerIsPlayer === true2281
&& !entityIsPassive(world.ecs, targetHandle)2282
&& ensureMobCombat(world.ecs, targetId)2283
)2268
{2284
{2269
engageTarget(world.ecs, targetId, attackerId, now);2285
engageTarget(world.ecs, targetId, attackerId, now);2270
if (profile?.mode === "ranged")2286
if (profile?.mode === "ranged")@@ -2607,7 +2623,11 @@ export function applyDamageAndKill (world, attackerId, targetId, damage, now = D2607
});2623
});2608
2624
2609
const attackerHandle = world.ecs.handleOf(attackerId);2625
const attackerHandle = world.ecs.handleOf(attackerId);2610
if (attackerHandle != null && ensureMobCombat(world.ecs, targetId))2626
if (2627
attackerHandle != null2628
&& !entityIsPassive(world.ecs, targetHandle)2629
&& ensureMobCombat(world.ecs, targetId)2630
)2611
{2631
{2612
const attackerIsPlayer = !!world.ecs.get(attackerHandle, Component.character);2632
const attackerIsPlayer = !!world.ecs.get(attackerHandle, Component.character);2613
const targetCombat = world.ecs.get(targetHandle, Component.combat);2633
const targetCombat = world.ecs.get(targetHandle, Component.combat);@@ -98,6 +98,7 @@ export function collectSpawnRequests (world, now = Date.now())
98
98
level: config.level,
99
99
bounty: config.bounty,
100
100
aggressive: !!config.aggressive,
101
passive: !!config.passive,
101
102
spells: config.spells,
102
103
persistent,
103
104
sex: staff.sex,
@@ -146,6 +147,7 @@ export function collectSpawnRequests (world, now = Date.now())
146
147
aggressive: isHumanoidMob(config.mobTypeId) || config.townGuard
147
148
? !!config.aggressive
148
149
: undefined,
150
passive: !!config.passive,
149
151
spells: config.spells,
150
152
persistent,
151
153
sex: config.sex,
@@ -308,6 +310,8 @@ export function mobComponents (request)
308
310
const aggressive = request.aggressive != null
309
311
? !!request.aggressive
310
312
: !!def.aggressive;
313
// Passive only when Aggressive is off (config + resolved flag).
314
const passive = !aggressive && !!request.passive;
311
315
// Humanoid Aggressive flag forces bounty 0; wildlife can be aggressive and still pay kill bounty.
312
316
const bounty = request.aggressive === true
313
317
? 0
@@ -320,6 +324,7 @@ export function mobComponents (request)
320
324
bounty,
321
325
level,
322
326
aggressive,
327
passive,
323
328
centralExchange: !!request.centralExchange,
324
329
townGuard: !!request.townGuard || isTownGuardMob(def.mobTypeId),
325
330
stationTileX: null,
@@ -98,6 +98,7 @@ export function collectSpawnRequests (world, now = Date.now())98
level: config.level,98
level: config.level,99
bounty: config.bounty,99
bounty: config.bounty,100
aggressive: !!config.aggressive,100
aggressive: !!config.aggressive,101
passive: !!config.passive,101
spells: config.spells,102
spells: config.spells,102
persistent,103
persistent,103
sex: staff.sex,104
sex: staff.sex,@@ -146,6 +147,7 @@ export function collectSpawnRequests (world, now = Date.now())146
aggressive: isHumanoidMob(config.mobTypeId) || config.townGuard147
aggressive: isHumanoidMob(config.mobTypeId) || config.townGuard147
? !!config.aggressive148
? !!config.aggressive148
: undefined,149
: undefined,150
passive: !!config.passive,149
spells: config.spells,151
spells: config.spells,150
persistent,152
persistent,151
sex: config.sex,153
sex: config.sex,@@ -308,6 +310,8 @@ export function mobComponents (request)308
const aggressive = request.aggressive != null310
const aggressive = request.aggressive != null309
? !!request.aggressive311
? !!request.aggressive310
: !!def.aggressive;312
: !!def.aggressive;313
// Passive only when Aggressive is off (config + resolved flag).314
const passive = !aggressive && !!request.passive;311
// Humanoid Aggressive flag forces bounty 0; wildlife can be aggressive and still pay kill bounty.315
// Humanoid Aggressive flag forces bounty 0; wildlife can be aggressive and still pay kill bounty.312
const bounty = request.aggressive === true316
const bounty = request.aggressive === true313
? 0317
? 0@@ -320,6 +324,7 @@ export function mobComponents (request)320
bounty,324
bounty,321
level,325
level,322
aggressive,326
aggressive,327
passive,323
centralExchange: !!request.centralExchange,328
centralExchange: !!request.centralExchange,324
townGuard: !!request.townGuard || isTownGuardMob(def.mobTypeId),329
townGuard: !!request.townGuard || isTownGuardMob(def.mobTypeId),325
stationTileX: null,330
stationTileX: null,@@ -408,6 +408,58 @@ test("attack engages the attacker; target retaliates on first swing", () =>
408
408
{ harness.close(); }
409
409
});
410
410
411
test("passive spawner mob takes hits but does not retaliate", () =>
412
{
413
const harness = makeSimulation({ workerCount: 1 });
414
try
415
{
416
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });
417
const playerId = harness.simulation.spawnCharacter(1, character);
418
const npcId = harness.simulation.spawnEntity(mobComponents({
419
tileX: 9,
420
tileY: 8,
421
mobTypeId: MobId.humanoid,
422
spawnerId: "passive-npc",
423
originTileX: 9,
424
originTileY: 8,
425
wanderRangeTiles: 1,
426
level: 1,
427
aggressive: false,
428
passive: true,
429
displayName: "Pacifist",
430
sex: "male"
431
}));
432
433
harness.simulation.enqueue(1, {
434
type: "attack",
435
characterId: character.character_id,
436
targetEntityId: npcId
437
});
438
harness.simulation.step();
439
assert.equal(componentsOf(harness.simulation, playerId).combat.targetEntityId, npcId);
440
441
let swung = false;
442
for (let i = 0; i < 80; i++)
443
{
444
harness.advance(50);
445
const events = harness.simulation.step().events;
446
if (events.some((event) => event.type === "combat-swing" || event.type === "combat-hit" || event.type === "combat-miss"))
447
{
448
swung = true;
449
break;
450
}
451
}
452
assert.ok(swung, "expected a melee swing against the passive npc");
453
assert.equal(
454
componentsOf(harness.simulation, npcId).combat?.targetEntityId ?? null,
455
null,
456
"passive npc must not retaliate"
457
);
458
}
459
finally
460
{ harness.close(); }
461
});
462
411
463
test("melee swing only resolves at Chebyshev distance 1", () =>
412
464
{
413
465
const harness = makeSimulation({ workerCount: 1 });
@@ -408,6 +408,58 @@ test("attack engages the attacker; target retaliates on first swing", () =>408
{ harness.close(); }408
{ harness.close(); }409
});409
});410
410
411
test("passive spawner mob takes hits but does not retaliate", () =>412
{413
const harness = makeSimulation({ workerCount: 1 });414
try415
{416
const character = makeCharacter(harness.stateDb, { tileX: 8, tileY: 8 });417
const playerId = harness.simulation.spawnCharacter(1, character);418
const npcId = harness.simulation.spawnEntity(mobComponents({419
tileX: 9,420
tileY: 8,421
mobTypeId: MobId.humanoid,422
spawnerId: "passive-npc",423
originTileX: 9,424
originTileY: 8,425
wanderRangeTiles: 1,426
level: 1,427
aggressive: false,428
passive: true,429
displayName: "Pacifist",430
sex: "male"431
}));432
433
harness.simulation.enqueue(1, {434
type: "attack",435
characterId: character.character_id,436
targetEntityId: npcId437
});438
harness.simulation.step();439
assert.equal(componentsOf(harness.simulation, playerId).combat.targetEntityId, npcId);440
441
let swung = false;442
for (let i = 0; i < 80; i++)443
{444
harness.advance(50);445
const events = harness.simulation.step().events;446
if (events.some((event) => event.type === "combat-swing" || event.type === "combat-hit" || event.type === "combat-miss"))447
{448
swung = true;449
break;450
}451
}452
assert.ok(swung, "expected a melee swing against the passive npc");453
assert.equal(454
componentsOf(harness.simulation, npcId).combat?.targetEntityId ?? null,455
null,456
"passive npc must not retaliate"457
);458
}459
finally460
{ harness.close(); }461
});462
411
test("melee swing only resolves at Chebyshev distance 1", () =>463
test("melee swing only resolves at Chebyshev distance 1", () =>412
{464
{413
const harness = makeSimulation({ workerCount: 1 });465
const harness = makeSimulation({ workerCount: 1 });@@ -237,6 +237,71 @@ test("aggressive humanoid stores aggro flag and zero bounty", () =>
237
237
});
238
238
assert.equal(components.spawnOrigin.aggressive, true);
239
239
assert.equal(components.spawnOrigin.bounty, 0);
240
assert.equal(components.spawnOrigin.passive, false);
241
});
242
243
test("passive humanoid stores passive flag when not aggressive", () =>
244
{
245
const config = normalizeSpawnerConfig({
246
mobTypeId: MobId.humanoid,
247
aggressive: false,
248
passive: true,
249
bounty: 10
250
}, "passive-1");
251
assert.equal(config.aggressive, false);
252
assert.equal(config.passive, true);
253
assert.equal(config.bounty, 10);
254
255
const cleared = normalizeSpawnerConfig({
256
mobTypeId: MobId.humanoid,
257
aggressive: true,
258
passive: true,
259
bounty: 10
260
}, "passive-cleared");
261
assert.equal(cleared.aggressive, true);
262
assert.equal(cleared.passive, false);
263
assert.equal(cleared.bounty, 0);
264
265
const components = mobComponents({
266
tileX: 8,
267
tileY: 8,
268
mobTypeId: MobId.humanoid,
269
spawnerId: "passive-npc",
270
level: 2,
271
bounty: 5,
272
aggressive: false,
273
passive: true,
274
displayName: "Pacifist",
275
sex: "female"
276
});
277
assert.equal(components.spawnOrigin.aggressive, false);
278
assert.equal(components.spawnOrigin.passive, true);
279
assert.equal(components.spawnOrigin.bounty, 5);
280
});
281
282
test("wildlife passive stores on spawn origin; aggressive wildlife clears it", () =>
283
{
284
const deer = normalizeSpawnerConfig({
285
mobTypeId: MobId.deer,
286
passive: true
287
}, "deer-passive");
288
assert.equal(deer.passive, true);
289
290
const rat = normalizeSpawnerConfig({
291
mobTypeId: MobId.rat,
292
passive: true
293
}, "rat-passive");
294
assert.equal(rat.passive, false);
295
296
const components = mobComponents({
297
tileX: 4,
298
tileY: 4,
299
mobTypeId: MobId.deer,
300
spawnerId: "deer-p",
301
passive: true
302
});
303
assert.equal(components.spawnOrigin.passive, true);
304
assert.equal(components.spawnOrigin.aggressive, false);
240
305
});
241
306
242
307
test("killing a bounty mob awards player bounty and can wake town guards", () =>
@@ -237,6 +237,71 @@ test("aggressive humanoid stores aggro flag and zero bounty", () =>237
});237
});238
assert.equal(components.spawnOrigin.aggressive, true);238
assert.equal(components.spawnOrigin.aggressive, true);239
assert.equal(components.spawnOrigin.bounty, 0);239
assert.equal(components.spawnOrigin.bounty, 0);240
assert.equal(components.spawnOrigin.passive, false);241
});242
243
test("passive humanoid stores passive flag when not aggressive", () =>244
{245
const config = normalizeSpawnerConfig({246
mobTypeId: MobId.humanoid,247
aggressive: false,248
passive: true,249
bounty: 10250
}, "passive-1");251
assert.equal(config.aggressive, false);252
assert.equal(config.passive, true);253
assert.equal(config.bounty, 10);254
255
const cleared = normalizeSpawnerConfig({256
mobTypeId: MobId.humanoid,257
aggressive: true,258
passive: true,259
bounty: 10260
}, "passive-cleared");261
assert.equal(cleared.aggressive, true);262
assert.equal(cleared.passive, false);263
assert.equal(cleared.bounty, 0);264
265
const components = mobComponents({266
tileX: 8,267
tileY: 8,268
mobTypeId: MobId.humanoid,269
spawnerId: "passive-npc",270
level: 2,271
bounty: 5,272
aggressive: false,273
passive: true,274
displayName: "Pacifist",275
sex: "female"276
});277
assert.equal(components.spawnOrigin.aggressive, false);278
assert.equal(components.spawnOrigin.passive, true);279
assert.equal(components.spawnOrigin.bounty, 5);280
});281
282
test("wildlife passive stores on spawn origin; aggressive wildlife clears it", () =>283
{284
const deer = normalizeSpawnerConfig({285
mobTypeId: MobId.deer,286
passive: true287
}, "deer-passive");288
assert.equal(deer.passive, true);289
290
const rat = normalizeSpawnerConfig({291
mobTypeId: MobId.rat,292
passive: true293
}, "rat-passive");294
assert.equal(rat.passive, false);295
296
const components = mobComponents({297
tileX: 4,298
tileY: 4,299
mobTypeId: MobId.deer,300
spawnerId: "deer-p",301
passive: true302
});303
assert.equal(components.spawnOrigin.passive, true);304
assert.equal(components.spawnOrigin.aggressive, false);240
});305
});241
306
242
test("killing a bounty mob awards player bounty and can wake town guards", () =>307
test("killing a bounty mob awards player bounty and can wake town guards", () =>