• Welcome to Final Fantasy Hacktics. Please login or sign up.
 
November 10, 2024, 02:46:05 pm

News:

Use of ePSXe before 2.0 is highly discouraged. Mednafen, RetroArch, and Duckstation are recommended for playing/testing, pSX is recommended for debugging.


Need formulas or spreadsheets to calculate stat gains and damage

Started by nitwit, September 06, 2016, 04:02:59 pm

nitwit

I saw them somewhere, but I don't recall where.

I need something that will calculate stats at level 1, 99, and somewhere in between for given raw stats and class growths and multipliers.  If I can then select an ability or a formula and the x/y values for it and have the damage at various levels that would be cool too.

http://www.gamefaqs.com/ps/197339-final-fantasy-tactics/faqs/3876

statBonus at any given level = [currentRawStat / (Growth + Level)]

I know there's some math function - probably related to either sequences or series - that deals with this sort of thing, but I can't remember it.  I could easily write a loop to figure this out, or even a recursive function... if only I had paid attention in discrete math 2!

EDIT

Screw it, I can make a command line program to do the calculations for me.

http://ffhacktics.com/wiki/Data/Table_Locations

RAM -> File
-0x67000 -> WLDCORE.bin
-0x67000 -> Battle.bin
-0xE0000 -> World.bin
-0xF800 -> SCUS

800610b8 - 0x518B8 - Job Data

0x00 - Skillset
0x01 - Innate Ability 1
0x03 - Innate Ability 2
0x05 - Innate Ability 3
0x07 - Innate Ability 4
0x09 - Equippable Items 1
0x0a - Equippable Items 2
0x0b - Equippable Items 3
0x0c - Equippable Items 4
0x0d - HP Growth
0x0e - HP Multiplier
0x0f - MP Growth
0x10 - MP Multiplier
0x11 - Speed Growth
0x12 - Speed Multiplier
0x13 - PA Growth
0x14 - PA Multiplier
0x15 - MA Growth
0x16 - MA Multiplier
0x17 - Move
0x18 - Jump
0x19 - C-EV
0x1a - Innate Statuses 1
0x1b - Innate Statuses 2
0x1c - Innate Statuses 3
0x1d - Innate Statuses 4
0x1e - Innate Statuses 5
0x1f - Status Immunity 1
0x20 - Status Immunity 2
0x21 - Status Immunity 3
0x22 - Status Immunity 4
0x23 - Status Imminity 5
0x24 - Starting Statuses 1
0x25 - Starting Statuses 2
0x26 - Starting Statuses 3
0x27 - Starting Statuses 4
0x28 - Starting Statuses 5
0x29 - Absorbed Elements
0x2a - Nullified Elements
0x2b - Halved Elements
0x2c - Elemental Weakness
0x2d - Monster Portrait
0x2e - Monster Palette
0x2f - Monster Graphic[\code]




8005fbf0 - 0x503F0 - Ability Data 2

0x00 - Range
0x01 - Effect Area
0x02 - Vertical
0x03: Flags 1
0x04: Flags 2
0x05: Flags 3
0x06: Flags 4
0x07 - Element
0x08 - Formula
0x09 - X
0x0a - Y
0x0b - Inflict Status
0x0c - CT
0x0d - MP Cost


8005e90c - 0x4F10C - Base Data (12 bytes each, 4 total)
   Order: 0 = Male, 1 = Female, 2 = Ramza, 3 = Monster

0x00 - HP (these * 16384 = Min Raw)
0x01 - MP
0x02 - SP
0x03 - PA
0x04 - MA
0x05 - Helmet
0x06 - Armor
0x07 - Accessory
0x08 - RH Weapon
0x09 - RH Shield
0x0a - LH Weapon
0x0b - LH Shield


rawStats.csv (4 entries - male, female, ramza, monster)
hp, mp, sp, pa, ma

jobs.csv (0x9a entries - squire 0x00 to 0x9a ultima demon)
hpc,hpm,mpc,mpm,spc,spm,pac,pam,mac,mam

0x0d - HP Growth
0x0e - HP Multiplier
0x0f - MP Growth
0x10 - MP Multiplier
0x11 - Speed Growth
0x12 - Speed Multiplier
0x13 - PA Growth
0x14 - PA Multiplier
0x15 - MA Growth
0x16 - MA Multiplier

abilities.csv (0x001 cure to 0x164 parasite)
formula,x,y

0x08 - Formula
0x09 - X
0x0a - Y

Darkholme

