øAslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&topic=2329.0e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index657a-2.htmlslickproductions.org/forum/index.php?PHPSESSID=5f0fck550j2m4m2fpbtkj2vkm1&board=17.20e:/My Web Sites/Slick Productions - FFIV Message Board/slickproductions.org/forum/index657a-2.html.zx9h^ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÈ °Vc:OKtext/htmlISO-8859-1gzip8:Öc:ÿÿÿÿÿÿÿÿWed, 11 Mar 2020 01:20:48 GMT0ó°° ®0®P®€§²ð®9h^ÿÿÿÿÿÿÿÿ 3c: Altering stats

Author Topic: Altering stats  (Read 1877 times)

Xardas

  • Siren
  • *
  • Posts: 75
    • View Profile
Altering stats
« on: January 12, 2017, 04:57:47 AM »
Hallo again.
This time I want to learn more about stat editing. Here is what I already can change:
Stats of jobs
Character stat bonus

Here is what I want to learn additionally:
Ability stat bonus (eg. the strength value which is implied by using "Equip Swords")
The base stats (If you don't know what I mean, it's the one which is 24 for every stat)

The base stats are not that important to me, so no big drama if that cannot be modified (yet). I basically want it to be 19 instead of 24.
But the ability stat bonuses are, mainly because I reduced the magic stat of some magical jobs. But due to having Summon5, Black6 or White6 equipped automatically, the stat drop was not there at all - it would have only be in action on a Freelancer/Mime which mastered a magic job.
I thought that would be in "Ability data" section, but every offset in Ability Data is "FF" on the ROM, which looks odd to me.
Thanks in advance (since I know someone already knows a solution ^^)

Squall

  • Dark Dragon
  • *
  • Posts: 486
    • View Profile
Re: Altering stats
« Reply #1 on: January 12, 2017, 06:43:01 AM »
Quote
The base stats (If you don't know what I mean, it's the one which is 24 for every stat)
Unfortunately that's common misconception, that you will see in almost every guide for FF5.

If you can imagine a jobless characters (not possible in the game), without equipment and ability they will have stats:
Code: [Select]
               Str  Agl  Vit  Mag
Butz             4    1    3    1
Lenna            1    2    1    4
Galuf            3    0    4    0
Faris            3    3    2    2
Cara             1    4    0    3

When a character equip a job his stats get increased by:
Job Stat Bonus
Code: [Select]
               Str  Agl  Vit  Mag
Normal/Mimic    24   24   24   24
Knight          47   25   44   10
Monk            50   25   50    1
Thief           25   40   26   18
Dragoon         42   29   39   12
Ninja           39   38   27   14
Samurai         43   26   43   12
Berserker       45   15   49    1
Hunter          40   36   25   19
Mystic Knight   38   38   38   25
White Mage      17   25   24   49
Black Mage      15   24   22   55
Time Mage       19   26   21   48
Summoner        14   23   23   57
Blue Mage       16   25   27   47
Red Mage        32   29   18   32
Mediator        37   25   32   21
Chemist         26   27   30   20
Geomancer       28   26   28   48
Bard            16   32   15   35
Dancer          29   29   14   19

On top of that, ALL abilities also carry stat bonus. I know this is not you've heard or experience, but most ability carry stats of 0 0 0 0, so for you nothing change. Unfortunately I don't know a link that have full list of stat bonus ability have, so I will suggest to open my Viewer on Ability section, there you will see the full picture.

Now the question is how all of this affect character stats?
Code: [Select]
Character Stats = Char Base Stats + MAX(Job Bonus, Ability Bonus)
MAX - bigger of arguments
- above is calculated for each stat: Str, Agi, Sta, Mag

Example:
Code: [Select]
Bartz as Knight with Equip Sword ability:
Equip Sword has stat bonus of 47, 0, 0, 0
Str = 4 + MAX(47, 47) = 4+47 = 51
Agi = 1 + Max(25, 0 ) = 1+25 = 26
Sta = 3 + MAX(44, 0 ) = 3+44 = 47
Mag = 1 + MAX(10, 0 ) = 1+10 = 10

