øA slickproductions.org /forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&action=printpage;topic=329.0 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index414b.html slickproductions.org /forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=329.0 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index414b.html.z x à¡g^ ÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ àž/ öp OK text/html ISO-8859-1 gzip 8:Ö öp ÿÿÿÿÿÿÿÿ Tue, 10 Mar 2020 14:35:35 GMT 0ó° °® 0® P® €§² ð® ß¡g^ r öp
Print Page - The Holy Grail - Magic Algorithm
Board of Slick
Library of the Ancients => Final Fantasy IV Research & Development => Topic started by: Deathlike2 on February 22, 2008, 03:56:38 AM
Title: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on February 22, 2008, 03:56:38 AM
For those that care, I believe I've figured out the basic magic damage algorithm. Remember to truncate where applicable.
For reference:
Split Damage Modifier: Spell Targets Only All Enemies or All Allies = 1 Every Other Spell = 1/number of targets List of spells that ignore split damage can be found here: http://slickproductions.org/forum/index.php?topic=359.0
Undead Modifier: Drain Elemental (Osmose/Psych and Drain) vs Undead = -1 Unapplicable = 1
Note: Sylph works against Undead w/o this penalty for its "special" Drain attack.
Absorb Modifier: Target Absorbs vs Element = -1 Unapplicable = 1
Note: If the target reacts to any of the elemental attacks, continue using the multiplier during an uninterrupted attack such as one given by Zeromus EG from FF4A. Stop using the multiplier when the uninterrupted attack ends. Elemental multipliers do not stack.
Appendix: Refer to this for how the game deals with elemental magic attacks - http://slickproductions.org/forum/index.php?topic=426.0
Healing Modifier: Target is Ally = -1 Target is Undead = 1 Unapplicable = 1
Magic Defense:
Base Magic Defense (character) = sum of all armor magic defense values Note: Unequipped sections have a magic defense of 0. Base Magic Defense (monster) = Whatever is listed by the game
Note: If Magic Defense > 255 in your equipment, Magic Defense = 255. This is here just so you know.
Magic Defense = Base Magic Defense * Magic Defense Modifier
Magic Evade:
Base Magic Evade (character) = (Wisdom (Intelligence) + Will (Spirit))/8 + all the armor magic evade values Base Magic Evade (monster) = 0
Magic Evade Modifier: Target is Monster and its Magic Defense is 255 sets Base Magic Evade = 99 Target is Blind = 1/2 Unapplicable = 1 Note: The Monster has 99 Magic Evade, regardless of Blind status...
If Base Magic Evade > 99, Base Magic Evade = 99.
Magic Evade = Base Magic Evade * Magic Evade Modifier
Note: When Monster Magic Defense is naturally at 255 (with no help from Shell), they are intentionally "invincible" to magic.
Magic Defense Multiplier:
Base Magic Defense Multiplier (character) = Agility/32 + (Wisdom (Intelligence) + Will (Spirit))/32 Base Magic Defense Multiplier (monster) = irrelevent
Note: Since monster magic evade = 0, it doesn't matter what the magic evade value is, except when monster magic defense = 255.
Magic Defense Multiplier Modifer: Target is Monster and its Magic Defense is 255 sets Magic Defense Multiplier = 99 Target has Toad status sets Magic Defense Multiplier = 0 Unapplicable = Magic Defense Multiplier = Base Magic Defense Note: When Monster Magic Defense is naturally at 255 (with no help from Shell), they are intentionally "invincible" to magic.
Spell Hit Rate:
Base Spell Hit Rate = Whatever is stored internally If Base Spell Hit Rate > 128, Base Spell Hit Rate -= 128. List of spells affected by the 128 point difference can be found here: http://slickproductions.org/forum/index.php?topic=360.0
Spell Hit Rate Modifier: Weapon Used As Item Magic sets Spell Hit Rate = 100 Caster is Blind = 1/2 **Caster is in Slot 1 (the Middle position) = 5/4 Unapplicable = 1
Note: Spells cast by a weapon used as an item have a 100% hit rate, regardless of blind status or the original spell's hit rate.
Spell Hit Rate = (Base Spell Hit Rate + (Wisdom (Intelligence) or Will (Spirit) or Monster''s Magic Stat)/2) * Spell Hit Rate Modifier
Spell Power:
Base Spell Power (for most spells) = Whatever is listed internally for that spell * 4 Base Spell Power (Summon spells) = Whatever is listed internally for that spell * 8
Elemental Power Multiplier: Weak vs Element and Weak+ = 4 Weak vs Element = 2 Resist vs Element = 1/2 Immune vs Element = 0 Unapplicable = 1
Note: If the target reacts to any of the elemental attacks, continue using the multiplier during an uninterrupted attack such as one given by Zeromus EG from FF4A. Stop using the multiplier when the uninterrupted attack ends. Elemental multipliers do not stack.
Appendix: Refer to this for how the game deals with elemental magic attacks - http://slickproductions.org/forum/index.php?topic=426.0
Spell Power = Base Spell Power * Elemental Power Multiplier * (rand (100, 150)/100) - Target's Magic Defense If Spell Power < 0, Spell Power = 0
Or... you could also say:
Spell Power = Base Spell Power * Elemental Power Multiplier * (rand (100, 150)/100) If Spell Power < Target's Magic Defense, then Spell Power = 0. Else Spell Power -= Target's Magic Defense.
Note: You only need to randomize once for the algo to work properly.
Spell Power Multiplier:
Spell Power Multiplier (White) = Will (Spirit) /4 + 1 Spell Power Multiplier (Black) = Wisdom (Intelligence) /4 + 1 Spell Power Multiplier (Ninja) = Wisdom (Intelligence) /4 + 1 Spell Power Multiplier (Summon) = Wisdom (Intelligence) /4 + 1 Spell Power Multiplier (Monster) = Whatever their magic stat says /4 + 1 Spell Power Multiplier (Weapon Magic) = Whatever that value is listed **Spell Power Multiplier (Status Effects) = 1
Note: Blind status does not hurt the weapon magic's spell multiplier.
**Refer to this thread for status effect spells that manipulate this value: http://slickproductions.org/forum/index.php?topic=370.0
//Multiplier Madness! - These checks redo the spell power multiplier based on spell hit rate and target's magic evasion.
New Spell Power Multiplier = Caster's Spell Power Multiplier; // initial
while (Caster's Spell Power Multiplier > 0) { if (rand (0, 99) <= Spell's Hit Rate) // check if individual spell hit is successful due to spell hit rate { while (Target's Magic Defense Multiplier > 0) // consider the Magic Defense Multiplier the number of chances to evade magic hits // we try again on failure and stop when there is no more { Target's Magic Defense Multiplier--; if (rand (0,99) < Target's Magic Evade) // see if the target evades the magic hit { New Spell Power Multiplier--; break; // exit this loop since target has evaded successfully } } else // executed when individual spell hit fails to hit target and ignores magic evade - think of Tellah's suckage { New Spell Power Multiplier--; } Caster's Spell Power Mulitplier--; }
Here we go!
Damage = New Spell Power Multiplier * Spell Power * Split Damage Modifier * Undead Modifer * Absorb Modifier * Healing Modifier;
If Damage = 0, then Damage = 1;
It is worth pointing out that monster magic evade = 0. Attack magic generally has a hit rate of 100%, although Venom/Poison is "the exception", since it does both inflict a status and "deal damage".
HP based damage algo can be found here - http://slickproductions.org/forum/index.php?topic=448.0
Feel free to comment, question or mock my algo. If you mock it, :banonsmash:
Title: Re: The Holy Grail - Magic Algorithm
Post by: Entroper on February 22, 2008, 04:37:58 AM
Most of that looks spot-on. I have but one question: From where are you getting the rand(100, 150)/100 part? It's in the logical place in the formula, and it seems reasonable. But does the 1-1.5 number come from somewhere in the code, or from testing, or what exactly?
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on February 22, 2008, 04:54:10 AM
Most of that looks spot-on. I have but one question: From where are you getting the rand(100, 150)/100 part? It's in the logical place in the formula, and it seems reasonable. But does the 1-1.5 number come from somewhere in the code, or from testing, or what exactly?
It's the randomness factor. It is the same factor when you deal physical damage.
Test Cure1 while at 99 Spirit/Will in battle. The range of the healing is 400-600. You will then see why it is randomized.
I'm still tweaking the formula, so stay tuned.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on February 22, 2008, 04:38:34 PM
Non-Damage Magic Algo (for most, if not all other spells, generally applicable to status changing magic)
Target Count: Single = 1 All Targets = number of targets
Level based spell reference: http://slickproductions.org/forum/index.php?topic=358.0 Spells (ones that apply status effects) affected by spell multiplier manipulation: http://slickproductions.org/forum/index.php?topic=370.0
:omghax: Looks like a nice programming-esque representation of how they play out. This could translate to easily makable (yes, that's spelled correctly, even though it doesn't look like it) assembly code...
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on February 23, 2008, 02:16:52 AM
:omghax: Looks like a nice programming-esque representation of how they play out. This could translate to easily makable (yes, that's spelled correctly, even though it doesn't look like it) assembly code...
Probably, but it won't be calculated in that order for a number of reasons...
1) 2x hits can still deal 1 damage total to the same character. (Though that's for physical attacks).
2) Multi-hits (consective uninterruptable attacks... magic and otherwise) involving elementals and absorption accumulate healing instead of damage.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on February 28, 2008, 12:20:02 AM
Most of that looks spot-on. I have but one question: From where are you getting the rand(100, 150)/100 part? It's in the logical place in the formula, and it seems reasonable. But does the 1-1.5 number come from somewhere in the code, or from testing, or what exactly?
Btw, BSiron's FAQ mentions 3/2 in the damage range calculations, which is where the number comes from if you think about it.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 01, 2008, 03:13:45 PM
Fixed the magic algo like I did with the attack algo. Attack magic is always applied against magic defense. The Magic Defense Multiplier's significance is beneficial for Magic Evade to reduce the damage intake similar to what the Defense Multiplier does for Evade.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 02, 2008, 01:47:48 AM
Fixed a huge logical and mathematical error. The magic evade is not supposed to be tested against the spell hit rate, but that out of 100%. :tongue:
Title: Re: The Holy Grail - Magic Algorithm
Post by: Imzogelmo on March 02, 2008, 02:34:59 AM
Any chance of a comprehensive Algorithm FAQ like we've long had with FFVI? Something that can factor in the chance to hit and amount of damage for physical and magical attacks, with either monster or characters attacking? And if there are any exceptions to the rules for such (special commands, things that skip certain steps, etc.)?
Not to mention other algos, like when an attack occurs, ATB timers, etc.?
Something verbose enough to translate into an Excel spreadsheet (or the sheet itself :tongue:).
Reason I ask is that I'd like to be able to write a general enough set of functions that could handle FFIV-FFVI with some switches for different rule sets, of course.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 02, 2008, 03:00:42 AM
Any chance of a comprehensive Algorithm FAQ like we've long had with FFVI? Something that can factor in the chance to hit and amount of damage for physical and magical attacks, with either monster or characters attacking? And if there are any exceptions to the rules for such (special commands, things that skip certain steps, etc.)?
Not to mention other algos, like when an attack occurs, ATB timers, etc.?
Something verbose enough to translate into an Excel spreadsheet (or the sheet itself :tongue:).
Reason I ask is that I'd like to be able to write a general enough set of functions that could handle FFIV-FFVI with some switches for different rule sets, of course.
I was thinking of that - http://slickproductions.org/forum/index.php?topic=190.0
The issue though is that noone seems to have dumped any code relating to the ATB system to verify any of the algos. I haven't even touched the ATB system because it is still relatively foreign to me (I mean, until FF4A, there was no ATB bar that I could even think of referencing against).
However, the bits and pieces of info about stuff are lingering all around this forum, so you are welcome to test/verify and contribute if you can. I'm bored to death thinking of stuff to be testing... the next commands worth a damn looking at is Throw and Steal at this point...
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 02, 2008, 06:28:36 PM
Finding this tidbit... http://s-endo.skr.jp/ff4magparam.txt , I am adjusting the formulas accordingly.
Most notably, I didn't know that Piggy had a atrocious 10% hit rate.
Other changes include the Summon multiplier... the multiplier is doubled naturally. The spell power of the summon is consistant through since it doesn't deal 9999 against Behemoths... which implies that the spell multiplier is simply doubled.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 03, 2008, 01:18:46 AM
Updated spell algo to include updated Sylph info and level check info.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 03, 2008, 02:31:21 AM
Updated info to include new split damage findings.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 03, 2008, 11:19:36 PM
Updated spell algo to factor in new blind status findings.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 04, 2008, 02:00:46 AM
Corrected spell formula flaw. Elemental weakness does not set the target's magic defense to 0. Spell Power is adjusted by elemental weakness or resistance.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 04, 2008, 04:50:07 PM
Corrected spell multiplier and spell base power math for summon spells.
Man, I should pay more attention to BSiron's info.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 04, 2008, 06:41:57 PM
Like the physical damage algo, the magic damage algo follows the multiplier rule as well.
It is actually possible that a blind Tellah fail to cast any attack spell successful on a target.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 12, 2008, 04:04:24 PM
Updated algo to factor in weapons that cast magic when used as an item.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 13, 2008, 06:38:14 PM
Updated info to factor in elemental immunity.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 13, 2008, 10:53:17 PM
Clarified sections regarding elementals with a separate thread.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 20, 2008, 01:41:47 AM
Refer to this thread: http://slickproductions.org/forum/index.php?topic=442.0
Thanks to Phoenix for his spell hit rate findings, and the algo is updated to reflect that. I would've never noticed or found them myself...
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 20, 2008, 09:12:05 AM
Finally updated the new spell multiplier bit info that affects status effects particularly.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 20, 2008, 11:46:10 AM
Added a link to the HP damage algo.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on March 21, 2008, 07:15:29 AM
Added Phoenix's find on Toad status and monster's "invicibility" to magic info.
Title: Re: The Holy Grail - Magic Algorithm
Post by: Deathlike2 on June 06, 2008, 03:11:50 PM
I'm currently convinced that all spells that target the allies will always have the targets having 0 magic defense and 0 magic evade.