Skip to content

Overhaul magic effects

Evil Eye requested to merge Assumeru/openmw:effective_magic into master

Fixes #1751 (closed), #4297 (closed), #4414 (closed), #5198 (closed), #5207 (closed), #5454 (closed), #5596 (closed), #5621 (closed), #5801 (closed), #5863 (closed), #6087 (closed).

This MR changes magic effects to be tracked in the ActiveSpells class. Previously effects were split between ActiveEffects (temporary effects), Spells (abilities, diseases), and InventoryStore (CE enchantments).

Magic effects are now applied using a function that is called every frame, and a function that is called when the effect is removed. Effects with the AppliedOnce flag do nothing except in the first frame. Effects without the flag have their magnitudes recalculated every frame.

Corprus was also overhauled (for the third time now?) because it didn't work for effects other than Fortify/Drain Attribute. As mentioned on the research page of the wiki, Corprus should reapply every AppliedOnce effect. I confirmed Morrowind.exe behaves this way by modifying the disease to apply Blind and Summon Ancestor Ghost (the latter summons an additional ghost every 24 hours and only despawns one when cured.)

Summons now store their actor ID in the effect that spawned them (reusing mArg which was previously used only for attributes and skills). This allowed me to simplify the summons map by removing redundant data.

Some progress was made towards #4508 (closed) by storing the inventory slot of the enchanted item, but it's not possible to implement the feature satisfactory without assigning a (persistent) unique identifier to magic items. Potentially ties in with #6148 (closed). Fixing these issues is left to future MRs as this one was getting plenty big already.

Most of the interesting code is in the new spelleffects.cpp file.

Edited by Evil Eye

Merge request reports