Assuming you aren't changing the formulas from vanilla, and you're just plugging in your own data, I'm pretty sure this is accurate, and doesn't require you to calculate any levels except the one you want to look at. Someone tell me if I'm wrong, and I'll correct it.

Stats
Modifier=16384
RAWBaseStat = PreRawBaseStat * Modifier.
StatGrowthPerLevel = RAWBaseStat / (GrowthMultiplier+1)
RawStat@Level = RawBaseStat + (StatGrowthPerLevel*(Level-1)) **This only works if every job has the same growth. If the growths vary, you have to do it one level at a time, based on what job you were when you got the levelup.
NakedStat@Level = RawStat@Level*Multiplier/(Modifier*100)

Typical Average Damage Formula
Damage=PA(Or MA)*WV
Though some are
PA*PA, or WV*WV, or PA*rand(1..WV), or PA*(WV+Y), or SP*WV, or what have you. Some also factor in Brave as a damage percentage modifier.

In my own hack I'm working on, I intend to have basically everything be based on some variation of (PA||MA||Min(PA,MA))*(N||WV||Y||WV+Y). But for Vanilla there's a wider range of formulas at use.

There's a nifty ASM someone already that lets you take that final damage number and apply a multiplier, which is good if you want to scale all your damage up or down without modifying the WVs or PAs you're using.

And if you want More *Useful* stats, you need to calculate some meta-stats.

For this you need to know what your other options are, and you'll likely want a spreadsheet for that, but you could populate a bunch of 2d arrays programmatically if you'd prefer.

These numbers are for same-level matchups. If you want stats for fighting higher or lower level opponents you'd need to run these formulas again with the numbers for the level matchups you're looking for.

%KillPerHit (Bad Attack v Good HP)
Worst%KillPerHit=AvgDamage[low]/AvgHP[high]
Med%KillPerHit=AvgDamage[med]/AvgHP[med]
Best%KillPerHit=AvgDamage[high]/AvgHP[low]

#HitsPerKill (Bad Attack v Good HP)
WorstHitsperKill=ROUNDUP(1/Worst%KillPerHit)
MedHitsperKill=ROUNDUP(1/Med%KillPerHit)
BestHitsperKill=ROUNDUP(1/Best%KillPerHit)

Avg%KillPerAttack (Bad Attack v Good HP)
Worst%KillPerAtk=AvgDamage[low]/AvgHP[high]*FinalHitChance
Med%KillPerAtk=AvgDamage[med]/AvgHP[med]*FinalHitChance
Best%KillPerHit=AvgDamage[high]/AvgHP[low]*FinalHitChance

Avg#TurnsPerKill (Bad Attack v Good HP)
WorstAtksPerKill=ROUNDUP(1/Worst%KillPerAtk)
MedAtksPerKill=ROUNDUP(1/Med%KillPerAtk)
BestAtksPerKill=ROUNDUP(1/Best%KillPerAtk)

As for FinalHitChance, it'll be a %. But I don't actually already know how to calculate that one.

Using the above, you could spit out (and graph) how many turns/hits it takes for a unit to kill or be killed by an enemy of the same level through raw damage. Very useful for calibrating damage output and defenses.

nitwit

preRawStats.csv (4 entries - male, female, ramza, monster)
hp, mp, sp, pa, ma

jobs.csv (0x9a entries - squire 0x00 to 0x9a ultima demon)
hpc,hpm,mpc,mpm,spc,spm,pac,pam,mac,mam

abilities.csv (0x001 cure to 0x164 parasite)
x,y,formula

I'll write two programs.  One to grab the values listed above from SCUS_942.21 and put them into 3 *.csv files.  Another to take the values in the *.csv files and either print something to terminal or save to a text file.

Probably it will print the stats for every job at levels 1, 9, 19, 29,... and 99.  Might print less than that.

I also need to print the damage/healing/hit-rate output for all the abilities at each of the above levels, for each job.

Goal is to figure out how I need to change the growths for monsters and the x/y values for monster abilities so that I can create a good blue mage.  Generally the same thing for the zodiac abilities too.  Instead of giving monster and enemy-only abilities absurd x/y values, monsters and enemy-only jobs would have differently scaled growths and multipliers to reach the same damage/healing/hit-rate output as in vanilla.

Because this is an awful lot to print, I should probably find a way to parameterize input for the program so I only print off specific levels, specific jobs, and specific abilities.  I'm sure I'll come up with a good way to do that, probably by feeding it integers that delimits each of the three things to be printed inclusive at both ends.

