[High] [Bug] Spells from enchanted equipment bypass mana cost / never fire during spire combat #345
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Bug: Spells from enchanted weapons do not cost mana while climbing the spire
Description
There are actually two interrelated bugs affecting spells from enchanted equipment during spire climbing:
Bug A: Equipment spell enchantments never fire during combat (no damage, no mana cost)
Root cause:
equipmentSpellStatesincombatStore.tsis initialized as[](empty array) and is never populated from the player's actual equipped gear before or during the combat tick.Code path:
combatStore.tsline 68:equipmentSpellStates: []— starts emptygameStore.tsline ~291: The combat tick result writesequipmentSpellStates: cr.equipmentSpellStatesback, butcr.equipmentSpellStatesis just a copy of the empty input arraycombat-actions.tsline 130:const updatedEquipmentSpellStates = [...state.equipmentSpellStates];— spreads the empty arraycombat-actions.tslines 198-250: The equipment spell loop iterates over this empty array → never executesThe utility function
getActiveEquipmentSpells()incombat-utils.ts(lines 335-360) correctly scans equipped instances foreffect.type === 'spell'enchantments, but it is only used by the DPS calculation (getTotalDPS) and is never called during the combat tick setup. It is never wired intoequipmentSpellStates.Result: Casters, staves, and other equipment with spell-type enchantments (e.g.,
spell_manaBolt,spell_fireball) produce zero combat damage. Since they never fire, they also never deduct mana — but not because of a bypass, rather because the system is completely disconnected.Bug B: Weapon enchantment spells (fireBlade, frostBlade, lightningBlade, voidBlade) have mana costs defined but never consume mana
Root cause: Weapon enchantments like
fireBladeare defined inconstants/spells-modules/enchantment-spells.tswith costs (e.g.,rawCost(1)for fireBlade). They haveisWeaponEnchant: true. However, they are not processed through the equipment spell state system (Bug A makes this irrelevant). Instead, they are processed throughcalcMeleeDamage()incombat-utils.ts(lines 298-333), which:effect.type === 'special'enchantments (noteffect.type === 'spell')canAffordSpellCostordeductSpellCost— melee attacks are freeCode path:
combat-actions.tslines 218-260: Melee sword attack loopcalcMeleeDamage()which applies elemental bonus from weapon enchantmentscanAffordSpellCostguardResult: If a player enchants a sword with fireBlade (which has a defined cost of
rawCost(1)), the fire damage bonus is applied to melee attacks for free. Thecostfield on theSpellDefis never consulted for weapon-enchant spells during melee processing.Severity Assessment
Files Involved
src/lib/game/stores/combatStore.ts(line 68)equipmentSpellStates: []— never populatedsrc/lib/game/stores/combat-actions.ts(lines 130, 198-250)src/lib/game/stores/combat-actions.ts(lines 218-260)src/lib/game/stores/gameStore.ts(~line 270-295)src/lib/game/utils/combat-utils.ts(lines 335-360)getActiveEquipmentSpells()— correct logic, only used for DPS calcsrc/lib/game/utils/combat-utils.ts(lines 298-333)calcMeleeDamage()— no mana deductionsrc/lib/game/constants/spells-modules/enchantment-spells.tsReproduction Steps
spell_manaBoltorspell_fireball)For weapon enchants:
Related Code Observations
weaponMana/weaponManaMax/weaponManaRegen/weaponManaTypefields exist onEquipmentInstance(intypes/equipment.ts) and incrafting-initial-state.ts, suggesting a "weapon mana pool" was planned for weapon enchant costs but was never implemented.gameStore.tsline ~281 passesattackSpeedMult: 1(hardcoded) toprocessCombatTick, ignoring the computedattackSpeedMultiplierfromcomputeAllEffects(). This affects casting speed but is separate from the mana cost bug.Starting work on Issue #345. Two bugs: (A) equipmentSpellStates never populated from equipped gear, (B) weapon enchant spells bypass mana cost in melee. Reading gameStore.ts combat tick setup to understand the wiring.
✅ Fixed Issue #345 (both bugs):
Bug A - Equipment spell enchantments never fire:
getActiveEquipmentSpells()call ingameStore.tscombat tick setup to populateequipmentSpellStatesfrom equipped gear beforeprocessCombatTickrunsspell-type enchantments (e.g., spell_manaBolt on casters/staves) now properly fire during combatBug B - Weapon enchant spells bypass mana cost:
deductWeaponEnchantCosts()helper incombat-damage.tscombat-actions.tsnow deducts mana for weapon enchant spells (fireBlade, frostBlade, lightningBlade, voidBlade) per hitAll 1141 tests pass (65 test files), no regressions.