Calculating Magic Damage

==Actual Damage==
Actual Damage is calculated by multiplying the following factors in order and flooring after each step.
1) D
2) Multiple-Target Damage Reduction
3) resist
4) Staff Bonus
5) Day | Weather Bonus
6) Magic Burst Bonus
6a) Magic Burst Bonus Gear #1
6b) Magic Burst Bonus Gear #2
7) MAB / MDB
8) Target Magic Damage Adjustment
There is reason to believe that the magic burst portion is calculated prior to MAB. Further testing would be necessary to confirm the order of the other parts with respect to magic bursts.
==Explanation of Factors==
===Calculation of D===
Each magic tier has an inherent mutliplier value M.
Each magic spell has a base value V.
Let dINT be (Caster's INT - Target's INT).
For dINT < 0: D = V + dINT (when dINT is a penalty, the tier mult. is always 1)
For dINT > 0, but less than some inflection point: D = V + (dINT * M)
For dINT > 0, but after some inflection point: D = V + (const + (dINT-const) * M / 2))
(above some critical value, adding INT becomes half as effective)
For dINT > 0, but after some cap: D = cap
M = 1.0 for all I/II single-target nukes
M = 1.0 for all -ga spells up to Blizzaga II
M = 1.5 for all III single-target nukes
M = 1.5 for all -ga spells Thundaga II and beyond
M = 2.0 for all IV and AM I/II spells.
V values by spell:
Spell 	Earth	Water	Wind	Fire	Blizzard	Thunder
I 	10 	16 	25 	35 	46 	60
II 	78 	95 	113 	133 	155 	178
III 	210 	236 	265 	295 	320 	345
IV 	381 	410 	440 	472 	506 	541
I-ga 	56 	74 	93 	120 	145 	172
II-ga 	201 	232 	266 	312 	350 	392
III-ga	434 	480 	527 	589 	642 	697
AM I 	577 	630 	552 	657 	526 	603
AM II 	710 	710 	710 	710 	710 	710
===Multiple-Target Damage Reduction===
single-target spells = 1.0
-ga spells with one target = 1.0
-ga spells with 2 through 9 targets = 0.9 - 0.05T where T is the number of targets
-ga spells with 10 or more targets = 0.4
===Resist===
resist = 1, 1/2, 1/4, 1/8, or 1/16
===Staff Bonus===
HQ Staff matching element = 1.15
NQ Staff matching element = 1.1
No staff = 1.0
NQ Staff ascendant element = 0.9
HQ Staff ascendant element = 0.85
===Day of the Week | Weather Bonus===
Day | Weather Bonus is calculated as:
1.0
+0.1 for the correct day
-0.1 for the weak day
+0.05 for Sorcerer's Tonban
+0.1 for single weather
+0.25 for double weather
This term is capped at 1.35, even in the presence of day, double weather, and Sorcerer's Tonban.
===Magic Burst Bonus===
MB bonus is 1.0 for no MB and 1.3 for a 2-WS renkei, gaining 5% per extra WS in the renkei series (i.e. 1.35, 1.4 etc)
Sorcerer's Gloves multiply the magic burst bonus by 1.05.
Static Earring multiplies the magic burst bonus by 1.05.
ex. floor(floor(floor(floor(... * MB) * Sorc.Gloves) * St.Earring) * ...) ->
floor(floor(floor(floor(... * 1.3) * 1.05) * 1.05) * ...)
===Magic Attack Bonus / Magic Defense Bonus===
MAB is divided by MDB.
MAB is as we know it (i.e. MAB I = 1.2, MAB II = 1.24 etc). Items with the description "Magic Atk. Bonus"+X means to add X/100 to the current MAB. For example, Moldavite Earring which states "Magic Atk. Bonus"+5 means to add 0.05. Correct element potency merits are +2 MAB per merit, which adds 0.02.
MDB is 1.0 if not present and depends on the target of the magic.
After calculating the ratio of MAB to MDB, this term is truncated to two decimal places. 
===Target Magic Damage Adjustment===
Target Magic Damage Adjustment means exactly what it sounds like. Certain targets are designed to take more or less % damage. Values for this portion of the equation appear to use the 256 number system. The base value is 1 (256/256) and is adjusted according to the fractional values in the charts below. The values are added together in the presence of more than one adjustment.
ex. Ahriman have a TMDA value of (1 - 64/256) = 192/256
ex. An Evil Weapon with Shell has a TMDA value of (1 - 32/256 - 24/256) = 200/256
Note: For player targets, this value is capped at 128/256 (50%).
Monster 	Base Adjustment (%)	Adjustment (256ths)
Ahriman 	75% 	-64/256
Flans 	125% 	+64/256
Cardians 	75% 	-64/256
Corse 	75% 	-64/256
Demons 	75% 	-64/256
Evil Weapons 	87.5% 	-32/256
Ghrahs 	87.5% 	-32/256
Magic Pots 	50% 	-128/256
Effect 	Base Adjustment (%)	Adjustment (256ths)
Shell 	90.6% 	-24/256
Shell II 	85.9% 	-36/256
Shell III 	81.2% 	-48/256
Shell IV 	78.1% 	-56/256
Shell V (1 merit) 	75.8% 	-62/256
Shell V (2 merits)	75% 	-64/256
Shell V (3 merits)	74.2% 	-66/256
Bubble Curtain 	50% 	-128/256
Shining Ruby 	96% 	-10/256
Player Equipment 	varies 	varies
==Sources==
http://www.bluegartrls.com/forum/viewtopic.php?p=297899#297899
http://ffxi.allakhazam.com/db/jobs.html?fjob=3;mid=1137029463237848499;num=50;page=1
http://ff11.s101.xrea.com/index.php?%B4%F0%C1%C3%C3%CE%BC%B1#content_1_7