Probably accept at least 7 parameters:
* level start - first level to print
* level jump - number of levels to skip before printing values
* number of jumps - number of times to jump
* the first job to print
* the last job to print
* the first ability to print
* the last ability to print


Darkholme

In my opinion, your problem is much easier to solve with an excel sheet than a program.

It's quite a simple excel sheet to make.

Plot the values for the player jobs, plot the values for the monsters, compare and graph them visually so the progressions line up - not so difficult.

Though I'm not sure there's a hell of a lot to do with a blue mage to begin with.

Are there that many monster skills that aren't just reskinned versions of regular skills? What would your Blue Mage skill list look like? Most of the monster skills are basic damage attacks for example.

But anyways...

Just spit out a visual chart, your life will be much easier. Look at max/min/average stats for humans, WITH equipment. Look at max/min/average stats for monsters. Compare what you're making to that.

[Edit]
There are like 78 monster skills that aren't basic attacks (rough count).
Several of those are going to be repeats of skills in human jobs, or repeats with a name change and an insignificant tweak or two.
You get at most, 16 slots, but 8 would be more reasonable, I imagine.

The hard part, is picking the skill set for your blue mage.

I am, however, interested in those csv files. For abilities, you should also be grabbing Range, AoE, Vertical, CT, MP, and the flags. Those things are all important in balancing skills.

nitwit

You're probably right, but I don't/can't use excel and I never quite figured out how to create drop down lists and validation.  I'm more comfortable with printing formatted text.


Darkholme

Quote from: nitwit on September 07, 2016, 05:09:45 pm
You're probably right, but I don't/can't use excel and I never quite figured out how to create drop down lists and validation.  I'm more comfortable with printing formatted text.


Frankly, a CSV dump of the entire default contents of FFTPatcher would be handy. Both the PSX Dataset and the PSP Dataset. Useful for planning, useful for if you want to populate fields via formulas, useful if you want to reorganize the data in your patch without having to manually do all the adjustments.

I've not done much in the way of drop-down lists in excel either, but I have never needed to thus far.

nitwit

Installing the .NET 4.0 framework nuked my Windows XP Virtual Box setup.  I'm installing Windows 7 again so I can verify the number of entries in Job data.  Looks like I need to burn network and maybe USB drivers to a DVD to get them on my now Windows 7 laptop.

Quote from: Darkholme on September 07, 2016, 06:58:39 pm
Frankly, a CSV dump of the entire default contents of FFTPatcher would be handy.

Wouldn't be terribly hard, but I'd have to find where most of the data is.  Besides I'm only interested in the things I mentioned thus far.  Probably would be a good idea to specify in which files specific data tables and routines are located.  Making a duplicate page would be lame, so I guess you could specify in which file each routine/table is located in the list of tables and routines.

Quote from: Darkholme on September 07, 2016, 06:58:39 pm
Both the PSX Dataset and the PSP Dataset. Useful for planning, useful for if you want to populate fields via formulas, useful if you want to reorganize the data in your patch without having to manually do all the adjustments.

What do you mean by reorganize?  Present it in a different manner?

Quote from: Darkholme on September 07, 2016, 06:58:39 pm
I've not done much in the way of drop-down lists in excel either, but I have never needed to thus far.

Maybe someday Raven will teach us.

Darkholme

Quote from: nitwit on September 07, 2016, 09:26:58 pmWouldn't be terribly hard, but I'd have to find where most of the data is.  Besides I'm only interested in the things I mentioned thus far.
For now, maybe. Who's to say when you might need the rest of the data you're skipping because you don't need it just this instant?
And if you're not factoring in range and AoE and status effects and MP and CT and targeting restrictions when determining what kind of damage is reasonable? Well, your abilities are not going to come out very well balanced.

Quote from: nitwit on September 07, 2016, 09:26:58 pmProbably would be a good idea to specify in which files specific data tables and routines are located. Making a duplicate page would be lame, so I guess you could specify in which file each routine/table is located in the list of tables and routines.
For sure. would be good to know where all that stuff is located.

Quote from: nitwit on September 07, 2016, 09:26:58 pmWhat do you mean by reorganize?  Present it in a different manner?

I mean organize it differently for the purpose of modmaking. Many things (item properties, status afflictions, jobs, items, etc) are stored in a haphazard manner, which can make looking for a particular item a real pain in the ass. You could save things in a more rational order, such that you could scroll through them and find what you are looking for quickly and easily.

Quote from: nitwit on September 07, 2016, 09:26:58 pmMaybe someday Raven will teach us.

I'll just google it, if I ever actually need to do it.

nitwit

