Research:Magic

Comments
The cast chance calculation is used in multiple places, some where magicka use may not be important, so there is a, which is normally true for casting/AI use and the inventory spell list, and false for all other UI uses of spell chance. The function returns the weakest school used out of all the effects, which is the skill that will gain progress when the spell is cast. Note that spells that are marked "always succeed" do not seem to contribute to skill progress.

Cast cost
Casting cost is an independent variable in the spell data. For spellmaker generated spells, refer to Spell merchant. Failed casts still incur all costs.

Casting incurs a fatigue hit. which is how Morrowind behaves but is clearly incorrect; a fixed formula is

The GMST fFatigueSpellCostMult is unused.

Comments
Note that this punishes casting difficult (low cast chance) spells versus high willpower enemies. The castChance scaling will go almost guarantee resists if castChance < 25%.

Has an interesting situation, where spells with magnitude _do_ take resistance from willpower but at a very low rate (0.01x due to lack of rescaling) than would be expected, making willpower resistance almost useless for that class of spells.

The way resistance affects the final attribute, is that magnitude is stored untouched, resistance is stored with the active effect, and resistance is applied every time the spell has an application tick. The outward effect is that spell effect tooltips list the original magnitude, without factoring resistance.

Using enchanted items
This makes items last 10 times longer at 100 enchant compared to 10 enchant, making it scale a little too well. MCP uses x = 0.025 * (400 - pcEnchant).

Natural recharge
When an enchanted item is cast by any actor, both on-use or on-strike, the item is placed onto a list of items that need recharging. Every item in this list charges by tickTime * fMagicItemRechargePerSecond every frame, and items are removed when they are full. This list is not saved; instead, on loading a game, all non-fully charged items stored in the savegame are placed on the recharge list.

There is a bug where on-use enchanted items used by an NPC do not get placed on the recharge list after they are cast, resulting in an item that does not appear to charge until the player uses it, or on load/save.

Soulgem charging
Refer to Player Craft Skills.

Magic effects
Spells are combinations of one or more effects, which have associated code specific to the effect, and properties which cover cast ranges, resistances and other generalized behaviours that may be shared by a small set of effects.

Effect attributes
All actors have "hidden" attributes that effects apply to, to allow effects to stack, have resistance applied and counteract each other. These attributes are saved with actors, appearing in the actor data in the same order. All effect attributes are applied and stored as integers. Resists and weaknesses are unified under the Resist- attributes, with resistances being positive and weaknesses being negative. Non-magnitude spells have an effective attribute of 1 when active.

Some attributes provide resistance values vs magic effects when calculating magic mitigation. These resistances only apply in certain cases, check magic resistance.

Effect flags
These are the properties of magic effects. Excluding flags 0x200, 0x400 and 0x800 they are all obtained from the code and are not affected by mods.

Flags for all effects:

int effectFlags[] = { 0x11c8, 0x11c0, 0x11c8, 0x11e0, 0x11e0, 0x11e0, 0x11e0, 0x11d0, 0x11c0, 0x11c0, 0x11e0, 0x11c0, 0x11184, 0x11184, 0x1f0, 0x1f0, 0x1f0, 0x11d2, 0x11f0, 0x11d0, 0x11d0, 0x11d1, 0x1d2, 0x1f0, 0x1d0, 0x1d0, 0x1d1, 0x1f0, 0x11d0, 0x11d0, 0x11d0, 0x11d0, 0x11d0, 0x11d0, 0x11d0, 0x11d0, 0x11d0, 0x1d0, 0x1d0, 0x11c8, 0x31c0, 0x11c0, 0x11c0, 0x11c0, 0x1180, 0x11d8, 0x11d8, 0x11d0, 0x11d0, 0x11180, 0x11180, 0x11180, 0x11180, 0x11180, 0x11180, 0x11180, 0x11180, 0x11c4, 0x111b8, 0x1040, 0x104c, 0x104c, 0x104c, 0x104c, 0x1040, 0x1040, 0x1040, 0x11c0, 0x11c0, 0x1cc, 0x1cc, 0x1cc, 0x1cc, 0x1cc, 0x1c2, 0x1c0, 0x1c0, 0x1c0, 0x1c1, 0x11c2, 0x11c0, 0x11c0, 0x11c0, 0x11c1, 0x11c0, 0x21192, 0x20190, 0x20190, 0x20190, 0x21191, 0x11c0, 0x11c0, 0x11c0, 0x11c0, 0x11c0, 0x11c0, 0x11c0, 0x11c0, 0x11c0, 0x11c0, 0x1c0, 0x11190, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x9048, 0x11c0, 0x1180, 0x1180, 0x5048, 0x5048, 0x5048, 0x5048, 0x5048, 0x5048, 0x1188, 0x5048, 0x5048, 0x5048, 0x5048, 0x5048, 0x1048, 0x104c, 0x1048, 0x40, 0x11c8, 0x1048, 0x1048, 0x1048, 0x1048, 0x1048, 0x1048 };

Specific magic effects
While all magic effects have programmed behaviour, there are specific ones that may have complicated side effects. Any particular information for a single effect is documented here.

Corprus
The corprus effect is closely linked to the corprus spell. Every 24 hours after the contraction of corprus, all other effects on the same spell as corprus, that also have effect flag 0x1000 (APPLIED_ONCE) are re-applied in a special case. This increases the magnitude of the effect, while correctly recording the amount applied so it can be removed later. Without other effects on the spell, corprus does nothing.

On removal, the drain spells are removed normally, while another special case interdicts any removal of positive attribute effects. Instead, a fortification is converted into a restore effect of the same magnitude.

Sun Damage
TitleCaps variables indicate values taken from the morrowind.ini section related to that object.