Code: [Select]
Bartz as Knight with Equip Harps ability:
Equip Harps has stat bonus of 0, 32, 0, 35
Str = 4 + MAX(47, 0 ) = 4+47 = 51
Agi = 1 + Max(25, 32) = 1+32 = 33
Sta = 3 + MAX(44, 0 ) = 3+44 = 47
Mag = 1 + MAX(10, 35) = 1+35 = 45

Squall

  • Dark Dragon
  • *
  • Posts: 486
    • View Profile
Re: Altering stats
« Reply #2 on: January 12, 2017, 07:04:46 AM »
That's how the game do the calculation internally. There are no negative values. That mean that every doc, faq, walktrough that uses negative values ... well lets just say its not worth readying, because the author bases his thought on wrong base and doesn't really comprehend how things work (which makes 99% of things on the net).

I will suggest that you get my Damage Calculator and experiment. There you may see jobless characters or apply different jobs/abilities and see how char stats change.
In my Viewer you can see pretty much all things available for Abilities (Innates, Equipment Added, Action codes,...)
For list of ROM addresses check Jorgur:FF5 Jobs and abilities

Xardas

  • Siren
  • *
  • Posts: 75
    • View Profile
Re: Altering stats
« Reply #3 on: January 12, 2017, 10:52:07 AM »
That pretty much answers my question - thanks!
But it lead me to another problem:
So I was looking at the action abilities, especially X-Fight (starts on offset D15A98, right?)
The only bytes not having the value 00 are 0 (Targeting), 3 (Reflectable/MP Cost) and 4 (Unavoid/Formula)
While I see nothing wrong with the targeting being 08 (automatically attacks enemies), I do at Ref/MP and Un/For
The value for Ref/MP is 8C, which means "Un-reflectable with a cost of 12MP" while 7F at Un/For means "no attack" (btw, it's also 7F for Aim).

Obviously, I am missing something here. How on earth do these values lead to "attack 4 times with 0,5xM while ignoring defense and automatically hitting"?
My only clue would be, that 80 does not mean un-reflecteble in some cases. As Aim has exactly 80 on Ref/MP, I guess 80 on action abilities means "auto hit" rather than "un-reflectable".

Squall

  • Dark Dragon
  • *
  • Posts: 486
    • View Profile
Re: Altering stats
« Reply #4 on: January 12, 2017, 01:14:53 PM »
I have no my Viewer atm to check Action bytes of X-Fight but here you are few things:

The most important part of all 8 bytes is DF (damage formula). It tells the asm code which subroutine to use when handling specific action. How the rest of the 7 bytes will be used (if used at all) depend on that code!!!

- That mean that things that are called Reflectable/Unavoidable may mean something else in a different DF (especially 7F ones). A good example is Unavoidable, which is not used at all in GBA. Although Jorgur had named 7F 'No attack' it actually mean more like 'other' - something that dont fit in all previously 00-7E formulas. Its used for some 'no attack' actions but is used in some quite damaging actions too :D

- That also mean, the asm code may hardcode specific actions, so "attack 4 times with 0,5xM while ignoring defense and automatically hitting" most likely is hardcoded rather encoded in the 7 bytes. I'm speculating atm, we must see the specific code, but its pretty much good guess :D

Xardas

  • Siren
  • *
  • Posts: 75
    • View Profile
Re: Altering stats
« Reply #5 on: January 12, 2017, 04:19:16 PM »
Hard coded you say. So I'm afraid it's somewhere between extremely complicated and impossible to, let's say, nerf X-Fight by removing auto-hit and defense ignore. A little bit of a step backwards because doing that was one of my very first ideas.
I also had some nerfing (little MP cost) for Gaia/Terrain and Animals in mind.
But still, that won't stop me. Good thing is, thanks to you, I can now realize the abilities "Equip Knives" and "Equip Magic Armor".

Squall

  • Dark Dragon
  • *
  • Posts: 486
    • View Profile
Re: Altering stats
« Reply #6 on: January 13, 2017, 03:23:29 AM »
Quote
Hard coded you say. So I'm afraid it's somewhere between extremely complicated and impossible to, let's say, nerf X-Fight by removing auto-hit and defense ignore. A little bit of a step backwards because doing that was one of my very first ideas.
Hardcoded simply mean that there is an asm block that take care of specific task without taking into account external params.

If your goal is to remove auto-hit & ignore defense, you just need to change few asm instuctions:

1. HIT DETERMINATION FOR PHYSICAL ATTACKS
Quote
1)  If the Target has Sleep, Paralyze or Charm status, the attack automatically
    hits.  Goto Step 10.
