[Guide/Formula] Critical hit rate, cont. attack chance, wars

If you are stuck in the Dunan Unification Wars; or wish for more details on the gameplay systems, this is the place.
Post Reply
psychedelist
Posts: 68
Joined: Sat Oct 27, 2018 1:45 pm

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by psychedelist »

Very useful info, Omnigamer and Z3R01337, thanks for that. I kept noticing that the characters "on the right side and back row" are much more likely to be targeted, as well as that a character can be targeted only once per turn (unless the attack misses or there are no other available targets). Except for Neclord's bat attack maybe, that one has a really weird pattern.

About attack probabilities, each enemy data entry can have up to 4 attack data sub-entries, i already felt that some of the first bytes in each entry might affect the probabilities, and you just prompted me to verify that the second attack-related byte is indeed the probability that affects the actual chance, the posted Luca values match the data. But still those values are like "recommendations" for the enemy-specific AI routines that may or may not use them. For example TargetLady starts using explosion anyway as long as some of the other enemies are defeated. Rowd, Nightmare and Culgan can use healing spells but pretty sure they (or other enemies) need to be considerably damaged for them to even consider using it.
First off, critical only applies to physical attacks.
Would you happen to know if having more than one crit character in a single unit helps the probability?

About the escape probability, i just loaded up the original game version (was using Pyriel's patch before). If you hack your current party characters to have 1 luck, get into a battle and press Run on the 1st turn, here are some breakpoint addresses of interest (1st turn of a battle only):
8002DAE0 This Lhu loads a character's Luck for the first time, then loops through other characters to find the max value, then turns it into a value in 5-30 range, which stands for the chance to fail escaping (if everyone's Luck is 1, the value will be 30)
8002DBA8 This Slt compares the calculated chance against a normalized rng value, then Xori reverses the result and the function will return v0 value as "IsRunSuccess". If you modify v0 at this point, you can see it indeed affects the outcome of Run. Now you can also give 200 or more Luck to at least one character, re-enter a battle (Luck isn't recalculated upon pressing Run), and the calculated chance to fail will be 5 instead of 30. I'm pretty new to the game and its modding community so i'm not sure why it's became the general consensus that this part of code isn't actually used, especially since Pyriel did find this part of code and has a disassembly of it. I'm pretty sure it does work, it's just hard to notice the difference on practice, especially in normal gameplay (Hero's Luck growth is very strong). Hope someone else can confirm it after debugging it. Omnigamer, you say this code isn't executed, but were you trying it on the first turn of a battle? It's still there for 2nd+ turns, just the address would be different, but that might have helped the impression that it isn't executed. Also, if you have have Stallion (or anyone with a hacked True Holly Rune) in the party, it won't execute indeed as that rune always turns Run into instant success.

I recently updated my reference document with some evade and counter conditions and formulas, if anyone has any comments, additions or corrections, it'll be very appreciated.
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by Omnigamer »

Neclord's bat attack has a targeting preference/requirement. It will always/only target members that are Female, and prioritize members that are Youth. I don't believe it follows the same rules for normal Single Target attacks in that it can target the same character twice in one round. The Youth part is conjecture, but it checks out based on available data, ie he will always target Eilie in a party of both Eilie and Rina.

For Criticals, every unit with a Critical skill gets an independent chance for it to trigger. So if you have 3 members of a unit with Critical skill, all of them have the potential to trigger for 4 total damage. But each one is checked independently, so you can drastically increase your chances of a crit with more than one member having Critical.

What I was referring to with code not being executed was actually escape code that tries to check party level relative to enemy party level. It had branches for different multiples of the of the the enemy's party level, but I believe each branch pointed to the same code, effectively doing nothing different. It's been a couple years since I looked at it though.

