Fix spawner spell cast-chance label to use Magic vs spell tier.
Show channel success from Level-as-Magic and the selected spell's tier instead of the AI attempt percent.
@@ -10,7 +10,7 @@ import
10
10
isCentralExchangeSpawner,
11
11
spawnerEquipmentSlot
12
12
} from "/shared/definitions/mobs.js";
13
import { mobSpellCastChancePercent } from "/shared/definitions/mobCombat.js";
13
import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";
14
14
import { SPELL_DEFINITIONS } from "/shared/definitions/spells.js";
15
15
import { centralExchangeStaffCount } from "/shared/market/exchange.js";
16
16
import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries } from "/shared/definitions/items.js";
@@ -23,6 +23,15 @@ import { OVERWORLD_ID, normalizeDimensionId } from "/shared/world/dimensions.js"
23
23
const DOORWAY_STATES = Object.freeze(["door", "ladder", "hole", "cave"]);
24
24
const ITEM_SEARCH_PAGE_SIZE = 40;
25
25
26
function formatCastChancePercent (pct)
27
{
28
const n = Number(pct);
29
if (!Number.isFinite(n))
30
{ return "0"; }
31
const rounded = Math.round(n * 10) / 10;
32
return Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(1);
33
}
34
26
35
/** Items that can be worn in a given equipment slot. */
27
36
export function listEquippableItemsForSlot (slot)
28
37
{
@@ -837,7 +846,7 @@ export function initTileConfigModal ({
837
846
838
847
const hint = document.createElement("p");
839
848
hint.className = "hint";
840
hint.textContent = "Cast chance is derived from the mob Level (shown as a label). Only Attack (entity) spells are used in combat. Mobs only learn spells their Level can cast.";
849
hint.textContent = "Cast success uses the mob Level as Magic vs the spell tier (same contest as players). Only Attack (entity) spells are used in combat. Mobs only learn spells their Level can cast.";
841
850
wrap.append(hint);
842
851
843
852
if (!Array.isArray(spellsDraft) || !spellsDraft.length)
@@ -865,7 +874,6 @@ export function initTileConfigModal ({
865
874
return;
866
875
}
867
876
const level = Math.max(1, Number(form.querySelector('[name="level"]')?.value) || 1) | 0;
868
const castChance = mobSpellCastChancePercent(level);
869
877
for (let index = 0; index < spellsDraft.length; index++)
870
878
{
871
879
const line = spellsDraft[index];
@@ -893,12 +901,14 @@ export function initTileConfigModal ({
893
901
});
894
902
895
903
const minLv = def?.minMagicLevel | 0 || 1;
904
const tier = def?.tier | 0 || 1;
905
const successPct = spellCastSuccessChancePercent(level, tier);
896
906
const chanceLabel = document.createElement("span");
897
907
chanceLabel.className = "hint";
898
chanceLabel.title = "Cast chance from mob Level";
908
chanceLabel.title = `Channel success: Magic ${level} vs tier ${tier} (difficulty ${tier * 2})`;
899
909
chanceLabel.textContent = level < minLv
900
910
? `needs Lv.${minLv}`
901
: `cast ${castChance}%`;
911
: `cast ${formatCastChancePercent(successPct)}%`;
902
912
903
913
const remove = document.createElement("button");
904
914
remove.type = "button";
@@ -10,7 +10,7 @@ import10
isCentralExchangeSpawner,10
isCentralExchangeSpawner,11
spawnerEquipmentSlot11
spawnerEquipmentSlot12
} from "/shared/definitions/mobs.js";12
} from "/shared/definitions/mobs.js";13
import { mobSpellCastChancePercent } from "/shared/definitions/mobCombat.js";13
import { spellCastSuccessChancePercent } from "/shared/combat/magic.js";14
import { SPELL_DEFINITIONS } from "/shared/definitions/spells.js";14
import { SPELL_DEFINITIONS } from "/shared/definitions/spells.js";15
import { centralExchangeStaffCount } from "/shared/market/exchange.js";15
import { centralExchangeStaffCount } from "/shared/market/exchange.js";16
import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries } from "/shared/definitions/items.js";16
import { ITEM_DEFINITIONS, itemDefinition, isDyeableClothing, listAllItemPickerEntries } from "/shared/definitions/items.js";@@ -23,6 +23,15 @@ import { OVERWORLD_ID, normalizeDimensionId } from "/shared/world/dimensions.js"23
const DOORWAY_STATES = Object.freeze(["door", "ladder", "hole", "cave"]);23
const DOORWAY_STATES = Object.freeze(["door", "ladder", "hole", "cave"]);24
const ITEM_SEARCH_PAGE_SIZE = 40;24
const ITEM_SEARCH_PAGE_SIZE = 40;25
25
26
function formatCastChancePercent (pct)27
{28
const n = Number(pct);29
if (!Number.isFinite(n))30
{ return "0"; }31
const rounded = Math.round(n * 10) / 10;32
return Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(1);33
}34
26
/** Items that can be worn in a given equipment slot. */35
/** Items that can be worn in a given equipment slot. */27
export function listEquippableItemsForSlot (slot)36
export function listEquippableItemsForSlot (slot)28
{37
{@@ -837,7 +846,7 @@ export function initTileConfigModal ({837
846
838
const hint = document.createElement("p");847
const hint = document.createElement("p");839
hint.className = "hint";848
hint.className = "hint";840
hint.textContent = "Cast chance is derived from the mob Level (shown as a label). Only Attack (entity) spells are used in combat. Mobs only learn spells their Level can cast.";849
hint.textContent = "Cast success uses the mob Level as Magic vs the spell tier (same contest as players). Only Attack (entity) spells are used in combat. Mobs only learn spells their Level can cast.";841
wrap.append(hint);850
wrap.append(hint);842
851
843
if (!Array.isArray(spellsDraft) || !spellsDraft.length)852
if (!Array.isArray(spellsDraft) || !spellsDraft.length)@@ -865,7 +874,6 @@ export function initTileConfigModal ({865
return;874
return;866
}875
}867
const level = Math.max(1, Number(form.querySelector('[name="level"]')?.value) || 1) | 0;876
const level = Math.max(1, Number(form.querySelector('[name="level"]')?.value) || 1) | 0;868
const castChance = mobSpellCastChancePercent(level);869
for (let index = 0; index < spellsDraft.length; index++)877
for (let index = 0; index < spellsDraft.length; index++)870
{878
{871
const line = spellsDraft[index];879
const line = spellsDraft[index];@@ -893,12 +901,14 @@ export function initTileConfigModal ({893
});901
});894
902
895
const minLv = def?.minMagicLevel | 0 || 1;903
const minLv = def?.minMagicLevel | 0 || 1;904
const tier = def?.tier | 0 || 1;905
const successPct = spellCastSuccessChancePercent(level, tier);896
const chanceLabel = document.createElement("span");906
const chanceLabel = document.createElement("span");897
chanceLabel.className = "hint";907
chanceLabel.className = "hint";898
chanceLabel.title = "Cast chance from mob Level";908
chanceLabel.title = `Channel success: Magic ${level} vs tier ${tier} (difficulty ${tier * 2})`;899
chanceLabel.textContent = level < minLv909
chanceLabel.textContent = level < minLv900
? `needs Lv.${minLv}`910
? `needs Lv.${minLv}`901
: `cast ${castChance}%`;911
: `cast ${formatCastChancePercent(successPct)}%`;902
912
903
const remove = document.createElement("button");913
const remove = document.createElement("button");904
remove.type = "button";914
remove.type = "button";