2)  If the Attacker is using Aim, Jump, Throw, Sword Dance or X-Fight or if the
    Attacker is attacking himself, the attack automatically hits.  Goto Step 10.
3)  If the Target can't evade Physical (check "Can't Evade" parameter), the
    attack automatically hits.  Goto Step 10.
4)  Check to see if Evade ability, Weapon Block (due to Hardened or Defender),
    Weapon Block (due to Guardian) or Elf Cape succeed (6.3.4).  If any of their
    checks succeed, the attack misses;  do not follow any more steps.  None of
    these abilities can succeed if the Target has Sleep, Paralyze, Charm or Stop
    status or is attacking himself.
5)  Apply Target status effect modifiers to physical Hit% (6.3.7)
6)  Apply Attacker status effect modifiers to physical Hit% (6.3.8)
7)  Let N1 = (0..99) 
    If N1 >= Hit%, the attack misses;  do not follow any more steps.
8)  If the Target has Stop status, it does not get an Evade check and the attack
    hits.  Goto Step 10
9)  Let N2 = (0..99) 
    If N2 < Evade%, the attack misses;  do not follow any more steps.
10)  If the Target has Image status, the attack misses, but the Target loses one
     Image;  do not follow any more steps.
11)  The attack hits.  Follow the rest of the steps to calculate damage.
As you may see to remove auto-hit that mean to remove the check in step 2. That check is usually comparing with bit-field, so you really need to change that bit field (1 byte) to exclude X-Fight. In worst case scenario you must remove the whole check - thats few NOPs

2. COMMAND MODIFIERS TO ATTACK, DEFENSE AND M
Quote
1) If the Attacker is using SwordDance, Attack = Attack * 2 and M = M * 2
2) If the Attacker is using Throw, Attack = Attack * 2
3) If the Attacker is using BuildUp, M = M * 2
4) If the Attacker is using X-Fight, M = M / 2 and Defense = 0
5) If the Target is Defending, M = M / 2
6) If the Target is Guarding, Damage = 0
To remove ignore defense, you must remove Defense = 0 in step 4. That's just few NOPs

So it should be fairly easy task  :laugh:

**NOP - asm instruction with meaning - No Operation

Jorgur

  • Moderator
  • *
  • Posts: 437
  • Gender: Male
    • View Profile