The escape testing I've done is via a special script that can brute force test conditions while manually altering the RNG. A lot of that testing was also done a long time ago, but I believe at least some of it was performed during the first walk through North Sparrow Pass, when all levels would have been very low. Even in that scenario, you would successfully run away 90% of the time after several thousand trials. I will test again to be sure, and your addresses do provide good reference points.
Z3R01337
Posts: 62
Joined: Sat Feb 06, 2016 6:06 am

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by Z3R01337 »

I'm gonna have a look into the escape stuff as well. Those addresses should provide a great starting point, thanks for those! Anecdotally speaking, I feel like it isn't just a flat 90% as the escape rate seems way worse in the early game.

If you have any info on the enemy structures in terms of probabilities, that would be great! I've been gathering my data via brute force scripts & it would save a lot of time if I could just check probabilities by examining the structure. I've personally been looking at the in-battle enemy structures to gather data. I've been trying to keep an eye out for probabilities there but haven't had any luck. For reference, each structure is 0x7c in length and the first one is generally at 0x145ba4 or 0x195ba4. It starts with your characters and then moves onto enemies. Some interesting addresses I found there as well that are worth sharing:

Code: Select all


Offsets from start of structure:
0x42: Number of attacks enemy had taken
0x43: Number of attacks enemy can/must take.
0x54: Current enemy attack index. This matches up psychedelist's attack data sheet.

0x42 is only used until the game calculates the turn, afterwards it's reset to 0. Usually lasts a frame or 2. 0x54 will be the last attack used at the end of the turn. If tracking writes you can see it change as the game is calculating the enemy attack.

As for special cases like healing, I haven't looked into those considerably. I did run tests for Culgan though, here are his probabilities. I did seperate tests where in one I didn't damage either Seed or Culgan and in the other I used one Blazing Camp. Also worth noting that in most of these tests I artificially limited the test target to one attack per turn & the other enemies in the group to 0 attacks per turn. This was done by editing the byte at 0x43.

No Damage: Attack 70%, Lightning 30%.
Damage: Attack 50% Kindness Rain 30% Lightning 20%.

I don't know how these match up to the probabilities in the enemy data but it might give us some insight on that as well.
psychedelist
Posts: 68
Joined: Sat Oct 27, 2018 1:45 pm

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by psychedelist »

That's what i meant with the Neclord's attack being weird, he didn't care for anyone else until Nanami was down in my game too. It also seemed like he likes to use that attack almost exclusively for the first few turns, then switch to magic-only for several turns. Could been just the rng though. Thanks for the crit answer as well, sounds like a good idea to have a double critical unit.

I only know character and enemy levels matter for the Let Go condition, wasn't aware it mattered (or was meant to matter) for Run anyhow. I loaded Sparrow Pass Save from here, the calculated failure chance is 30 as expected. But i wouldn't be surprised if the rng function is just that much biased even over the long periods. I had to enter a battle like 10 times before getting an rng value under 30 now. Could it be that the function is less likely to return small values? It seems to load some seed value, multiply it by some magic number, get the lower 32-bit result, add another magic number, save the result so that it becomes the seed value for the next rng call, finally right-shift by 16 bits and ensure that the final value isn't higher than 7fff. I don't know where the original seed value comes from and how those "magical numbers" were chosen, does anyone have a mathematical or intuitive explanation of why such a calculation would be at least remotely fair for all possible values in the intended 0-7fff range?
If you have any info on the enemy structures in terms of probabilities, that would be great!
Sure, actually i made and have been using an app to edit monster and character stats, thought i'd mention it later when the time comes, but if anyone thinks it really could be of use, then give me a hint. It's far from perfect and not entirely user friendly though, but it gets the job done for my project. For now, here's how my current enemy source data mapping goes,

Code: Select all

