Difference between revisions of "FF7/DamageFormula"

From Final Fantasy Inside
< FF7
Jump to navigation Jump to search
my_wiki>NFITC1
(Added detailed damage calculations. Accuracy functions will have to wait.)
my_wiki>NFITC1
(Damage Calculations)
Line 145: Line 145:
  
  
==Damage Calculations==
+
=Damage Calculations=
 
For standard damage functions
 
For standard damage functions
  
 
X0:
 
X0:
:Sets Target's 02h flag to 1. (Unknown effect)
+
<pre>Sets Target's 02h flag to 1. (Unknown effect)</pre>
 
----
 
----
 
X1:
 
X1:
:If Attack Property "Always Critical" is Set
+
<pre>If Attack Property "Always Critical" is Set
::Set Critical Damage Flag
+
Set Critical Damage Flag
:End If
+
End If
  
:x = ( Actor's Level * Actor's (M)Attack ) / 32
+
x = ( Actor's Level * Actor's (M)Attack ) / 32
:y = ( Actor's Level + Actor's (M)Attack ) / 32
+
y = ( Actor's Level + Actor's (M)Attack ) / 32
:z = Actor's (M)Attack + ( x * y )
+
z = Actor's (M)Attack + ( x * y )
:z = z * ( 512 - target's defense ) * Attack's Power
+
z = z * ( 512 - target's defense ) * Attack's Power
:Damage = z / 4096
+
Damage = z / 4096
  
:If Critical Damage Flag is set
+
If Critical Damage Flag is set
::Damage = Damage * 2
+
Damage = Damage * 2
:End If
+
End If
  
:If Actor's Statuses include Berserk
+
If Actor's Statuses include Berserk
::Damage = Damage * 3 / 2
+
Damage = Damage * 3 / 2
:End If
+
End If
  
:Long_Range = 0
+
Long_Range = 0
:If Target is in Back Row
+
If Target is in Back Row
::Set Long_Range = 1
+
Set Long_Range = 1
:End If
+
End If
:If Attack is Short Range OR Command is Enemy Attack
 
::If Actor is in Back Row
 
:::Long_Range = 1
 
::End If
 
:Else
 
::Long_Range = 0
 
:End If
 
:If Long_Range != 0
 
::Damage = Damage / 2
 
:End If
 
  
:If Target is Defending
+
If Attack is Short Range OR Command is Enemy Attack
::Damage = Damage / 2
+
If Actor is in Back Row
:End If
+
Long_Range = 1
 +
End If
 +
Else
 +
Long_Range = 0
 +
End If
  
:If Target's Back is exposed
+
If Long_Range != 0
::Damage = Damage * ( Target's Back Attack Modifier / 8 )
+
Damage = Damage / 2
:End If
+
End If
  
:If Actor's Statuses includes Frog
+
If Target is Defending
::Damage = Damage / 4
+
Damage = Damage / 2
:End If
+
End If
  
:Damage = Sadness( Damage )
+
If Target's Back is exposed
:Damage = Split( Damage, 0 )
+
Damage = Damage * ( Target's Back Attack Modifier / 8 )
:Damage = Barrier( Damage )
+
End If
 +
 
 +
If Actor's Statuses includes Frog
 +
Damage = Damage / 4
 +
End If
 +
 
 +
Damage = Sadness( Damage )
 +
Damage = Split( Damage, 0 )
 +
Damage = Barrier( Damage )
 
    
 
    
:If Actor's Statuses include Mini
+
If Actor's Statuses include Mini
:: Damage = 0
+
Damage = 0
:End If
+
End If
 
+
Damage = Variance( Damage )</pre>
:Damage = Variance( Damage )
 
 
----
 
----
 
X2:
 
X2:
:multiNoSplit = ( ( ( Attack's Target Flags AND Ch ) - 4 ) == 0 ? 1 : 0 )
+
<pre>
:Base = (Actor's Attack + Actor's Level) * 6
+
multiNoSplit = ( ( ( Attack's Target Flags AND Ch ) - 4 ) == 0 ? 1 : 0 )
:Damage = (512 - Target's Defense) * Base * Attack's Power
+
Base = (Actor's Attack + Actor's Level) * 6
:Damage = Sadness( Damage )
+
Damage = (512 - Target's Defense) * Base * Attack's Power
:Damage = SplitDamage( Damage, multiNoSplit )
+
Damage = Sadness( Damage )
:Damage = Barrier( Damage )
+
Damage = SplitDamage( Damage, multiNoSplit )
:Damage = Variance( Damage )
+
Damage = Barrier( Damage )
 +
Damage = Variance( Damage )
 +
</pre>
 
----
 
----
 
X3:
 
X3:
:If Attack Properties Damage MP is clear
+
<pre>
::Damage = Target's HP
+
If Attack Properties Damage MP is clear
:Else
+
Damage = Target's HP
::Damage = Target's MP
+
Else
:End If
+
Damage = Target's MP
:Damage = Damage * Attack's Power / 32
+
End If
:If ActionData[AC] != 0 (?)
+
 
::Damage = Damage / 2
+
Damage = Damage * Attack's Power / 32
:End If
+
 
:Damage
+
If ActionData[AC] != 0 (?)
 +
Damage = Damage / 2
 +
End If</pre>
 
----
 
----
 
X4:
 
X4:
:If Attack Properties Damage MP is clear
+
<pre>If Attack Properties Damage MP is clear
::Damage = Target's MHP
+
Damage = Target's MHP
:Else
+
Else
::Damage = Target's MMP
+
Damage = Target's MMP
:End If
+
End If
:Damage = Damage * Attack's Power / 32
+
 
:If ActionData[AC] != 0 (?)
+
Damage = Damage * Attack's Power / 32
::Damage = Damage / 2
+
 
:End If
+
If ActionData[AC] != 0 (?)
:Damage
+
Damage = Damage / 2
 +
End If
 +
</pre>
 
----
 
----
 
X5:
 
X5:
:Damage = (Actor's (M)Attack + Actor's Level) * 6 + (Attack's Power * 22)
+
<pre>
:Damage = SplitDamage( Damage )
+
Damage = (Actor's (M)Attack + Actor's Level) * 6 + (Attack's Power * 22)
:Damage = Barrier( Damage )
+
Damage = SplitDamage( Damage )
:Damage = Variance( Damage )
+
Damage = Barrier( Damage )
 +
Damage = Variance( Damage )</pre>
 
----
 
----
 
X6:
 
X6:
:Damage = Attack's Power * 20
+
<pre>Damage = Attack's Power * 20</pre>
 
----
 
----
 
X7:
 
X7:
:Damage = ( ( 512 - Target's Def ) * Attack's Power / 32 )
+
<pre>
:Damage = Variance( Damage )
+
Damage = ( ( 512 - Target's Def ) * Attack's Power / 32 )
 +
Damage = Variance( Damage )
 +
</pre>
 
----
 
----
 
X8:
 
X8:
:If ActionData[0x230] AND 40h
+
<pre>
::ActionData[0x230] = 1
+
If ActionData[0x230] AND 40h
:Else
+
ActionData[0x230] = 1
::ActionData[0x230] = 80h
+
Else
:End If
+
ActionData[0x230] = 80h
 +
End If
 +
//presumably this checks if the target heals from restore element and will either recover or kill based on the result</pre>
 
----
 
----
 
X9:
 
X9:
:Actor's Attack = Actor's Strength * 2
+
<pre>
:Use Damage X1 with adjusted stat
+
Actor's Attack = Actor's Strength * 2
 +
Use Damage X1 with adjusted stat
 +
</pre>
 
----
 
----
 
XA:
 
XA:
Damage = ( Attack's Power + Number of Targets - 1 ) / Number of Targets
+
<pre>Damage = ( Attack's Power + Number of Targets - 1 ) / Number of Targets</pre>
----
+
==Additional Checks==
 
Sadness( Damage ):
 
Sadness( Damage ):
:If Target's Status includes Sadness
+
<pre>
::Damage = Damage - (Damage * 3 / 10)
+
If Target's Status includes Sadness
:End If
+
Damage = Damage - (Damage * 3 / 10)
:Return Damage
+
End If
 +
Return Damage</pre>
 
----
 
----
 
SplitDamage( Damage, multiNoSplit ):
 
SplitDamage( Damage, multiNoSplit ):
:If multiNoSplit == 0
+
<pre>
::If No. of Attack's Targets >= 2
+
If multiNoSplit == 0
:::Set Attack's split damage Target Flag
+
If No. of Attack's Targets >= 2
::Else
+
Set Attack's split damage Target Flag
:::Set multiNoSplit == 1
+
Else
::End If
+
Set multiNoSplit == 1
:End If
+
End If
:If ActionData[0xAC] == 0
+
End If
::Damage = Damage / 2
+
 
:Else
+
If ActionData[0xAC] == 0
::If multiNoSplit == 0
+
Damage = Damage / 2
:::Damage = Damage * 3 / 2
+
Else
::End If
+
If multiNoSplit == 0
:End If
+
Damage = Damage * 3 / 2
:Return Damage
+
End If
 +
End If
 +
Return Damage
 +
</pre>
 
----
 
----
 
Barrier( Damage ):
 
Barrier( Damage ):
:If Attack Property "Physical" is 0
+
<pre>
::If Target's Statuses include MBarrier
+
If Attack Property "Physical" is 0
:::Set ActionData "MBarrier Active" flag
+
If Target's Statuses include MBarrier
::End If
+
Set ActionData "MBarrier Active" flag
:Else
+
End If
::If Target's Statuses include Barrier
+
Else
:::Set ActionData "Barrier Active" flag
+
If Target's Statuses include Barrier
::End If
+
Set ActionData "Barrier Active" flag
:End If
+
End If
:If ActionData "MBarrier Active" or "Barrier Active" flags are set
+
End If
::Damage = Damage / 2
+
 
:End If
+
If ActionData "MBarrier Active" or "Barrier Active" flags are set
:If attack is Magic and EnabledMagic[7] == 0 (?)
+
Damage = Damage / 2
::Damage = Damage + ( Damage * ( EnabledMagic[7] * (10 / 32) ) / 100 )
+
End If
:End If
+
 
:Return Damage
+
If attack is Magic and EnabledMagic[7] == 0 (?)
 +
Damage = Damage + ( Damage * ( EnabledMagic[7] * (10 / 32) ) / 100 )
 +
End If
 +
Return Damage
 +
</pre>
 
----
 
----
 
Variance( Damage ):
 
Variance( Damage ):
:Damage = Damage ([0..255] + 3841) / 4096  //from RNGLUT in KERNEL.BIN
+
<pre>
:If Damage == 0
+
Damage = Damage ([0..255] + 3841) / 4096  //from RNGLUT in KERNEL.BIN
::Damage == 1
+
 
:End If
+
If Damage == 0
:Return Damage
+
Damage == 1
 +
End If
 +
Return Damage
 +
</pre>

Revision as of 19:13, 29 March 2012

Damage Formula's description

0x11:

Prepare Function 0x0 (calculate physical hit chance)

Prepare Function 0x2 (calculate critical chance)

Damage Function 0x1


0xA0:

Prepare Function 0x0 (calculate physical hit chance)

Prepare Function 0x2 (calculate critical chance)

Damage Function 0x1

damage = damage * (1 + number_of_status1 + 2 * number_of_status2).

number_of_status1 are calculated as sum of attacker statuses darkness, slow, silence, sadness, poison, near death.

number_of_status2 are calculated as sum of attacker statuses death sentence, slow-numb.


0xA1:

Prepare Function 0x0 (calculate physical hit chance)

Prepare Function 0x2 (calculate critical chance)

Damage Function 0x1

if current hp less then max hp / 4 then damage = damage * 2.

if attacker in death sentence then damage = damage * 4.


0xA2:

Prepare Function 0x0 (calculate physical hit chance)

Prepare Function 0x2 (calculate critical chance)

Damage Function 0x1

damage = damage * (1 + number_of_dead_player_units).


0xA3:

Prepare Function 0x0 (calculate physical hit chance)

Prepare Function 0x2 (calculate critical chance)

power_modifier = total_level_of_all_enemy_target / number_of_enemy_target.

(this only use enemy units from 4 to 10 that includes in target mask after all preparation)

Damage Function 0x1


0xA4:

Prepare Function 0x0 (calculate physical hit chance)

Prepare Function 0x2 (calculate critical chance)

power_modifier = 1 + (((current_hp * 3) / max_hp) * power_modifier).

Damage Function 0x1


0xA5:

Prepare Function 0x0 (calculate physical hit chance)

Prepare Function 0x2 (calculate critical chance)

power_modifier = 1 + (((current_mp * 3) / max_mp) * power_modifier).

Damage Function 0x1


0xA6:

Prepare Function 0x0 (calculate physical hit chance)

Prepare Function 0x2 (calculate critical chance)

power_modifier = 1 + (((total_ap / 10000) * power_modifier) / 16).

(total_ap is no more than ap needed for max star, so underwater materia won't work)

Damage Function 0x1



0xA7:

Prepare Function 0x0 (calculate physical hit chance)

Prepare Function 0x2 (calculate critical chance)

power_modifier = 10 + (((number_of_kills / 128) * power_modifier) / 16).

Damage Function 0x1


0xA8:

Prepare Function 0x0 (calculate physical hit chance)

Prepare Function 0x2 (calculate critical chance)

power_modifier = 1 + (((limit_bar_value * (limit_level + 1) / 16) * power_modifier) / 16).

Damage Function 0x1


Damage Calculations

For standard damage functions

X0:

Sets Target's 02h flag to 1. (Unknown effect)

X1:

If Attack Property "Always Critical" is Set
	Set Critical Damage Flag
End If

x = ( Actor's Level * Actor's (M)Attack ) / 32
y = ( Actor's Level + Actor's (M)Attack ) / 32
z = Actor's (M)Attack + ( x * y )
z = z * ( 512 - target's defense ) * Attack's Power
Damage = z / 4096

If Critical Damage Flag is set
	Damage = Damage * 2
End If

If Actor's Statuses include Berserk
	Damage = Damage * 3 / 2
End If

Long_Range = 0
If Target is in Back Row
	Set Long_Range = 1
End If

If Attack is Short Range OR Command is Enemy Attack
	If Actor is in Back Row
		Long_Range = 1
	End If
Else
	Long_Range = 0
End If

If Long_Range != 0
	Damage = Damage / 2
End If

If Target is Defending
	Damage = Damage / 2
End If

If Target's Back is exposed
	Damage = Damage * ( Target's Back Attack Modifier / 8 )
End If

If Actor's Statuses includes Frog
	Damage = Damage / 4
End If

Damage = Sadness( Damage )
Damage = Split( Damage, 0 )
Damage = Barrier( Damage )
  
If Actor's Statuses include Mini
	Damage = 0
End If
Damage = Variance( Damage )

X2:

multiNoSplit = ( ( ( Attack's Target Flags AND Ch ) - 4 ) == 0 ? 1 : 0 )
Base = (Actor's Attack + Actor's Level) * 6
Damage = (512 - Target's Defense) * Base * Attack's Power
Damage = Sadness( Damage )
Damage = SplitDamage( Damage, multiNoSplit )
Damage = Barrier( Damage )
Damage = Variance( Damage )

X3:

If Attack Properties Damage MP is clear
	Damage = Target's HP
Else
	Damage = Target's MP
End If

Damage = Damage * Attack's Power / 32

If ActionData[AC] != 0 (?)
	Damage = Damage / 2
End If

X4:

If Attack Properties Damage MP is clear
	Damage = Target's MHP
Else
	Damage = Target's MMP
End If

Damage = Damage * Attack's Power / 32

If ActionData[AC] != 0 (?)
	Damage = Damage / 2
End If

X5:

Damage = (Actor's (M)Attack + Actor's Level) * 6 + (Attack's Power * 22)
Damage = SplitDamage( Damage )
Damage = Barrier( Damage )
Damage = Variance( Damage )

X6:

Damage = Attack's Power * 20

X7:

Damage = ( ( 512 - Target's Def ) * Attack's Power / 32 )
Damage = Variance( Damage )

X8:

If ActionData[0x230] AND 40h
	ActionData[0x230] = 1
Else
	ActionData[0x230] = 80h
End If
//presumably this checks if the target heals from restore element and will either recover or kill based on the result

X9:

Actor's Attack = Actor's Strength * 2
Use Damage X1 with adjusted stat

XA:

Damage = ( Attack's Power + Number of Targets - 1 ) / Number of Targets

Additional Checks

Sadness( Damage ):

If Target's Status includes Sadness
	Damage = Damage - (Damage * 3 / 10)
End If
Return Damage

SplitDamage( Damage, multiNoSplit ):

If multiNoSplit == 0
	If No. of Attack's Targets >= 2
		Set Attack's split damage Target Flag
	Else
		Set multiNoSplit == 1
	End If
End If

If ActionData[0xAC] == 0
	Damage = Damage / 2
Else
	If multiNoSplit == 0
		Damage = Damage * 3 / 2
	End If
End If
Return Damage

Barrier( Damage ):

If Attack Property "Physical" is 0
	If Target's Statuses include MBarrier
		Set ActionData "MBarrier Active" flag
	End If
Else
	If Target's Statuses include Barrier
		Set ActionData "Barrier Active" flag
	End If
End If

If ActionData "MBarrier Active" or "Barrier Active" flags are set
	Damage = Damage / 2
End If

If attack is Magic and EnabledMagic[7] == 0 (?)
	Damage = Damage + ( Damage * ( EnabledMagic[7] * (10 / 32) ) / 100 )
End If
Return Damage

Variance( Damage ):

Damage = Damage ([0..255] + 3841) / 4096  //from RNGLUT in KERNEL.BIN

If Damage == 0
	Damage == 1
End If
Return Damage