Final Fantasy IV Research & Development / Re: The Holy Grail - Magic Algorithm
« on: February 23, 2008, 01:55:43 AM »Would a code tag help with that organization at all?
Laziness ftw?
øA slickproductions.org /forum/index.php?PHPSESSID=4rpmddblr0qsa28id791kk1410&action=profile;u=6;area=showposts;start=3120 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexa1fd-2.html slickproductions.org /forum/index.php?PHPSESSID=4rpmddblr0qsa28id791kk1410&action=profile;area=showposts;u=6 e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/indexa1fd-2.html.z x &žh^ ÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ ÀK úÑ OK text/html ISO-8859-1 gzip @øÕ úÑ ÿÿÿÿÿÿÿÿ Wed, 11 Mar 2020 08:31:58 GMT 0ó° °® 0® P® €§² ð® %žh^ ÿÿÿÿÿÿÿÿV. úÑ
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Would a code tag help with that organization at all?
while (Target Count > 0)
{
reset Spell Type Multiplier();
Succesful Hit = false;
while (Spell Type Multiplier > 0)
{
if ((rand(0, 99) <= Spell Hit Rate) || ((Level Check == true) && (rand(0, Target's Level) <= rand(0, Caster's Level)))
{
Successful Hit = true;
break;
}
Spell Type Multiplier--;
}
if(Successful Hit == false)
{
return false;
}
Target Count--;
}
return true;
while (Target Count > 0)
{
if((attack type == status effect)&&(!target.isresistant(status effect))
{
reset Spell Type Multiplier();
while (Spell Type Multiplier > 0)
{
if ((rand(0, 99) <= Spell Hit Rate) || ((Level Check == true) && (rand(0, Target's Level) <= rand(0, Caster's Level)))
{
apply status effect(); // if immune/resistant, silently fail? probably won't matter
break; // success
}
Spell Type Multiplier--;
}
}
Target Count--;
}
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?
//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--;
}

Those look like really round numbers, now I'm wondering what the formula is.
BLACK:
the effectiveness of black magic is dependent on the WIS stat of the caster.
some spells have a base damage, which is then multiplied by the black magic
multiplier, B, which is determined as B = [ WIS / 4 ] + 1.
WHITE:
likewise for white magic, the power of the spell is dependent only on WILL.
there is a similar white magic multiplier, W = [ WILL / 4 ] + 1.