The whole enemy entry is no less than 159 bytes (haven't identified the data past 159th byte)
// General stats
[16 bytes] enemy's name (in custom encoding), the one used during the battle
[2 bytes] Counter Str (listed as plain Str in the bestiary)
[2] Mag
[2] Prot
[2] Mdef
[2] Tech
[2] Speed
[2] Luck
[2] HP
[1] Enemy level
[3] unknown, probably always 0 and unused
// 1st Attack entry (24 bytes)
[1] always 1 or 2, not tested yet but suspecting it might be for Silent Lake check
[1] attack probability (in percent, 0-100)
[2] unknown, usually 0 but not always, never seen higher than 9
[2] Attack's Str
[2] Attack's Hit (like Tech but for calculating the chance that the character will dodge this attack)
[1] Inflicted Status ID
[1] Status Probability
[1] Attack type data. Lower 4 bits are for attack's Element (1 is Fire, 2 is Water, then Wind, Earth, Lightning, Resurrection, Darkness, Bright Shield).
If higher 4 bits are "1" then the attack is Physical (Character's Def and enemy's AttackStr (Counter Str is [i]not[/i] added) are used), if it's "2" then the attack is Magical (Character's Mdef and enemy's Mag+AttackStr are used). I don't know how and if other higher bits are used here. An example: 10001 = 11 (hex) = Physical Fire; 100010 = 22 = Magical Water
[1] unused
[2] Target data. A lot of stuff goes here, each bit may mean something, i haven't mapped them all, but they're mainly for defining the target type (single target in any row, or only front row, or all party, column, etc), there's also a bit for whether the attack can be countered or not.
[10] Either empty or some RAM addresses, maybe for AI routines used by the attack
// 3 more Attack entries like the above
...
// Resistances and loot
[1] Unknown resistance but often used by bosses (it's just now that i noticed this byte, will test it later, hopefully it's for Unbalanced)
[1] Fire resistance (0 normal, 1 weak, 2 strong, 3 invulnerable)
[1] Water
[1] Wind
[1] Earth
[1] Lightning
[1] Resurrection
[1] Darkness
[1] Bright Shield
[1] Silence
[1] Physical (listed as Knockdown in the bestiary, not used by anyone except Neclord)
[1] Sleep
[1] Poison
[1] Instant Death
[2] unknown
[2] Potch (divided by 10 for bosses)
[2] Item1 (Id and Modifier)
[2] Item2
[2] Item3
[1] Item1 drop chance
[1] Item2 drop chance
[1] Item3 drop chance
To find these entries, i just search the rom or RAM for the enemy names, the custom encoding can be found in this file by Pyriel posted in some other thread, i have a text encode/decode feature in my editor as well.
This matches up psychedelist's attack data sheet.
If you mean attack properties data, sorry i wasn't making sure they're exactly in the same order as in the raw data. There could be some other inaccuracies, like Flyers have two attacks, one for back row and other for front row, yet i considered it to be equivalent to a single "any single target" attack for simplicity. Not sure if it was the right approach. By the way i'm watching your s2 speedruns these days, great stuff.
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by Omnigamer »

I've managed to dig into the escape rate a bit better now. I was using a flawed check for battle state before - while I haven't found a "correct" address to check for battle state, I've instead been able to check the dialog text characters after starting to run away as my conditional. It only works for a small subset of battles, but I set up a good manipulable instance for party luck before the battle starts. It also must use some mirrors somewhere to store the max character LCK, since modifying both the slot-aligned LCK values and source character LCK values don't affect it mid-battle. The character's LCK needs to be manipulated prior to the battle start.

The relationship seems to be this:

Escape failure rate = max(30%-max((LCK-100)/4,0),5%)

That is, for every 4 LCK your luckiest character has over 100, you gain an extra 1% escape chance. If you have 100 or less, then you see no benefit at all. After 200, you are at the max of 95%. Note that each 4 threshold is important - 100 through 103 would still give the same 30% rate. 104 through 107 would give 29%, and so on.

Sorry I dismissed your formula initially based on my own flawed tests! I appreciate the corrections and further information in tracking it all down.
makotech222
Posts: 5
Joined: Sat Mar 05, 2016 1:30 pm

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by makotech222 »

Does anyone have the .iso memory addresses that contain every character's war stats (Atk, Def, Skills)? I would like to edit those if they were available.
OneRune
Posts: 25
Joined: Fri Jan 27, 2017 12:29 pm

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by OneRune »

So is evasion based on Tech or Speed? Also, is there another variable for countering an attack?
psychedelist
Posts: 68
Joined: Sat Oct 27, 2018 1:45 pm

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by psychedelist »

If you mean the chance for a character to hit, the one that's listed on site, the formula should be:
((Attacker TECH - (Defender TECH - 80)) * M + HitBonus
M is various multipliers added by some runes.

The character's evasion is:
Player TECH - Enemy HIT + 20 + D
D = 20 if player is defending, 0 if not.
HIT is like TECH, but defined separately for each enemy attack. Typically it's close to enemy's TECH, but if you need a precise calculation, you can't fully rely on the TECH value that is listed in the bestiary.

Character counter is a separate chance that calculates only if evasion succeeds in the first place:
(Player TECH - Enemy HIT) * M
M is a x1.5 multiplier that is added by the following things (all stack with each other) - Defend, Mangosh, Counter rune.

Both evade and counter chances max out at 80% (unless you have Revenge Earth, then it's always 100%).
OneRune
Posts: 25
Joined: Fri Jan 27, 2017 12:29 pm

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by OneRune »

Does the Thunder Amulet decrease hit chance for the Player or Enemy?
User avatar
Matroska
Posts: 9
Joined: Fri Jan 08, 2021 8:31 am

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by Matroska »

OneRune wrote: Tue Jan 19, 2021 3:33 pm Does the Thunder Amulet decrease hit chance for the Player or Enemy?
It increases hit chance, not decreases it, for the player by 15%.
OneRune
Posts: 25
Joined: Fri Jan 27, 2017 12:29 pm

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by OneRune »

Matroska wrote: Wed Jan 20, 2021 6:44 am
OneRune wrote: Tue Jan 19, 2021 3:33 pm Does the Thunder Amulet decrease hit chance for the Player or Enemy?
It increases hit chance, not decreases it, for the player by 15%.
Ahh you're right! I was thinking of the Falcon Rune >_<
User avatar
Matroska
Posts: 9
Joined: Fri Jan 08, 2021 8:31 am

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by Matroska »

OneRune wrote: Fri Jan 22, 2021 8:22 am
Matroska wrote: Wed Jan 20, 2021 6:44 am
OneRune wrote: Tue Jan 19, 2021 3:33 pm Does the Thunder Amulet decrease hit chance for the Player or Enemy?
It increases hit chance, not decreases it, for the player by 15%.
Ahh you're right! I was thinking of the Falcon Rune >_<
Ah okay, no problem :) - that lowers it for the player. You can see a lot of information about the runes here: http://www.suikosource.com/runes/list/?rune_id=24
KFCrispy
Global Admin
Posts: 6174
Joined: Wed Jun 30, 2004 3:29 pm

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by KFCrispy »

Oh this just came up as I was watching a Twitch streamer--I asked in 2007 but it doesn't seem like we have figured it out. Are there any rules/formulas about Knockdown chance? :)
JustSomeGuy
Posts: 3
Joined: Fri Aug 27, 2021 10:54 am

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by JustSomeGuy »

I have a couple of questions about formulae and stats:
  1. What does the enemy Strength stat do?
  2. What's the most accurate physical-attack damage-calculation formula?
I know these both sound ridiculous but I was just experimenting with the Commander/Highland soldiers you fight at the start of the game and it's not clear.

Giving the Commander a Strength stat of 255 makes no visible difference to me; it didn't change his counter damage (which looks to be around 1) or his regular attacks, which are between 7 and 12.

I will say this though: I was editing his stats in-memory after starting the battle, not before the game had been loaded, so it's possible his stat had already been factored in to damage calculations ahead of time.

But changing his Technique and Speed stats did have visible effects, so I'm not sure this is the reason.

Secondly, the damage formula. On SuikoSource (and elsewhere in this thread and forum), this is the formula given:

(Power * BerserkStatus - Defence) * RuneModifiers

But nowhere in this is the random variance I'm seeing accounted for. Someone else in this thread said he saw betwen 3 and 8 points of damage being added on; I'm seeing 1-9.

Riou and Jowy, with 21 attack each, are doing between 16 and 24 damage on the Highlands soldiers at the start of the game (who have 6 Protection, which means they should be doing a flat 15 damage).

And I assume there's a different formula entirely for the enemy damage, because these soldiers (Strength of 15, for whatever that's worth), routinely do between 1 and 3 damage to the boys with approximately 22 defence.

If anybody has up to date information, I'd be much obliged. I'm grateful to see in this thread that someone has cleared up that the enemy's Technique stat is what factors in to their chance to dodge; I was about to leave a comment saying that it definitely wasn't their Speed stat (or some nebulous "area speed stat") like this thread/SuikoSource claims.

EDIT: I have a third question. I've just started a brand new game and my hero, level two, has a protection stat of 16. Given the information on SuikoSource, I don't see how that's possible.

According to the information, the hero has a protection growth rate of C+. C+ means he should start at level 1 with 12 and then gain either 2 or 3 stat points every level. So he can only have a maximum protection value of 15 at level 2.

Do people know if his growth rate is wrong for this stat or SuikoSource is incorrect about how many points per level are awarded for some growths?
thcrock
Global Admin
Posts: 1546
Joined: Thu Aug 07, 2003 10:57 am

Re: [Guide/Formula] Critical hit rate, cont. attack chance, wars

Post by thcrock »

JustSomeGuy wrote: Fri Aug 27, 2021 11:11 am I have a couple of questions about formulae and stats:
  1. What does the enemy Strength stat do?
  2. What's the most accurate physical-attack damage-calculation formula?
I know these both sound ridiculous but I was just experimenting with the Commander/Highland soldiers you fight at the start of the game and it's not clear.

Giving the Commander a Strength stat of 255 makes no visible difference to me; it didn't change his counter damage (which looks to be around 1) or his regular attacks, which are between 7 and 12.

I will say this though: I was editing his stats in-memory after starting the battle, not before the game had been loaded, so it's possible his stat had already been factored in to damage calculations ahead of time.

But changing his Technique and Speed stats did have visible effects, so I'm not sure this is the reason.

Secondly, the damage formula. On SuikoSource (and elsewhere in this thread and forum), this is the formula given:

(Power * BerserkStatus - Defence) * RuneModifiers

But nowhere in this is the random variance I'm seeing accounted for. Someone else in this thread said he saw betwen 3 and 8 points of damage being added on; I'm seeing 1-9.

Riou and Jowy, with 21 attack each, are doing between 16 and 24 damage on the Highlands soldiers at the start of the game (who have 6 Protection, which means they should be doing a flat 15 damage).

And I assume there's a different formula entirely for the enemy damage, because these soldiers (Strength of 15, for whatever that's worth), routinely do between 1 and 3 damage to the boys with approximately 22 defence.

If anybody has up to date information, I'd be much obliged. I'm grateful to see in this thread that someone has cleared up that the enemy's Technique stat is what factors in to their chance to dodge; I was about to leave a comment saying that it definitely wasn't their Speed stat (or some nebulous "area speed stat") like this thread/SuikoSource claims.
As the part-author of the Damage Equations guide from 20 years ago I can say it's mostly just that the initial work is incomplete. 16-year-old me was doing these guides playing the vanilla unhacked game on my playstation and writing stuff down on paper. The game analysis community has come a long way since then, both in tools and attention to detail. We can and will apply corrections; it looks like we have a number of corrections to apply from this thread.
Post Reply