[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
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

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

Post by Omnigamer »

Huh. This was somewhat unexpected. I finally found a good condition to watch for run success.

For every location, enemy group, and level setup I tested, you have a 10% chance of failing an escape. This was determined empirically, with 8192 samples each time.

Things I tried:
-Testing against enemies in various dungeons and world map locations
-Testing different types of encounters
-Testing both first and second turns of battle
-Testing with Riou only and level forced to 1
-Tested with various different "natural" party setups for different locations

Every time, it came out to be approximately 10% failed escapes. This is somewhat odd, but consistent with prior testing I've done. The odd part of this is that there is code that is meant to scale the escape chance with the level of the party. It just sets the same value regardless of how imbalanced your levels are. Specifically, there are branches for:

-You are more than 2x enemy party level
-You are more than 1.5x enemy party level
-You are more than 1x enemy party level
-You are less than enemy party level

But again, these don't seem to actually get used. This leads me to believe that it was intended to be a feature, but was scrapped partway through and just changed to a fixed escape rate.

The only thing left on this front is to look into Let Go conditions for dungeons. I believe I understand the conditions for World Map, but dungeons seem to behave a bit differently.
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 can confirm the formula for Let Go now. I thought it was different between World Map and dungeons, but it turns out that it is universal. It also matches up with what I previously thought to be the formula, just with a new tweak.

To get Let Go to appear, you must:

-Have a party level higher than the enemy's party level.
-Have at least one character be at least 6 levels higher than the highest-leveled enemy.

What was wrong/missing from my previous formula was that 6. I thought you only had to be one level higher, but I tested with a bit more rigor this time and it seems the magic difference is in fact 6.

The last thing I think I will investigate is in regard to encounter types. I will probably test via brute force once I find some good addresses, but I just want to see what the rate of different encounters are for some areas. If they are all equally likely, great. If not, knowing which ones are more likely than others can go a long way.
User avatar
Pyriel
Webmaster
Posts: 1227
Joined: Wed Aug 18, 2004 1:20 pm

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

Post by Pyriel »

Offhand, I don't recall any specific likelihood being assigned to different encounters. I believe it's just the base chance of an encounter followed by picking one at random. However, they do have a tendency to reference the same enemy party multiple times in the array of available encounters. All encounters are definitely not equally likely, but, except in cases where they put one party in 10 times to every other party's 1, it'll take an awful lot of testing in every area to sort out the probabilities.

In a theoretical zone where the list of encounters all point to unique parties, all chances should be even, though.

Edit: I could have sworn I already investigated "Let Go" in the code. Turns out it was over at GameFAQs.

http://www.gamefaqs.com/boards/198844-s ... /807580276
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

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

Post by Omnigamer »

Right, I'm expecting they just load up multiple instances of the same encounter in the table to make them show up more often. I don't intend to make an exhaustive list, but the subset I want to know are things relating to how common certain encounters pop up for the purpose of speedrun routing and whether the rates are universal for a dungeon or change by room you are in.
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 tested some other things on a whim last Saturday to fill in the remaining gaps for War Battle calculations.

Archer vs Melee at Melee range: Hit rate follows standard formula, gaining +4 roll modifier
Archer vs anything from distance: Standard hit formula
Mage vs Melee at Melee range: Hit rate is reduced to 5% (!) for the mage, also the melee attacker has a +8 (!) roll modifier

In short, never attack anything at melee range with your mages. It's a bad time.
User avatar
wataru14
Guide Writer
Posts: 715
Joined: Thu Aug 05, 2010 10:37 am
Location: Las Vegas

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

Post by wataru14 »

So Archers are better at fighting Infantry hand-to-hand? That's odd.
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

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

Post by Omnigamer »

+4 is the standard roll bonus. It's better interpreted as an equal chance to hit whether ranged or melee, however they have an additional penalty on their defense when attacking at melee range. This isn't true for mages, who are hampered heavily in offense and defense if they engage at melee range.
User avatar
wataru14
Guide Writer
Posts: 715
Joined: Thu Aug 05, 2010 10:37 am
Location: Las Vegas

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

Post by wataru14 »

So the melee unit gets +4 from the normal hit formula and then an additional +4 for fighting an archer in melee?
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

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

Post by Omnigamer »

No.

Melee (A) vs Melee (D): A gets +4 to attack, D also gets +4 to attack
Melee (A) vs Archer (D) at melee range: A gets +6 to attack, D gets +4 to attack
Melee (A) vs Mage (D) at melee range: A gets +8 to attack, D gets -6 (or less) to attack
Archer (A) vs Mage (D) at distance: A gets +4 to attack, D gets +4 to attack
Archer (A) vs Mage (D) at melee range: A gets +8 to attack, D gets -6 to attack

Defense values are kept static. This changes in situations where Melee (skill) comes into play, which doubles the bonus. Summary is that archers do not have a reduced attack when fighting at melee range, however other units are more effective against them. Mage attacks are gimped heavily at melee range, and any melee units fighting them gain a large bonus.
HighlandSeed
Posts: 1
Joined: Fri Aug 10, 2018 1:56 pm

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

Post by HighlandSeed »

What about for runes such as Technique, Down, Sleep, etc? Does a higher hit% help with the percentage already given by the rune?
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

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

Post by Omnigamer »

Almost certainly not, but I have not tested that. Most of those algorithms have just a static chance of success.
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

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

Post by Omnigamer »

Wanted to drop some new info that Z3R01337 and I have been working out by a mix of code-checking and brute-force scenario testing with special scripts. This is also just to make sure it's listed somewhere to reference later as well.

Enemy Targeting AI

Like many things in the game, their approach to how an enemy chooses a particular target is... naive. This was all tested through brute-force testing to a significant number of trials (often 1000+).

A couple things matter for this: Your initial party orientation, and the eligible targets for a given attack. Attack types come in many flavors, but for the purpose of this discussion we'll just focus on Single Front (SF) and Single All (SA). Rules for rows apply much the same way, however enemy column attacks always target their same column for as long as such a column of characters isn't KO'd.

OK, to put this in better context, here's an example: You have 3 characters in your party arranged in slots 1, 2, and 3, and an enemy uses either a SF or SA attack. The probability of that attack hitting any given slot is:

Code: Select all

1....2....3
25%..25%..50%

That's right, the third slot position is twice as likely to be targeted as the first two. The picture changes a bit if you're attacked with a SA attack and have 4 members...

Code: Select all


1....2....3     
12%..12%..25%
4
50%
The simple way to understand this is that every consecutive character slot is more likely to be targeted, if they are available. If that were a SF attack instead of SA though, it would still have the 25-25-50 probabilities as in the first case. This is because a SF attack only has at-most 3 eligible targets. SA can attack all non-KO'd party members, so it could have up to 6 eligible targets. The remaining probability cases are below, just for completeness.

Code: Select all


1....2....3     
6%...6%...12%
4....5
25%..50%

Code: Select all


1....2....3     
3%...3%...6%
4....5....6
12%..25%..50%
Technical reasoning for this is that they use some fairly flawed logic versus what you'd expect for a "fair" targeting system. It could have been developed this way on purpose for some fairly obtuse reasons, but more likely is they just didn't think it through very well. My working theory is that when the enemy starts an attack, it calls RNG once to determine who to attack. It then checks bit (eligible targets-1) of the RNG. If it's 1, then it targets that slot. If zero, then check the next lowest bit, and repeat until you find a 1. If all are zero, then you attack slot 1. This makes it so that each consecutive slot is twice as likely as the prior one to be targeted, with the exception of the first two.
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

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

Post by Omnigamer »

Shift Effects on Targeting

Though the slot ordering makes sense, I want to stress that it only applies to original slot ordering. If a party member changes to a different slot over the course of battle for whatever reason, their processing order is still in the context of their original position.

Here's a new example. Let's say an enemy uses a SF attack on a party with 4 party members. This is the normal expected outcome:

Code: Select all


1....2....3
25%..25%..50%
4
0%
However, at some point during the battle, the character in slot 1 is KO'd or shifts to the back row. The slot 4 character is now eligible to be targeted by the SF attack, however the probabilities still follow the order of their original slots. So instead, the probability of a character getting attacked is now:

Code: Select all


1....2....3
0%..25%..25%
4
50%
The above is shown with respect to their original, un-shifted positions, so you can more easily understand the point. The slot 4 character would be taking up slot 1 in-battle for this scenario.
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

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

Post by Omnigamer »

Enemy Attack Choice Probabilities

We haven't quite identified where these thresholds are stored/originate, but every boss (and likely every enemy) has specific chances to select one attack over others. These chances are internally probabilities out of 100, and often on multiples of 10%. For example, Luca's attack probabilities are:

SF Physical Attack : 50%
FR Flame Row: 30%
CC Flame Column: 20%

Eventually I'd like to make a script that parses all the enemy attacks and their probabilities, but it's not a priority for right now. Would make a nifty supplement to the bestiary though.

War Battle Minutia

We learned some other mechanics relating to War Battles and how enemy AI will behave.

First off, critical only applies to physical attacks. Archers and mages will never critical when attacking at range.

Second, enemy units will avoid combat with units that have defense higher than their attack + modifier (see earilier in the thread for the modifier; in most cases it will be 4) and if the unit has attack higher than their defense. Basically, they won't risk an attack when they have minimum chance to hit, but have higher than minimum chance to be hit. Sorry the explanation is a little roundabout, but the end result is that if you load up a fairly strong unit with plenty of defense, you can charge into the enemy forces and not be attacked by most. Special units (bosses etc) may not play by these same AI rules, however.

Lastly, though we haven't confirmed it or tested extensively, the current working theory is that the war battle targeting works by tracking only the nearest allied unit. When multiple units are tied, it may instead move toward the centroid of all allied units. Again, it's only a working theory, but we may investigate further as things go on.
Omnigamer
Posts: 324
Joined: Wed Feb 13, 2013 11:48 am

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

Post by Omnigamer »

Multiple Turn Mechanics

I touched on this briefly in the Turn Order thread, but we have a better handle on the exact mechanics now. It can be simplified as follows:

For every entity that has multiple turns in a single action round, every consecutive turn has a 10% speed penalty. Ex: 2nd attack has a 10% speed penalty. 3rd Attack has a 20% speed penalty.

This applies most often to bosses, but can also apply to your characters when Double Beat is in play. For how this works with enemy's +-10% random speed factor, the order of operations is:

(SPD*RAND(.9:1.1))*(1-Penalty)

Another important note: enemies are restricted from using the same single-target attack on a character twice in one round. This means if Luca uses two physical attacks in a round, they will never target the same person. This changes the targeting rules discussed previously by effectively removing a previously-hit individual from the eligible target pool. However, if the attack misses, this does not apply and they can be targeted again.

Things Re-confirmed or Debunked

A couple of things have come up recently that were re-tested based on the reference posted by Psychadelist in the Hex Editor thread.

Escape Rate - In the reference, psychadelist postulates that whichever member has the highest LCK influences your escape success rate. I have re-tested this in a variety of scenarios, but I have not found any that differ from a fixed 90% success rate. His findings jive with what I previously posted in this thread, but when I traced through it seemed like there was never a case where that code would be executed. So unless there's something further that I'm not taking into account, I don't think there is any kind of scaling on escape rate.
See update on this in next page.

.... more to come when I remember them.
Last edited by Omnigamer on Mon Aug 19, 2019 10:41 pm, edited 3 times in total.
Post Reply