Re: Altering stats
« Reply #7 on: January 13, 2017, 06:49:58 AM »
Here is the code in question:
Code: [Select]
Hit% Determination for physical
C2/7EBE: A6 49        LDX $49
C2/7EC0: BD 1B 20     LDA $201B,X
C2/7EC3: 1D 71 20     ORA $2071,X
C2/7EC6: 29 70        AND #$70      (Target Status = Sleep, Paralyze or Charm)
C2/7EC8: D0 28        BNE $7EF2
C2/7ECA: A6 32        LDX $32
C2/7ECC: BD 1F 20     LDA $201F,X   (Check for Autohit abilities)
C2/7ECF: 30 21        BMI $7EF2
C2/7ED1: A5 39        LDA $39
C2/7ED3: AA           TAX
C2/7ED4: BD FD 79     LDA $79FD,X
C2/7ED7: A6 49        LDX $49
C2/7ED9: 3D 64 20     AND $2064,X  (Check Target Can't Evade vs. Attack type)
C2/7EDC: D0 14        BNE $7EF2
C2/7EDE: 20 FC 7C     JSR $7CFC    (Check for Evade, Weapon Block or Elf Cape)
C2/7EE1: A5 56        LDA $56
C2/7EE3: D0 10        BNE $7EF5
C2/7EE5: 20 AC 7D     JSR $7DAC    (Target Status Effect Modifiers to Hit%)
C2/7EE8: 20 D1 7D     JSR $7DD1    (Attacker Status Effect Modifiers to Physical Hit)
C2/7EEB: 20 23 7E     JSR $7E23    (Check for Physical Hit)
C2/7EEE: A5 56        LDA $56
C2/7EF0: D0 03        BNE $7EF5
C2/7EF2: 20 E2 7D     JSR $7DE2    (Check for Target Image)
C2/7EF5: 60           RTS
Code: [Select]
Command modifications to damage
C2/83BD: A6 32        LDX $32
C2/83BF: BD 1F 20     LDA $201F,X
C2/83C2: 29 40        AND #$40
C2/83C4: F0 06        BEQ $83CC
C2/83C6: C2 20        REP #$20
C2/83C8: 06 50        ASL $50      (Damage = Damage * 2)
C2/83CA: E2 20        SEP #$20
C2/83CC: BD 1F 20     LDA $201F,X
C2/83CF: 29 20        AND #$20
C2/83D1: F0 07        BEQ $83DA
C2/83D3: C2 20        REP #$20
C2/83D5: 46 50        LSR $50      (Damage = Damage / 2)
C2/83D7: 7B           TDC
C2/83D8: E2 20        SEP #$20
C2/83DA: BD 1F 20     LDA $201F,X
C2/83DD: 29 10        AND #$10
C2/83DF: F0 06        BEQ $83E7
C2/83E1: C2 20        REP #$20
C2/83E3: 06 52        ASL $52      (M = M * 2)
C2/83E5: E2 20        SEP #$20
C2/83E7: BD 1F 20     LDA $201F,X
C2/83EA: 29 08        AND #$08
C2/83EC: F0 07        BEQ $83F5
C2/83EE: C2 20        REP #$20
C2/83F0: 46 52        LSR $52      (M = M / 2)
C2/83F2: 7B           TDC
C2/83F3: E2 20        SEP #$20
C2/83F5: BD 1F 20     LDA $201F,X
C2/83F8: 29 04        AND #$04
C2/83FA: F0 04        BEQ $8400
C2/83FC: 7B           TDC
C2/83FD: AA           TAX
C2/83FE: 86 54        STX $54      (Defense = 0)
C2/8400: A6 49        LDX $49
C2/8402: BD 65 20     LDA $2065,X  (Target Creature Type = Human?)
C2/8405: 10 0F        BPL $8416
C2/8407: A6 32        LDX $32
C2/8409: BD 1F 20     LDA $201F,X
C2/840C: 29 01        AND #$01
C2/840E: F0 06        BEQ $8416
C2/8410: C2 20        REP #$20
C2/8412: 06 50        ASL $50      (Damage = Damage * 2)
C2/8414: E2 20        SEP #$20
C2/8416: A6 49        LDX $49
C2/8418: BD 1E 20     LDA $201E,X
C2/841B: 10 07        BPL $8424    (If Target is Defending)
C2/841D: C2 20        REP #$20
C2/841F: 46 52        LSR $52      (M = M / 2)
C2/8421: 7B           TDC
C2/8422: E2 20        SEP #$20
C2/8424: BD 1E 20     LDA $201E,X
C2/8427: 29 40        AND #$40
C2/8429: F0 04        BEQ $842F    (If Target is Guarding)
C2/842B: 7B           TDC
C2/842C: AA           TAX
C2/842D: 86 50        STX $50      (Damage = 0)
C2/842F: 60           RTS

Squall

  • Dark Dragon
  • *
  • Posts: 486
    • View Profile
Re: Altering stats
« Reply #8 on: January 13, 2017, 08:24:39 AM »
Yes, thats the asm code for the scripted version I quoted from instructrtrepe doc. Thank you Jorgur!

It seems that instead of checking the command (X-Fight), internally it uses $201F to hold flags for auto-hit and command damage modifiers. Luckily for us $201F is exact value that is stored in 4th byte of the action (called: Reflectable + MP cost in Wiki).
Code: [Select]
C2/1A8C: BF E3 59 D1  LDA $D159E3,X
C2/1A90: 99 1F 20     STA $201F,Y

If you check in my Viewer you will see:
Code: [Select]
Name:          Rapid Fire
Index:         23 (17)
Type:          Command

               Str Agi Sta Mag
Stat Bonus:      0   0   0   0

Action:        08 00 00 8C 7F 00 00 00
Action Delay:  1

So the 4th byte is $8C, which mean:
 - Auto-Hit
 - M = M / 2
 - Defense = 0

OMG Xardas, you are sooooo lucky, its not hardcoded!!! You need to change $8C to $00 - you will accomplish your task  :laugh:

 :edit:
Since you want to keep M/2, then you must change to $8c to $08, sorry!
« Last Edit: January 13, 2017, 08:41:17 AM by Squall »

Xardas

  • Siren
  • *
  • Posts: 75
    • View Profile
Re: Altering stats
« Reply #9 on: January 13, 2017, 02:45:45 PM »
Thank you for your patience guys!
I admit that I looked on some disassembly lists, but whenever I see these...
Code: [Select]
$C0/0000: 78      SEI
$C0/0001: 18      CLC
$C0/0002: FB      XCE
...I am completely lost, because I have literally no clue what all those 3 letter codes mean. As I said, I really don't know anything (except for bin and hex system). Maybe in the future I might be doing something to understand that and maybe even working more in-depth.
But I think all my questions are answered for now (well, maybe I will do something about the chicken knife damage parameter, but that's going to be even more complicated because I'm using fractional M already).
All the best!

Squall

  • Dark Dragon
  • *
  • Posts: 486
    • View Profile
Re: Altering stats
« Reply #10 on: January 14, 2017, 05:52:56 AM »
Quote
I am completely lost, because I have literally no clue what all those 3 letter codes mean
Hehe that comment made my day :D but seriously if you decide to learn ASM we can help you understand it.

Quote
But I think all my questions are answered for now
Great! If you have more don't hesitate to ask.

TBH by trying to help you I learned new interesting things  :cycle:

Praetarius5018

  • Vargas
  • *
  • Posts: 88
    • View Profile
Re: Altering stats
« Reply #11 on: January 15, 2017, 04:09:35 AM »
...I am completely lost, because I have literally no clue what all those 3 letter codes mean.
maybe this reference will help a bit to get started:
https://wiki.superfamicom.org/snes/show/65816+Reference
it has a list of both the hexcodes and their respective 3-letter codes with a short description what it should mean

Xardas

  • Siren
  • *
  • Posts: 75
    • View Profile
Re: Altering stats
« Reply #12 on: February 19, 2017, 10:24:54 AM »
Quote
The base stats (If you don't know what I mean, it's the one which is 24 for every stat)
Unfortunately that's common misconception, that you will see in almost every guide for FF5.
Well, I now have a problem which kinda DOES say that 24 ist more than just the Freelancer and Mime stat...
So I am done editing all Character, Ability and Job stat bonuses. Everything working fine, except for Freelancer (I guess Mime too).
I gave Freelancer and Mime 20 for every stat. However, all stats are 4 too high in the game. Still counts "24" when using Freelancer. To verify, I gave Freelancers completely different values for every stat. Still counts "24" for every stat.
I also double-checked in FFV editor (said 20) and Hex-Editor (said 14, which is 20 too).
I also started new games. Still 24.
And it's only Freelancer/Mime Job acting weird.
Does anyone know what I forgot to do?
« Last Edit: February 19, 2017, 10:46:53 AM by Xardas »

Squall

  • Dark Dragon
  • *
  • Posts: 486
    • View Profile
Re: Altering stats
« Reply #13 on: February 20, 2017, 04:48:11 AM »
Its possible the editor saves in wrong place.

In order to verify, check values at $D156B0 (file offset: 1156B0). Every 4 bytes represent these values. Also you may check the ROM trough my Viewer on Job tab - all values are taken from the ROM. If I remember correctly Mimic & Freelancer are at the in end of that table with index 20 & 21. That mean that their data is +20x4 = +80 ($50)

P.S. File offset may vary depending on the ROM with header or without. Unchanged ROM should have 8 bytes of 24 ($18) at that offset

Xardas

  • Siren
  • *
  • Posts: 75
    • View Profile
Re: Altering stats
« Reply #14 on: February 20, 2017, 06:34:16 AM »
Its possible the editor saves in wrong place.

In order to verify, check values at $D156B0 (file offset: 1156B0). Every 4 bytes represent these values. Also you may check the ROM trough my Viewer on Job tab - all values are taken from the ROM. If I remember correctly Mimic & Freelancer are at the in end of that table with index 20 & 21. That mean that their data is +20x4 = +80 ($50)
Come on, I already said that I checked the Hex-editor too ^^.  :childish:
Mimik and Freelancer are 115700 and all their values are 14 (Decimal 20). Still, the game thinks it should be Decimal 24 for some reason. As I said, every other Job works fine.