Quote from: Darkholme on September 08, 2016, 12:33:36 am
For now, maybe. Who's to say when you might need the rest of the data you're skipping because you don't need it just this instant?

Abstraction hell is a thing.  Printing data I don't need right now is confusing.  Since I'm a programmer, if I need something later I can make it.

Quote from: Darkholme on September 08, 2016, 12:33:36 am
And if you're not factoring in range and AoE and status effects and MP and CT and targeting restrictions when determining what kind of damage is reasonable? Well, your abilities are not going to come out very well balanced.

Once they are roughly on par with human abilities balancing them will be the same as balancing human abilities.

Getting the drivers for my Windows laptop (since I don't have an activation key) is more of a pain than writing a few loops, conditionals, and print statements.  I have wifi, usb 2.0, and ethernet.  I need to get usb 3.0 and a touchpad driver (so I can disable tap-click).  Still can't find the usb 3.0 driver, giving up on that.

Quote from: Darkholme on September 08, 2016, 12:33:36 am
I mean organize it differently for the purpose of modmaking. Many things (item properties, status afflictions, jobs, items, etc) are stored in a haphazard manner, which can make looking for a particular item a real pain in the ass. You could save things in a more rational order, such that you could scroll through them and find what you are looking for quickly and easily.

For an editor?  Or something to present a text breakdown of your mod?

Darkholme

Quote from: nitwit on September 08, 2016, 01:04:10 pm
Abstraction hell is a thing.  Printing data I don't need right now is confusing.  Since I'm a programmer, if I need something later I can make it.

Eh. When I write some kind of tool I typically find it better to cover my bases than just do the bare minimum for what I need that instant. I've found it to be less work in the long run. But whatever works for you.

Quote from: nitwit on September 08, 2016, 01:04:10 pmOnce they are roughly on par with human abilities balancing them will be the same as balancing human abilities.
That's one approach I suppose.

Quote from: nitwit on September 08, 2016, 01:04:10 pmGetting the drivers for my Windows laptop (since I don't have an activation key) is more of a pain than writing a few loops, conditionals, and print statements.  I have wifi, usb 2.0, and ethernet.  I need to get usb 3.0 and a touchpad driver (so I can disable tap-click).  Still can't find the usb 3.0 driver, giving up on that.

I personally like to backup all the drivers on my machine long before I format reinstall, and if possible, I hunt down driver installers and save them.

Quote from: nitwit on September 08, 2016, 01:04:10 pmFor an editor?  Or something to present a text breakdown of your mod?
For in an editor, yes. For instance, in status afflictions, there are several identical copies of "inflict poison", and the order of the afflictions doesn't make any sense.

nitwit

Quote from: Darkholme on September 08, 2016, 01:41:55 pm
For in an editor, yes. For instance, in status afflictions, there are several identical copies of "inflict poison", and the order of the afflictions doesn't make any sense.

There's a patch for that.  Several of them.

Xifanie

  • Modding version: PSX
Love what you're seeing? https://supportus.ffhacktics.com/ 💜 it's really appreciated

Anything is possible as long as it is within the hardware's limits. (ie. disc space, RAM, Video RAM, processor, etc.)
<R999> My target market is not FFT mod players
<Raijinili> remember that? it was awful

Darkholme

Wow, Xif, I clearly need to go through the tools forum again. I didn't realize this existed.

Though not quite what I was describing to nitwit, still very helpful for finding unused afflictions and duplicates.

I was talking to him about automatic sorting by category and automatically updating references to match the reorganized data. But with the data not automatically reorganized, this makes the edits much easier to do, for sure.

nitwit



The *.csv generator is done.




You'll need JRE 7 or greater installed if you want to run it.  If you want to compile it yourself or modify it, you need JDK 7 or greater.

Linux users get to use openJDK by following these instructions:
http://openjdk.java.net/install/index.html

I recommend openJDK if you want to avoid anything straight from Oracle.

Everyone else must get them from Oracle:
http://www.oracle.com/technetwork/java/javase/downloads/index.html

Click on either the JRE or JDK as needed and follow the download instructions.  Do not install the Ask.com toolbar or any other stupid thing Oracle tries to foist on you (except Java, of course).




To compile:
javac MakeCSV.java

To run:
java MakeCSV

Make sure that SCUS_942.30 is in the same folder as MakeCSV.




For Windows users, you must navigate to the folder where both of them are stored by using the change directory (cd) and display directory contents (dir) commands in the command line.  Start the command line then type:
dir
and press Enter.  This will display the contents of your directory.

From there type
cd
and the name of the folder you want to navigate to (hint: pick a folder that was output by the dir command) and press Enter.

It's usually easier for beginners to cd one directory at a time, but you can do more than one.  If you are in:
C:
and you need to get to
C://Users/Nitwit/Downloads
you could type:
cd Users
cd Nitwit
cd Downloads

Or you could type:
cd Users/Nitwit/Downloads

To move up a directory, type:
cd ..

To move up 2 directories, type:
cd ../..

To move up 3 directories, type:
cd ../../..

I think you get the picture from that.

tl;dr

To navigate:
cd [folder name]

To navigate up a folder:
cd ..

To print folder contents:
dir




September 9, 2016
12:45 PM
Minor revision to MakeCSV.java.  Removed empty line at end of *.csv files.

September 11, 2016
11:53 AM
Saving work done on StatCalc.java in case of crash.  MakeCSV.java is done.

nitwit

How should I deal with raw stats?

I think the most effective way to deal with raw stats is to calculate with the only available raw stat where it's a foregone conclusion.
* Ramza with his base classes
* Monsters with monster classes
* Bard and male NPCs with male raw stats
* Dancer and female NPCs with female raw stats
* Everyone else the average of male and female raw stats, rounded down.

From there I iterate through jobs and print when necessary, and within that I iterate through abilities and print when necessary.  The only excessively tedious part is the conditionals for dealing with formulas.

Darkholme

Quote from: nitwit on September 09, 2016, 08:53:14 pmHow should I deal with raw stats?

Tricky question. That's going to depend on your specific needs.

For myself, I've completely abandoned the default raw stats, in favor of a custom set of them which I'm using for everyone.

nitwit

Darkholme, can you check out the nested for loops starting at line 76 in StatCalc.java?  I'm getting some Loony Toons print statements from it.


nitwit@desktop ~/Projects/fft/statCalc $ javac StatCalc.java
nitwit@desktop ~/Projects/fft/statCalc $ java StatCalc a b c d e f g
3014654
2815645
3015655
358555
35 8 5 5 5 - 0
0 0 0 0 0 - 1
0 0 0 0 0 - 2
0 0 0 0 0 - 3

The first 4 lines are the raw stats when they are read into the 2d array at about line 31.  That works as intended.  The second attempt to print the contents of int[][] rawStats at line 71 seems to print the last array and then zeros, despite both the outer and inner array counters being correct.




Nevermind, I didn't realize I was setting i equal to zero at the beginning of every outer loop.




Do all abilities have x/y values?  How many entries long is ability data table 2?  FFTPatcher shows it stopping with 0x170 Potion, but maybe those abilities have x/y values but with a different context.

3lric

  • Modding version: PSX

nitwit

I really, really don't understand how stats are calculated.

http://finalfantasy.wikia.com/wiki/Stat_growth_%28Tactics%29

Could someone do an example of a male squire leveling from 1 to 2, and from 2 to 3?




Nevermind, I got it.


                System.out.println(rawStats[0][3]);//male pa
                System.out.println(jobs[74][6]);//squire pa growth
                System.out.println(jobs[74][7]);//squire pa
                int malePA = rawStats[0][3] * 16384;//malepa raw in extended form
                int squirePAC = jobs[74][6];//squire pa growth
                int squirePAM = jobs[74][7];//squire pa multiplier
                int squirePA = malePA;
                System.out.println(squirePA);
                System.out.println((squirePA * squirePAM) / 1638400);
                for (int i = 2; i < 100; i++)
                {
                    System.out.println("Level " + i);
                    squirePA = squirePA + (squirePA / (squirePAC + (i - 1)));
                    System.out.println(squirePA);
                    System.out.println((squirePA * squirePAM) / 1638400);
                    System.out.println();
                }


The output matches perfectly with what I found on this ftp:
http://philsov.ffhacktics.com/Classstats/male_squire.txt

That (i - 1) threw me off for a bit until I looked up the level up section on the wiki:
http://ffhacktics.com/wiki/Level_Up_Section

The PA transitions were always 1 level off until I realized that the stat recalculation would use your current level, not the one you are moving into.

I need to clean it up a bit and make it pretty, then I'll add in the rest of the calculations for other stats in a given job.  Get the terminal parameters to work too.

Darkholme

I sent it to you in PM form in response to the PM you sent me. If you'd like to post it here, I'm sure people could tell you if I made any errors (Certainly Possible) For instance, I'm unsure if stat growth considers "variance" as I did, or if it is based on the RAW numbers with a variance of 0.