Research:Magic

From OpenMW Wiki
Revision as of 20:17, 7 September 2012 by Hrnchamd (talk | contribs) (→‎Magic effects: Added effect attributes)
Jump to navigation Jump to search

Spell Casting

Chance of successful Spell Cast

Actions affected On cast attempt
Description
Implementation status not started yet
Analysis status Accurate, but requires more work; spell skill depends on dominant school for multi effect spells, but is unspecified; Sound spell effect is not accounted for
chance = (Spells Skill * 2 + Willpower / 5 + Luck / 10 - SpellCost + CastPenalty) * (CurrentFatigue + MaximumFatigue * 1.5) / (MaximumFatigue * 2)


Cast cost

Actions affected On cast attempt
Description
Implementation status not started yet
Analysis status Does not account for multiple effect spells, non-duration spells or fixed magnitude spells
cost = 0.1 + ((min effect value / 20) + (max effect value / 20)) * ((duration - 1) / 2) + (range / 40).

x1.5 for ranged spell. Constant effect enchantments use fEnchantmentConstantDurationMult as their duration values (default 100).

  • Touch/Self
cost = base cost * ((max + min) * duration * 0.025 + area * 0.0125)
  • Target
cost = base cost * ((max + min) * duration * 0.3125 + area * 0.0125)
  • Constant effect
cost = base cost * ((max + min) * 2.5 + area * 0.025)

The base cost are here


Magic Damage and Mitigation

Actions affected On magic hit
Description
Implementation status not started yet
Analysis status Ignores willpower resists; which effects magic resistance apply to; reflection and absorption
Spell Damage = Damage - Damage * ( Resistance - Weakness ) / 100


Item Charge

Using enchanted items

Actions affected On enchanted item use
Description Charge consumed on use depends on skill.
Implementation status not started yet
Analysis status Verified; but a poorly scaling mechanic
x = 0.01 * (110 - pcEnchant)
charge used = int(x * enchant base charge cost)

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

Actions affected On game tick
Description Enchanted items may gain charge over time.
Implementation status not started yet
Analysis status Verified

Every item in the player's inventory charges by tickTime * fMagicItemRechargePerSecond. Items anywhere else do not charge.


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.

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

Index Name Provides resistance against magic effects
0 Fortify Attack
1 Sanctuary Disintegrate *
2 Resist Magicka Drain *, Damage *, Absorb *, Weakness to *, Burden, Charm, Silence, Blind, Sound, Calm, Frenzy, Demoralize, Rally, Turn Undead
3 Resist Fire Fire
4 Resist Frost Frost
5 Resist Shock Shock
6 Resist Common Disease Vampirism
7 Resist Blight Disease
8 Resist Corprus Corprus
9 Resist Poison Posion
10 Resist Paralysis Paralysis
11 Chameleon
12 Resist Normal Weapons
13 Water Breathing
14 Water Walking
15 Swift Swim
16 Jump
17 Levitate
18 Shield
19 Sound
20 Silence
21 Blind
22 Paralyze
23 Invisibility
24 Fight
25 Flee
26 Hello
27 Alarm


Effect flags

These are fixed properties of magic effects. Obtained from the code, these are not affected by mods.

Bit Enum name Description
0x1 TARGET_SKILL Affects a specific skill, which is specified elsewhere in the effect structure.
0x2 TARGET_ATTR Affects a specific attribute, which is specified elsewhere in the effect structure.
0x4 NO_DURATION Has no duration. Only runs effect once on cast.
0x8 NO_MAGNITUDE Has no magnitude.
0x10 NEGATIVE Counts as a negative effect. Interpreted as useful for attack, and is treated as a bad effect in alchemy.
0x20 Unverified.
0x40 CAST_SELF Allows range - cast on self.
0x80 CAST_TOUCH Allows range - cast on touch.
0x100 CAST_TARGET Allows range - cast on target.
0x200 - 0x20000 Unverified.


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
};